akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string S[N];
    set<string> st;
    REP(i, 0, N) {
        cin >> S[i];
        st.insert(S[i]);
    }
    cout << st.size() << endl; 
}


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

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

    vector<int> t(4);
    for (int i = 0; i < 4; i++){
        t.at(i) = n / pow(10, (3-i));
        n = n % (int)pow(10, (3-i));
    }

    int t7;

    for (int i = 0; i < 8; i++){

        int sumt = t.at(0);

        for (int j = 0; j < 3; j++){
            if ((i % (int)pow(2, (3 - j))) / (int)pow(2, (2 - j)) == 1){
                sumt += t.at(j + 1);
            }else{
                sumt -= t.at(j + 1);
            }
        }

        if (sumt == 7){
            t7 = i;
            break;
        }
    }

    cout << t.at(0);
    for (int i = 0; i < 3; i++){
        if ((t7 % (int)pow(2, (3 - i))) / (int)pow(2, (2 - i)) == 1){
            cout << "+" << t.at(i + 1); 
        }else{
            cout << "-" << t.at(i + 1);
        }
    }
    cout << "=7" << endl;
    //cout << t.at(0) << t.at(1) << t.at(2) << t.at(3) << endl;
}

Measured memory_bytes: 4092
#include <stdio.h>
#define N 10000

int isprime(int);

int main(void) {

  int n, cnt;
  int i;
  int a[N];
  int b;
  cnt =0;
  scanf("%d",&n);
 for(i=0;i<n;i++){
   scanf("%d",&a[i]);
 }
 
 for(i=0;i<n;i++){
   b = isprime(a[i]);
   if(b==1)cnt++;
 }

 printf("%d\n",cnt);

 return 0;
}

int isprime(int x){

  int i;
  
  if (x == 2){
    return 1;
  }

  else if(x < 2 || x % 2 == 0){
    return 0;
  }
 
  i = 3;
  


  for(i=3;i*i<=x;i=i+2){

    if(x%i==0)return 0;

  }
  return 1;

  }

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

int main(){
   int N;
   std::cin >> N;
   std::vector<int> A(N), B(N), C(N);
   for(int i=0; i<N; ++i)
      std::cin >> A[i];
   for(int i=0; i<N; ++i){
      std::cin >> B[i];
   }
   for(int i=0; i<N; ++i){
      std::cin >> C[i];
   }

   std::sort(A.begin(),A.end());
   std::sort(B.begin(),B.end());
   std::sort(C.begin(),C.end());

   long long ans = 0;
   for(int i=0; i<N; ++i){
      long long ba = lower_bound(A.begin(),A.end(),B[i]) - A.begin();
      long long bc = C.end() - lower_bound(C.begin(),C.end(),B[i]+1);
      ans += ba * bc;
   }
   std::cout << ans << std::endl;

   return 0;

}


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

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = scan.next();
        StringBuilder current = new StringBuilder(s).reverse();
        current = remove(current, "resare");
        current = remove(current, "esare");
        current = remove(current, "remaerd");
        current = remove(current, "maerd");
        System.out.println(current.length() == 0 ? "YES" : "NO");
    }
    private StringBuilder remove(StringBuilder sb, String search) {
        StringBuilder result = new StringBuilder();
        char[] d = search.toCharArray();
        int length = search.length();
        for (int i = 0; i < sb.length(); i++) {
            boolean ng = false;
            for (int j = 0; j < length; j++) {
                if (sb.length() <= i + j) {
                    ng = true;
                    break;
                }
                if (sb.charAt(i+j) != d[j]) {
                    ng = true;
                    break;
                }
            }
            if (!ng) {
                i = i + length - 1;
                continue;
            }
            result.append(sb.charAt(i));
        }
        return result;
    }
}


Measured memory_bytes: 28320
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1]*n
        for i in range(n):
            self.parents[i] = i

    # 要素xが所属するグループの根を返す
    def root(self, x) -> int:
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.root(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        elif x > y:
            u.parents[x] = y
        elif x < y:
            u.parents[y] = x

    def same(self, x, y) -> bool:
        return self.root(x) == self.root(y)


n, m = map(int, input().split())
cnt = n
u = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())
    if u.same(a-1, b-1):
        continue
    else:
        u.unite(a-1, b-1)
        cnt -= 1
if cnt > 0:
    print(cnt-1)
else:
    print(cnt)


Measured memory_bytes: 12704
using System;
class abc163_b{
  public static void Main(){
    String[] str = Console.ReadLine().Split(' ');
    int day = int.Parse(str[0]);
    int hw = int.Parse(str[1]);
    str = Console.ReadLine().Split(' ');
    for(int i=0; i<hw; i++){
      day -= int.Parse(str[i]);
    }
    if(day < 0){
      day = -1;
    }
    Console.WriteLine(day);
  }
}


Measured memory_bytes: 19324
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    if (b % a == 0) {
        cout << a + b << endl;
    } else {
        cout << b - a << endl;
    }
}


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

using namespace std;

void solve()
{
	int N, K;
	cin >> N >> K;
	if (N % 2 == 0)
	{
		if (N / 2 >= K)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
	else
	{
		if ((N + 1) / 2 >= K)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int h,w,n,count;
  cin>>h>>w>>n;
  if(h>w)
  {
	count = n/h;
    if(n%h != 0)
      count++;
  }
  else
  {
	count = n/w;
    if(n%w != 0)
      count++;
  }
  cout<<count;
  return 0;
}


Measured memory_bytes: 256
#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=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<int,P>Pa;
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;
}


int n,h[100005],ma;
long long ans=0;
int main() {
	cin>>n;
	for(long long i=0;i<n;++i)ans+=i;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var input string
	fmt.Scan(&input)
	s := []byte(input)
	minCost := 100000
	for i := 0; i < 26; i++ {
		t := make([]byte, 0, len(s)+1)
		t = append(s, byte('a'+i))
		maxDist := 0
		before := -1
		for j, v := range t {
			if v == byte('a'+i) {
				if dist := j - before - 1; dist > maxDist {
					maxDist = dist
				}
				before = j
			}
		}
		if cost := maxDist; cost < minCost {
			minCost = cost
		}
	}
	fmt.Println(minCost)
}


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

using namespace std;
typedef long long ll;

int gcd(int s, int t) {
    if(t == 0) {
        return s;
    }
    return gcd(t, s % t);
}

int main(void) {
    int K;
    cin >> K;

    vector<int> numbers;

    for(int a = 1; a <= K; a++) {
        for (int b = 1; b <= K; b++) {
            int gcd_ab = gcd(a, b);

            for (int c = 1; c <= K; c++) {
                numbers.push_back(gcd(gcd_ab, c));
            }
        }
    }

    cout << accumulate(numbers.begin(), numbers.end(), 0) << endl;

    return 0;
}

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

string s1, s2;
int dp[3005][3005];
stack<char>stk;

void initialize()
{
    for(int i=0;i<=3000;i++)
        for(int j=0;j<=3000;j++)
            dp[i][j] = -1;
}

int LCS(int i, int j)
{
    if(i<=0 or j<=0) return 0;

    if(dp[i][j]!=-1) return dp[i][j];

    int ret = max(LCS(i-1, j), LCS(i, j-1));

    if(s1[i-1]==s2[j-1])
        ret = max(ret, LCS(i-1, j-1)+1);

    dp[i][j] = ret;

    return ret;
}


void printChar(int i, int j)
{
    if(dp[i][j]<=0) return;

    if(dp[i][j]==dp[i-1][j]) printChar(i-1, j);
    else if(dp[i][j]==dp[i][j-1]) printChar(i, j-1);
    else
    {
        stk.push(s1[i-1]);
        printChar(i-1, j-1);
    }
}

int main()
{
    initialize();

    int n, m;
    cin>>s1>>s2;

    int retVal = LCS(s1.size(), s2.size());

    printChar(s1.size(), s2.size());
    //cout<<retVal<<endl;

    while(!stk.empty())
    {
        cout<<stk.top();
        stk.pop();
    }

    cout<<endl;

    return 0;
}


Measured memory_bytes: 35968
#include<bits/stdc++.h>
using namespace std;
inline long long read(void){
	long long num = 0, f = 1;
	char ch;
	while(!isdigit(ch=getchar())) if(ch == '-') f = -1;
	while(isdigit(ch)) num = num*10 + ch-'0', ch = getchar();
	return num * f;
}
int main()
{
	long long n = read(), d = read(), ans = 0;
	for(int i = 1; i <= n; i++){
		long long x = read(), y = read();
		if(x*x + y*y <= d*d) ans++;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3760
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

int main()
{
  unsigned short *A, *B;

  int C[VMAX+1];
  int n,i,j;
  scanf("%d",&n);

  A = malloc( sizeof(short) * n + 1);
  B = malloc( sizeof(short) * n + 1);

  for(i = 0;i <= VMAX;i++)C[i] = 0;

  for( i = 0; i < n; i++ )
  {
    scanf("%hu",&A[i + 1]);
    C[A[i + 1]]++;
  }

  for(i = 1;i <= VMAX;i++)C[i] = C[i] + C[i - 1];

  for( j = 1; j <= n; j++ )
  {
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for(i = 1;i <= n;i++)
  {
    if( i > 1 )printf(" ");
    printf("%d", B[i]);
  }
  
  printf("\n");

  return 0;
}

Measured memory_bytes: 8464
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int A,B,C,X,Y; cin >> A >> B >> C >> X >> Y;
    ll price = 1e9;
    for (int c=2*max(X,Y);c>=0;c--){
        int a = max(X-(c/2),0);
        int b = max(Y-(c/2),0);
        price = min(price,ll(A*a+B*b+C*c));
    }
    cout << price << endl;
    return 0;
}

Measured memory_bytes: 256
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var a = o.a(), b = o.a(), k = o.a();
  if(a >= k)a -= k, k = 0;
  else k -= a, a = 0;
  if(b >= k)b -= k;
  else b = 0;
  return a+" "+b;
}

Measured memory_bytes: 21064
// https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_a

#include "algorithm"
#include "cmath"
#include "functional"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll X, Y;
  cin >> X >> Y;

  VL ms(4);
  ms[1] = 300000;
  ms[2] = 200000;
  ms[3] = 100000;

  ll res = 0;

  if (X <= 3) res += ms[X];
  if (Y <= 3) res += ms[Y];
  if (X == 1 && Y == 1) res += 400000;

  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
// Aizu 1602: ICPC Calculator
// 2017.9.21 bal4u@uu

#include <stdio.h>
#include <ctype.h>

char e[20][50]; int n;

int calc(int lv, int *k)
{
	int i, x, y, op, f, m;
	char *p;
	
	m = *k;
	p = e[m]; for (i = 0; *p && i < lv; i++) *p++;
	if (isdigit(*p)) { *k = m+1; return *p - '0'; }
	if (!*p) return 0;  // Panic 
	op = *p, lv++, m++; if (op == '+') x = 0; else x = 1;
	while (m < n) {
		f = 0;
		p = e[m]; for (i = 0; *p && i < lv; i++) if (*p++ != '.') break;
		if (i < lv) break;
		if (isdigit(*p)) y = *p - '0', f = 1;
		else             y = calc(lv, &m);
		if (op == '+') x += y; else x *= y;
		if (f) m++;
	}
	*k = m;
	return x;
}

int main()
{
	int i;
	while (scanf("%d", &n) && n) {
		for (i = 0; i < n; i++) scanf("%s", e[i]);
		i = 0; printf("%d\n", calc(0, &i));
	}
	return 0;
}

Measured memory_bytes: 1820
function Main(input) {
  input = input.split('\n');

  var h = parseInt(input[0].split(' ')[0], 10);
  var w = parseInt(input[0].split(' ')[1], 10);

  var s = [];
  for (var i = 0; i < h; i++) {
    s.push(input[1 + i].split(''));
  }

  var cnt = new Array(h).fill([]).map(() => new Array(w).fill(0));

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

  for (var i = 0; i < h; i++) {
    for (var j = 0; j < w; j++) {
      if (s[i][j] == '#') {
        for (var k = 0; k < 8; k++) {
          var y = i + dy[k];
          var x = j + dx[k];
          if (!(0 <= y && y < h)) continue;
          if (!(0 <= x && x < w)) continue;
          cnt[y][x]++;
        }
      }
    }
  }

  for (var i = 0; i < h; i++) {
    for (var j = 0; j < w; j++) {
      if (s[i][j] == '#') cnt[i][j] = -1;
    }
  }

  for (var i = 0; i < h; i++) {
    console.log(cnt[i].map(v => v == -1 ? '#' : v).join(''));
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        c: [chars;3]
    }
    let v = vec![c[0][0],c[1][1],c[2][2]];
    println!("{}",
        v.into_iter().collect::<String>());
}


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


map<string,int>data;
int main(){
	
	string str;
	int ma;
	string ans1,ans2;
	while(cin>>str){
		data[str]++;
		if(ma<data[str]){
			ma=data[str];
			ans1=str;
		}
		if(ans2.size()<str.size())ans2=str;
	}
	cout<<ans1<<" "<<ans2<<endl;
}

Measured memory_bytes: 1196
#include<bits//stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,x[4];
    cin>>a>>b;
    x[0]=a+b;
    x[1]=a-b;
    x[2]=a*b;
    sort(x,x+3);
    cout<<x[2]<<endl;
}


Measured memory_bytes: 3636
// Problem : B - Distance 
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

db f(int x, int y){
    return (db)sqrt(x*x + y*y);
}

void solve(){
    int n,d;
    cin>>n>>d;
    int ans = 0;
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        if(f(x,y) <= (db)d) ans++;
    }
    cout<<ans;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3696
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
typedef unsigned long long ull;
typedef signed long long sll;
using namespace std;

#define INF 0x7FFFFFFFFFFFFFFF
#define BIG_PRIME 1000000007

vector<vector<sll>> a;
vector<sll> box,dp;

#define COUNT(x,mask,shift) ((((x)&((mask)<<(shift)))>>(shift))+((x)&(mask)))
 
sll Count(sll x)
{
  x=COUNT(x,0x5555555555555555,1);
  x=COUNT(x,0x3333333333333333,2);
  x=COUNT(x,0x0F0F0F0F0F0F0F0F,4);
  x=COUNT(x,0x00FF00FF00FF00FF,8);
  x=COUNT(x,0x0000FFFF0000FFFF,16);
  return x;
}

sll calc_box(sll x)
{
  if(Count(x)==1)return 0;
  if(box[x]==INF)
  {
    sll i,j;
    for(i=0;(2LL<<i)<=x;++i)
    {
      if(x&(1LL<<i))
      {
        box[x]=calc_box(x&~(1LL<<i));
        for(j=i+1;(1LL<<j)<=x;++j)
        {
          if(x&(1LL<<j))
          {
            box[x] += a[i][j];
          }
        }
        break;
      }
    }
  }
  return box[x];
}

sll calc_dp(sll x)
{
  if(Count(x)==1)return 0;
  if(dp[x]==INF)
  {
    //全員でできる塊の値を計算
    dp[x] = calc_box(x);
    //分割した合計が上回るかを計算
    //部分集合の部分集合でfor
    //参考：https://qiita.com/drken/items/7c6ff2aa4d8fce1c9361
    for(sll bit = x; ; bit = (bit-1) & x)
    {
      if(!bit)break;//空集合に分割したくないので先頭でbreak
      if(bit<(x&~bit))//2重処理を避けるのとbit==xで処理させないようにする
      {
        dp[x] = max(dp[x],calc_dp(bit)+calc_dp(x&~bit));
      }
    }
  }
  return dp[x];
}

int main()
{
  sll i,j,N;
  cin >> N;
  a.resize(N);
  dp.resize(1<<N,INF);
  box.resize(1<<N,INF);
  for(i=0;i<N;++i)
  {
    a[i].resize(N);
    for(j=0;j<N;++j)
    {
      cin >> a[i][j];
    }
  }
  cout << calc_dp((1LL<<N)-1);
  return 0;
}


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

int main(){
  int n,x,y,b,p;
  int hoge;
  double ans;
  
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> x >> y >> b >> p;
    if(b>=5 && p>=2){
      ans=x*b+y*p;
      ans=ans-0.2*ans;
      cout << ans << '\n';
    }else if(b>=5){
      ans=x*b+y*2;
      ans=ans-ans*0.2;
      hoge=x*b+y*p;
      if(ans<hoge){
	cout << ans << '\n';
      }else{
	cout << hoge << '\n';
      }
    }else if(p>=2){
      ans=x*5+y*p;
      ans=ans-ans*0.2;
      hoge=x*b+y*p;
      if(ans<hoge){
	cout << ans << '\n';
      }else{
	cout << hoge << '\n';
      }
    }else{
      ans=x*5+y*2;
      ans=ans-ans*0.2;
      hoge=x*b+y*p;
      if(ans<hoge){
	cout << ans << '\n';
      }else{
	cout << hoge << '\n';
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3240
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define MOD 1000000007


int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> a(n);
	rep(i, n) {
		cin >> a.at(i).first;
		a.at(i).second = i + 1;
	}
	sort(a.begin(), a.end());
	rep(i, n) cout << a.at(i).second << " ";
	return 0;
}

Measured memory_bytes: 1536
import sys
input = sys.stdin.readline

def f(n):
    s = (n*(n+1))//2
    return s


N,K = map(int,input().split())
m= 10**9+7
ln = list(range(N+1))
num = 0
for i in range(K,N+2):
    num += f(N+1)-f(N+1-i)-f(i)+1
print(num%m)
    


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

int main(){
  int N;
  cin >> N;
  vector<int> v1(N), v2(N), v3(N-1);
  rep(i, N) cin >> v1.at(i);
  rep(i, N) cin >> v2.at(i);
  rep(i, N-1) cin >> v3.at(i);
  
  int ans = 0;
  rep(i, N){
    int a = v1.at(i);
    if(i == N - 1) ans += v2.at(a-1);
    else{
      int b = v1.at(i+1);
      if(b == a + 1) ans += v2.at(a-1) + v3.at(a-1);
      else ans += v2.at(a-1);
    }
  }

  cout << ans << endl;


  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ll n, w; cin >> n >> w;
	vector<ll> v[4];
	ll w1, v1; cin >> w1 >> v1;
	v[0].push_back(v1);
	for(ll i = 1; i < n; i++){
		ll po, yo; cin >> po >> yo;
		v[po - w1].push_back(yo);
	}
	for(ll i = 0; i < 4; i++){
		sort(v[i].begin(), v[i].end());
		reverse(v[i].begin(), v[i].end());
	}
	ll dp[v[0].size() + 1][v[1].size() + 1][v[2].size() + 1][v[3].size() + 1];
	dp[0][0][0][0] = 0;
	for(ll a = 0; a <= v[0].size(); a++){
		if(a) dp[a][0][0][0] = dp[a - 1][0][0][0] + v[0][a - 1];
		for(ll b = 0; b <= v[1].size(); b++){
			if(b) dp[a][b][0][0] = dp[a][b - 1][0][0] + v[1][b - 1];
			for(ll c = 0; c <= v[2].size(); c++){
				if(c) dp[a][b][c][0] = dp[a][b][c - 1][0] + v[2][c - 1];
				for(ll d = 0; d <= v[3].size(); d++){
					if(d) dp[a][b][c][d] = dp[a][b][c][d - 1] + v[3][d - 1];
				}
			}
		}
	}
	ll ans = 0;
	for(ll a = 0; a <= v[0].size(); a++)for(ll b = 0; b <= v[1].size(); b++)for(ll c = 0; c <= v[2].size(); c++)for(ll d = 0; d <= v[3].size(); d++)ans = max<ll>(ans, (a * w1 + b * (w1 + 1) + c * (w1 + 2) + d * (w1 + 3) <= w ? dp[a][b][c][d] : 0));
	cout << ans << endl;
	return 0;
}

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

int main()
{
    int x,y;
    cin>>x>>y;
    if(y<2*x || y>4*x)
        cout<<"No"<<endl;
    else
    {
        if(y&1)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
    }
    return 0;
}


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

int main(void){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i, n) cin>>a[i];
    int flag=0;
    rep(i, n){
        if(a[i]%2!=1 & a[i]%3!=0 & a[i]%5!=0) {
            flag=1;
            break;
        }
    }
    if(flag==1) cout<<"DENIED"<<endl;
    else cout<<"APPROVED"<<endl;
    
}

Measured memory_bytes: 256
def lucas_number(n):
  l = [2, 1]
  l_i_1 = 1
  l_i_2 = 2
  if n == 1:
    return l[1]
  
  for i in range(n-1):
    tmpl = l[-1] + l[-2]
    l.append(tmpl)
    
  return l[-1]

n = int(input())
print(lucas_number(n))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
 int $(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }

signed main(){
  int a;
  cin>>a;
//  vector<int> b(a,0);
  int a1,a2,a3,a4,a5;
  int b1,b2,b3,b4,b5;
    cin>>a1>>a2>>a3>>a4>>a5;
  b1=$(a,a1),b2=$(a,a2),b3=$(a,a3),b4=$(a,a4),b5=$(a,a5);
  cout<<max(max(max(b1,b2),b3),max(b4,b5))+4<<endl;
}
//  for(int )


Measured memory_bytes: 256
import itertools
# import math
# import sys
# import numpy as np

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
H, W, K = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# S = input()

# d = sorted(d.items(), key=lambda x:x[0])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

cells = []
for i in range(H):
    cells.append(input())

rows = list(itertools.product((0,1), repeat=H))
columns = list(itertools.product((0,1), repeat=W))

def num_of_blacks(row, column):
    tot = 0
    for i in range(H):
        if row[i] == 0:
            continue
        for j in range(W):
            if column[j] == 0:
                continue
            if cells[i][j] == "#":
                tot += 1
    return tot

ans = 0
for row in rows:
    for column in columns:
        _ = num_of_blacks(row, column)
        if _ == K:
            ans += 1

print(ans)

Measured memory_bytes: 9008
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll dig(ll a){
    ll ret = 0;
    while(a){
        a /= 10;
        ret++;
    }
    return ret - 1;
}

ll dsum(ll a){
    ll ret = 0;
    while(a){
        ret += a % 10;
        a /= 10;
    }
    return ret;
}

int main() {
    init();
    ll K;
    cin >> K;

    vl cand;
    ll P = 150, ps = 1;
    rep(i, 17){
        repe(x, 1, min(ps * 10, P)){
            ll a = x;
            rep(_, i - dig(x)) a *= 10, a += 9;
            cand.eb(a);
        }
        ps *= 10;
    }
    sort(all(cand));
    cand.erase(unique(all(cand)), cand.end());
    ll cn = cand.size();

    vc<ld> E(cn);
    vc<bool> B(cn, true);
    rep(i, cn) {
        E[i] = (ld)cand[i] / dsum(cand[i]);
    }
    repr(i, cn - 1){
        if (chmin(E[i], E[i + 1])) B[i] = false;
    }

    ll cnt = 0;
    rep(i, cn){
        if(B[i]){
            cout << cand[i] << '\n';
            cnt++;
        }
        if (cnt == K) break;
    }
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  string s;
  cin>>s;
  int p = 0;
  unordered_map<int, int> dp;
  dp[p] = 0;
  for(char c:s) {
    p ^= 1 << (c - 'a');
    for(auto&& i:irange(0,26)) {
      int q = p ^ (1 << i);
      if (dp.count(q)) {
        if (!dp.count(p)) dp[p] = dp[q] + 1;
        else dp[p] = min(dp[p], dp[q] + 1);
      }
    }
  }
  cout<<max(dp[p], 1)<<endl;
  return 0;
}


Measured memory_bytes: 8652
from sys import stdin
import sys
import math
from functools import reduce
import itertools

n,m = [int(x) for x in stdin.readline().rstrip().split()]

x = list('a'*n)

for i in range(m):
    a, b = [x for x in stdin.readline().rstrip().split()]
    a = int(a) - 1

    if x[a] == 'a' or x[a] == b:
        x[a] = b
    else:
        print(-1)
        sys.exit()

if x[0] == '0' and n != 1:
    print(-1)
    sys.exit()

if x[0] == 'a' and n > 1: x[0] = '1'
if x[0] == 'a' and n == 1: x[0] = '0'

for i in range(1,n):
    if x[i] == 'a': x[i] = '0'

print(''.join(x))



Measured memory_bytes: 9468
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();
        for(int i = 1; i <= n; i++){
            int x = i;
            if(x%3==0){
                System.out.print(" " + i);
            }
           else if(Integer.toString(i).contains("3")){
               System.out.print(" " + i);
           }
               
           
        }
        System.out.println("");
    }
}




Measured memory_bytes: 28904
n=int(input(""))
a=1
b=2
c=1
while(n>10):
    n-=10
    a*=10**10
    b*=9**10
    c*=8**10
    a%=(10**9+7)
    b%=(10**9+7)
    c%=(10**9+7)

    
for i in range(n):
    a*=10
    b*=9
    c*=8
    if(i%10==0):
        a%=(10**9+7)
        b%=(10**9+7)
        c%=(10**9+7)

s=a+c-b
s%=(10**9+7)
print(s)

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

int main(){
  int R, C, K;
  cin >> R >> C >> K;
  vector dp(R+1,vector(C+1,vector(4,0LL)));
  vector A(R+1,vector(C+1,0));
  for(int i = 0; i < K; ++i){
    int r, c, v;
    cin >> r >> c >> v;
    --r,--c;
    A[r][c] += v;
  }
  long long ans = 0;
  for(int i = 0; i <= R; ++i){
    for(int j = 0; j <= C; ++j){
      for(int k = 0; k <= 3; ++k){
        ans = max(ans,dp[i][j][k]);
        if(i+1 <= R)
          dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][k]);
        if(j+1 <= C)
          dp[i][j+1][k] = max(dp[i][j+1][k],dp[i][j][k]);
        if(k < 3){
          if(i+1 <= R)
            dp[i+1][j][0] = max(dp[i+1][j][0],dp[i][j][k]+A[i][j]);
          if(j+1 <= C)
            dp[i][j+1][k+1] = max(dp[i][j+1][k+1],dp[i][j][k]+A[i][j]);
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 671836
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream> 
 #include <queue>
 #include <vector>
 #include <string>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
////////////////いろいろあるよ//////////////////////////////////
int main(){
	string a;
  	cin >> a;
  if(a[2]==a[3] && a[4]==a[5])cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
    int64_t n,k,i;
    cin>>n>>k;
    vector<int64_t> h(n);
    for(i=0;i<n;i++) cin>>h[i];
    sort(h.begin(),h.end());
    int64_t ans;
    for(i=0;i<n-k;i++) ans+=h[i];
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1792
from itertools import product


def solve(string):
    n, s = string.split()
    r, g, b = [], [], []
    r2, g2, b2 = set([]), set([]), set([])
    for i, _s in enumerate(s):
        if _s == "R":
            r.append(i)
            r2.add(2 * i)
        if _s == "G":
            g.append(i)
            g2.add(2 * i)
        if _s == "B":
            b.append(i)
            b2.add(2 * i)
    ans = len(r) * len(g) * len(b)
    ans -= sum(i + j in r2 for i, j in product(g, b))
    ans -= sum(i + j in g2 for i, j in product(b, r))
    ans -= sum(i + j in b2 for i, j in product(r, g))
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 9564
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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; }

int gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

int main(){
  ll n; int k; cin >> n >> k;
  // if(k == 0){
  //   std::cout << n*n << '\n';
  //   return 0;
  // }
  ll ans = 0;
  for (int b = 1; b <= n; b++) {
    //std::cout << ans << '\n';
    if(b <= k) continue;
    int cnt = n/b;
    ans += (b-k)*cnt;
    int num = n%b;
    if(k != 0) ans += max(num+1-k, 0);
    if(k == 0) ans += num;
  }

  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define se second
#define endl "\n"
#define pii pair<int, int>

#define PI 3.14159265358979323846
const int N = 100 + 10;
const int INF=2e9;


int n;
int wyn,cnt;

void solve() {
	int n;
	cin>>n;
	vector<int> v,vp;
	for(int i=0;i<n;i++) {
		  int x;
		  cin>>x;
		  v.pb(x);
		}
	   
	wyn=n;

          
          while(1){
			  int f1=0,nax=0,tot=0;
		  for(int i=0;i<v.size() ;i++) {
			    if(i+1==v[i]) {					  
					  f1=i;
					  nax=v[i];					  
					}
				else {
					  tot++;
					}					
			  }
			  
			  if(tot==v.size()) {
				    if(tot>0)
				      cnt++;
				    break;
				  } 
			  
			  if(nax!=0) {
			   vp.pb(nax);
			   v.erase(v.begin()+f1);			  
			  }			  
			  
		  }
		  		
		if(cnt) {
			  cout<<-1;
			  return ;
			}
	     else {
			 	reverse(vp.begin(),vp.end());
			   for(int i=0;i<vp.size();i++) 
			      cout<<vp[i]<<endl;
			 }		
 		
}


int32_t main() {
  fast;
  int t = 1;
  while (t--)
	solve();

  return 0;
}


Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//227
	int a,b;
	cin>>a>>b;
	cout<<a-b+1;
	
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3608
for i in range(100000):
    s = input().rstrip().split(" ")
    a = int(s[0])
    b = s[1]
    c = int(s[2])
    if b =="?":
        break
    if b == "+":
        print(a+c)
    if b == "-":
        print(a-c)
    if b == "*":
        print(a*c)
    if b == "/":
        print(int(a/c))

Measured memory_bytes: 7600
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define true 1
#define false 0
#define MAX 1000000
typedef long long ll;
typedef unsigned char Uchar; 

int main(void){
 
  char a[1005],b[1005];
  scanf("%s %s",a,b);
  
  int i,j;
  int n1=0,n2=0;
  int ans = MAX;
  
  for(i=0;i<strlen(a)-strlen(b)+1;i++){
    //printf("%d",i);
    for(j=0;j<strlen(b);j++){
      
     if(a[i+j] == b[j]){
       n1++;
     }else{
       n2++;
     }    
      
    }
    
    if(ans > n2){
     ans = n2; 
    }
    n1 = 0;
    n2 = 0; 
  }
  
  if(ans == MAX){
  printf("%d",(int)strlen(b));  
  }else printf("%d",ans);
  
  return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
#define ll long long
#define P pair<int,int>
using namespace std;
const int maxn = 3e5 + 50;
int a[maxn];
ll sum[maxn];
ll pre[maxn];
int n;
vector<int> v;
void init(){
    scanf("%d", &n);
    for(int i = 0; i < n; ++i){
        int x; scanf("%d", &x); a[x]++;
    }
    for(int i = 1; i <= n; ++i) pre[a[i]]++;
    for(int i = 1; i <= n; ++i) sum[i] = sum[i-1] + i*pre[i], pre[i] += pre[i-1];
}
bool check(int k, int lim){
    k -= (pre[n] - pre[lim-1]);
    if(k <= 0) return true;
    return sum[lim-1] >= (ll)k*lim;
}
void sol(){
    printf("%d\n", n);
    int p = 0;
    for(int k = 2; k <= n; ++k){
        if(k > pre[n]){
            printf("0\n"); continue;
        }
        int l = 0, r = n;
        int ans;
        while(l <= r){
            int mid = (l+r)>>1;
            if(check(k,mid)) ans = mid, l = mid + 1;
            else r = mid-1;
        }
        printf("%d\n", ans);
    }
}
int main()
{
	init(); sol();
}


Measured memory_bytes: 6784
<?php
error_reporting(0);
$N = trim(fgets(STDIN));
$A = explode(" ",trim(fgets(STDIN)));
//list($N,$M) = explode(" ",trim(fgets(STDIN)));
$all=1;
$bad=1;
for($i=0;$i<$N;$i++) {
  $all *= 3;
  if (($A[$i] % 2) == 0) $bad *= 2;
}
printf("%d\n",$all - $bad);


Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main() {
	int n;
	cin >> n;
	
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			if (n == i * j) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;

int main(){
    int h,w,n;
    std::cin >> h>>w>>n;
    std::cout << ceil(n/double(max(h,w))) << std::endl;
}

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

#define REP(i, a, b) for (int i = (int)a; i <= (int)b; i++)
#define fi first
#define sc second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int>> vpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<int, int> pii;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

const i64 MOD = 1000000007;
const int INF = 2000000000;

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

    int x, a;
    cin >> x >> a;

    if (x < a) cout << 0 << endl;
    else cout << 10 << endl;

	return 0;
}


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

int main()
{
	int i, size, flag = 0;
	string s;

	cin >> s;
	size = s.length();

	for (i = 0; i < size; i++) {
		if ((i + 1) % 2 == 0) {
			if ((s[i] != 'L') && (s[i] != 'U') && (s[i] != 'D')) {
				cout << "No" << endl;
				return 0;
			}
		}

		else if ((i + 1) % 2 != 0) {
			if ((s[i] != 'R') && (s[i] != 'U') && (s[i] != 'D')) {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
#include<queue>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int64_t n,a,b;
    cin>>n>>a>>b;
    if(a>b) cout<<0<<endl;
    else if(n==1&&a!=b) cout<<0<<endl;
    else if(n==1&&a==b) cout<<1<<endl;
    else{
        cout<<(n-2)*b-(n-2)*a+1<<endl;
    }
}


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

int main() {
	string s; cin >> s;
	int n = s.size();
	int k; cin >> k;

	REP(i, n) {
		int tmp = ('z' + 1) - s[i];
		if (k >= tmp && s[i] != 'a') {
			s[i] = 'a';
			k -= tmp;
		}
	}
	s[n - 1] += k % 26;
	cout << s << '\n';
	return 0;
}

Measured memory_bytes: 3724
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
#include<cstdint>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(17)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);

int main(){
      string s;
      cin>>s;
      int K;
      cin>>K;
      int n=s.size();
      rep0(i,n){
            int d=('a'-s[i]+26)%26;
            if(i==(n-1)){
                  if(s[i]+(K%26)<='z') s[i]+=(K%26);
                  else s[i]-=(26-(K%26))%26;
            }
            else if(d<=K){
                  s[i]='a';
                  K-=d;
            }
      }
      cout<<s<<endl;

      return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
static const int INF = (1 << 21);
int main(void){
    // Your code here!
    int N;
    cin >> N;
    vector<int> h(N+1);
    h.at(0) = INF;
    for(int i = 0; i < N; i++){
        cin >> h.at(i+1);
    }
    
    
    
    vector<int> dp(N+1);
    dp.at(0) = INF;
    dp.at(1) = 0;
    
    for(int i = 2; i <= N; i++){
        dp.at(i) = min(dp.at(i-1) + abs(h.at(i)-h.at(i-1)), dp.at(i-2) + abs(h.at(i)-h.at(i-2)));
    }
    cout << dp.at(N) << endl;
    
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
void chmin(int &a, int b) {
    if (a > b) a = b;
}
const int INF = 1e9 + 10;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    vector<int> dp(n, INF);
    dp[0] = 0;
    rep(i, n) {
        for (int j=1; j<=k && i+j<n; ++j) {
            chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }
    cout << dp[n-1] << endl;
}

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

const int INF =1e9;
const int MOD =1e9+7;

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

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

int main()
{
int x;
cin>>x;
cout<<(x/500)*1000+((x%500)/5)*5<<endl;;

}

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

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

    double n;
    cin >> n;

    for(double i = 1; i <= 50000; i++){
        double t = int(i * 1.08);
        if(t == int(n)){
            cout << int(i) << endl;
            return 0;
        }
        if(n <= t) break;
    }
    
    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
from fractions import Fraction
N, K = map(int, input().split())
F = 0

for i in range(1, N + 1):
    point = i
    j = 0
    while point < K:
        point *= 2
        j += 1
    F += float((1/N) * ((1/2) ** j))

print(F)

Measured memory_bytes: 5304