akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int n,m;
    cin >> n >> m;
    vector<P> work(n);
    rep(i,n) cin >> work[i].first >> work[i].second;
    sort(all(work));
    int now = 0;
    priority_queue<int> q;
    int ans = 0;
    for(int i = m-1; i >= 0; i--) {
        int ab = m-(i);
        while(now < n && work[now].first <= ab) {
            q.push(work[now].second);
            now++;
        }
        if(!q.empty()) {
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1660
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n;
	int a[3];
	cin>>n;
	for(int i=0;i<n;i++){
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[0]*a[0]+a[1]*a[1]==a[2]*a[2]){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	}
}

Measured memory_bytes: 3096
def bubbleSort(sort_list):
    flag = True
    count = 0
    while flag:
        flag = False

        for j in range(len(sort_list) - 1, 0, -1):
            if sort_list[j] < sort_list[j - 1]:
                tmp = sort_list[j]
                sort_list[j] = sort_list[j - 1]
                sort_list[j - 1] = tmp
                count += 1
                flag = True

    print(' '.join([str(i) for i in sort_list]))
    print(count)


if __name__ == "__main__":
    N = int(input())
    sort_list = [int(i) for i in input().split()]

    bubbleSort(sort_list)



Measured memory_bytes: 5608
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    h, w, n = map(int, readline().split())
    sr, sc = map(int, readline().split())
    s = input()
    t = input()

    c = dict()
    c["L"], c["R"] = sc, sc
    c["U"], c["D"] = sr, sr

    for first, second in zip(s, t):
        if first == "L" or first == "U":
            c[first] -= 1
        else:
            c[first] += 1

        if c["L"] == 0 or c["R"] == w + 1 or c["U"] == 0 or c["D"] == h + 1:
            return print("NO")

        if second == "L":
            c["R"] -= 1
            c["R"] = max(1, c["R"])
        if second == "R":
            c["L"] += 1
            c["L"] = min(w, c["L"])
        if second == "U":
            c["D"] -= 1
            c["D"] = max(1, c["D"])
        if second == "D":
            c["U"] += 1
            c["U"] = min(h, c["U"])

    print("YES")


if __name__ == '__main__':
    main()


Measured memory_bytes: 75484
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		int a = sc.nextInt();
		int b = sc.nextInt();
		String s = sc.next();

		boolean flag = s.length() == a + b + 1;
		for (int i = 0; flag && i < s.length(); i++) {
			if (i == a) {
				flag = s.charAt(i) == '-';
			} else {
				flag = '0' <= s.charAt(i) && s.charAt(i) <= '9';
			}
		}

		out.println(flag ? "Yes" : "No");
		out.flush();
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) return true;
		else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) return false;
		}
		return true;
	}

	private byte readByte() {
		if (hasNextByte()) return buffer[ptr++];
		return -1;
	}

	private boolean isPrintableChar(byte c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public int nextInt() {
		if (!hasNext()) throw new NoSuchElementException();
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}

	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) throw new NumberFormatException();
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}
}

Measured memory_bytes: 23380
N = int(input())
hs = list(map(int, input().split()))

Cost = [1e10 for _ in range(N)]
Cost[0] = 0

for i in range(N):
  if (i+1 > N-1):
    continue
  Cost[i+1] = min(Cost[i+1], Cost[i] + abs(hs[i]-hs[i+1]))
  if (i+2 > N-1):
    continue
  Cost[i+2] = min(Cost[i+2], Cost[i] + abs(hs[i]-hs[i+2]))

print(Cost[N-1])


Measured memory_bytes: 55800
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  int n,ans = 0;
  cin >> n;
  vector<int> d(n);
  rep(i,n) cin >> d[i];
  sort(d.begin(),d.end());
  ans = d[n/2] - d[n/2-1];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
N=int(input())
x=input()
num=0
n=0
def twice(a):
    ans=0
    while a:
        ans+=a%2
        a//=2
    return ans

ma=5*10**5
dp=[0]*ma
for i in range(1,ma):
    dp[i]=dp[i%twice(i)]+1
c=x.count("1")
a=int(x,2)%(c+1)
if c==1:
    for i in range(N):
        if x[i]=="0":
            print(dp[(a+pow(2,N-i-1,2))%2]+1)
        else:
            print(0)
    exit()
b=int(x,2)%(c-1)
for i in range(N):
    if x[i]=="0":
        print(dp[(a+pow(2,N-i-1,c+1))%(c+1)]+1)
    else:
        print(dp[(b-pow(2,N-i-1,c-1))%(c-1)]+1)

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

#define ll long long

typedef pair< int, int > ii;
typedef vector< ii > vii;

void solve(){
	ll n, k; cin>>n>>k;
	cout<<min((n%k), (k - n%k))<<endl;
}

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



Measured memory_bytes: 3624
import { readFileSync } from "fs";

function B(count: number, values: number[], costs: number[]) {
    const diff: number[] = [];
    for (let i = 0; i < count; i++) {
        diff.push(values[i] - costs[i]);
    }
    return diff
        .filter(v => {
            return v > 0;
        })
        .reduce((r, c) => {
            return r + c;
        }, 0);
}

const inputB = readFileSync("/dev/stdin", "utf8");
const changeInputB = inputB.split(/\r?\n/).map((v, i) => {
    if (i == 0) return Number(v);
    return v.split(" ").map(Number);
});
console.log(B(changeInputB[0] as number, changeInputB[1] as number[], changeInputB[2] as number[])


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

void happiness(int yen){
    int happiness=0;
    while(yen!=0){
        if(yen>=500){
            yen-=500;
            happiness+=1000;
        }
        else if(yen>=5){
            yen-=5;
            happiness+=5;
        }
        else if(yen>=1){
            yen-=1;
        }
    }
    cout<<happiness;
}

int main(){
    int input;
    cin >> input;
    happiness(input);
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int x;
    Scd(x);

    if( x < 1200 ){
        printf ("ABC\n");
    }else{
        printf ("ARC\n");
    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N, A;
  cin >> N >> A;

  if(N % 500 <= A)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
// const int mod=998244353;
const int INF=4e18+10;
const int MOD=mod;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


bool no(string s)
{
    return !(s=="0011" || s=="0101"|| s=="1110" || s=="1111");
}

int pow(int a, int b)
{
    int prod=1;
    int mult=a%mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod*=mult;
            prod%=mod;
        }
        mult*=mult;
        mult%=mod;
        b/=2;
    }
    return prod;
}
int inverse(int q)
{
   return pow(q, mod-2);
}

signed main()

{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
       cout.tie(NULL);
     #ifndef ONLINE_JUDGE
        if(fopen("INPUT.txt","r"))
        {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
        }
     #endif
    auto clk=clock(); 
    // -------------------------------------Code starts here---------------------------------------------------------------------     
    int x, y,z;
    cin>>x>>y>>z;
    cout<<z<<" "<< x<<" "<<y<<endl; 
    // -------------------------------------Code ends here------------------------------------------------------------------

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


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

int main()
{
    ll n;
    cin>>n;
    vector<ll> arr(n),dp(n,INT_MAX);
    for(int i=0;i<n;i++)
      cin>>arr[i];

    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(int i=1;i<n;i++)
    {
      dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
    }

    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 4824
#include <stdio.h>
#define NODE (100)
#define INF (100000000)

int U[NODE];
int dist[NODE];
int prev[NODE];
int cost[NODE][NODE];
int V;

void dijkstra(int s)
{
	int i, j;
	int v;
	
	dist[s] = 0;
	prev[s] = 0;
	
	for (i = 0; i < V; i++){
		U[i] = 1;
	}
	
	for (i = 0; i < V; i++){
		v = -1;
		
		for (j = 0; j < V; j++){
			if (U[j] == 1 && (v == -1 || dist[v] > dist[j])){
				v = j;
			}
		}
		
		if (v == -1){
			break;
		}
		
		U[v] = 0;
		
		for (j = 0; j < V; j++){
			if ((dist[j] > dist[v] + cost[v][j]) && U[j] == 1){
				dist[j] = dist[v] + cost[v][j];
				prev[j] = v;
			}
		}
	}
}

int main(void)
{
    int i, j;
    int n, k;
    int ord;
    int from, to, money;
    
    while (1){
        scanf("%d%d", &n, &k);
        
        if (n + k == 0){
            break;
        }
        
        V = n;
        
        for (i = 0; i < V; i++){
			for (j = 0; j < V; j++){
				cost[i][j] = INF;
			}
			dist[i] = INF;
		}
        
        for (i = 0; i < k; i++){
            scanf("%d", &ord);
            
            if (ord == 0){
                scanf("%d%d", &from, &to);
                
                for (j = 0; j < V; j++){
                    dist[j] = INF;
                }
                
                dijkstra(from - 1);
                
                if (dist[to - 1] == INF){
                    printf("-1\n");
                }
                else {
                    printf("%d\n", dist[to - 1]);
                }
            }
            
            else {
                scanf("%d%d%d", &from, &to, &money);
                if (cost[from - 1][to - 1] > money){
                    cost[from - 1][to - 1] = money;
                }
                if (cost[to - 1][from - 1] > money){
                    cost[to - 1][from - 1] = money;
                }
            }
        }
    }
    
    return (0);
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int f(int a) {
  return (a * a + 4) / 8;
}

ll memo[1000];
ll fib(ll n) {
  if(n == 0) return 2;
  else if(n == 1) return 1;
  else if(memo[n]) return memo[n];
  else return memo[n] = fib(n-1) + fib(n-2);
}

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

  int n; cin >> n;
  int mi = INF;
  for(int i=0;i<n;++i) {
    int a; cin >> a;
    int cnt = 0;
    while(a % 2 == 0) {
      cnt++;
      a /= 2;
    }
    mi = min(mi, cnt);
  }
  cout << mi << endl;
  
}


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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__)
#else
#define debug(...) 47
#endif
const int MAXN=1010101;
int main(){
  fastIO();
  int n,ans=0;
  cin>>n;
  vector<int>a(n);
  vector<bool>marked(MAXN,false);
  vector<bool>mask(MAXN,false);
  vector<int>reps(MAXN);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    reps[a[i]]++;
    if(!marked[a[i]]){
      marked[a[i]]=true;
      for(int j=a[i]*2;j<MAXN;j+=a[i]){
        mask[j]=true;
      }
    }
  }
  for(int i=0;i<n;i++){
    if(reps[a[i]]>1||mask[a[i]])ans++;
  }
  cout<<n-ans<<endl;
  return 0;
}


Measured memory_bytes: 8116
#include<iostream>
#include<math.h>
using namespace std;

int main(void){
    long long N , D , x , y ,ans=0;
    cin >> N >> D;
    for(long long i=0;i<N;i++){
        cin >> x >> y;
        if(sqrt((double)(x*x) + (double)(y*y)) <= D){
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;

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

ll cnt(vector<int> &A, vector<int> &B, vector<int> &C)
{
  ll tmp = 0;
  for (int i = 0; i < A.size(); i++)
  {
    int indexj = upper_bound(B.begin(), B.end(), A[i]) - B.begin();
    if (indexj == B.size())
      continue;
    for (int j = indexj; j < B.size(); j++)
    {
      int indexk = upper_bound(C.begin(), C.end(), B[j]) - C.begin();
      if (indexk == C.size())
        continue;
      int ng = 2 * B[j] - A[i];
      if (binary_search(C.begin(), C.end(), ng))
        tmp += C.size() - indexk - 1;
      else
        tmp += C.size() - indexk;
    }
  }
  return tmp;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  string S;
  cin >> N >> S;
  vector<int> R;
  vector<int> G;
  vector<int> B;
  for (int i = 0; i < N; i++)
  {
    if (S[i] == 'R')
      R.push_back(i);
    else if (S[i] == 'G')
      G.push_back(i);
    else
      B.push_back(i);
  }
  ll ans = 0;
  sort(R.begin(), R.end());
  sort(G.begin(), G.end());
  sort(B.begin(), B.end());

  ans += cnt(R, G, B);
  ans += cnt(R, B, G);
  ans += cnt(B, G, R);
  ans += cnt(B, R, G);
  ans += cnt(G, R, B);
  ans += cnt(G, B, R);

  cout << ans << endl;
  return 0;
}


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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = ((int)b); i <= ((int)e); i++)
#define RPT0(i, n) RPT(i, 0, ((int)n) - 1)
#define RPT1(i, n) RPT(i, 1, (n))
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

void resolve()
{
    int N;
    cin >> N;
    vector<string> S(N);
    RPT0(i, N) cin >> S[i];

    set<string> k;
    RPT0(i, N) k.insert(S[i]);
    int ans = k.size();
    cout << ans << endl;
}

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


Measured memory_bytes: 25052
#include<bits/stdc++.h>
using namespace std;
int main(){
    int w,h,x,y;
    cin >> w >> h >> x >> y;
    if(x+x==w&&y+y==h)cout << fixed << setprecision(8) << double(w)*double(h)/2.0 << ' ' << 1;
    else cout << fixed << setprecision(8) << double(w)*double(h)/2.0 << ' ' << 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001

int main() {
    int n;cin >> n;
    vector<int> b(n);for(int i=0;i<n;i++) cin >> b[i];
    vector<int> ans;
    for(int i = 0; i < n; i++) {
        for(int j = b.size()-1; j >=0; j--) {
            if(b[j]==j+1){
                ans.push_back(b[j]);
                b.erase(b.begin()+j);
                break;
            }
        }
    }
    if(ans.size()!=n){
        cout << -1 << endl;
        return 0;
    }

    for(int i = 0; i < n; i++) {
        cout << ans[n-1-i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3572
ENV[Z='RUBY_THREAD_VM_STACK_SIZE']||exec({Z=>?5*8},'ruby',$0)
p=*0...gets.to_i;
f=->a{a==p[a]?a: p[a]=f[p[a]]}
a,b=$<.map{|s|s.split.map &:to_i}.transpose.map{|a|a.each_with_index.sort.each_cons(2).map{|(x,i),(y,j)|[y-x,i,j]}};
s=0;
(a+b).sort_by{|a,b,c|a}.each{|c,a,b|(s+=c;p[f[b]]=f[a])if f[a]!=f[b]}
p s

Measured memory_bytes: 92748
#include <stdio.h>
#define LENGTH 45

int a[LENGTH];

int fibonacci(int n) {
  if(a[n] != -1)
    return a[n];
  else
    return a[n] = fibonacci(n - 1) + fibonacci(n - 2);
}

int main() {
  int i, n;

  for(i = 0;i < LENGTH;i++)
    a[i] = -1;
  a[0] = 1;
  a[1] = 1;

  scanf("%d", &n);
  printf("%d\n", fibonacci(n));

  return 0;
}



Measured memory_bytes: 2104
#include <cstdio>
#include <algorithm>
#define INF (ll)1<<32
using namespace std;
typedef long long ll;
int n,m;
ll ans;
ll f(int k) {
	if (k<3)
		return INF;
	if (k%3==0)
		return 0;
	return 1;
}
int main() {
	scanf("%d %d",&n,&m);
	ans=min(f(n)*m,f(m)*n);
	for (int i=1;i<m;i++) {
		ll a=(ll)n*i,b=(ll)(n/2)*(m-i),c=(ll)(n-n/2)*(m-i);
		ans=min(ans,max(a,max(b,c))-min(a,min(b,c)));
	}
	for (int i=1;i<n;i++) {
		ll a=(ll)m*i,b=(ll)(m/2)*(n-i),c=(ll)(m-m/2)*(n-i);
		ans=min(ans,max(a,max(b,c))-min(a,min(b,c)));
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

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

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int x;
	cin >> x;
	int r = 400;
	rep (i, 8) {
	  if (x >= r && x < r + 200) {
		cout << 8 - i << endl;
		return 0;
	  }
	  r += 200;
	}
	
    return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c,d;
int i[300000];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s,w;
  cin >>a;
  int ans=1,sum=0;
  for(int n=0;n<a;n++){
    cin >>i[n];
    if(i[n]==ans) ans++;
    else sum++;
  }
  if(sum==a) cout <<"-1\n";
  else 
  cout <<sum<<'\n';
  return (0);
}


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

int main(){

    long long n , m;

    long long a;
    //count = 0;

    cin >> n >> m;

    for(long long i = 0; i < m; i++){
        cin >> a;
        //count = count + a;
        n = n - a;
    }

    if(n < 0){
        printf("-1\n");
    }
    else{
        printf("%lld\n", n);
    }

    return 0;
	
}


Measured memory_bytes: 3772
#include<bits/stdc++.h>
#define lp(i,n) for(int i=0;i<n;i++)
#define rp(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a+b==15)cout<<"+"<<endl;
	else if(a*b==15)cout<<"*"<<endl;
	else cout<<"x"<<endl;
	
	return 0;
}



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

using namespace std;

int main(void) {
  string s;
  char c;
  while(1) {
    cin >> s >> c;
    if(c == 'X') break;
    switch(c) {
    case 'U':
      for(int i = 0; i < s.length(); i++) {
	if(i == 0) cout << (char)toupper(s[i]);
	else if(s[i] == '_') cout << (char)toupper(s[++i]);
	else cout << s[i];
      }
      break;
    case 'L':
      for(int i = 0; i < s.length(); i++) {
	if(i == 0) cout << (char)tolower(s[i]);
	else if(s[i] == '_') cout << (char)toupper(s[++i]);
	else cout << s[i];
      }
      break;
    case 'D':
      for(int i = 0; i < s.length(); i++) {
	if(i == 0) cout << (char)tolower(s[i]);
	else if(isupper(s[i])) cout << '_' << (char)tolower(s[i]);
	else cout << s[i];
      }
      break;
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;
vector <int> adjlist[100005];
typedef pair <int, int> pi;
int dist[100005][3];
int main()
{
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int a, b; cin >> a >> b;
		adjlist[a].push_back(b);
	}
	int s, t; cin >> s >> t;
	queue <pi> q;
	q.push(pi(s, 0));
	memset(dist, -1, sizeof(dist));
	dist[s][0] = 0;
	while (!q.empty())
	{
		pi c = q.front(); q.pop();
		int node = c.first, time = c.second;
		//cout << node << ' ' << time << ' ' << dist[node][time] << '\n';
		for (auto it : adjlist[node])
		{
			if (dist[it][(time+1) % 3] == -1)
			{
				if (((time+1) % 3) == 0) dist[it][(time+1) % 3] = dist[node][time] + 1;
				else dist[it][(time+1) % 3] = dist[node][time];
				q.push(pi(it, (time+1) % 3));
				
			}
		}
	}
	cout << dist[t][0];
	return 0;
} 

Measured memory_bytes: 6912
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

int main() {
  string in;
  while (cin >> in) {
    if (in == "0") break;
    int i = 1, ct_a = 0, ct_b = 0;
    for (; i < in.size(); ++i) {
      in[i] == 'A' ? ct_a++ : ct_b++;
    }
    ct_a > ct_b ? ct_a++ : ct_b++;
    cout << ct_a << " " << ct_b << endl;
  }
  return 0;
}

Measured memory_bytes: 0
N = int(input())
A = list( map(int, input().split()) )
B = [i for i in A]

for i in range(N):
  B[N-i-1] += B[N-i]

if(N == 0 and A[0] == 1):
  print(1)
  exit()  
  

if(0 in B):
  print(-1)
  exit()
  
if(A[0] != 0):
  print(-1)
  exit()

a = 1
sum = a
for i in range(1, N):
  a = min(2*(a-A[i-1]) , B[i])
    
  if(a <= A[i]):
    print(-1)
    exit()
  sum += a

if(2*(a-A[-2]) < A[-1]):
  print(-1)
  exit()
print(sum + A[-1])



Measured memory_bytes: 20012
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define cerr                                                                   \
  if (true)                                                                    \
  cerr
#define dump(v) (cerr << #v << ": " << v << endl)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<unsigned long long> vull;
typedef pair<int, int> pii; // p.first p.second

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(long long X, long long t) { cout << max((ll)0, X - t) << endl; }

int main() {
  ios::sync_with_stdio(false);
  long long t;
  long long X;
  cin >> X;
  cin >> t;
  solve(X, t);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int m[200000][2];
int count(int n,int d){
  int ct=0;
  for(int i=0;i<n;i++){
    double x=pow(m[i][0],2.0)+pow(m[i][1],2.0);
    if(sqrt(x)<=d){
      ct++;
    }
  }
  return ct;
}

int main(){
  int n,d;
  scanf("%d %d",&n,&d);
  for(int i=0;i<n;i++){
    scanf("%d %d",&m[i][0],&m[i][1]);
  }
  printf("%d",count(n,d));
  return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"-----------------"#x"-----------------\n"
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
                    For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
LL read(){
    LL x=0,f=0;
    char ch=getchar();
    while (!isdigit(ch))
        f=ch=='-',ch=getchar();
    while (isdigit(ch))
        x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
    return f?-x:x;
}
const int N=300005;
int n;
int a[N],s[N];
bool check(int x){
    int v=0;
    for (int i=1;i<n;i+=2)
        if (s[i]-v>=x)
            v=min(v,s[i+1]);
    return s[n]-v>=x;
}
int main(){
    n=read();
    For(i,1,n)
        a[i]=read();
    if (n%2==0){
        int s0=0,s1=0;
        For(i,1,n)
            if (i&1)
                s0+=a[i];
            else
                s1+=a[i];
        cout<<max(s0,s1)<<" "<<min(s0,s1)<<endl;
        return 0;
    }
    For(i,1,n)
        if (i&1)
            s[i]=s[i-1]+a[i];
        else
            s[i]=s[i-1]-a[i];
    int L=1,R=n*1000,mid,ans=L;
    while (L<=R){
        mid=(L+R)>>1;
        if (check(mid))
            L=mid+1,ans=mid;
        else
            R=mid-1;
    }
    For(i,1,n)
        if (i%2==0)
            ans+=a[i];
    int s=0;
    For(i,1,n)
        s+=a[i];
    cout<<ans<<" "<<s-ans<<endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef	long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef set<int> si;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef pair<ll, pll> plll;
typedef vector<pair<int, pii>> viii;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define tc int tt;cin>>tt;while(tt--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fio ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#define RED "\033[31m"
#define GREEN "\033[32m"
#define RESET "\033[0m"
#define sleep for (int i = 1, a;i < 100000000;i++, a = a * a)
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ranked_pairset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ranked_map;

const int N = 2e6+1;

int main() {
	fio;
	ll d, t, s;
	cin >> d >> t >> s;
	(d <= t * s && cout << "Yes\n") || cout << "No\n";
}


Measured memory_bytes: 3592
def bomb(x,y):
    s=M[y]
    if s[x]=="0":return
    M[y]=s[:x]+"0"+s[x+1:]
    R=[-3,-2,-1,1,2,3]
    for e in R:
        bomb(x+e,y)
        bomb(x,y+e)
    return

A=range(3,11)
M=["00000000000000" for i in range(14)]
z="000"
n=input()
for i in range(n):
    s=raw_input()
    for j in A:
        M[j]=z+raw_input()+z
    x=input()+2
    y=input()+2
    bomb(x,y)
    print "Data %d:" %(i+1)
    for j in A:
        print M[j][3:-3]

Measured memory_bytes: 4288
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  int N = S.size();
  vector<int> p(0);
  for (int i=0;i<N;i++){
    if (S.at(i) == 'B'){
      p.push_back(i);
    }
  }
  int n = p.size();
  long long cnt = 0;
  for (int i=0;i<n;i++){
    cnt += N - 1 - i - p.at(n-1-i);
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1532
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<pair<int,string>, ll> memo;
string acgt = "ACGT";
ll mod = 1e9+7;
ll n;
ll dfs(int depth, string s){
    if(depth == n){return 1;}
    ll ret = 0;
    for(int i = 0;i < 4;i++){
        string ss = s + acgt[i];
        if(depth >= 3){
            string t = ss.substr(ss.size()-4,4);
            if(t[0] == 'A' && t[3] == 'C' && (t[1] == 'G' || t[2] == 'G')){
                continue;
            }
        }
        if(depth >= 2){
            string t = ss.substr(ss.size()-3,3);
            if(t == "AGC" || t == "GAC" || t == "ACG"){
                continue;
            }
        }
        string t = s + acgt[i];
        if(depth >= 2)t = t.substr(t.size()-3,3);
        
        auto p = make_pair(depth,t);
        if(memo.count(p) == 0)memo[p] = dfs(depth+1, s + acgt[i]);
        ret += memo[p];
        ret %= mod;
        
    }
    return ret;
}
int main(){
    cin >> n;
    cout << dfs(0,"") << endl;
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a[10],i;
    for(i=0;i<10;i++)cin>>a[i];
    sort(a,a+10);
    for(i=9;i>6;i--)cout<<a[i]<<endl;
    return 0;
}

Measured memory_bytes: 1176
import java.util.Scanner;

class Main{
     public static void main(String[] args){

        Scanner as = new Scanner(System.in);
        int a = as.nextInt();
        int b = as.nextInt();
        int c = as.nextInt();

        if(a>=b){
          
 
        System.out.println("No");
         }
        else if(b>=c){
        
        System.out.println("No");
             
               }
             else{
                 
                  System.out.println("Yes");
              }
 
 
   }
 
 
}

Measured memory_bytes: 26280
N, K = map(int, input().split())
A = list(map(int, input().split()))
ones = [0] * 40
for i in A:
    for j in range(40):
        if (i >> j) & 1:
            ones[j] += 1
x = 0
for i in range(39, -1, -1):
    if x + (1 << i) > K:
        continue
    elif ones[i] < N - ones[i]:
        x += (1 << i)

ans = 0
for i in A:
    ans += x ^ i

print (ans)

Measured memory_bytes: 14208
k = int(input())
s = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
l = s.split(",")
print(l[k-1])

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(void){
  int N, M, X;
  int a,c;
  int total = 0;
  int cnt;

  cin >> N >> M >> X;

  int A[N][M+1] = {{0}};

  for(int i = 0;i < N;i++){
    for(int j = 0;j < M+1;j++){
      cin >> A[i][j];
    }
  }

  int min_total = 10000000;
  for(int k = 0;k < (1 << N);k++){
    total = 0;
    int a[M] = {0};
    for(int i = 0;i < N;i++){
      if(k & (1<<i)){
        total += A[i][0];
        cnt = 0;
        for(int j = 1;j < M+1;j++){
          a[j-1] += A[i][j];
          if(a[j-1] >= X)cnt++;
        }
        if(cnt >= M){
          min_total = min(min_total,total);
          break;
        }
      }
    }
  }

  if(min_total < 10000000){
    cout << min_total << endl;
  }else{
    cout << -1 << endl;
  }

  return 0;
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();

        int x = d * 2 + 1;

        if (n % x == 0) {
            System.out.print(n / x);
        } else {
            System.out.print(n / x + 1);
        }
    }

}

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

using namespace std;

typedef long long int ll;
#define pb push_back
#define ALL(a) (a).begin() , a.end()

int mod = 1e9 + 7;

int add(int a, int b){
	if(a + b >= mod)return a+ b - mod;
	return a + b;
}
int mul(int a, int b){
	return 1LL * a * b  % mod;
}
int power(int a, int b){
	if(b < 0)return 0;
	int re = 1;
	while(b){
		if(b&1){
			re = mul(re, a);
		}
		a = mul(a, a);
		b >>= 1;
	}
	return re;
}
int const N = 100000 + 5;
int fact[N], inverse[N];
void FAC(){
 	fact[0] = 1;
	for(int x = 1; x< N; x++){
		fact[x] = mul(fact[x-1], x);
	}
	inverse[N-1] = power(fact[N-1], mod -2);
	for(int x = N-2; x>= 0; x--){
		inverse[x] = mul(x + 1, inverse[x+1]);
	}

 }

int ncr(int a, int b){
	if(a < b)return 0;
	return mul(fact[a], mul(inverse[a-b], inverse[b]));
}


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

void solve(){
	int n, m ;
	cin >> n >> m;
	vector<string> vec(n);
	for(auto &a : vec)cin >> a;
	int h = n * m;
	vector<vector<int>> ans(h, vector<int> (h, 1e5));
	for(int x =0; x<n; x++){
		for(int y =0; y<m; y++){
			ans[x*m+y][x*m+y] = 0;
			if(vec[x][y] == '.'){
				if(x - 1 != -1 && vec[x-1][y] == '.'){
					int x1 = (x-1)* m + y;
					ans[x*m + y][x1] = 1;
				}
				if(y - 1 != -1 && vec[x][y-1] == '.'){
					int x1 = x* m + y-1;
					ans[x*m + y][x1] = 1;
				}
				if(x + 1 != n && vec[x+1][y] == '.'){
					int x1 = (x+1)* m + y;
					ans[x*m + y][x1] = 1;
				}
				if(y +1 != m && vec[x][y+1] == '.'){
					int x1 = x* m + y+1;
					ans[x*m + y][x1] = 1;
				}

			}
		}
	}
	for(int k = 0; k<h; k++){
		for(int x = 0; x<h; x++){
			for(int y = 0; y<h; y++){
				if(vec[x/m][x%m] == '#' || vec[y/m][y%m] == '#' || vec[k/m][k%m] == '#')continue;
				if(ans[x][k] + ans[k][y] < ans[x][y] )
					ans[x][y] = ans[x][k] + ans[k][y];
			}
		}
	}
	// for(int k = 0; k<h; k++){
	// 	for(int x = 0; x<h; x++){
	// 		for(int y = 0; y<h; y++){
	// 			if(vec[x/m][x%m] == '#' || vec[y/m][y%m] == '#' || vec[k/m][k%m] == '#')continue;
	// 			if(ans[x][k] + ans[k][y] < ans[x][y] )
	// 				ans[x][y] = ans[x][k] + ans[k][y];
	// 		}
	// 	}
	// }
	// for(int k = 0; k<h; k++){
	// 	for(int x = 0; x<h; x++){
	// 		for(int y = 0; y<h; y++){
	// 			if(vec[x/m][x%m] == '#' || vec[y/m][y%m] == '#' || vec[k/m][k%m] == '#')continue;
	// 			if(ans[x][k] + ans[k][y] < ans[x][y] )
	// 				ans[x][y] = ans[x][k] + ans[k][y];
	// 		}
	// 	}
	// }
	int u = 1;
	for(int x =0; x<h; x++){
		for(int y =0; y<h; y++){
			if(ans[x][y] < 1e5){
				u = max(u, ans[x][y]);
			}
		}
	}

	cout << u ;
}


/******************************************************/
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(nullptr);
	int t;
	t = 1;
	// cin >> t;
	while(t--){
		solve();
	}

}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#define ll long long

using namespace std;


int main(void){
   ll h, w;
   cin >> h >> w;
   ll ans;
   if(h > 1 && w > 1){
      if(w%2!=0 && h%2!=0)
         ans = (w/2+1)*(h/2+1) + (w/2)*(h/2);
      else if(w%2==0 && h%2!=0)
         ans = w*h/2;
      else if(w%2!=0 && h%2==0)
         ans = w*(h/2);
      else if(w%2==0 && h%2==0)
         ans = w*h/2;
   }
   else
      ans = 1;
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << a + b + c - max(max(a, b), c);
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <numeric>
#include <cstdio>
using namespace std;
int main(){
	int L,K;
	for(;~scanf("%d%d",&L,&K)&&L&&K;){
		vector<long long>a0(L+K),a1(L+K);
		a1[0]=1;
		for(int i=0;i<L;i++){
			a0[i+1]+=a1[i];
			a0[i+K]+=a1[i];
			a1[i+1]+=a0[i];
		}
		printf("%lld\n",accumulate(a0.begin()+1,a0.begin()+L+1,0LL));
	}
}

Measured memory_bytes: 2756
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <memory>
#include <queue>
#include <stack>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cin;
using std::cout;
using std::endl;

int main(void) {
    cout << std::fixed << std::setprecision(10);
    cin.tie(0);
    std::ios::sync_with_stdio(false);
    int h, w, n;
    std::unique_ptr<int[]> barrier_mostsouth(new int[200010]);
    std::unique_ptr<std::unordered_set<int>[]> barrier(
        new std::unordered_set<int>[200010]);
    cin >> h >> w >> n;
    for (int i = 1; i <= h; i++) {
        barrier_mostsouth[i] = w + 1;
    }
    barrier_mostsouth[h + 1] = 1;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        barrier[x].insert(y);
        if (barrier_mostsouth[x] > y) {
            barrier_mostsouth[x] = y;
        }
    }
    for (int i = 1; i <= h; i++) {
        barrier[i].insert(w + 1);
    }
    for (int i = 1; i <= w + 1; i++) {
        barrier[h + 1].insert(i);
    }

    int pos_x = 1, pos_y = 1;
    while (!(barrier_mostsouth[pos_x + 1] <= pos_y)) {

        pos_x++;
        // cout << "posx++: " << pos_x - 1 << " -> " << pos_x << endl;
        if (barrier[pos_x].find(pos_y + 1) == barrier[pos_x].end()) {
            pos_y++;
            // cout << "posy++: " << pos_y - 1 << " -> " << pos_y << endl;
        }
    }
    cout << pos_x << endl;

    return 0;
}


Measured memory_bytes: 42056
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int d = scan.nextInt();
        int out = 0;
        for(int i = 0; i < n; i++){
            long x = scan.nextInt();
            long y = scan.nextInt();
            double distance = Math.sqrt(x * x + y * y);
            if(distance <= d) out++;
        }
        System.out.println(out);
    }
    
    public static void main(String[] args){
        new Main().solve();
    }
}

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

#define int long long
#define endl '\n'
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rep(i, l, r) for(int i=(int)(l);i<=(int)(r);i++)
const int inf = 1e18;

using namespace std;

int dp[2005];

int ok(int n) {
    if (n == 0)
        return 1;
    if (n == 1 or n == 2)
        return 0;
    if (n == 3 or n == 4 or n == 5)
        return 1;
    if(dp[n] != -1)
        return dp[n];

    else {
        int total = 0;
        for (int i = 3; i <= n; i++) {
                total = ((total % mod) + ok(n - i) % mod) % mod;
        }
        return dp[n] = total % mod;
    }

}

void solve() {
    int n;
    cin >> n;
    memset(dp, -1, sizeof dp);
    dp[0] = 1;
    cout << ok(n) << endl;
}


int32_t main() {
    fastIO
    int t = 1;
    //  cin >> t;
    while (t--) {
        solve();
    }
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
 
using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;
 
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
 
template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}
 
template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}
 
signed main(){
	int N,K;
	cin>>N>>K;
	string S;cin>>S;
 
	vint R;
	if(S[0]=='0')R.pb(0);
	int cur=0;
	while(cur<N){
		int nex=cur;
		while(nex<N&&S[cur]==S[nex])nex++;
		R.pb(nex-cur);
		cur=nex;
	}
	if(S.back()=='0')R.pb(0);
 
	vint acc(R.size()+1);
	rep(i,R.size())acc[i+1]=acc[i]+R[i];
	if(R.size()<=2*K+1){
		cout<<N<<endl;
		return 0;
	}
	int ans=0;
	for(int i=0;i+2*K+1<=R.size();i+=2)chmax(ans,acc[i+2*K+1]-acc[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2164
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;
  n %= 1000;
  if(n != 0){
    cout << 1000-n << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 3648
N, M = map(int, input().split())

student = [list(map(int, input().split())) for _ in range(N)]
checkP = [list(map(int, input().split())) for _ in range(M)]

for s in student:  
  ans = 0
  min_dist = 1<<60
  for i, c in enumerate(checkP, 1):    
    dist = abs(s[0]-c[0]) + abs(s[1]-c[1])
    if dist < min_dist:      
      min_dist = dist
      ans = i
  print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=100100;
int i,j,k,n,m,na,En,x,y,X,Y,ch,ff,ans,t;
int h[N],f[N],dp[N],fa[N],a[N];
struct edge { int s,n;} E[N<<1];
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void E_add(int x,int y) {
	E[++En].s=y;E[En].n=h[x];h[x]=En;
	E[++En].s=x;E[En].n=h[y];h[y]=En;
}
void dfs(int x,int F) {
	dp[x]=dp[F]+1;fa[x]=F;
	if (dp[x]&1) f[x]=1;
	else f[x]=-1;
	for (int k=h[x];k;k=E[k].n) if (E[k].s!=F) {
		if (dp[E[k].s]) X=x,Y=E[k].s;
		else {
			dfs(E[k].s,x);
			f[x]+=f[E[k].s];
		}
	}
}
int main() {
	R(n);R(m);
	for (i=1;i<=m;i++) {
		R(x);R(y);
		E_add(x,y);
	}
	dfs(1,0);
	if (n==m) {
		if ((dp[X]&1)==(dp[Y]&1)) {
			if (f[1]&1) return puts("-1"),0;
			t=-f[1]/2;
			while (X) f[X]+=t,X=fa[X];
			while (Y) f[Y]+=t,Y=fa[Y];
			ans+=abs(t);
		}
		else {
			int tx=X,ty=Y;
			while (dp[X]>dp[Y]) a[++na]=f[X],X=fa[X];
			while (dp[Y]>dp[X]) a[++na]=-f[Y],Y=fa[Y];
			sort(a+1,a+na+1);
			if (na&1) t=-a[na/2+1];
			else {
				if (abs(a[na/2])<abs(a[na/2+1])) t=-a[na/2];
				else t=-a[na/2+1];
			}
			X=tx;Y=ty;
			while (X) f[X]+=t,X=fa[X];
			while (Y) f[Y]-=t,Y=fa[Y];
			ans+=abs(t);
		}
	}
	if (f[1]) return puts("-1"),0;
	for (i=1;i<=n;i++) ans+=abs(f[i]);
	printf("%d\n",ans);
}

Measured memory_bytes: 8320