akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
//#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;

int main() {
	int N,b;
	cin >> N;
	vector<pair<int,int>>a(N);
	for (int i = 0; i < N; i++) {
		cin >> b;
		pair<int, int>pa (b,i + 1);
		a[i] = pa;
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < N; i++) {
		cout << a[i].second << " ";
	}
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())

using namespace std;
typedef pair<int,int> P;

// 最大公約数
int64_t gcd(int64_t a, int64_t b) {
  return b != 0 ? gcd(b, a % b) : a;
}

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

int ctoi(char c){
  return c - '0';
}

std::vector<int> enum_div(int n)//nの約数を列挙
{
  std::vector<int> ret;
  for(int i=1 ; i*i<=n ; ++i)
  {
    if(n%i == 0)
    {
      ret.push_back(i);
      if(i!=1 && i*i!=n)
      {
        ret.push_back(n/i);
      }
    }
  }
  return ret;
}

int main(){
  int64_t n;
  cin >> n;
  vector<int> vec(n);
  REP(i,n){
    cin >> vec.at(i);
  }
  vector<int> vec2(n+1, 0);
  for(int i=n;i>0;i--){
    int c = vec2.at(i) % 2;
    if (vec.at(i-1) == 0){
      if (c == 0){
        vec2.at(i) = 0;
      }else{
        vec2.at(i) = 1;
        auto r = enum_div(i);
        for (auto a: r){
          if (i!=a){
            vec2.at(a)++;
          }
        }
      }
    }else{
      if (c == 0){
        vec2.at(i) = 1;
        auto r = enum_div(i);
        for (auto a: r){
          if (i!=a){
            vec2.at(a)++;
          }
        }
      }else{
        vec2.at(i) = 0;
      }
    }
  }
  int t = 0;
  REP(i,n+1){
    if (i!=0){
      if (vec2.at(i) % 2 == 1){
        t++;
      }
    }
  }
  cout << t << endl;
  bool chk = false;
  REP(i,n+1){
    if (i!=0){
      if (vec2.at(i) % 2 == 1){
        if (!chk){
          cout << i;
          chk = true;
        }else{
          cout << " " << i;
        }
      }
    }
  }
  if (chk){
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 2432
import Control.Applicative
main = solve

solve = do
    n <-  fmap (read :: String -> Int) . words <$> getLine
    let a = n !! 0
        b = n !! 1
    printAnswer a b
    where
        printAnswer :: Int -> Int -> IO ()
        printAnswer x y
            | x < y = putStrLn "a < b"
            | x > y = putStrLn "a > b"
            | otherwise = putStrLn "a == b"

Measured memory_bytes: 3640
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  int h[n];
  for (size_t i = 0; i < n; i++) {
    scanf("%d", h+i);
  }
  for (size_t i = n-1; i > 0; i--) {
    if (h[i-1]-h[i] == 1) {
      h[i-1]--;
    }else if (h[i-1]-h[i] > 1) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}


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

int main(){
    int a[5],b[5];
    rep(i,5){
        a[i]=i+1;
        cin>>b[i];
        if(a[i]!=b[i]){
            cout<<i+1<<endl;
            return 0;
        }
    }
}

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

void insertionSort(int a[], int n);
void displayArray(int a[], int n);

int main() {
  int a[100], n;
  int v,j;
  cin >> n;
  for(int i = 0; i < n; i++) cin>>a[i];
  displayArray(a, n);
  insertionSort(a, n);
  return 0;
}

void insertionSort(int a[], int n) {
  int v,j;
  for(int i = 1; i < n; i++) {
    v = a[i];
    j = i -1;
    while(j >= 0 && a[j] > v) {
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
    displayArray(a, n);
  }
}

void displayArray(int a[], int n) {
  for(int i = 0; i < n; i++) {
    cout << a[i];
    if(i == n-1) cout << "\n";
    else cout << " ";
  }
}


Measured memory_bytes: 3100
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long 
int main()

{
	int a[5];
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	for(int i=0;i<3;i++)
	{
		for(int j=0;j<i;j++)
		{
			if(a[i]>a[j])
				swap(a[i],a[j]);
		}
	}
	if(a[0]==a[1]&&a[0]==a[2])
		puts("0");
	else
	{
		int cnt=0;
		int x=a[0]-a[1];
		int y=a[0]-a[2];
		while(x!=0)
		{
			if(x>=2)
			{
				cnt++;
				x=x-2;
			}
			else if(y!=0)
			{
				x--;
				y--;
				cnt++;
			}
			else
				break;
		}
		while(y!=0)
		{
			if(y>=2)
			{
				cnt++;
				y=y-2;
			}
			else
				break;
		}
		if((x==0&&y==1)||(x==1&&y==0))
			cnt=cnt+2;
		printf("%d\n",cnt);
	}
	return 0;
}


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

using namespace std;
int dp[20][50001];
int c[20];

typedef long long ll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> c[i];
	}
	
	for (int i = 0; i < m; i++) {
		for (int j = 0; j <= n; j++) {
			int* a = &dp[i][j];
			if (j == 0) {
				*a = 0;
			} else if (i == 0) {
				*a = j;
			} else if (j < c[i]) {
				*a = dp[i-1][j];
			} else {
				*a = (dp[i-1][j] > dp[i][j-c[i]] + 1 ? dp[i][j-c[i]] + 1 : dp[i-1][j]);
			}
			/*cout << *a;
			if (j == n) cout << endl;*/
		}
	}
	cout << dp[m-1][n] << endl;
	return 0;
}

Measured memory_bytes: 7100
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,a[200000],b[200000],ans = 0,tmp = 2;
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i];
	for(int i = 0;i < n;i++) cin >> b[i];
	for(int i = 0;i < 29;i++){
		int cnt = 0;
		vector<int> vec;
		for(int j = 0;j < n;j++) vec.push_back(b[j] % tmp);
		sort(all(vec));
		for(int j = 0;j < n;j++){
			int t = a[j] % tmp;
			cnt += upper_bound(all(vec),tmp - 1 - t) - lower_bound(all(vec),tmp / 2 - t) + upper_bound(all(vec),tmp * 2 - 1 - t) - lower_bound(all(vec),tmp + tmp / 2 - t);
		}
		if(cnt % 2) ans += (1 << i);
		tmp *= 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7028
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
struct team{
	int num,p,cnt;
	int w[11];
	void init(int n)
	{
		num=n;
		p=0;
		cnt=0;
		for(int i=0;i++<10;)w[i]=0;
	}
	void submit(int m,int i,int j)
	{
		if(j)w[i]++;
		else p+=m+w[i]*20,cnt++;
	}
	bool operator<(team a)
	{
		if(cnt!=a.cnt)return cnt>a.cnt;
		else if(p!=a.p)return p<a.p;
		else return num>a.num;
	}
	bool operator==(team a)
	{
		return cnt==a.cnt&&p==a.p;
	}
};
int M,T,P,R;
main()
{
	while(cin>>M>>T>>P>>R,M)
	{
		team a[55];
		for(int i=0;i++<T;)a[i].init(i);
		for(int i=0;i<R;i++)
		{
			int b,c,d,e;cin>>b>>c>>d>>e;
			a[c].submit(b,d,e);
		}
		sort(a+1,a+T+1);
		for(int i=0;i++<T;)
		{
			if(i==1)cout<<a[i].num;
			else
			{
				cout<<(a[i-1]==a[i]?"=":",")<<a[i].num;
			}
		}
		cout<<endl;
	}
}



Measured memory_bytes: 3124
#include<iostream>
int h,w,k,a[15][1005],s[15][1005],ans=2000,dfn[15],cnt;
inline int C(int a1,int b1,int a2,int b2){
	int p=s[a2][b2]-s[a2][b1]-s[a1][b2]+s[a1][b1];
	return p;
}
inline void check(){
	int cost=cnt,last=0;
	for(int i=1;i<=w;++i){
		for(int j=1;j<=cnt;++j)
			if(C(dfn[j],i,dfn[j-1],last)>k){
				if(last==i-1)return;
				++cost,last=i-1;
			}
		if(C(h,i,dfn[cnt],last)>k){
			if(last==i-1)return;
			++cost,last=i-1;
		}
	}
	if(ans>cost)ans=cost;
	return;
}
inline void dfs(int x){
	if(x==h){check();return;}
	dfn[++cnt]=x,dfs(x+1),--cnt,dfs(x+1);return;
}
using namespace std;
int main(){
	ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
	cin>>h>>w>>k;char ch;
	for(int i=1;i<=h;++i)for(int j=1;j<=w;++j)
			cin>>ch,s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+(a[i][j]=(ch=='1'));
	return dfs(1),printf("%d",ans),0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int a[100005];
int main(){
	int n;
	memset(a,0,sizeof(a));
	int maxn = 0;
	scanf("%d",&n);
	for(int i = 0;i < n;i++){
		int k;
		scanf("%d",&k);
		a[k]++;
		a[k+1]++;
		if(k!=0)
		a[k-1]++;
		maxn = max(maxn,a[k]);
		maxn = max(maxn,a[k+1]);
		if(k!=0)
		maxn = max(maxn,a[k-1]);
	}
	printf("%d",maxn);
} 

Measured memory_bytes: 1272
import java.util.*;

public class Main {	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		if(a <= 8 && b <= 8) {
			System.out.println("Yay!");
		} else {
			System.out.println(":(");
		}
	}
}


Measured memory_bytes: 23892
import java.util.*;
import java.io.*;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 32768);
    static PrintWriter out = new PrintWriter(System.out);
    static StringTokenizer t;

    static String sn() {
        while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return t.nextToken();
    }

    static int ni() {
        return Integer.parseInt(sn());
    }

    static long nlo() {
        return Long.parseLong(sn());
    }

    public static void main(String args[]) {
        int t = 1;//ni();
        while (t-- > 0) {
            solve();
        }
        out.close();
    }

    static long mod = 998244353;

    static long pro(long a, long b) {
        return (a % mod * b % mod) % mod;
    }

    static long add(long a, long b) {
        return (a + b) % mod;
    }

    static int maxn = 200005;

    static void solve() {
        long n, k, x, y;
        n = nlo();
        k = nlo();
        x = nlo();
        y = nlo();
        long ans = Math.min(n, k) * x;
        ans += y * (((n - k) > 0) ? (n - k) : 0);
        out.println(ans);
    }
}

Measured memory_bytes: 23124
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<int> h(n);
  for (auto& hi: h) scanf("%d", &hi);

  int res = 0;
  int max = 0;
  for (size_t i = 0; i < n; ++i) {
    if (max <= h[i]) {
      ++res;
      max = h[i];
    }
  }
  printf("%d\n", res);
}


Measured memory_bytes: 256
import itertools
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, A, B, C = list(map(int, sys.stdin.buffer.readline().split()))
L = [int(sys.stdin.buffer.readline()) for _ in range(N)]

# 4**8=65536 通り全部試す
ans = INF
for choices in itertools.product(range(4), repeat=N):
    a = []
    b = []
    c = []

    for i, choice in enumerate(choices):
        if choice:
            [a, b, c][choice - 1].append(L[i])

    if a and b and c:
        mp = 0
        mp += (len(a) - 1) * 10 + abs(A - sum(a))
        mp += (len(b) - 1) * 10 + abs(B - sum(b))
        mp += (len(c) - 1) * 10 + abs(C - sum(c))
        ans = min(mp, ans)
print(ans)


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

ll inf=9223372036854775806;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a,b;
	cin>>a>>b;
	cout<<max(max(a-b,a+b),a*b);
	return 0;
}

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return x;}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename T>
bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>
bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	auto X=in(),Y=in();
	if(Y-2*X<0 || (Y-2*X)%2){
		out("No");
		return 0;
	}
	auto B = (Y-2*X)/2;
	auto A = X-B;
	if(A<0){
		out("No");
		return 0;
	}
	out("Yes");
	
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>  // std::accumulate(m.begin(), m.end(), 0LL);
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int A, B; std::cin >> A >> B;
  std::string S; std::cin >> S;
  auto pos = S.find("-");
  
  std::string l = S.substr(0,pos);
  std::string r = S.substr(pos+1,S.size());

  if ( pos == std::string::npos ) std::cout << "No" << std::endl;
  else if ( l.find("-") != std::string::npos ) std::cout << "No" << std::endl;
  else if ( r.find("-") != std::string::npos ) std::cout << "No" << std::endl;
  else if ( l.size() != A || r.size() != B ) std::cout << "No" << std::endl;
  else std::cout << "Yes" << std::endl;

  return 0;
}


Measured memory_bytes: 256
/* @ by batr (T) */
#include <bits/stdc++.h>
 
#define ll long long
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
 
#define cmp_all(X) (X).begin(), (X).end(), cmp
 
#define B begin()
#define E end()
#define sz size()
#define skip continue
 
#define ppi pair<pair<int, int>, int>
#define pii pair<int, int> 
#define pli pair<ll, int>
#define pcc pair<char, char>
 
#define F first
#define S second

using namespace std;
 
const int maxn = 1e7 + 17;
const int MAXN = maxn * 4;
const int darr = 1e3 + 17;
const ll INF = 1e17 + 5;
const int mod = 1e9 + 7;
 
void Need_For_Speed () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, l, r;

int main () {
	Need_For_Speed();
	cin >> n >> l >> r;
	if (l > r || (n == 1 && l != r)) {
		cout << 0;
		return 0;
	}
	if (n == 1) {
		cout << 1;
		return 0;
	}
	n -= 2;
	cout << r * 1ll * n - l * 1ll * n + 1;
	return 0;
}	

Measured memory_bytes: 256
n = gets.chomp.to_i

ana = {}
n.times do
  s = gets.chomp.split('').sort.join
  if ana.has_key?(s.to_sym)
    ana[s.to_sym] += 1
  else
    ana[s.to_sym] = 1
  end
end

res = 0
ana.each do |arr|
  n = arr[1]
  res += n * (n-1) / 2
end

print(res)


Measured memory_bytes: 39420
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<queue>
#include<iostream>
#include<cmath>
#include<stack>
using namespace std;
typedef long long LL;

const int maxn = 1e5 + 5;
vector<int> G[maxn];
int low[maxn],dfn[maxn],in[maxn];
bool vis[maxn];
stack<int> st;

LL cost[maxn],p[maxn],sum = 0,num = 0;
priority_queue<LL, vector<LL>, greater<LL> > que;
int n,m,ind,cnt;

void dfs(int x){
	low[x] = dfn[x] = ++ind;
	st.push(x),vis[x] = 1;
	for(int i = 0;i < G[x].size();i++){
		int v = G[x][i];
		if(!dfn[v]){
			dfs(v);
			low[x] = min(low[x],low[v]);
		}
		else if(vis[v]){
			low[x] = min(low[x],dfn[v]);
		}
	}
	if(low[x] == dfn[x]){
		int all = 0;
		cnt++;
		bool flag = false;
		while(!st.empty()){
			int tot = st.top();
			st.pop();
			vis[tot] = 0;
			in[tot] = 0;
			in[tot] = cnt;
			p[++all] = cost[tot];
			flag = true;
			if(tot == x) break;
		}
		if(flag){
			sort(p + 1,p + 1 + all);
			sum += p[1];
			num++;
			for(int i = 2;i <= all;i++) que.push(p[i]);
		}
	}
}

int main(){
	scanf("%d %d",&n,&m);
	for(int i = 0;i < n;i++) scanf("%lld",&cost[i]);
	for(int i = 1;i <= m;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		G[x].push_back(y);
		G[y].push_back(x);
	}
	if(n < 2 * (n - m - 1)){
		printf("Impossible\n");
		return 0;
	}
	else if(n == m + 1){
		printf("0\n");
		return 0;
	}
	for(int i = 0;i < n;i++){
		if(!dfn[i]) dfs(i);
	}
	while(num < 2 * (n - m - 1)){
		if(!que.empty()){
			LL ans = que.top();
			que.pop();
			sum += ans;
			num++;
		}
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 10056
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int A, B, C;
  cin >> A >> B;
  C=A*B;
  C=C%2;
  if(C==0){cout << "Even" << endl;}else{
  cout << "Odd" << endl;}
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	
	int a,b;
	scanf("%d %d",&a,&b);
	
	if(a<b){
		printf("a < b\n");
	}
	
	if(a>b){
		printf("a > b\n");
	}
	
	if(a==b){
		printf("a == b\n");
	}
	
	return 0;
}

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

int main() {
    long long n; cin >> n; 
    long long ans = 0;
    for (int i = 1; i <= n; i ++) {
        long long r = n/i; r = (r*(r+1)) / 2;
        ans = ans + (r*i);
    } cout << ans << endl;
}

Measured memory_bytes: 3604
#include <stdio.h>

int main()
{
    int a,i;
    float j=0.0,sum=0.0;
    int c[100];
    scanf("%d",&a);
    for(i=0;i<a;i++)
    {
       scanf("%d",&c[i]);
    }
    for(i=0;i<a;i++)
    {
        j=j+(1.0/c[i]);
    }
    sum=1.0/j;
    printf("%f",sum);
    return 0;
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;

const ll MOD = 1e9+7;

// n^m%MOD を求める。O( log(m) )
ll modpow(ll n, int m){
	ll ret=1;
	for(int i=1; i<=m; i<<=1, (n*=n)%=MOD){
		if( m&i ) (ret *= n) %= MOD;
	}
	return ret;
}

// 逆元を求める
ll modinv(ll n){
	return modpow( n, MOD-2 );
}

// 階乗を求める。O(1)  準備O( n*log(n) )
// fact[n]     : nの階乗
// fact.inv[n] : nの階乗の逆元
class FACTORIAL{
public:
	vector<ll> fact, inv;
	FACTORIAL(int MAX_NUM): fact(MAX_NUM), inv(MAX_NUM) {
		fact[0] = inv[0] = 1;
		for(ll i=1; i<MAX_NUM; i++){
			fact[i] = (fact[i-1] * i) % MOD;
			inv[i] = modinv( fact[i] );
		}
	}
	const ll& operator [ ] ( const int i ) const {
		return fact[i];
	}
} fact(1000006); // nの最大値を指定


// 組み合わせ(Combinationを求める) O(1)
ll cmb(unsigned int n, unsigned int r){
	if( n < r ) return 0;
	return fact[n] * fact.inv[r] % MOD * fact.inv[n-r] % MOD;
}


int main(){
	//ios_base::sync_with_stdio(false);
	ll H, W, A, B;

	cin >> H >> W >> A >> B;
	// H--;
	// W--;

	ll ans = cmb(H+W-2, H-1);
	//cout << ans << endl;
	reps(i,1,A+1){
		ll a = cmb(H-i+B-1, B-1);
		ll b = cmb(i-1+W-B-1, W-B-1);
		//cout << -a*b << endl;
		ans = (ans + MOD - (a*b)%MOD) % MOD;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 15872
a=bin(input()+(1<<60))[2:]
b=bin(input()+(1<<60))[2:]
if a==b:
	print 1
	exit()
while a[0]==b[0]:
	a=a[1:]
	b=b[1:]
assert a[0]=="0" and b[0]=="1"
result=int("1"+"0"*(len(a)-1), 2)-int(a, 2)
b=b[1:]
while b and b[0]=="0":
	b=b[1:]
if not b:
	b=0
else:
	b=(1<<len(b))-1
if b>=int(a, 2):
	result+=(1<<(len(a)-1))
else:
	result=result*2+b+1
print result

Measured memory_bytes: 2696
H, W, K = map(int, input().split(' '))
mat = []
for _ in range(H):
    mat.append(input())

ans = 0
for ib in range(1<<H):
    for jb in range(1<<W):
        count = 0
        for i in range(H):
            for j in range(W):
                if ib>>i&1:
                    continue
                if jb>>j&1:
                    continue
                if mat[i][j] == '#':
                    count += 1
        if count == K:
            ans += 1
print(ans)


Measured memory_bytes: 9052
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;



namespace Test1 {

    class ClassMain {




        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                string[] strs = line.Split(' ');
                int n = int.Parse(strs[0]);
                int m = int.Parse(strs[1]);
                if (n == 0) { break; }
                load[] loads = new load[n];
                for (int i = 0; i < n; i++) {
                    strs = Console.ReadLine().Split(' ');
                    loads[i] = new load(int.Parse(strs[0]), int.Parse(strs[1]));
                }
                reduceLoad(loads, m);

                Console.WriteLine(osowareKaisuu(loads) );






            }
        }
        public static void reduceLoad(load[] loads , int money) {
            Array.Sort(loads);
            Array.Reverse(loads);
            for (int i = 0; i < loads.Length; i++) {
                load a_load = loads[i];
                if (money < a_load.len) { a_load.len -= money; money = 0; }
                else { money -= a_load.len; a_load.len = 0; }
                if (money == 0) { break; }

            }

            

        
        }
        public static int osowareKaisuu(load[] loads) {
            int count = 0;
            for (int i = 0; i < loads.Length; i++) {
                count += loads[i].len * loads[i].kitai;
            }
            return count;
        }


        public class load : IComparable {
            public int len;
            public int kitai;
            public load(int l, int k) { len = l; kitai = k; }
            public int CompareTo(object obj) {
                load obj_l = (load)obj;
                int kitai_obj = obj_l.kitai;
                return kitai - kitai_obj;                
            }

        }


       

        


    }
}

Measured memory_bytes: 6444
#include <stdio.h>
#include <math.h>

int main()
{
	int w,a;
	double x=0.0,y=0.0;
	double age=90.0;
	double r;
	while(1){
		scanf("%d,%d",&w,&a);
		if(w==0&&a==0)break;
		r=(age/180.0*M_PI);
		x+=cos(r)*w;
		y+=sin(r)*w;
		age-=a;
	}
	printf("%d\n%d\n",(int)x,(int)y);
	return 0;
}

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

using namespace std;
#define pb push_back
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef set<char> setc;
typedef set<int> seti;

void solve(){
	//write solution here
	string x,y;
	cin>>x;
	cin>>y;
	string ans = "";
	int n = x.length()+y.length();
	for(int i = 0; i < n; i++){
		if(i%2){
			ans+=y[i/2];
		}
		else{
			ans+=x[i/2];
		}
	}
	cout<<ans<<endl;
}

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

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

int main( void ){
  int a;
  char* s;

  scanf("%d", &a);

  s = (char*)malloc(sizeof(char) * a);

  scanf("%s", s);

  if(a < 3200){
    printf("red\n");
  }else{
    printf("%s\n", s);
  }

  free(s);

  return 0;
}



Measured memory_bytes: 128
def main():
    N = int(input())
    
    array = []
    
    for i in range(N):
        array2 = list(map(int,input().split()))
        array.append(array2)

    num = [[0,0,0] for z in range(N)]
    for m in range(3):
        num[0][m] = array[0][m]

    

    for j in range(1,N):
        
        for z in range(3):
            for y in range(3):
                if y == z:
                    continue
                else:
                    num[j][z] = max(num[j][z],array[j][z]+num[j-1][y])
            
    
    print(max(num[-1]))
    
main()

Measured memory_bytes: 47320
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
 
using namespace std;

int comp_two_sum_of_digits (int a, int b) {
  int sum = 0;
  while (a > 0) {
    sum += a % 10;
    a /= 10;
  }
  while (b > 0) {
    sum += b % 10;
    b /= 10;
  }
  return sum;
}

int main() {
  int N; cin >> N;
  
  int ans = 10000000;
  for (int i=1; i<int(N/2)+1; i++) {
    int j = N - i;
    int res = comp_two_sum_of_digits(i, j);
    if (ans > res) ans = res;
  }
  cout << ans << endl;
}

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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, -1, 0, 1, 1, 1, -1, -1};
const int L = 3500;
const int N = 1000000;
int grid[L][L];
void init(){
  int l = 1;
  int x = L / 2;
  int y = L / 2;
  int r = 0;
  int rest = 1;
  for(int y = 0; y < L; y++) {
    for(int x = 0; x < L; x++){
      grid[y][x] = INF;
    }
  }
  for(int i = 1; i <= N; i++){
    assert(grid[y][x] == INF);
    grid[y][x] = i;
    x += dx[r];
    y += dy[r];
    rest--;
    if(rest == 0){
      r = (r + 1) % 4;
      if(r % 2 == 0) l++;
      rest = l;
    }
  }
}

bool prime[N + 1] = {};
void make_prime(){
  for(int i = 2; i <= N; i++) prime[i] = true;
  for(int i = 2; i <= N; i++) if(prime[i]){
    for(int j = 2 * i; j <= N; j += i){
      prime[j] = false;
    }
  }
}


int main(){
  init();
  make_prime();
  int max_n, st;
  while(cin >> max_n >> st && max_n){
    static int dp[L][L];
    for(int y = 0; y < L ; y++){
      for(int x = 0; x < L; x++){
        if(grid[y][x] == st) dp[y][x] = prime[ grid[y][x] ];
        else                 dp[y][x] = -INF;
      }
    }
    int ans1 = 0;
    int ans2 = 0;
    for(int y = 1; y < L; y++){
      for(int x = 0; x < L; x++) if(grid[y][x] <= max_n){
        for(int dx = -1; dx <= 1; dx++)if(x + dx >= 0 && x + dx < L){
          dp[y][x] = max(dp[y][x], dp[y - 1][x + dx] + prime[ grid[y][x] ]);
          if(dp[y][x] > ans1 && dp[y][x] > 0 && prime[ grid[y][x] ]){
            ans1 = dp[y][x];
            ans2 = grid[y][x];
          }else if(dp[y][x] == ans1 && dp[y][x] > 0 && prime[ grid[y][x] ]){
            ans2 = max(ans2, grid[y][x]);
          }
        }
      }
    }
    printf("%d %d\n", ans1, ans2);
  }
  return 0;
}

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

int main() {
    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a),q(b),r(c);
    rep(i,a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i,c) cin >> r[i];
    sort(p.rbegin(),p.rend()); sort(q.rbegin(),q.rend()); sort(r.rbegin(),r.rend());
    ll ans = 0;
    rep(i,x) ans+=p[i];
    rep(i,y) ans+=q[i];
    ll z = 0;
    while(1){
        if(x==0&&y==0){
            break;
        }else if(x==0){
            if(q[y-1]<r[z]){
                ans-=q[y-1]; ans+=r[z];
                y--; z++;
                continue;
            }else{
                break;
            }
        }else if(y==0){
            if(p[x-1]<r[z]){
                ans-=p[x-1]; ans+=r[z];
                x--; z++;
                continue;
            }else{
                break;
            }
        }
        if(z==c) break;
        if(p[x-1]>=q[y-1]){
            if(q[y-1]<r[z]){
                ans-=q[y-1]; ans+=r[z];
                y--; z++;
            }else{
                break;
            }
        }else{
            if(p[x-1]<r[z]){
                ans-=p[x-1]; ans+=r[z];
                x--; z++;
            }else{
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5556
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */


int n;
int a[500];
int ma[500];

int getNeed(int t)
{
    uint64_t msum;
    for(int i=0;i<n;i++)
    {
        ma[i] = a[i]%t;
    }
    qsort(ma, n,sizeof(int), acs);
    msum = 0;
    for(int i=0;i<n;i++)
    {
        //printf("%d%c",ma[i],i==n-1?'\n':' ');
        msum += ma[i];
    }
    uint64_t need;
    need = 0;
    for(int i=0;i<n-(msum/t);i++)
    {
        need += ma[i];
    }
    return need;
}


int main(void)
{
    int k;
    uint64_t sum;
    scanf("%d",&n);
    scanf("%d",&k);

    sum = 0;
    for(int i=0;i<n;i++)
    {
        scanf("%d", &(a[i]));
        sum += a[i];
    }

    uint64_t ans;
    ans = 1;
    for(int i=1; sum >= i*i;i++)
    {
        if( sum %i == 0)
        {
            int n;
            n = getNeed(i);
            if( n<=k) ans = ans < i ? i: ans;
            n = getNeed(sum/i);
            if( n<=k) ans = ans < sum/i ? sum/i: ans;
        }
    }

    printf("%ld\n",ans);
    
    return 0;
}



Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    long long sum = 0;

    for (int i = 1; i <= N; i++) {
        if (i % 15 == 0 || i % 3 == 0 || i % 5 == 0) {
            continue;
        }
        sum += i;
    }

    cout << sum << endl;
}

Measured memory_bytes: 3636
n = int(input())
c = 0
d,t = [0]*n,[0]*n
d[0],t[0] = map(int,input().split())
d[1],t[1] = map(int,input().split())

for i in range(2,n):
	d[i],t[i] = map(int,input().split())
	if d[i] == t[i] and d[i-1] == t[i-1] and d[i-2] == t[i-2]:
		c += 1
if c != 0:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 2e5 + 1;
int n, k;
vi v(mxn);

bool chk(int x){
    int cuts = 0;
    rep(i, 0, n){
        if(v[i] <= x)
            continue;
        cuts += (v[i] + x - 1)/x - 1;
    }
    if(cuts <= k)
        return true;
    else
        return false;
}

int solve(){
    cin>> n>> k;
    rep(i, 0, n)
        cin>> v[i];
    int l = 1, r = mod;
    while(l < r){
        int mid = (l + r)/2;
        if(chk(mid))
            r = mid;
        else
            l = mid + 1;
    }
    cout<< l<< endl;
    return 0;
}
//Counting problems: Sometimes easier to find complement of the answer
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

int main(){
    ll N;
    cin >> N;
    set<ll> A;
    while(N--){
        ll a; cin >> a;
        A.insert(a);
    }

    ll M;
    cin >> M;
    set<ll> B;
    while(M--){
        ll b; cin >> b;
        B.insert(b);
    }

    vector<ll> C;
    set_union(ALL(A), ALL(B), back_inserter(C));

    for(ll c : C){
        p(c);
    }

    return 0;
}


Measured memory_bytes: 25752
#include <iostream>
#include<vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
typedef long long ll;

using namespace std;



int main() {
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n) cin>>a[i];
    ll x0 = 0;
    rep(i,n){
        if(i%2) x0 -= a[i];
        else x0 += a[i];
    }
    vector<int>ans(n);
    ans[0] = x0/2;
    rep(i,n-1){
        ans[i+1] = a[i]-ans[i];
    }
    rep(i,n) cout<<2*ans[i]<<" ";

    return 0;
}

Measured memory_bytes: 4012
#include <iostream>
#include <string>

using namespace std;

char solve(char board[9]) {
	//テァツクツヲ
	for (int i = 0; i < 3; i++)
		if (board[i] != '+' && board[i] == board[i + 3] && board[i] == board[i + 3 * 2]) 
			return board[i];

	//テヲツィツェ
	for (int i = 0; i < 9; i += 3)
		if (board[i] != '+' && board[i] == board[i + 1] && board[i] == board[i + 2])
			return board[i];

	//テヲツ鳴愿」ツつ?
	if (board[0] != '+' && board[0] == board[3 + 1] && board[0] == board[3 * 2 + 2])
		return board[0];
	if (board[2] != '+' && board[2] == board[3 + 1] && board[2] == board[3 * 2])
		return board[2];

	return 0;
}

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

	while (1) {
		char board[9];
		cin >> board[0];
		if (board[0] == '0') break;
		for (int i = 1; i < 9; i++)
			cin >> board[i];
		char c;
		if ((c = solve(board)))
			cout << c << endl;
		else
			cout << "NA" << endl;
	}
}

Measured memory_bytes: 1164
# @author 

import sys

class EVirusTree2:

    def solve(self):
        from collections import defaultdict
        import sys
        sys.setrecursionlimit(10 ** 5 + 5)

        MOD = 10 ** 9 + 7
        n, k  = [int(_) for _ in input().split()]
        adj = defaultdict(list)
        for i in range(n - 1):
            a, b = [int(_) for _ in input().split()]
            a -= 1
            b -= 1
            adj[a].append(b)
            adj[b].append(a)
        done = [0] * n
        def dfs(s, rem):
            done[s] = 1
            if rem < 0:
                return 0
            res = 1
            for x in adj[s]:
                if done[x]:
                    continue
                if rem <= 0:
                    return 0
                res = (res * rem) % MOD
                res = (res * dfs(x, k - 2)) % MOD
                rem -= 1
                if res == 0:
                    return 0
            return res

        print((dfs(0, k - 1) * k) % MOD)




solver = EVirusTree2()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 110132
<?php
$n=explode(" ",trim(fgets(STDIN)));
$s=trim(fgets(STDIN));
$i=0;
while($i<$n[0]){
  if($i!=$n[1]-1){
    echo $s[$i];
  }else{
    echo strtolower($s[$n[1]-1]);
  }
  ++$i;
}

Measured memory_bytes: 4728
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>;
template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MAX = 1e5 + 5, MOD = 1e9 + 7;
constexpr ll LINF = 1ll << 60; constexpr double EPS = 1e-6;
constexpr int dy[4] = { 0,1,0,-1 }, dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int Q;

int main() {
    cin >> Q;

    rep(i, Q) {
        ll A, B;
        cin >> A >> B;

        if (A == B) write(2 * A - 2);
        else {
            if (A > B) swap(A, B);

            ll C = A * B;
            ll D = max((ll)0, (ll)sqrt(C - 1) - 10);
            while (D * D < C) D++;
            D--;
            if (D * (D + 1) < C) {
                write(2 * D - 1);
            }
            else {
                write(2 * D - 2);
            }
        }
    }
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <stdexcept>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>
  
using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
  
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define fill(x, y) memset(x, y, sizeof(x))
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define itn int
#define re return
#define prev PREV
#define next NEXT
  
#define sz(x) ((int)x.size())
  
const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int MAXN = 1e5;
#define FILENAME ""
const double eps = 1e-6;
const int maxn = 1001;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    //freopen("unionday.in", "r", stdin);
    //freopen("unionday.out", "w", stdout);
    int n, k;
    cin >> n >> k;
    cout << n - k + 1;
    return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int h, w;
    cin >> h >> w;
    vector<vector<int> > field(h, vector<int>(w, 0));

    for(int i=0;i<h;++i) {
        for(int j=0;j<w;++j) {
            cin >> field[i][j];
        }
    }

    int count=0;
    vector<vector<bool> > move(h, vector<bool>(w, false));
    for(int i=0;i<h;++i) {
        if(i&1) {
            for(int j=w-2;j>=0;--j) {
                if (field[i][j+1]&1) {
                   move[i][j+1] = true;
                   --field[i][j+1]; ++field[i][j];
                   ++count;
                }
            }
            if (i<h-1 && (field[i][0]&1)) {
                move[i][0] = true;
                --field[i][0]; ++field[i+1][0];
                ++count;
            }
        } else {
            for(int j=1;j<w;++j) {
                if (field[i][j-1]&1) {
                   move[i][j-1] = true;
                   --field[i][j-1]; ++field[i][j];
                    ++count;
                }
            }
            if (i<h-1 && (field[i][w-1]&1)) {
                move[i][w-1] = true;
                --field[i][w-1]; ++field[i+1][w-1];
                ++count;
            }
        }
    }

    cout << count << endl;
    for(int i=0;i<h;++i) {
        if(i&1) {
            for(int j=w-2;j>=0;--j) {
                if (move[i][j+1]) {
                    cout << i+1 << " " << j+2 << " " << i+1 << " " << j+1 << endl;    
                }
            }
            if (move[i][0]) {
                cout << i+1 << " " << 1 << " " << i+2 << " " << 1 << endl;    
            }
        } else {
            for(int j=1;j<w;++j) {
                if (move[i][j-1]) {
                    cout << i+1 << " " << j << " " << i+1 << " " << j+1 << endl;
                }
            }
            if (move[i][w-1]) {
                cout << i+1 << " " << w << " " << i+2 << " " << w << endl;    
            }
        }
    }


    
    return 0;
}


Measured memory_bytes: 3200
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

typedef int64_t int64;
typedef int64_t ll;

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

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

using namespace std;


class C {
	int n, k;
public:
	C()
	{
		cin >> n >> k;
	}
	void solve()
	{
		if (k >= n)
		{
			cout << 1 << endl;
			return;
		}

		int ans{ 1 };
		n -= k;
		ans += (int)ceil((double)n / (k - 1));

		cout << ans << endl;

	}
};


int main()
{
	C solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
long long int mod = (long long int)1000000007;
using namespace std;

void solve()
{
    ll i,j,k,n;
    std::cout.precision(10);
    int yes=0;
    cin>>n;
    double m,a[n];
    cin>>m;
    double sum=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    double lim=sum/((double)4*m);

    ll c=0;
    for(i=0;i<n;i++)
    {
        //cout<<a[i]/sum;
        if(a[i]>=lim)
        {
            c++;
        }
    }
    if(c>=m)
    cout<<"Yes";
    else
    cout<<"No";
    
}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int t;
    std::cout.precision(10);
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 3712
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

res = 0
for i in range(n):
  res += b[a[i]-1]
  if i != 0:
    if a[i] == a[i-1]+1:
      res += c[a[i]-2]
print(res)


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


int main() {
  int N;
  string S;
  
  cin >> N >> S;
  
  if (N == 1) cout << 1 << endl;
  else {
    int ans = 1;
    rep(i,N-1) {
      if (S[i] != S[i+1]) ans++;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 512
s = int(input())
lst = [s]
while True:
    if lst[-1]%2 == 0:
        a = lst[-1]//2
    else:
        a = 3*lst[-1] + 1
    if a in lst:
        lst.append(a)
        print(len(lst))
        break
    lst.append(a)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define sz(x) ((int) x.size())
#define orta ((bas+son)/2)
#define all(x) x.begin(),x.end()
#define inf 1000000000
#define MOD 1000000007 
#define N 100005
#define M 1000000
#define LOG 20
#define KOK 300
#define EPS 0.0000001
using namespace std;

struct edge {
	
	int a,b,c;

};

vector<edge> e;
int l;
int tut[22];

int main() {

	scanf("%d",&l);

	int cur=0;

	for(int i=19;i>=0;i--) {

		if(l&(1<<i)) {

			if(!cur) {

				int now=1;

				for(int j=i-1;j>=0;j--,now++) {

					e.pb({now,now+1,1<<j});
					e.pb({now,now+1,0});

					tut[j]=now;

				}

			}
			else {

				e.pb({1,tut[i]+1,cur});

			}

			cur+=(1<<i);

		}
	
	}

	printf("%d %d\n",tut[0]+1,sz(e));

	for(auto x:e) {

		printf("%d %d %d\n",x.a,x.b,x.c);

	}

}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cout << #x << " -> " << x << endl
#define booga cout << "booga" << endl
#define ll long long int
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;


void testcase(){
	int n,a[200005];
	int nim = 0;
	cin >> n;
	for(int i{0};i < n;i++){
		cin >> a[i];
		nim ^= a[i];
	}
	for(int i{0};i < n;i++){
		cout << (int)(nim ^ a[i]) << " ";
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	while(t--){
		testcase();
	}
	return 0;
}


Measured memory_bytes: 4436
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k,l;
  int s[10001],n;
  int ct;
  memset(s,0,sizeof(s));
  s[2]=1;
  for(i=3;i<10000;i+=2){
    l=(int)sqrt(i)+1;
    for(k=3;k<l;k+=2){
      if(i%k==0)
	break;
    }
    if(k>=l)
      s[i]=1;
  }
  while(cin>>n){
    ct=0;
    for(i=1;i<n+1;i++){
      if(s[i]&s[n-i+1])
	ct++;
    }
    cout<<ct<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
ans = 0
for ll in range(len(N)):
    S = N[ll]
    flag = True
    for i in range(len(S) // 2):
        if S[i] != S[len(S)-i-1]:
            flag = False
            break
    if flag:
        ans += 1
print(ans)


Measured memory_bytes: 5560