akhauriyash/Code-Regression huggingface dataset:
// AOJ ALDS1_10_C Longest Common Subsequence
// 2018.4.27 bal4u

#include <stdio.h>
#include <stdlib.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

// Longest Common Subsequence
int c[1005][1005];
int LCS(char *x, int m, char *y, int n)
{
	int i, j;

	for (i = 0; i <= m; i++)  c[i][0] = 0;
	for (j = 0; j <= n; j++)  c[0][j] = 0;

	for (i = 1; i <= m; i++) for (j = 1; j <= n; j++) {
		if (x[i-1] == y[j-1]) c[i][j] = c[i-1][j-1] + 1;
		else {
			if (c[i-1][j] >= c[i][j-1]) c[i][j] = c[i-1][j];
			else c[i][j] = c[i][j-1];
		}
	}
	return c[m][n];
}

char x[1005], y[1005];

int main()
{
	int q, lx, ly, c;
	char *p;

	q = in();
	while (q--) {
		p = x; while ((c = gc()) > ' ') *p++ = c;
		*p = 0, lx = p-x;
		p = y; while ((c = gc()) > ' ') *p++ = c;
		*p = 0, ly = p-y;
		printf("%d\n", LCS(x, lx, y, ly));
	}
	return 0;
}



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

constexpr int inf = 0x3f3f3f3f;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> l(n), r(n);
  int res = 0, mn = inf, mi = -1;
  for (int i = 0; i < n; ++i) {
    cin >> l[i] >> r[i];
    --l[i];
    res = max(res, r[i] - l[i]);
    if (r[i] < mn) {
      mn = r[i];
      mi = i;
    }
  }
  int lo = -inf, hi = inf;
  auto add = [&](int i) {
    lo = max(lo, l[i]);
    hi = min(hi, r[i]);
  };
  auto get = [&] {
    if (hi == inf) {
      return -inf;
    }
    return max(hi - lo, 0);
  };
  vector<int> idx;
  int max_len = -inf;
  for (int i = 0; i < n; ++i) {
    if (i != mi) {
      max_len = max(max_len, r[i] - l[i]);
      if (l[i] <= l[mi]) {
      } else if (l[i] < mn) {
        idx.push_back(i);
      } else {
        add(i);
      }
    }
  }
  sort(begin(idx), end(idx), [&](int i, int j) {
    return l[i] > l[j];
  });
  if (hi == inf) {
    res = max(res, (mn - (idx.empty() ? l[mi] : l[idx[0]])) + max_len);
  }
  for (int i : idx) {
    res = max(res, (mn - l[i]) + get());
    add(i);
  }
  res = max(res, (mn - l[mi]) + get());
  cout << res << '\n';
}


Measured memory_bytes: 1788
'use strict'
function main(input) {
  input = input.trim().split('\n')
  input.shift()
  let min = 0
  let max = 1000000
  input.forEach(val => {
    let temp = val.split(' ').map(val => Number(val))
    if (temp[0] > min) min = temp[0]
    if (temp[1] < max) max = temp[1]
  })
  let ans = max - min + 1
  console.log(ans > 0 ? ans : 0)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29072
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

class UnionFindTree {
public:
    this(size_t n) {
        parent = iota(n).array();
        rank = new size_t[](n);
    }
    size_t find(size_t n) {
        if(n == parent[n]) {
            return n;
        } else {
            parent[n] = find(parent[n]);
            return parent[n];
        }
    }
    void unite(size_t n, size_t m) {
        auto p1 = find(n);
        auto p2 = find(m);
        if(n == m) {
            return;
        }
        if(rank[p1] < rank[p2]) {
            swap(p1, p2);
        }
        if(rank[p1] == rank[p2]) {
            ++rank[p1];
        }
        parent[p2] = p1;
    }
private:
    size_t[] parent;
    size_t[] rank;
}
unittest {
    auto uft = new UnionFindTree(10);
    foreach(i; iota(10)) {
        assert(uft.find(i) == i);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0).drop(1)) {
        uft.unite(i, i-3);
    }
    foreach(i; iota(10).filter!(a => a%3 == 0)) {
        assert(uft.find(0) == uft.find(i));
    }
    foreach(i; iota(10).filter!(a => a%3 != 0)) {
        assert(uft.find(0) != uft.find(i));
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

//a+b == s, a^b == xとなる個数
long f(long s, long x) {
    if(s == 0 && x == 0) {
        return 1;
    }
    if(s < 0 || x < 0) {
        return 0;
    }
    auto ans = memoize!f(s/2, x/2) + memoize!f(s/2-1, x/2);
    if(s > 0 && x > 0) {
        ans += memoize!f((s-1)/2, (x-1)/2);
    }
    return ans % p;
}

void main(){
    auto n = readLong();
    writeln(f(n, n));
}



Measured memory_bytes: 256
#include <cstdio>

int log_2(long N) {
    if (N < 2) return 0;
    else return log_2(N/2) + 1;
}

int main() {
    long X,Y;
    scanf("%ld %ld",&X,&Y);
    printf("%d\n",log_2(Y/X)+1);
}

Measured memory_bytes: 128
N = int(input())
S = list(input())
alphabet = 'abcdefghijklmnopqrstuvwxyz'
count = 0
ans = 0

for i in range(1,N):
    for a in alphabet:
        X = S[:i].count(a)
        Y = S[i:].count(a)
        if X > 0 and Y > 0:
            count += 1
    ans = max(ans, count)
    count = 0

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

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

		if(W >= S) {
			System.out.println("unsafe");
		}else {
			System.out.println("safe");
		}

	}
}


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

using namespace std;

#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T &b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T &b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { 1,  0, -1,  0,  1, -1,  1, -1};
static const int dy[8] = { 0,  1,  0, -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 1e5+5;

string s;
set<int> st;
int dis[maxn];
int ans[maxn];
int N,M;
int ok = 0;

void searching(int v){
    int sz = s.size();
    int d = dis[v];
    if(v == N) ok = 1;

    _rec(i,M,1){
        if(ok) return;
        int w = i+v;
        if(w <= N && s[w] != '1' && dis[w] == -1){
            dis[w] = d + 1;
            searching(w);
        }
    }
}

int main()
{
    cin >> N >> M;
    cin >> s;
    reverse(ALL(s));
    MEM(dis,-1);
    MEM(ans,-1);
    dis[0] = 0;
    _rep(i,1,N){
        if(s[i] == 0) st.insert(i);
    }

    searching(0);
    if(dis[N] == -1){
        cout << -1 << endl;
    }
    else{
        //_rep(i,0,N) printf("%d ",dis[i]);
        _rep(i,0,N){
            int d = dis[i];
            if(d != -1) ans[d] = i;
        }
        stack<int> st;
        int i = 0;
        while(ans[i+1] != -1){
            st.push(ans[i+1] - ans[i]);
            i++;
        }
        while(!st.empty()){
            int o = st.top();
            st.pop();
            if(st.empty()){
                printf("%d\n",o);
            }else{
                printf("%d ",o);
            }
        }

    }


    return 0;
}


Measured memory_bytes: 6348
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define vi vector<int>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define mp make_pair
#ifdef LOCAL
#define debug(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define check(...) assert(__VA_ARGS__)
#else
#define debug(fmt, ...)
#define check(...)
#endif

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

    int n, m;
    cin >> n >> m;
    vi a(m);
    int acc = 0;
    rep(i, 0, m) {
        cin >> a[i];
        acc += a[i];
    }
    if (n >= acc) {
        cout << n - acc;
    } else {
        cout << -1;
    }
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int A, B, C, K;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> A >> B >> C >> K;
	int need = 0;
	while (B <= A) B *= 2, need++;
	while (C <= B) C *= 2, need++;

	if (need <= K) cout << "Yes" << endl;
	else cout << "No" << endl;
}







Measured memory_bytes: 3692
#include<stdio.h>
#include<queue>
#include<string.h>

using namespace std;
char c[11];
int d[10];
int bfs[59049];
int temp[10];
int main(){
	while(1){
		scanf("%s",c);
		if(c[0]=='0')return 0;
		queue<int> Q;
		for(int i=0;i<59049;i++)bfs[i]=-1;
		int first=0;
		int s=strlen(c);
		for(int i=0;i<s;i++){
			first*=3;
			if(c[i]=='r')first+=2;
			if(c[i]=='g')first++;
		}
		bfs[first]=0;
		Q.push(first);
		while(Q.size()){
			int now=Q.front();
			int val=now;
			for(int i=0;i<s;i++){
				d[s-i-1]=val%3;
				val/=3;
				temp[s-i-1]=d[s-i-1];
			}
			for(int i=0;i<s-1;i++){
				if(d[i]!=d[i+1]){
					if(d[i]!=0&&d[i+1]!=0){
						temp[i]=temp[i+1]=0;
						int next=0;
						for(int j=0;j<s;j++){
							next*=3;
							next+=temp[j];
						}
						if(bfs[next]==-1){
							bfs[next]=bfs[now]+1;
							Q.push(next);
						}
					}
					if(d[i]!=1&&d[i+1]!=1){
						temp[i]=temp[i+1]=1;
						int next=0;
						for(int j=0;j<s;j++){
							next*=3;
							next+=temp[j];
						}
						if(bfs[next]==-1){
							bfs[next]=bfs[now]+1;
							Q.push(next);
						}
					}
					if(d[i]!=2&&d[i+1]!=2){
						temp[i]=temp[i+1]=2;
						int next=0;
						for(int j=0;j<s;j++){
							next*=3;
							next+=temp[j];
						}
						if(bfs[next]==-1){
							bfs[next]=bfs[now]+1;
							Q.push(next);
						}
					}
					temp[i]=d[i];
					temp[i+1]=d[i+1];
				}
			}
			Q.pop();
		}
		int q=0;
		for(int i=0;i<s;i++){
			q*=3;
			q++;
		}
		int r=0;
		for(int i=0;i<s;i++){
			r*=3;
			r+=2;
		}
		int ans=99999999;
		if(bfs[0]!=-1&&ans>bfs[0])ans=bfs[0];
		if(bfs[q]!=-1&&ans>bfs[q])ans=bfs[q];
		if(bfs[r]!=-1&&ans>bfs[r])ans=bfs[r];
		if(ans==99999999)printf("NA\n");
		else printf("%d\n",ans);
	}
}

Measured memory_bytes: 1060
N=input()
n=int(N)

p=input().split()

for i in range(n):
    p[i]=int(p[i])

t=[]
q=0

for i in range(n):
    if p[i]%2==0:
        t.append(p[i])
        q=q+1

flag=True
for i in range(q):
    if t[i]%3!=0 and t[i]%5!=0:
        flag=False

if flag== True:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 3064
from collections import defaultdict
 
N = int(input())
raw_numbers = list(map(int, input().split()))
Q = int(input())
 
total = sum(raw_numbers)
 
numbers = defaultdict(int)
 
for num in raw_numbers:
    numbers[num] += 1

for _ in range(Q):
    a, b = list(map(int, input().split()))
    taken = numbers[a]
    total -= numbers[a]*a
    numbers[b] += numbers[a]
    numbers[a] = 0
    total += taken*b
    print(total)

Measured memory_bytes: 94424
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;

int main(){
	int n,a,b;
    cin>>n>>a>>b;
    OUT(min(n*a,b));
	return 0;
}

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

using namespace std;
using ll = long long;
const ll D = 33;

const vector<vector<ll>> dir = {{0, 1}, {1, 0}};

/*********************************/
template<class T> inline ostream& operator<<(ostream& os,vector<T> arr) {os << "["; for(ll i = 0; i < (ll)arr.size(); i++)os << arr[i] << (i == (ll)arr.size() - 1 ? "]\n" : ",");;return os;}
template<typename A, typename B> ostream& operator<<(ostream& os, const pair<A,B>& p){os << "{" << p.first << "," << p.second << "}";return os; }
#define prvec(v) cerr<<#v<<": [";for(ll __i = 0;__i < (ll)(v).size(); __i++)cerr<<((v)[__i])<<(__i+1==(ll)(v).size()?"]\n":",");
#define prll(x) cerr<<#x<<": "<<(x)<<endl
/*********************************/

int main()
{
    ll h, w, k;
    cin >> h >> w >> k;
    vector<vector<ll>> cost(h, vector<ll>(w));
    for(ll i = 0; i < k; i++) {ll r, c; cin >> r >> c; r--, c--; cin >> cost[r][c];}
    vector<vector<vector<ll>>> dp(h, vector<vector<ll>>(w, vector<ll>(4)));
    dp[0][0][0] = 0;
    if(cost[0][0])dp[0][0][1] = cost[0][0];


    for(ll i = 0; i < h; i++) {
        for(ll j = 0; j < w; j++) {
            for(ll t = 0; t <= 3; t++) {

                {//下に移動

                    ll ny = i + 1, nx = j;
                    if(ny < h) {
                    if(cost[ny][nx]) {
                        dp[ny][nx][1] = max(dp[i][j][t] + cost[ny][nx], dp[ny][nx][1]);
                    }
                    dp[ny][nx][0] = max(dp[i][j][t], dp[ny][nx][0]);
                    }
                }

                {//横に移動
                    ll ny = i, nx = j + 1;
                    if(nx < w){
                    if(cost[ny][nx] && t != 3) {
                        dp[ny][nx][t + 1] = max(dp[ny][nx][t + 1], dp[i][j][t] + cost[ny][nx]);
                    }
                    dp[ny][nx][t] = max(dp[ny][nx][t], dp[i][j][t]);
                }
                }
            }
        }
    }

    // cerr << cost << endl;
    // cerr << dp[1] << endl;
    ll nax = 0;
    for(ll i = 0; i < h; i++) {
        for(ll j = 0; j < w; j++) {
            nax = max(nax, *max_element(dp[i][j].begin(), dp[i][j].end()));
        }
    }
    cout << nax << endl;

    // cout << *max_element(dp[h - 1][w - 1].begin(), dp[h - 1][w - 1].end()) << endl;

}


Measured memory_bytes: 706664
//减少BFS的次数，否则一定会TLE。 
#include<bits/stdc++.h>
#include<queue>
#define INF 1e9
#define DAN 1e8
using namespace std;
typedef pair<int,int> P;
int n,m;
vector<string> vs;
int mp[20][20];
int BFS(pair<int,int> poss)
{
	int dx[4] = {0,0,-1,1};
	int dy[4] = {1,-1,0,0};
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			if(vs[i][j] == '.')
				mp[i][j] = INF;
			else
				mp[i][j] = DAN;
	queue<P> que;
	que.push(poss);
	mp[poss.first][poss.second]=0;
	int max1 = -1e8;
	while(que.size())
	{
		P p = que.front();
		que.pop();
		for(int i=0;i<4;i++)
		{
			int nx = p.first+dx[i];
			int ny = p.second+dy[i];
			if(nx>=0&&ny>=0&&nx<n&&ny<m&&mp[nx][ny] == INF)
			{
				mp[nx][ny] = mp[p.first][p.second]+1;
				que.push(make_pair(nx,ny));
				if(max1<mp[nx][ny])
				{
					max1 = mp[nx][ny];
				}
			}
		}
	}
	return max1;
}
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		vs.push_back(s);
	}
	long long max44 = -1;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(vs[i][j]!='#')
			{
				long long bfs = BFS(make_pair(i,j));
//				cout<<"max integer of the BFS:"<<bfs<<endl;
				if(bfs>max44)
				{
					max44 = bfs;
				}
			}
		}
	}
	cout<<max44<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;

int main(){
    int n,k,total=0;
    cin>>n>>k;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
        total += 2*min(k-a[i],a[i]);
    }
    cout<<total<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;
class Program {
    static void Main (string[] arg){
        string[] input = Console.ReadLine().Split(' ');
        string a = input[0];
        input[0] = input[1];
        input[1] = a;
        a = input[0];
        input[0] = input[2];
        input[2] = a;
        Console.WriteLine(string.Join(" ",input));
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<iterator>
#include<algorithm>
#include<cmath>
#include<functional>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
//#include<bits/stdc++.h>
using namespace std;

int main(){
	int k,x;
	cin >> k >> x;
	for (int i = x - k + 1; i < x + k; i++)
	{
		cout << i << " ";
	}	
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

ll modpow(ll a, ll b) {
  ll r = 1;
  while (b) {
    if (b & 1) r = r * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return r;
}

int main() {
  ll n, t, cnt = 1;
  cin >> n;
  unordered_map<int, int> mp;

  rep(i, n) cin >> t, mp[t]++;

  bool flg = true;
  if (n % 2 == 1) {
    if (mp[0] != 1) flg = false;
    for (int i = 2; i < n; i += 2)
      if (mp[i] != 2) flg = false;
  } else {
    for (int i = 1; i < n; i += 2)
      if (mp[i] != 2) flg = false;
  }

  cout << (flg ? modpow(2, n / 2) : 0) << endl;
  return 0;
}


Measured memory_bytes: 3748
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder0607
{
	class Program
	{
		static void Main(string[] args)
		{
			A();

		}

		static void A()
		{
			var cases = int.Parse(Console.ReadLine());
			var sols = new bool[cases];

			for (int i = 0; i < cases; i++)
			{
				var n = int.Parse(Console.ReadLine());
				var a = Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray();
				var s = Console.ReadLine();

				bool ok = true;
				for (int j = 0; j < n; j++)
				{
					if (s[j] == '0')
						continue;

					var one = a[j]; var zeroes = a.Where((x, ind) => ind > j && s[ind] == '0').ToArray();
					var reducedZeroes = Reduce(zeroes);

					if (one == 0)
						continue;

					var oneCpy = one;
					for (int ind = 0; ind < 64; ind++)
					{
						if ((oneCpy & (1UL << ind)) == 0)
							continue;

						oneCpy ^= reducedZeroes[ind];
					}

					if (oneCpy != 0)
						ok = false;
				}

				sols[i] = !ok;
			}

			foreach (var sol in sols)
				Console.WriteLine(sol ? 1 : 0);
		}

		private static ulong[] Reduce(ulong[] vectors)
		{
			var N = 64;
			var X = vectors.ToList();
			for (int i = vectors.Length; i < N; i++)
				X.Add(0);

			var deadInds = new HashSet<int>();

			for (int row = 0; row < N; row++)
			{
				//First ensure that we have a non-zero entry in X[K,K]
				if ((X[row] & (1UL << row)) == 0)
					for (int i = 0; i < X.Count; ++i)
					{
						if (i < row && !deadInds.Contains(i))
							continue;

						if ((X[i] & (1UL << row)) != 0)
						{
							var tmp = X[i];
							X[i] = X[row];
							X[row] = tmp;
							break;
						}
					}

				if ((X[row] & (1UL << row)) == 0)
				{
					deadInds.Add(row);
					continue;
				}

				// Do full row elimination.
				for (int i = 0; i < X.Count; ++i)
					if (i != row && ((X[i] & (1UL << row)) != 0))
						X[i] ^= X[row];
			}

			return Enumerable.Range(0, N).Select(x => X[x]).ToArray();
		}
	}
}


Measured memory_bytes: 41712
import java.util.*;

public class Main {
    static int modP = 1000000007;
    static long inf  = 1 << 61;
    static int[] x4 = {-1, 0, 0, 1};
    static int[] y4 = {0, -1, 1, 0};
    static int[] x8 = {-1, -1, 0, 1, 1, 1, 0, -1};
    static int[] y8 = {0, -1, -1, -1, 0, 1, 1, 1};

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(true) {
            int w = Integer.parseInt(in.next());
            int h = Integer.parseInt(in.next());
            if(w == 0 && h == 0) break;

            char[][] map = new char[h][w];
            for(int i = 0; i < h; i++){
                for(int j = 0; j < w; j++) {
                    map[i][j] = in.next().charAt(0);
                }
            }

            int ans = 0;
            for(int i = 0; i < h; i++) {
                for(int j = 0; j < w; j++) {
                    if(map[i][j] == '1') {
                        ans++;
                        ArrayDeque<P> queue = new ArrayDeque<>();
                        queue.push(new P(i, j));
                        while(!queue.isEmpty()) {
                            P c = queue.pop();
                            map[c.x][c.y] = '0';
                            for(int k = 0; k < 8; k++) {
                                int x = c.x + x8[k];
                                int y = c.y + y8[k];
                                if(0 <= x && x < h && 0 <= y && y < w && map[x][y] == '1') {
                                    P neibor = new P(c.x+x8[k], c.y+y8[k]);
                                    queue.push(neibor);
                                }
                            }
                        }
                    }
                }
            }
            System.out.println(ans);
        }
    }

    static public void printArray2D(char[][] map) {
        for(int i = 0; i < map.length; i++) {
            for(int j = 0; j < map[i].length; j++) {
                System.out.format("%c\t", map[i][j]);
            }
            System.out.print("\n");
        }
    }
}

class P {
    int x, y;
    P(int x, int y) {
        this.x = x;
        this.y = y;
    }
}



Measured memory_bytes: 40768
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF = (1LL<<60)-1;
const int maxN = 1000001;
int32_t main(){
    SPEED;
    int n, x, t;
    cin >> n >> x >> t;
    for(int i = 1; i <= 100000; ++i){
        if((x * i) >= n){
            cout << i * t ;
            return 0;
        }
    }
}

Measured memory_bytes: 3656
main = interact $ unlines . map (show . short_phrase) . read' . lines
 where
  read' ("0":_) = []
  read' (n:xs) = take (read n) xs : read' (drop (read n) xs)

short_phrase fs = short_phrase' 1 1 [5,7,5,7,7] fs
 where
  short_phrase' s _ [] _ = s
  short_phrase' s i (n:ns) (f:fs')
   | length f > n = short_phrase' (s+1) (s+1) [5,7,5,7,7] (drop s fs)
   | length f == n = short_phrase' s (i+1) ns fs'
   | otherwise = short_phrase' s (i+1) (n-(length f):ns) fs'

Measured memory_bytes: 4052
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    // get value from StandardIn
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int k = sc.nextInt();
    
    if(a>k){
      System.out.println(k);
    }else if((a+b)>=k){
      System.out.println(a);
    }else{
      System.out.println(a-(k-a-b));
    }
    // System.out.println(n);
  }
}


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

int main(){
  int r,g,b;
  cin >> r >> g >> b;
  int x=100*r+10*g+b;
  if(x%4==0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch, cw, dh, dw = ch - 1, cw - 1, dh - 1, dw - 1
s = [list(input()) for i in range(h)]
d = [[-1] * w for i in range(h)]
Q = deque([(ch, cw, 0)])
while Q:
    x, y, broken = Q.popleft()
    if d[x][y] != -1:
        continue
    d[x][y] = broken
    for dx in range(-2, 3):
        for dy in range(-2, 3):
            if 0 <= x + dx < h and 0 <= y + dy < w and s[x + dx][y + dy] == "." and d[x + dx][y + dy] == -1:
                if abs(dx) + abs(dy) == 1:
                    Q.appendleft((x + dx, y + dy, broken))
                else:
                    Q.append((x + dx, y + dy, broken + 1))
print(d[dh][dw])

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li a[100100];
string s;
string words[4] = {"dream", "dreamer", "erase", "eraser"};

bool dfs(li x) {
    if (x == sz(s))return true;
    bool res = false;
    rep(i, 4) {
        if (s.substr(x, sz(words[i])) == words[i]) {
            res |= dfs(x + sz(words[i]));
        }
    }
    return res;
}

int main() {
    cin >> s;
    cout << (dfs(0) ? "YES" : "NO") << endl;

    return 0;
}

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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;

const int MAX_N = 2e5 + 10;

int N; pi Nr[MAX_N];
void update(pi &now, int val) {
	now.one = min(now.one, val);
	now.two = max(now.two, val);
}
ll calc(const pi &a, const pi &b) {return 1ll * (a.two - a.one) * (b.two - b.one);}
pi getRange(multiset<int> &s) {return pi(*s.begin(), *s.rbegin());}
int main() {
	cin >> N; 
	for(int i=0; i<N; i++) scanf("%d%d", &Nr[i].one, &Nr[i].two);
	for(int i=0; i<N; i++) if(Nr[i].one > Nr[i].two) swap(Nr[i].one, Nr[i].two);
	sort(Nr, Nr+N);

	ll ans = LINF;
	pi lv = pi(Nr[0].one, Nr[0].one), rv = pi(Nr[0].two, Nr[0].two);
	for(int i=0; i<N; i++) update(lv, Nr[i].one), update(rv, Nr[i].two);
	ans = min(ans, calc(lv, rv));

	pi range = pi(Nr[0].one, Nr[0].two);
	for(int i=0; i<N; i++) update(range, Nr[i].one), update(range, Nr[i].two);

	multiset<int> list;
	for(int i=0; i<N; i++) list.insert(Nr[i].one);
	ans = min(ans, calc(range, getRange(list)));
	for(int i=0; i<N; i++) {
		list.erase(list.find(Nr[i].one)), list.insert(Nr[i].two);
		ans = min(ans, calc(range, getRange(list)));
	}

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


Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

const int mod = 1e9 + 7;

long long int mypow(long long int a, long long int b) {
    if (b == 0) return 1;
    if (b == 1) return a;
    long long int res = mypow(a, b / 2);
    res = res * res % mod;
    if (b % 2 == 1) res = res * a % mod;
    return res;
}


int main() { 
    int n;
    cin >> n;
    vector<int> v(n, 0);
    for (int i = 1; i <= n; i++) {
        cin >> v[i - 1];
    }
    sort(v.begin(), v.end());
    int flag = 1;
    if (n % 2 == 1) {
        for (int i = 0; i < n; i++) {
            if ((i + 1) / 2 * 2 != v[i]) {
                flag = 0;
                break;
            }
        }
    } else {
        for (int i = 0; i < n; i++) {
            if (i / 2 * 2 + 1 != v[i]) {
                flag = 0;
                break;
            }
        }
    }
    if (flag == 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << mypow(2, n / 2) << endl;
}




Measured memory_bytes: 3692
from math import sqrt
q = int(input())

def norm(a):
    return sqrt(a[0] ** 2 + a[1] ** 2)

def dot(a, b):
    return sum([i * j for i,j in zip(a, b)])

def sub(a, b):
    return [a[0] - b[0],a[1] - b[1]]

def cross(a, b):
    return  a[0] * b[1] - a[1] * b[0]

def ccw(a, b, c):
    x = sub(b, a)
    y = sub(c, a)
    if cross(x, y) > 0: return 1
    if cross(x, y) < 0: return -1
    if dot(x, y) < 0: return 2
    if norm(x) < norm(y): return -2
    return 0

def intersect(p1, p2, p3, p4):
    return ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 and \
           ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0

for i in range(q):
    xp0, yp0, xp1, yp1, xp2, yp2, xp3, yp3 = map(int, input().split())
    print(1 if intersect([xp0, yp0], [xp1, yp1], [xp2, yp2], [xp3, yp3]) else 0)

Measured memory_bytes: 7916
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=200005,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x=(x+y)%mod;}
inline void read(int &x){
	x=0;char ch=getchar(),rev=0;
	while(ch>'9'||ch<'0') rev=(ch=='-'),ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	x=rev?-x:x;
}
inline int exp(int x,int y){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

int n,h,cnt,fa[N],l[N],r[N],du[N],tag[N],ans[N];

inline int find(int x){return fa[x]!=x?fa[x]=find(fa[x]):x;}
inline void add(int x,int y){
//	printf("%d %d\n",x,y);
	x=find(x);y=find(y);
	if(x!=y) fa[x]=y;
}

int main(){
#ifdef rqgao2014
	freopen("input.txt","r",stdin);
#endif
	scanf("%d%d",&n,&h);cnt=n;
	for(int i=1;i<=h;i++) l[i]=++cnt,r[i]=++cnt;
	for(int i=1;i<=cnt;i++) fa[i]=i;
	for(int i=1;i<=n;i++){
		int a,b,c,d;scanf("%d%d%d%d",&b,&d,&a,&c);
		if(!a) tag[i]++,add(r[b],i),du[r[b]]++; else tag[i]--,add(l[a],i),du[l[a]]--;
		if(!c) tag[i]++,add(i,l[d]),du[l[d]]++; else tag[i]--,add(i,r[c]),du[r[c]]--;
	}
	for(int i=1;i<=h;i++)
		if(du[l[i]]<0||du[r[i]]<0){puts("NO");return 0;}
	for(int i=1;i<=n;i++)
		ans[find(i)]+=tag[i];
	for(int i=1;i<=n;i++)
		if(ans[find(i)]<=0){puts("NO");return 0;}
	puts("YES");
	return 0;
}

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

using namespace std;

int main(void)
{
	int N,n,i;

	int A[100010];

	cin >> N;

	for(i=1;i<=N;i++)
	{

		cin >> n;
		A[n]=i;

	}

	for(i=1;i<=N;i++)
	{

		cout << A[i] << endl;

	}
	return 0;
	
}

	


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

typedef long long ll;
ll L[87];
//???????????????????????????????
int main() {
  int N; cin >> N;
  L[0] = 2, L[1] = 1;
  for (int i = 2; i <= N; i++){
    L[i] = L[i-2] + L[i-1];
  }

  cout << L[N] << endl;
}



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

#define FOR(i, l, r) for (size_t i = (l); i < (r); ++i)
#define REP(i, n) FOR(i, 0, n)

using namespace std;

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

    int D[N][2];
    REP(i, N)
    {
        cin >> D[i][1] >> D[i][2];
    }

    int max_counter = 0;
    int counter = 0;
    for (int i = 0; i < N; i++)
    {
        if (D[i][1] == D[i][2])
        {
            counter++;
        }
        else
        {
            counter = 0;
        }

        if (counter > max_counter)
        {
            max_counter = counter;
        }
    }

    string ret;
    if (max_counter >= 3)
    {
        ret = "Yes";
    }
    else
    {
        ret = "No";
    }

    cout << ret << "\n";
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,k,i,j;
	cin>>n>>k;
	long long int a[n+10];
	long long int ans[k+10];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	ans[0]=0;
	for(i=1;i<=k;i++)
	{
		ans[i]=0;
		for(j=0;j<n;j++)
		{
			if(a[j]>i)
			break;
			if(ans[i-a[j]]==0)
			{
				ans[i]=1;
				break;
			}
		}
	}
	if(ans[k])
	cout<<"First"<<endl;
	else
	cout<<"Second"<<endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int n, A[111111], B[111111];

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) scanf("%d", &A[i]);
    for(int i = 1; i <= n; i++) scanf("%d", &B[i]);
    for(int i = 1; i <= n; i++) A[i] += A[i - 1];
    for(int i = 1; i <= n; i++) B[i] += B[i - 1];
    int ans = 0;
    for(int i = 1; i <= n; i++) ans = max(ans, A[i] + B[n] - B[i - 1]);
    printf("%d\n", ans);
    return 0;
}

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

const int INF = 1e9;
vector<vector<int> > g(110, vector<int>(110, INF));
vector<int> bla(110, -1), d(110, 0);
int n, m, k;

int main(){
    cin >> n >> m >> k;
    for(int i = 0; i < m; i++){
        cin >> d[i];
        bla[--d[i]] = i;
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < k; j++){
            cin >> g[i][j];
            g[i][j]--;
        }
    }
    // i 桁目にいる時1, いない時0
    vector<int> dp(1 << m, -1);
    dp[(1 << m) - 1] = 0;
    queue<int> que;
    que.push((1 << m) - 1);
    while(!que.empty()){
        int cur = que.front();
        que.pop();
        if(cur == 0) break;
        for(int i = 0; i < k; i++){
            int bit = 0;
            for(int j = 0; j < m; j++){
                if(cur >> j & 1 && ~bla[g[d[j]][i]]){
                    bit |= 1 << bla[g[d[j]][i]];
                }
            }
            if(dp[bit] == -1){
                dp[bit] = dp[cur] + 1;
                que.push(bit);
            }
        }
    }
    cout << dp[0] << endl;
    return 0;
}



Measured memory_bytes: 3436
n = int(input())
a = [''.join(sorted(input())) for i in range(n)]
ans = 0
count = 0
a.sort()
for i in range(1,n) :
    if a[i] == a[i-1] :
        count += 1
        ans += count
    else :
        count = 0
print(ans)


Measured memory_bytes: 10640
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
using namespace std ; 
int main(){
	int h , n ; 
	cin>> h >> n ; 
	vector<int> a(n) ; 
	for(int &x : a) cin>> x ; 
	ll x = accumulate(a.begin() , a.end() , 0) ; 
	   if(x >= h)
	   cout<<"Yes"<<endl;
	   else
	   cout<<"No"<<endl;
	   
	
	
}


Measured memory_bytes: 640
n,k = map(int,input().split())
H = list(map(int,input().split()))

if k >= n-1:
    print(abs(H[0]-H[n-1]))

else:
    dp = [0 for i in range(n)]
    for i in range(k+1):
        dp[i] = abs(H[0]-H[i])

    for i in range(k+1,n):
        mincost = 10**9
        for j in range(1,k+1):
            mincost = min(mincost,dp[i-j]+abs(H[i]-H[i-j]))
        dp[i] = mincost

    print(dp[n-1])

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

int main(void) { 
    string s;
    cin >> s;
    
    int right = 0;
    int left = s.size() + 1;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'A') {
            left = min(left, i);
        }
        if(s[i] == 'Z'){
            right = max(right, i);
        }
    }
    // cout << right << left << endl;
    cout << right - left  + 1<< endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int d = scanner.nextInt();
		int p = scanner.nextInt();
		int x = a * p;
		int y = p > c ? b + (p - c) * d : b;
		System.out.println(x < y ? x : y);
		scanner.close();
	}

}



Measured memory_bytes: 26228
#include <algorithm>
#include <array>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
constexpr int INF = 100100100;

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

using namespace std;

int main() {
  // cout << fixed << setprecision(10);
  int N, K; cin >> N >> K;
  cout << (N - K + 1) << endl;
  return 0;
}


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

int main()
{
  int n;
  cin >> n;
  
  double sum = 0;
  double amount;
  string currency;
  for (int i = 0; i < n; i ++)
  {
    cin >> amount;
    cin >> currency;
    if (currency == "JPY")
      sum += amount;
    else
      sum += amount * 380000.0;
  }
  
  cout << sum << endl;
  return 0;
}

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


int main(void) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int low = max(a, c);
    int high = min(b, d);
    printf("%d\n", max(0, high - low));
    return 0;    
}

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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define llrp(i,n) for(long long i=0;i<n;i++)
#define llrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define vcin(a); rp(i,a.size()){cin>>a[i];}
#define vcout(a); rp(i,a.size()){cout<<a[i]<<endl;}
#define allchar(c) for(char c='a';c<='z';c++)

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef queue<int> qi;

const int mod=1e9+7;

ll modpow(ll a,ll b,ll p){
    if(b==0){
        return 1;
    }elif(b%2==0){
        return modpow((a*a)%p,b/2,p);
    }else{
        return (a*modpow(a,b-1,p))%p;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    S s;
    cin >> s;
    if(s.size()==2){
        cout << s << endl;
    }else{
        cout << s.at(2) << s.at(1) << s.at(0) << endl;
    }
    return 0;
}


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

using namespace std;
#define ll long long
#define stuff ios::sync_with_stdio(0);cin.tie(0)

ll abso(ll x)
{
    return (x>0)?x:-1*x;
}

int main()
{
    stuff;
    ll n;
    cin>>n;
    ll h[n],dp[n];
    for(ll i=0;i<n;i++)
    {
        cin>>h[i];
    }
    dp[0]=0;
    dp[1]=abso(h[1]-h[0]);
    for(ll i=2;i<n;i++)
    {
        dp[i]=min(abso(h[i]-h[i-1])+dp[i-1],abso(h[i]-h[i-2])+dp[i-2]);
    }
    cout<<dp[n-1]<<"\n";

    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {
var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var H = (int)inputArray[0];
			var W = (int)inputArray[1];

			var field = new int[H, W];

			for (int i = 0; i < H; i++) {
				var inp = retreiveLongArray();
				for (int j = 0; j < W; j++) {
					field[i, j] = (int)inp[j];
				}
			}

			var manupilates = new List<int[]>();
			//奇数をすべて右に寄せる

			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W-1; j++) {
					if (field[i,j]%2 ==1) {
						field[i, j]--;
						field[i, j + 1]++;
						var manupilate = new int[] { i, j, i, j + 1 };
						manupilates.Add(manupilate);
					}
				}
			}
			//一番右に集まった奇数を下に寄せる
			for (int i = 0; i < H-1; i++) {
				if (field[i, W-1] % 2 == 1) {
					field[i, W - 1]--;
					field[i+1, W - 1]++;
					var manupilate = new int[] { i, W - 1, i+1, W - 1 };
					manupilates.Add(manupilate);
				}
			}
			var N = manupilates.Count();
			Console.WriteLine(N);

			for (int i = 0; i < N; i++) {
				var output = String.Join(" ", manupilates[i].Select(x =>x+1));
				Console.WriteLine(output);
			}



		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 55984
n, p = map(int, input().split())

e = [tuple(map(int, input().split())) for _ in range(n)]
# e = [(w,b), ...]

e2 = sorted(((100 - p) * w + p * b for w, b in e), reverse=True)

rest = p * sum(b for _, b in e)

cur = 0
while rest > 0 and cur < n:
    rest -= e2[cur]
    cur += 1
print(cur)


Measured memory_bytes: 21392
import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]

H.sort()

answer = 10 ** 15
for i in range(N - K + 1):
  answer = min(answer, H[i + K - 1] - H[i])

print(answer)

Measured memory_bytes: 7500
import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int ans = 0;
		for(int i = a;i <= c;i+=a){
			ans += b;
		}
		System.out.print(ans);
	}




static String deletestr(String base,String remove){
	boolean flag = true;
	for(int i = 0;i < remove.length();i++){
		if(i == base.length()){
			flag = false;
			break;
		}
		if(base.charAt(i) - remove.charAt(i) != 0 && base.charAt(i) - remove.charAt(i) != 32 &&remove.charAt(i) - base.charAt(i)  != 32){
			flag = false;
			break;
		}
	}

	if(flag){
		base = base.substring(remove.length());
	}

	return base;

}



}


class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return from - otherpair.from;
	}
}




Measured memory_bytes: 21844
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a,b;
        while(true){
        a = sc.nextInt();
        b = sc.nextInt();
        if(a == 0 && b == 0){
            break;
        }else if(a <= b){
            System.out.println(a + " " + b);
        }else if(a > b){
            System.out.println(b + " " + a);
        }
        }
    }
}


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

using namespace std;

#define rep(i, a) for (int i = 0; i < a; i++)
#define reps(i, a, b) for (int i = a; i < b; i++)

int main()
{
	string s, t;
	cin >> s >> t;
	s = s + s;
	int l = t.length();
	rep(i, l) {
		bool f = true;
		rep(j, l) {
			if (s[i+j] != t[j]) f = false;
		}
		if (f) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
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; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string a,b,c;
cin>>a>>b>>c;
if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])cout<<"YES"<<endl;
else cout<<"NO"<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#define MAX 10000002
typedef long long ll;
int main(){
    ll N;
    scanf("%lld",&N);
    ll table[MAX]={0};
    for(ll i=1;i<=N;i++){
        for(ll j=1;i*j<=N;j++){
            table[i*j]++;
        }
    }
    ll ans=0;
    for(ll i=1;i<=N;i++)
        ans += table[i]*i;
    printf("%lld",ans);
}


Measured memory_bytes: 79860