akhauriyash/Code-Regression huggingface dataset:
//Rafiqul Islam, MBSTU,ICT

#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mk make_pair
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pf(a) printf("%d\n",a);
#define pfl(a) printf("%lld\n",a);
#define TEST int test; cin >> test ;while(test--)
#define ii pair<int,int>
#define iil pair<ll,ll>
#define loop(i,a,b) for(int i = a ; i < b ; i++)
#define INF 2147483647
#define endl "\n"
#define all(v) v.begin(),v.end()
#define SET(a)      memset((a), -1, sizeof(a))
#define CLR(a)      memset((a), 0, sizeof(a))

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

const double pi = acos(-1.0);
const ll mod = 1e9 + 7;;
const ll maxn = 1e6+5;

ll power(ll x, unsigned long long y)
{
    ll res = 1;     // Initialize result

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x)%mod;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x)%mod;  // Change x to x^2
    }
    return res%mod;
}
ll modOp(ll a, ll b)
{
    ll c = a % b;
    if (c < 0)
        c += b;
    return c;
}
ll iv[maxn + 1];
void mod_inv()
{
    iv[1] = 1;
    for(ll i = 2 ; i <= maxn ; i++ )
    {

        iv[i] = (mod - mod/i * iv[mod%i]%mod)%mod;
        //cout << iv[i] << endl;
    }
}

ll Logn(ll n, ll base)
{
    return (n > base - 1) ? 1 + Logn(n / base, base) : 0;
}
vector<vector<int>> adj;
vector<int>sub_tree_size;
vector<array<int,2>> edge;
void dfs(int child, int parant)
{
    sub_tree_size[child] = 1;
    for(int x: adj[child])
    {
        if(x == parant)
            continue;

        dfs(x,child);
        sub_tree_size[child] += sub_tree_size[x];
    }

}
int isPrime[1000001] ;
vector< vector<ll> > pff(1000000), pr(1000000);
void sieve(int n)
{
    for(int i = 2 ; i*i <= n ; i++)
    {
        if(isPrime[i] == 0)
        {
            for(int j = i+i ; j <= n; j = j + i)
            {
                isPrime[j] = 1;
            }
        }
    }
    return;
}
int d[1000001];
void run_case()
{
    //sieve(1000000);

    for(int i = 1 ; i <= 1e6 ; i++)
      for(int j = i; j <= 1e6; j+=i)
          d[j]++;

    ll n;
    cin >> n;
    ll a[n+10];
    a[0] = 0;
    a[1] = 0;
    a[2] = 1;
    a[3] = 3;
    for(int i = 4 ; i <= n ; i++)
    {
       a[i] = a[i-1]+d[i-1];
    }
    cout << a[n] << endl;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //TEST
    run_case();
    //main();
    return 0;
}


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

int main() {
  string a,b;
  cin >> a >> b;
  int counts =0;
  for(int i=0; i < a.size(); i++){
    if (a.at(i) != b.at(i)) counts++;
  }
  cout << counts << endl;
}

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

struct City {
    int i;
    int y;
    int p;
    int x;
};

bool birth_sort(const City &a, const City &b) {
    if (a.p != b.p) {
        return (a.p < b.p);
    }
    
    return (a.y < b.y);
}

bool city_sort(const City &a, const City &b) {
    return (a.i < b.i);
}

int main() {
    int n, m;
    cin >> n >> m;
    int cnt = 0;
    
    vector<City> c(m);
    
    for (int i = 0; i < m; i++) {
        c[i].i = i;
        cin >> c[i].p >> c[i].y;
    }
    
    sort(c.begin(), c.end(), birth_sort);
    
    /*for (int i = 0; i < m; i++) {
        printf("p=%d, y=%d, i=%d\n", c[i].p, c[i].y, c[i].i);
    }*/
    
    for (int i = 0; i < m; i++) {
        if ((i > 0) && (c[i - 1].p != c[i].p)) {
            cnt = 0;
        }
        
        cnt++;
        c[i].x = cnt;
    }
    
    sort(c.begin(), c.end(), city_sort);
    
    for (int i = 0; i < m; i++) {
        printf("%06d%06d\n", c[i].p, c[i].x);
    }
    
    return 0;
}

Measured memory_bytes: 3072
#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

#define FOR(i,init,n) for(int i = init; i < n ;i++)
#define REP(i,n)  FOR(i,0,n)


int main()
{
	//FILE* fin = freopen("input.txt", "r", stdin);
	//FILE* fout = freopen("output.txt", "w", stdout);
	//while (1){
		int w, h,x,y,r;
		int cleft, cright, ctop, cbottom;
		scanf("%d %d %d %d %d", &w, &h,&x,&y,&r);
		/*
		if (x < -100 || x >100){
			break;
		}
		else if (y < -100 || y >100){
			break;
		}
		else if (w <= 0 || w > 100){
			break;
		}
		else if (h <= 0 || h > 100){
			break;
		}
		else if (r <= 0 || r > 100){
			break;
		}
		*/
		cleft = x - r;
		cright = x + r;
		ctop = y + r;
		cbottom = y - r;
		if (cleft < 0 || cright > w || ctop > h || cbottom < 0 ){
			printf("No\n");
			//break;
		}
		else{
			printf("Yes\n");
			//break;
		}
	//}
	return 0;
}

Measured memory_bytes: 1012
from math import floor

def solve(s, k):
    counts = [0] * len(s)
    prev = ''
    index = -1
    for l in s:
        if prev == l:
            counts[index] += 1
        else:
            index += 1
            counts[index] = 1
        prev = l
    if index == 0:
        return floor(len(s) * k / 2)
    total = sum(floor(counts[i] / 2) * k for i in range(index + 1) if counts[i] > 1)
    if s[0] == s[-1] and counts[0] % 2 == 1 and counts[index] % 2 == 1:
        total += k - 1
    return total

_s = input()
_k = int(input())
print(solve(_s, _k))


Measured memory_bytes: 3064
import numpy as np

def grid_coloring():
	h,w = map(int, raw_input().split(" "))
	n = int(raw_input())
	a = map(int, raw_input().split(" "))
	_current_color = 1
	ans = np.zeros((h,w), dtype=int)
	for i in range(h):
		if i%2==0:
			for j in reversed(range(w)):
				if a[_current_color-1]!=0:
					ans[i][j]=_current_color
					a[_current_color - 1]-=1
				else:
					_current_color +=1
					ans[i][j] = _current_color
					a[_current_color - 1] -= 1
		else:
			for j in range(w):
				if a[_current_color-1]!=0:
					ans[i][j]=_current_color
					a[_current_color - 1]-=1
				else:
					_current_color +=1
					ans[i][j] = _current_color
					a[_current_color - 1] -= 1
	for i in range(h):
		print " ".join(map(str, ans[i]))


if __name__ == "__main__":
	grid_coloring()

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

int main() {
  int N,K;
  cin>>N>>K;
  vector<int>d(K);
  set<int>A;
  for(int i=0;i<K;i++){
    cin>>d.at(i);
    for(int j=0;j<d.at(i);j++){
      int a=0;
      cin>>a;
      A.insert(a);
    }
  }
  cout<<N-A.size()<< endl;
}
      

Measured memory_bytes: 3636
n = int(input())
hlst = list(map(int, input().split()))
inf = 10 ** 10
dp = [inf for _ in range(n)]
dp[0] = 0
for i in range(1, n):
    dp[i] = min(dp[i - 1] + abs(hlst[i] - hlst[i - 1]), dp[i - 2] + abs(hlst[i] - hlst[i - 2]))
print(dp[-1])

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  int result = 0;

  if(B/A > C){
    result = C;
  }
  else
  {
    result = B/A;
  }

  cout << result << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main(){
    string a;
    string b;
    cin >> a >> b;
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    int an = a.size();
    int bn = b.size();
    bool skip = false;
    rep(i,an-bn+1){
        rep(j,bn){
            if((a[i+j] != '?'&&b[j] != a[i+j]))break;
            if(j == bn-1){
                skip = true;
                rep(k,bn)a[i+k] = b[k];
                i += bn;
            }
        }
        if(skip)break;
    }
    reverse(a.begin(), a.end());
    rep(i,an)if(a[i] == '?')a[i] = 'a';
    if(skip)cout << a << endl;
    else cout << "UNRESTORABLE" << endl;
    return 0;
}

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

int N;

int main() {
	cin >> N;
	int a = N / 10;
	int b = N % 1000;
	if (a % 111 == 0 || b % 111 == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
S=input()
T=input()
N=len(S)
M=len(T)
U=[0 for i in range(N+1)]
V=[0 for i in range(M+1)]
for i in range(N):
    if S[i]=="A":
        U[i+1]=(U[i]+1)%3
    else:
        U[i+1]=(U[i]-1)%3
for i in range(M):
    if T[i]=="A":
        V[i+1]=(V[i]+1)%3
    else:
        V[i+1]=(V[i]-1)%3
q=int(input())
O=["" for i in range(q)]
for inp in range(q):
    a,b,c,d=map(int,input().split())
    if (U[b]-U[a-1]-V[d]+V[c-1])%3==0:
        O[inp]="YES"
    else:
        O[inp]="NO"
for i in O:
    print(i)


Measured memory_bytes: 6552
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int n, m, k, ans = 0;
  cin >> n >> m >> k;
  char M[n][m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      cin >> M[i][j];
  for (int p = 0; p < (1 << n); p++) {
    for (int q = 0; q < (1 << m); q++) {
      int cnt = 0;
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          if (M[i][j] == '#' && !((1 << i) & p) && !((1 << j) & q))
            cnt++;
        }
      }
      if (cnt == k)
        ans++;
    }
  }
  cout << ans;
  return 0;
}

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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
	int n;
	cin >> n;
	int a[100];
	for(int i = 0;i < n;i++) cin >> a[i+1];

	int dp[100] = {};
	int ans = 1000;
	dp[0] = 1000;
	for(int i = 1;i <= n;i++){
		int tmp = 1000; 
		for(int j = 1;j < i;j++){
			for(int k = 0;k < j;k++){
				int kane = dp[k];
				int zan = kane % a[j];
				int kabu = kane / a[j];
				chmax(tmp, kabu*a[i] + zan);
			}
		}
		dp[i] = tmp;
		chmax(ans, tmp);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>

//using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

using ll =  long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
template<typename T> void chadd(T& a, T b) { a = a + b; }

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

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

	int h, w;

	int bfs(std::vector<std::vector<char>>& s, std::pair<int, int>& start, const std::pair<int, int>& goal) {
		int dist = 0;

		// スタート地点からの距離
		std::vector<std::vector<int>> d(w, std::vector<int>(h, inf));
		d[start.first][start.second] = 0;

		std::queue<std::pair<int, int>> que;

		que.push(start);

		while (que.size()) {
			std::pair<int, int> p = que.front(); que.pop();

			// ゴールかどうか
			if (p.first == goal.first && p.second == goal.second) break;
			// 4方向に移動
			for (int i = 0; i < 4; ++i) {
				int nx = p.first + dx[i];
				int ny = p.second + dy[i];

				if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
				if (s[ny][nx] == '#') continue;
				if (d[nx][ny] != inf) continue;

				que.push(std::make_pair(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}

		return d[goal.first][goal.second];
	}
}


int main() {

	std::cin >> h >> w;
	std::vector<std::vector<char>> s(h, std::vector<char>(w));
	rep(i, h) rep(j, w) std::cin >> s[i][j];

	// 全探索
	// スタート，ゴールの位置を決め撃ち
	int ans = 0;

	std::vector<std::pair<int, int>> road;
	rep(i, h)rep(j, w) {
		if (s[i][j] == '.') {
			road.push_back(std::make_pair(j, i));
		}
	}

	rep(i, road.size() - 1) {
		Rep(j, i + 1, road.size()) {
			int dist = bfs(s, road[i], road[j]);
			ans = std::max(ans, dist);
		}
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Console;
using static ConsoleApp.Util;
using static System.Math;
namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {	

			//long[] arr  = ReadLine().Split().Select(long.Parse).ToArray();
			char c = ReadLine()[0];
			c =(char)(c + 1);

			WriteLine(c);

        }

    }


    static class Util{
        public static void ChMin(ref long a,long b){
            
            if(a > b){
                a = b;
            }
        }

        public static void ChMax(ref long a,long b){
            if(a < b){
                a = b;
            }
        }



		
    }
}



Measured memory_bytes: 11092
#include <stdio.h>

int main(void)
{
    int N, i, count;
    scanf("%d", &N);

    int a[N];

    for (i = 0; i < N; i++)
    {
        scanf("%d", &a[i]);
        while (a[i] % 2 == 0)
        {
            count++;
            a[i] /= 2;
        }
    }
    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define i64 unsigned long long
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll mod = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}


int pow(int x, int y, int mod){
    int ret=1;
    for(;y;y>>=1,x=1ll*x*x%mod){
        if(y&1) ret=1ll*ret*x%mod;
    }
    return ret;
}
void kill()
{
    cout << "No" << endl;
    exit(0);
}

template <class T>bool chmax(T &a, const T &b){if (a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;} return 0;}





int main(){
    sonic();
    ll n, ans=0;
    R n;
    Vec div;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0)div.push_back(i);
        if(i*i!=n)div.push_back(n/i);
    }

    for(auto it:div){
        if(it==1)continue;
        if(n%(it-1)==n/(it-1))ans+=it-1;
    }
    co(ans);
}


Measured memory_bytes: 11616
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

signed main() {
	string S; cin >> S;
	for (int i = 0; i < S.length(); ++i)
		cout << "x";
	cout << endl;
	return 0;
}

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

using namespace std;

const int N = 510;

int n, m, ans = 0x7fffffff;
int a[N][N], b[N];
bool sel[N];

int main() {
	
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= m; ++j)	scanf("%d", &a[i][j]);
	
	memset(sel, true, sizeof sel);
	
	for (int i = 1; i <= m; ++i) {
		memset(b, 0, sizeof b);
		for (int j = 1; j <= n; ++j) {
			for (int k = 1; k <= m; ++k) {
				if (sel[a[j][k]]) {
					++b[a[j][k]];
					break;	
				}
			}
		}
		int com = -0x7fffffff, cut;
		for (int j = 1; j <= m; ++j) {
			if (b[j] > com) {
				com = b[j];
				cut = j;
			}
		}
		ans = min(ans, com);
		sel[cut] = 0; 
	}
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
 
#define TRACE(x) cerr << #x << " = " << x << endl
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
#define SZ(x) (int)(x).size()
 
using namespace std;
 
typedef unsigned long long ll;
typedef pair<int, int> pii;
 
template<class Num>
Num mabs(Num A){
  if(A < 0) return -A;
  return A;
}

const int N = 2e5 + 10;

int n;
int a[N], b[N];

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n; i++)
    scanf("%d", &a[i]);
  
  for(int i = 0; i < n; i++)
    scanf("%d", &b[i]);
  
  sort(b, b + n, greater<int>());
  
  int l = -1, r = -1;
  int val = -1;
  
  for(int i = 0; i < n; i++){
    if(a[i] == b[i]){
      l = r = i; val = a[i];
      while(r < n && b[r] == a[r]){
        r++;
      }
      r--;
      break;
    }
  }
  
  if(l != -1){
    vector<int> free; free.clear();
    for(int i = 0; i < n; i++){
      if(i < l || i > r){
        if(val != a[i] && val != b[i]){
          free.pb(i);
        }
      }
    }
    
    if(SZ(free) < r - l + 1){
      printf("No\n");
    }else{
      printf("Yes\n");
      int pt = 0;
      for(int i = 0; i < r - l + 1; i++){
        swap(b[i + l], b[free[pt++]]);
      }
      for(int i = 0; i < n; i++) printf("%d ", b[i]);
      printf("\n");
    }
  }
  
  else{
    printf("Yes\n");
    for(int i = 0; i < n; i++) printf("%d ", b[i]);
    printf("\n");
  }
  
  
  return 0;
}


Measured memory_bytes: 5884
fn main() {
    let stdin = std::io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    let mut s = buf.split_whitespace();
    let w: u32 = s.next()
        .unwrap()
        .parse()
        .unwrap();
    let a: u32 = s.next()
        .unwrap()
        .parse()
        .unwrap();
    let b: u32 = s.next()
        .unwrap()
        .parse()
        .unwrap();
    let wa = w + a;
    let wb = w + b;
    if wa < b {
        println!("{}", b - wa);
    } else if wb < a {
        println!("{}", a - wb);
    } else {
        println!("0");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/


int main(){
    int n, k; cin >> n >> k;
    double ans = 0;

    
    for(int i = 1; i <= n; i++){
        int l = i;
        double p = 1.0 / n;
        while(l < k){
            l *= 2;
            p *= 0.5;
        }
        ans += p;
    }
    cout << setprecision(15) << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            int n= scanner.nextInt();
            if (n == 0)
                break;
            double sum = 0;
            int[] s = new int[n];
            for (int i = 0; i < n; i++) {
                s[i] = scanner.nextInt();
                sum += s[i];
            }
            double m = sum / n;
            double aa = 0;
            for (int i = 0; i < n; i++) {
                aa += Math.pow(s[i] - m, 2) / n;
            }
            System.out.println(Math.sqrt(aa));

        }

    }
}



Measured memory_bytes: 31200
N = int(input())
str = input()
str_list=list(str)
ans_list=[]
for i in range (N):
  str_first = str_list[0:i+1]
  str_second = str_list[i+1:]
  answer = len(list(set(str_first) & set(str_second)))
  ans_list.append(answer)
  
print(max(ans_list))

Measured memory_bytes: 3060
#include <math.h>
#include <bits/stdc++.h>
#include <deque>
#define ll long long int
#define l long double
#define pi 3.14159265358979323846
#define mod 1000000007
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    ll l1=s.length();
    ll l2=t.length();
    ll i=0,k=0,res=1000000;
    while(i<=l1-l2)
    {
        ll cnt=0,val=0;
        for(int j=0;j<l2;j++)
        {
            if(s[i++]==t[j])
            {
                cnt++;
            }
        }
        val=l2-cnt;
        if(res>val)
        res=val;
        k++;
        i=k;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3628
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var S string

	fmt.Scan(&S)
	n, _:= strconv.Atoi(S)
	s1 := n/100
	s2 := n%100

	if s1==0 || s1>12 {
		if s2==0 || s2>12 {
			fmt.Println("NA")
		} else {
			fmt.Println("YYMM")
		}
	} else {
		if s2==0 || s2>12 {
			fmt.Println("MMYY")
		} else {
			fmt.Println("AMBIGUOUS")
		}
	}

}


Measured memory_bytes: 512
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int length = s.length();
    int K = sc.nextInt();
    Set<String> set = new HashSet<>();

    for (int i=1; i<=K; i++) {
      for (int j=0; j<=length-i; j++) {
        set.add(s.substring(j, j+i));
      }
    }
    List<String> list = new ArrayList<>(set);
    Collections.sort(list);
    System.out.println(list.get(K-1));
  }
}


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

static const int MAX=50;
int R[MAX][MAX];
int N,M;
bool visited[MAX];

void init(){
    for(int i=0;i<N;i++){
        visited[i]=false;
    }
}

void dfs(int u){

    visited[u]=true;
  
    for(int i=0;i<N;i++){
        if(visited[i]==false&&R[u][i]!=0){
            dfs(i);
        }
    }

}

int main(){
    cin >> N >> M;
    int a[M],b[M];
    for(int i=0;i<M;i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        R[a[i]][b[i]]++;
        R[b[i]][a[i]]++;
    }

    int ans=0;

    for(int i=0;i<M;i++){
        R[a[i]][b[i]]--;
        R[b[i]][a[i]]--;
        init();
        dfs(0);

        bool bridge=false;
        for(int i=0;i<N;i++){
            if(visited[i]==false) bridge=true;
        }
        if(bridge) ans++;
      
        R[a[i]][b[i]]++;
        R[b[i]][a[i]]++;
       
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<complex>
 
#define rep(i,n) for(int i=0;i<(n);i++)
 
using namespace std;
 
typedef complex<double> Point;
 
const double EPS=1e-9;
 
int n;
Point p[300];
 
int f(const Point &c){
    int res=0;
    rep(i,n) if(abs(p[i]-c)<1+EPS) res++;
    return res;
}
 
int main(){
    for(;scanf("%d",&n),n;){
        rep(i,n){ double x,y; scanf("%lf%lf",&x,&y); p[i]=Point(x,y); }
 
        int ans=1;
        rep(j,n) rep(i,j) {
            double d=abs(p[j]-p[i])/2;
            Point v=(p[j]-p[i])/(2*d);
            if(d<1){
                ans=max(ans,f(p[i]+d*v+sqrt(1-d*d)*v*Point(0,+1)));
                ans=max(ans,f(p[i]+d*v+sqrt(1-d*d)*v*Point(0,-1)));
            }
        }
        printf("%d\n",ans);
    }
 
    return 0;
}


Measured memory_bytes: 2632
#include<bits/stdc++.h>
using namespace std;
int main()
{
//#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	//#endif
		ios_base::sync_with_stdio(0);
		cin.tie(0);
		int a,b,c,i,j,k=0,l=0;
	string w;
	cin>>w;
	a=w.size();
	for(i=0;i<a;i+=2){
		if(w[i]=='R' || w[i]=='U' || w[i]=='D') {}
			else {k=1;}
		}
	
	for(i=1;i<a;i+=2){
		if(w[i]=='L' || w[i]=='U' || w[i]=='D') {}
			else{ l=1;}

	}
	if(k==0 && l==0) cout<<"Yes";
	else if(k==1 || l==1)cout<<"No";
}

Measured memory_bytes: 256
n=int(input())
info=list(map(int,input().split()))

p_sort=sorted(info)
tem_1=0
tem_2=0
tem=0
for i in range(n-1):
  if info[i]>info[i+1]:
    tem_1=i
    for j in range(n-i-2):
      if info[i+j+1]>info[i+j+2]:
        tem_2=i+j+2
        break
    break
tem=info[tem_1]
info[tem_1]=info[tem_2]
info[tem_2]=tem


for i in range(n):
  if info[i]!=p_sort[i]:
    print("NO")
    break
  
  if i==n-1:
    print("YES")

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
#define df 0

string S="Sunny", C="Cloudy", R="Rainy";

int main(){
  if(df) printf("*debug mode*\n");
  string x; cin >>x;
  if(x==S) cout << C;
  if(x==C) cout << R;
  if(x==R) cout << S;
}

/// confirm df==0 ///
 
 

Measured memory_bytes: 256
import java.util.*;
class Main {
     
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        Dice dice1 = new Dice(stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt());
        Dice dice2 = new Dice(stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt());
        boolean a = solv(dice1, dice2, 0);
        System.out.println((a)?"Yes":"No");
    }
    public static boolean solv(Dice f, Dice dice,int count) {
        if(dice.Top == f.Top && dice.S == f.S && dice.Bottom == f.Bottom && dice.E == f.E && dice.N == f.N && dice.W == f.W) return true;
        if(count == 6) return false;
        Dice tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
        tmp.TurnN();
        if(solv(f,tmp,count+1)) {
            return true;
        }
        tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
        if(solv(f,tmp,count+1)) {
            return true;
        }
        tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
        tmp.TurnE();
        tmp = new Dice(dice.Top,dice.S,dice.E,dice.W,dice.N,dice.Bottom);
        tmp.TurnW();
        if(solv(f,tmp,count+1)) {
            return true;
        }
         
        return false;
    }
     
     
     
}
 
class Dice {
    int Top; //1
    int Bottom; //6
    int N; //   5
    int S; //   2
    int W; //左 4
    int E; //右 3
    Dice(int a, int b, int c, int d, int e, int f) {
        Top = a;
        S = b;
        E = c;
        W = d;
        N = e;
        Bottom = f;
    }
    public void TurnN() {
        int tmp = Top;
        Top = S;
        S = Bottom;
        Bottom = N;
        N = tmp;
    }
    public void TurnW() {
        int tmp = Top;
        Top = E;
        E = Bottom;
        Bottom = W;
        W = tmp;
    }
    public void TurnE() {
        int tmp = Top;
        Top = W;
        W = Bottom;
        Bottom = E;
        E = tmp;
    }
    public void TurnS() {
        int tmp = Top;
        Top = N;
        N = Bottom;
        Bottom = S;
        S = tmp;
    }
     
}


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

dp = [False]*(k+1)

for i in range(k+1):
    flag = 0
    for j in a:
        if i-j < 0:
            continue
        if not dp[i-j]:
            flag = 1
            break

    if flag:
        dp[i] = True

if dp[k]:
    print("First")
else:
    print("Second")


Measured memory_bytes: 68092
def check(x,y,d):
    if x**2+y**2<=d**2:
        return True
    return False
ans=0
n,d=[int(i) for i in input().split()]
for i in range(n):
    x,y=[int(i) for i in input().split()]
    if check(x,y,d):
        ans+=1
print(ans)


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

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


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<iomanip>
#include<set>
using namespace std ;

#define MOD 1000000007
#define MAXN 407


int n , c ;
int a[ MAXN ] ;
int b[ MAXN ] ;

long long pw[ MAXN ][ MAXN ] ;
long long pref[ MAXN ][ MAXN ] ;

long long dp[ MAXN ][ MAXN ] ;

void input ( ) {
    scanf ( "%d%d" , &n , &c ) ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        scanf ( "%d" , &a[ i ] ) ;
    }
    for ( int i = 1 ; i <= n ; ++ i ) {
        scanf ( "%d" , &b[ i ] ) ;
    }
}

void solve ( ) {
    for ( int i = 1 ; i <= 400 ; ++ i ) {
        pw[ i ][ 0 ] = 1 ;
        for ( int j = 1 ; j <= 400 ; ++ j ) {
            pw[ i ][ j ] = ( pw[ i ][ j - 1 ] * i ) % MOD ;
        }
    }
    for ( int i = 0 ; i <= 400 ; ++ i ) {
        pref[ i ][ 0 ] = 0 ;
        for ( int j = 1 ; j <= 400 ; ++ j ) {
            pref[ i ][ j ] = ( pref[ i ][ j - 1 ] + pw[ j ][ i ] ) % MOD ;
        }
    }
    dp[ n + 1 ][ 0 ] = 1 ;
    for ( int i = n ; i >= 1 ; -- i ) {
        for ( int j = 0 ; j <= c ; j ++ ) {
            long long sm = ( pref[ j ][ b[ i ] ] - pref[ j ][ a[ i ] - 1 ] + MOD ) % MOD ;
            for ( int t = 0 ; t + j <= c ; ++ t ) {
                dp[ i ][ j + t ] = ( dp[ i ][ j + t ] + ( sm * dp[ i + 1 ][ t ] ) % MOD ) % MOD ;
            }
        }
    }
    printf ( "%lld\n" , dp[ 1 ][ c ] ) ;
}


int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 4096
var i,j:longint;
    v:array[0..200000]of boolean;
    a,sum:array[0..200000]of longint;
    max,q,l,r:longint;
begin
  max:=100000;
  for i:=2 to max do
  if not v[i] then
  begin
    for j:=2 to (max div i) do
    v[i*j]:=true;
  end;
  for i:=2 to max do
  if i mod 2=1 then
    if (not v[i])and(not v[(i+1)div 2]) then
     a[i]:=1;
  for i:=1 to max do
  sum[i]:=sum[i-1]+a[i];
  read(q);
  for i:=1 to q do
  begin
    read(l,r);
    writeln(sum[r]-sum[l-1]);
  end;
end.


Measured memory_bytes: 1408
#![allow(unused_imports)]
#![allow(non_snake_case)]
#![allow(dead_code)]
use proconio::{input, fastout};
use proconio::marker::{Chars, Bytes, Usize1};

#[fastout]
fn main() {
    input!{
        n: usize, q:usize,
        c: [Usize1; n],
        query: [(Usize1, usize); q]
    }
    let mut g = query.iter().enumerate().collect::<Vec<_>>();
    g.sort_by_cached_key(|(_, &(x, y))| x / 700 * 600000 + y);
    let mut idxl = 0;
    let mut idxr = 0;
    let mut ans = vec![0; q];
    let mut cur = vec![0; n];
    let mut scr = 0;
    for &(i, &(l, r)) in &g {
        while idxr < r {
            if cur[c[idxr]] == 0 {
                scr += 1;
            }
            cur[c[idxr]] += 1;
            idxr += 1;
        }
        while idxl > l {
            idxl -= 1;
            if cur[c[idxl]] == 0 {
                scr += 1;
            }
            cur[c[idxl]] += 1;
        }
        while idxr > r {
            idxr -= 1;
            if cur[c[idxr]] == 1 {
                scr -= 1;
            }
            cur[c[idxr]] -= 1;
        }
        while idxl < l {
            if cur[c[idxl]] == 1 {
                scr -= 1;
            }
            cur[c[idxl]] -= 1;
            idxl += 1;
        }
        ans[i] = scr;
    }
    println!("{}", ans.iter().map(|x| x.to_string()).collect::<Vec<_>>().join("\n"));
}


Measured memory_bytes: 67732
import java.util.Scanner;

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

    int n = sc.nextInt();
    int m = sc.nextInt();

    int total = 0;
    for (int i = 0; i < m; i++ ) {
      total += sc.nextInt();
    }

    int rest = n - total;
    System.out.println(rest >= 0 ? rest : -1);
  }
}


Measured memory_bytes: 39028
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pair < pll, int > a, pair < pll, int > b)//true for a before b
{
	if(a.F.F*b.F.S <= b.F.F*a.F.S)
		return 1;
	return 0;
}

const int N = (1e6) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 2*550;
const int SQRT = BUCK+9;

ll fact[N], dp[N], sum[N];

void pre()
{
	int i;
	fact[0] = 1;
	fo(i,1,N)
		fact[i] = (fact[i-1] * 1LL * i)%mod;
	return;
}

inline ll calc_sum(int l, int r)
{
	l = max(l,0);
	if(l > r)
		return 0;
	return (sum[r]-sum[l]+dp[l]+mod)%mod;
}

void solve()
{
	pre();
	int n, h, d, i;
	ll val = 0, ans;
	cin >> n >> h >> d;
	fo(i,1,n+1)
		val += fact[i];
	val %= mod;
	dp[0] = sum[0] = 1;
	fo(i,1,h+1)
	{
		dp[i] = (calc_sum(i-d,i-1)*val)%mod;
		sum[i] = sum[i-1] + dp[i];
		if(sum[i] >= mod)
			sum[i] -= mod;
	}
	ans = (dp[h]*inmodx(val))%mod;
	ans = (ans * fact[n])%mod;
	cout << ans << '\n';
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(2);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 23680
#include <stdio.h>
int main(){
    int n,m;
    int a[110][110];
    int b[110];
    int i,j;
    int c;
    scanf("%d %d\n",&n,&m);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<m;i++){
        scanf("%d",&b[i]);
    }
    for(i=0;i<n;i++){
        c=0;
        for(j=0;j<m;j++){
            c+=a[i][j]*b[j];
        }
        printf("%d\n",c);
    }
    return 0;
}


Measured memory_bytes: 2048
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;
int Distribute(int N,int K){
    int result = N % K;
    if(result==0) return result;
    else return 1;
   
}
int main()
{ 
   int N,K;
   cin >> N;
   cin >> K;
   cout << Distribute(N,K);
}



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

int main() {
	int n; cin >> n;
	vector<int>a(n); for (auto&& x : a)cin >> x;
	long long ans1 = 0, ans2 = 0, sum = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i];
		if (i % 2 == 0 && sum <= 0) {
			ans1 += -sum + 1;
			sum = 1;
		}
		else if (i % 2 == 1 && sum >= 0) {
			ans1 += sum + 1;
			sum = -1;
		}
	}
	sum = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i];
		if (i % 2 == 1 && sum <= 0) {
			ans2 += -sum + 1;
			sum = 1;
		}
		else if (i % 2 == 0 && sum >= 0) {
			ans2 += sum + 1;
			sum = -1;
		}
	}
	cout << min(ans1, ans2) << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M1 					1000000007
#define M2 					998244353
#define ll 					long long int
#define pll 				pair<ll,ll>
#define mll 				map<ll,ll>
#define F 					first
#define S 					second
#define PB 					push_back
#define mp 					make_pair
#define lb 					lower_bound
#define ub 					upper_bound
#define V(a) 				vector<a>
#define endl 				'\n'
#define test(t) 			while(t--)
#define PI 					acos(-1.0)
#define rep(i,a,b) 			for(ll i=a;i<b;i++)
#define repp(i,b,a) 		for(ll i=b-1;i>=a;i--)
#define clr(ar, val)		memset(ar, val, sizeof(ar))
#define setbits(x) 			__builtin_popcountll(x)
#define zrobits(x) 			__builtin_ctzll(x)
#define ps(y) 				fixed << setprecision(y)
#define all(x) 				begin(x),end(x)
#define allr(x) 			rbegin(x),rend(x)
const int inf= 				0x3f3f3f3f;
const ll INF= 				0x3f3f3f3f3f3f3f3f;
const int dx[4]= 			{ 0, -1, 0, 1 };
const int dy[4]= 			{ -1, 0, 1, 0 };

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll CalculateMex(set<ll> Set){
    ll Mex = 0;
    while(Set.find(Mex)!=Set.end()){
        Mex++;
    }
    return Mex;
}

ll floor_div(ll a, ll b) {
	return a / b - (((a ^ b) < 0) and a % b);
}
ll ceil_div(ll a, ll b){
    return a / b + (((a ^ b) >= 0) and a % b);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

void solve()
{
    ll n;
    cin>>n;
    cout << ps(15) << 2*PI*n << endl;

}

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    test(t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3812
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        //入力
        Scanner scn=new Scanner(System.in);
        int[] anntena=new int[5];
        anntena[0]=scn.nextInt();
        anntena[1]=scn.nextInt();
        anntena[2]=scn.nextInt();
        anntena[3]=scn.nextInt();
        anntena[4]=scn.nextInt();
        int limit=scn.nextInt();
        //処理と出力
        if(anntena[4]-anntena[0]>limit){
            System.out.println(":(");
        }else{
            System.out.println("Yay!");
        }
    }
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; ll W; cin>>n>>W;
    vll w(n),v(n);
    vll a,b,c,d;
    rep(i,n) cin>>w[i]>>v[i];
    ll w0 = w[0];
    rep(i,n){
        if (w[i]==w0)   a.pb(v[i]);
        if (w[i]==w0+1) b.pb(v[i]);
        if (w[i]==w0+2) c.pb(v[i]);
        if (w[i]==w0+3) d.pb(v[i]);
    }
    sort(rall(a));
    sort(rall(b));
    sort(rall(c));
    sort(rall(d));
    vll A(a.size()+1,0),B(b.size()+1,0),C(c.size()+1,0),D(d.size()+1,0);
    rep(i,a.size()) A[i+1]=A[i]+a[i];
    rep(i,b.size()) B[i+1]=B[i]+b[i];
    rep(i,c.size()) C[i+1]=C[i]+c[i];
    rep(i,d.size()) D[i+1]=D[i]+d[i];
    ll ans=0;
    rep(i,A.size())rep(j,B.size())rep(k,C.size())rep(l,D.size()){
        ll wsum = i*w0 + j*(w0+1) + k*(w0+2) + l*(w0+3);
        if (wsum<=W) chmax(ans, A[i]+B[j]+C[k]+D[l]);
    }
    cout<<ans<<endl;
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

using ll = long long;
using ld = long double;


int main(){
  int N, K;
  cin >> N >> K;
  vector<int> digit(K);
  REP(i, K) { cin >> digit[i]; }
  sort(ALL(digit));
  vector<int> target;
  for(int i=N;;i++){
    int tmp = i;
    vector<int> v(10);
    while(tmp > 0){
      target.push_back(tmp%10);
      tmp /= 10;
    }
    sort(ALL(target));
    auto it = set_intersection(ALL(digit), ALL(target), v.begin());
    if(it == v.begin()) {cout << i << endl; break;}
    target.clear();
  }
  return 0;
}


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

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

  int a, b, k;
  cin >> a >> b >> k;

  vector<int> res;
  for (int i = a; i <= b; ++i) {
    if (i < a + k || i > b - k) res.push_back(i);
  }

  for (int x: res) cout << x << endl;
}


Measured memory_bytes: 3664
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int[] P = new int[N];
        for(int i=0;i<N;++i)P[i]=scan.nextInt()-1;
        Map<Integer,Integer> map = new HashMap<>();
        for(int i=0;i<N;++i)map.put(P[i], i);
        List<Integer> nglist = new ArrayList<>();
        for(int i=0;i<N-1;++i)if(map.get(i) > map.get(i+1))nglist.add(i);
        if(nglist.isEmpty()){
            System.out.println(0);
            return;
        }
        int ans = Math.min(N - nglist.get(0) -1, nglist.get(nglist.size()-1)+1);
        for(int i=0;i<nglist.size()-1;++i){
            ans = Math.min(nglist.get(i)+1 + N-nglist.get(i+1)-1, ans);
        }
        System.out.println(ans);
    }  
}

Measured memory_bytes: 83428
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL;
LL h,w,ans;
int main() {
	scanf("%lld%lld",&h,&w);
	if (h%3==0||w%3==0) {
		printf("0\n");
		return 0;	
	}
	ans=min(h,w);
	for (int i=1;i<h;i++) {
		LL now=w*i;
	    LL now1=(h-i)*(w/2),now2=(h-i)*w-now1;
		LL nowans=max(now,max(now1,now2))-min(now,min(now1,now2));
		ans=min(ans,nowans);
	}
	for (int i=1;i<w;i++) {
		LL now=h*i;
	    LL now1=(w-i)*(h/2),now2=(w-i)*h-now1;
		LL nowans=max(now,max(now1,now2))-min(now,min(now1,now2));
		ans=min(ans,nowans);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a>b)
	{
		n=a;
		a=b;
		b=n;
	}
	if(a>c)
	{
		n=a;
		a=c;
		c=n;
	}
	if(b>c)
	{
		n=b;
		b=c;
		c=n;
	}
	printf("%d",c-b+b-a);
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    ll n, w;
    cin >> n >> w;
    vector<ll> weight(n), value(n);
    rep(i, n) cin >> weight[i] >> value[i];
    ll max_v = 100100;
    vector<vector<ll>> dp(n+1, vector<ll>(max_v, LINF));
    dp[0][0] = 0;
    rep(i, n){
        rep(sum_v, max_v+10){
            if(sum_v - value[i] >= 0) chmin(dp[i+1][sum_v], dp[i][sum_v-value[i]] + weight[i]);
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }
    ll ans = 0;
    rep(i, max_v){
        if(dp[n][i] <= w) ans = i;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 80256
s = input()
t = input()
ans = 10 ** 10
ls = len(s)
lt = len(t)
for i in range(ls - lt + 1):
    cnt = 0
    for j in range(lt):
        if s[i + j] != t[j]:
            cnt += 1
    ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 9112
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var K = cin.ReadInt;

            var isEven = (N % 2) == 0;
            int ret = 0;
            if (isEven)
            {
                ret = N / 2;
            }
            else
            {
                ret = N / 2 + 1;
            }

            if (ret >= K)
            {
                Console.Write("YES");
            }
            else
            {
                Console.Write("NO");
            }
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220