akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


int main() {
  int N;
  cin >> N;
  int A[1000][1000];
  for(int i=0;i<N;i++) for(int j=0;j<N-1;j++) cin >> A[i][j], A[i][j]--;

  int deg[1000] = {};
  bool update = true;
  int add = 0;
  int to[1000][1000];
  memset(to, -1, sizeof(to));
  vector< int > alive(N);
  iota(begin(alive), end(alive), 0);
  while(update) {
    update = false;
    for(int i : alive) {
      if(to[i][A[i][deg[i]]] == add) {
        ++deg[A[i][deg[i]]];
        ++deg[i];
        update = true;
      } else {
        to[A[i][deg[i]]][i] = add;
      }
    }
    vector< int > nxt;
    for(auto &p : alive) {
      if(deg[p] == N - 1) continue;
      nxt.emplace_back(p);
    }
    alive.swap(nxt);

    ++add;
  }

  if(*min_element(deg, deg + N) == N - 1) cout << add - 1 << endl;
  else cout << -1 << endl;
}




Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define push_back(x) push_back(x)
#define ll long long
#define MP make_pair
int main()
{
	
	ll n;
	cin>>n;
	map<string,ll> mp;
	while(n--)
	{
		string s;
		cin>>s;
		mp.insert(pair<string,ll>(s,mp[s]++));

	}
	cout<<mp.size()<<endl;

}

Measured memory_bytes: 19256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const int Inf = 1 << 30;

int main()
{
	int N,L,ans;
	bool vis[105],ok;
	char s[105][105];
	while(~scanf("%d %d",&N,&L)){
		for(int i = 1;i <= N;i++) scanf("%s",s[i] + 1), vis[i] = 0;
		for(int i = 1;i <= N;i++){
			ok = false;
			for(int j = 1;j <= N;j++){
				if(vis[j]) continue;
				if(!ok) ans = j,ok = true;
				else if(strcmp(s[ans] + 1,s[j] + 1) > 0) ans = j;
			}
			printf("%s",s[ans] + 1);
			vis[ans] = 1;
		}
		printf("\n");
	}
    return 0;
}

Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!(
    s: chars
    );
    let mut s = s;
    let mut r_s = s.clone();
    r_s.reverse();
    let n = s.len();
    let mut s1 = s.clone();
    let sa = s1.split_off((n - 1) / 2);
    let mut r_s1 = s1.clone();
    r_s1.reverse();
    let s2 = s.clone().split_off((n + 3) / 2 -1);
    let mut r_s2 = s2.clone();
    r_s2.reverse();
    let ans = if s == r_s && s1 == r_s1 && s2 == r_s2 { "Yes" } else { "No" };
    print!("{}", ans);
}


Measured memory_bytes: 4352
# coding: utf-8
# Your code here!
 
from collections import defaultdict
 
R, G, B, N = map(int, input().rstrip().split(' '))
A = [R, G, B]
 
dp = defaultdict(lambda: defaultdict(lambda: -1))
def rec(i, n):
    if dp[i][n] != -1:
        return dp[i][n]
    if n == 0:
        return 1
    if i == 2:
        return n % A[2] == 0
       
    temp = 0
    for j in range(n // A[i] + 1):
        temp += rec(i + 1, n - j * A[i])
        
    dp[i][n] = temp
    
    return temp
    
print(rec(0, N))

Measured memory_bytes: 42348
N = int(input())

a = [0]

a.extend(list(map(int, input().split())))

result = [0] * (N+1)
numbers = []

for i in range(N, 0, -1):
    sum = 0

    for j in range(2*i, N+1, i):
        sum += result[j]

    if (a[i] - sum) % 2 == 0:
        result[i] = 0
    else:
        result[i] = 1
        numbers.append(i)

print(len(numbers))

for number in numbers:
    print(number, end=" ")


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

#define pb push_back
#define ff first
#define ss second

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

const int MAXN = 2 * 100 * 1000 + 17;

ll n, d, a, x[MAXN], h[MAXN], cur, ans, b[MAXN];
deque<pll> dq;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> d >> a;
	for (int i = 1; i <= n; i++)
		cin >> x[i] >> h[i], b[i] = i;
	sort(b + 1, b + n + 1, [](int i, int j) { return x[i] < x[j]; });
	for (int t = n; t > 0; t--) {
		int i = b[t];
		while (dq.size() && dq.front().ff - d > x[i])
			cur -= dq.front().ss * a, dq.pop_front();
		h[i] -= cur;
		if (h[i] > 0)
			dq.pb({x[i] - d, (h[i] + a - 1) / a}), ans += dq.back().ss, cur += a * dq.back().ss;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin >> x;
    int y = x / 500;
    x %= 500;
    int z = x / 5;
    int ans = y * 1000 + z * 5;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    D = int(input())
    C = [0] * 26
    C = list(map(int,input().split()))
    S = [ list(map(int,input().split(" "))) for i in range(D)]
    
    last = [0] * 26
    for i in range(D):
        max = -9999999999999
        max_t = 0
        for t in range(26):
            score = 0
            for j in range(26):
                if j == t:
                    #last[j] = 0
                    score += S[i][j]
                else:
                    #last[j] += 1
                    score -= (last[j]+3)*C[j]
            if  score > max:
                max = score
                max_t = t
        for j in range(26):
            if j == max_t:
                last[j] = 0
            else:
                last[j] += 1
        print(max_t + 1)
if __name__ == '__main__':
    main()

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

int main() {
	double n,sum;
	while(cin>>n){
		sum=n;
		for(int i=2;i<=10;i++){
			if(i%2==0){
				n*=2;
				sum+=n;
			}else{
				n/=3;
				sum+=n;
			}
		}printf("%.8lf\n",sum);
	}
	return 0;
}

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

using namespace std;

int main(){

  int d,n;

  cin>>d>>n;

  int tmp = 0;
  switch(d){
  case 0:
    tmp = 1;
    break;
  case 1:
    tmp = 100;
    break;
  case 2:
    tmp = 10000;
    break;
  }
  if(n != 100)
    cout<<tmp*n<<endl;
  else
    cout<<tmp*(n+1)<<endl;
  

  return 0;
}


Measured memory_bytes: 256
//code_sm
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu ((int)1e9+7)
#define set0(a) memset(a,0,sizeof(a))

//sieve generation begin
vi PRIME;
void sieve(int n)
{
	bool a[n+1];
	memset(a,0,sizeof(a));
	a[0]=1;
	a[1]=1;
	for(int i=2;i*i<=n;i++)
	{
		if(a[i]==0)
		{
			for(int j=i*i;j<=n;j+=i)
			a[j]=1;
		}
	}
	for(int i=2;i<=n;i++)
	{
		if(a[i]==0)
		PRIME.pb(i);
	}
}
//sieve generation end
ll gcd(ll a,ll b)
{
	while(b%a)
	{
		ll c=b;
		b=a;
		a=c%a;
	}
	return a;
}
ll bigpow(ll x,ll y)
{
	if(y==0)
	return 1;
	else if(y&1)
	{
		return (x*bigpow((x*x)%chotu,(y-1)/2))%chotu;
	}
	else 
	return bigpow((x*x)%chotu,y/2);
}
void solve()
{
fastio
string s;
cin>>s;
if(s=="ABC")
cout<<"ARC";
else
cout<<"ABC";	
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
	solve();
	cout<<'\n';
}

}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define scan2() int n,k; cin>>n>>k ; int a[n+1]; for(int i = 1 ; i<=n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005



int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);

        int a,b,c,k;
        cin >> a >> b >> c >> k;
        int i,j;
        int take=min(k,a);
        int ans=0;
        ans=take;
        k=k-take;
        take=min(k,b);
        k=k-take;
        take=min(k,c);
        ans+=(take*-1);
        k=k-take;
        cout << ans << '\n';

        

}

Measured memory_bytes: 3652
import numpy as np
import itertools as it

H,W,N = [int(i) for i in input().split()]
dat = np.array([list(input()) for i in range(H)], dtype=str)


emp_r = ["." for i in range(W)]
emp_c = ["." for i in range(H)]


def plot(dat, dict):
    for y in dict["row"]:
        dat[y,:] = emp_r
    for x in dict["col"]:
        dat[:,x] = emp_c
    return dat


def is_sat(dat):
    count = 0
    for y in range(W):
        for x in range(H):
            if dat[x, y] == "#":
                count += 1

    if count == N:
        return True
    else:
        return False

# def get_one_idx(bi, digit_num):
#     tmp = []
#     for j in range(digit_num):
#         if (bi >> j) == 1:
#             tmp.append()



# plot(dat, dict={"row": [], "col":[0, 1]})
combs = it.product([bin(i) for i in range(2**H-1)], [bin(i) for i in range(2**W-1)])
count = 0
for comb in combs:
    rows = comb[0]
    cols = comb[1]
    rc_dict = {"row": [], "col": []}
    for j in range(H):
        if (int(rows, 0) >> j) & 1 == 1:
            rc_dict["row"].append(j)

    for j in range(W):
        if (int(cols, 0) >> j) & 1 == 1:
            rc_dict["col"].append(j)

    dat_c = plot(dat.copy(), rc_dict)
    if is_sat(dat_c):
        count += 1

print(count)








Measured memory_bytes: 27084
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define NIL -1
using namespace std;

int count(const string& X, int i, const string Y, int j,
          vector<vector<int> >& MEMO){
    if (i >= X.size() || j >= Y.size()) return 0;
    if (MEMO[i][j] != NIL) return MEMO[i][j];
    int next_X = count(X, i + 1, Y, j, MEMO);
    int j_next = Y.find(X[i], j);
    if (j_next == string::npos) return MEMO[i][j] = next_X;
    int saiyou = count(X, i + 1, Y, j_next + 1, MEMO) + 1;
    return MEMO[i][j] = max(saiyou, next_X);
}

int main(){
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        string X, Y;
        cin >> X >> Y;
        vector<vector<int> > MEMO(X.size(), vector<int>(Y.size(), NIL));
        cout << count(X, 0, Y, 0, MEMO) << endl;
    }
    return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  auto S = make_v< string >(H);
  cin >> S;
  int ret = 0;
  for(int i = 0; i < (1 << H); i++) {
    for(int j = 0; j < (1 << W); j++) {
      int add = 0;
      for(int k = 0; k < H; k++) {
        for(int l = 0; l < W; l++) {
          if((i >> k) & 1 || (j >> l) & 1) continue;
          add += S[k][l] == '#';
        }
      }
      ret += add == K;
    }
  }
  cout << ret << "\n";
}

Measured memory_bytes: 3636
parseInt(x) = parse(Int,x)

function main()
  N = parseInt(readline())
  W = map(parseInt,split(readline()))
  S = zeros(Int64,N)
  for i=1:N
    S[i] = abs(sum(W[i+1:N])-sum(W[1:i]))
  end
  println(minimum(S))
end

main()

Measured memory_bytes: 123080
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
string S,T,U;
ll N;
ll A[200001];




int main(){
    bool found = true;
    cin >> N;
    for (int i=0;i<N;i++){
        cin >> A[i];
    }
    sort(A,A+N);
    for (int i=1;i<N;i++){
        if(A[i-1]==A[i]){
            found = false;
        }
    }
    if(found){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}




Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
using namespace std;
long long  s[1000009];
int main(){
	long long a,b,ans=0;
     cin>>a>>b;
     for(int i=1;i<=b;i++)
     cin>>s[i];
     for(int i=2;i<=b;i++){
     	ans=max(ans,s[i]-s[i-1]);
	 }
	 ans=max(ans,a-s[b]+s[1]);
	 cout<<a-ans<<endl;
}

Measured memory_bytes: 1792
from heapq import heappop, heappush

N, M = map(int, input().split())
X = sorted([list(map(int, input().split())) for _ in range(N)], key = lambda x: x[0])

hq = []
ans, j = 0, 0

for i in range(1, M + 1):  # M - i 日後にするバイトを考える
    while (j < N) and (X[j][0] <= i):
        heappush(hq, -X[j][1])  # 候補の追加
        j += 1
    if len(hq):
        ans += -heappop(hq)  # 候補があるとき、候補から最大値を取り出す

print(ans)


Measured memory_bytes: 31976
N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))

visited = [0] * (N + 1)
route = [0] * (N + 1)
next_ = 1
count = 0

for i in range(K + 1):
    if visited[next_] != 0:
        x = visited[next_]
        count = (K - (x - 1)) % (i + 1 - x) + x
        print(route[count])
        exit()
    visited[next_] = i + 1
    route[i + 1] = next_
    next_ = A[next_]

print(route[K + 1])


Measured memory_bytes: 32388
# -*- coding: utf-8 -*-

n = int(input())
t_point, h_point = 0, 0

for i in range(n):
    t_card,  h_card  = map(str, input().split())

    if t_card == h_card:
        t_point += 1
        h_point += 1
    elif t_card > h_card:
        t_point += 3
    elif t_card < h_card:
        h_point += 3

print('{0} {1}'.format(t_point, h_point))


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

class UnionFind {
  public:
    std::vector<int> par;
    std::vector<int> rank;
    std::vector<int> size;

    UnionFind(int N) : par(N), rank(N), size(N) {        
        for (int i = 0; i < N; i++) {
            par[i]  = i;
            rank[i] = 0;
            size[i] = 1;
        }
    }

    int find(int x)
    {
        if (par[x] == x) {
            return x;
        }
        return par[x] = find(par[x]);
    }

    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);

        if (x == y) { return; }

        if (rank[x] < rank[y]) {
            par[x] = y;
            size[y] += size[x];
        } else {
            par[y] = x;
            size[x] += size[y];
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }       
    }

    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
};

int main()
{
    int N, M;
    std::cin >> N >> M;

    UnionFind uf(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        std::cin >> a >> b;
        uf.unite(a - 1, b - 1);
    }
    
    int city = 0;
    int town = 0;
    std::vector<bool> used(N, false);
    
    for (int i = 0; i < N; i++) {
        int x = uf.find(i);
        if (used[x]) { continue; }

        used[x] = true;
        if (uf.size[x] == 1) {
            town++;
        } else {
            city++;
        }
    }

    int diff = town - city;
    std::cout << (diff < 0 ? -diff : diff) << std::endl;
    
    return 0;
}

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

int main()
{
	int n,k;
	cin>>n>>k;
	int h[n], dp[n];
	for(int i=0; i<n; i++) cin>>h[i];
	dp[0]=0;
	for(int i=1; i<n; i++)
	{
		int min=INT_MAX;
		for(int j=1; j<=k; j++)
		{
			if(i-j<0) break;
			int value=dp[i-j]+fabs(h[i]-h[i-j]);
			if(value<min) min=value;
		}
		dp[i]=min;
	}
	cout<<dp[n-1]<<endl;
} 

Measured memory_bytes: 1024
X = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

for i in range(len(make_divisors(X))):
    A = make_divisors(X)[i]
    for j in range(-64,119):
        if (A+j)**5-j**5==X:
            a = j + A
            b = j
            break
        else:
            continue
        break
    else:
        continue
    break
print(a,b)

Measured memory_bytes: 68204
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RREP(i,x) for(int i=(x);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
const int INF = 1000000000;


class DP{
public:
	int cost, n, x;
	
	DP(){}
	DP(int cc, int nn, int xx){
		cost = cc;x=xx;n=nn;
	}
	
	bool operator< (const DP &opp) const {
		return cost>opp.cost;
	}
};
int memo[105][105];
int N, M, L, K, A, H;
main(){
	int i,j;
	while(cin >> N >> M >> L >> K >> A >> H, N){
		vector< vector<pii> > g(N);
		set<int> freeze;
		REP(i, L){
			int x;
			cin >> x;
			freeze.insert(x);
		}
		REP(i, K){
			int x, y, t;
			cin >> x >> y >> t;
			g[x].push_back(pii(y, t));
			g[y].push_back(pii(x, t));
		}
		REP(i, N)REP(j, M+1) memo[i][j] = INF;
		priority_queue<DP> dp;
		DP S;
		dp.push(DP(0, A, M));
		while(!dp.empty()){
			S = dp.top();
			dp.pop();
			if(memo[S.n][S.x] < S.cost) continue;
			if(S.n == H) break;
			FOR(it, g[S.n]){
				DP T=S;
				T.x -= it->second;
				if(T.x < 0) continue;
				T.n = it->first;
				T.cost += it->second;
				if(memo[T.n][T.x] > T.cost){
					memo[T.n][T.x] = T.cost;
					dp.push(T);
				}
				if(freeze.count(T.n)){
					while(++T.x <= M){
						T.cost ++;
						if(memo[T.n][T.x] > T.cost){
							memo[T.n][T.x] = T.cost;
							dp.push(T);
						}
					}
				}
			}
		}
		if(S.n == H) cout << S.cost << endl;
		else cout << "Help!" << endl;
	}
	return 0;
}

Measured memory_bytes: 1628
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vi l(n);
    REP(i, n) cin >> l[i];
    int ans = 0;
    REP(i, n - 2) FOR(j, i + 1, n - 1) FOR(k, j + 1, n) {
        if (l[i] == l[j] or l[i] == l[k] or l[j] == l[k]) continue;
        int x = l[i] + l[j] + l[k] - max({l[i], l[j], l[k]});
        if (x > max({l[i], l[j], l[k]})) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3660
n = int(input())
arr = sorted([int(a) for a in input().split()])

res = 0
size = 0
for i in range(n-1):
    size += arr[i]
    if arr[i+1] > size * 2:
        res = 0
    else:
        res += 1
res += 1

print(res)


Measured memory_bytes: 20260
import itertools
import math

n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

nums = [i for i in range(1,n+1)]
lists = list(itertools.permutations(nums,n))

a = lists.index(p)
b = lists.index(q)

print(abs(a-b))

        
            
       

Measured memory_bytes: 7972
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 1005
using namespace std;

int main() {
  int n;
  double T, A;
  cin >> n >> T >> A;
  double h,ab;
  int count;
  ab=100005;
  for(int i=1;i<=n;i++) {
    double temp;
    cin >> h;
    temp=T-h*0.006;
    if(abs(ab-A) >= abs(temp-A)) {
      ab=temp;
      count = i;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> book[550];
int main(){
	int n,m,q,l[100010],r[100010],i,j,x,y,num;
	cin>>n>>m>>q;
	for(i=0;i<m;i++)
	{
		cin>>x>>y;
		book[x].push_back(y);
	}
	for(i=0;i<n;i++)
		sort(book[i].begin(),book[i].end());
	for(i=0;i<q;i++)
	{
		cin>>l[i]>>r[i];
	}
	for(i=0;i<q;i++)
	{
		num=0;
		for(j=l[i];j<=r[i];j++)
			num+=upper_bound(book[j].begin(),book[j].end(),r[i])-book[j].begin();
		cout<<num<<endl;
	}
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define lli long long int
#define timesave ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;

void solve()
{
    lli n;

    cin >> n;

    string ans = "";

    while(n){
        lli d = n%26;

        if(d == 0){
        	ans += 'z';
            n = (n/26) - 1;
        }
        else{
        	ans += (d-1)+'a';
        	n = n/26;
        }
    }

    reverse(ans.begin(), ans.end());

    cout << ans << "\n";
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //timesave; 

    int tc = 1;
    //cin >> tc;
    while(tc--	) solve();
 
    return 0;
}

Measured memory_bytes: 3628
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Spandan Mishra
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ARegistration solver = new ARegistration();
        solver.solve(1, in, out);
        out.close();
    }

    static class ARegistration {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.readString();
            String t = in.readString();
            if (t.substring(0, s.length()).equals(s))
                System.out.println("Yes");
            else
                System.out.println("No");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String readString() {
            final StringBuilder stringBuilder = new StringBuilder();
            int c = read();
            while (isSpaceChar(c))
                c = read();
            do {
                stringBuilder.append((char) c);
                c = read();
            } while (!isSpaceChar(c));
            return stringBuilder.toString();
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 32408
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define swap(typ, x, y) \
    do { \
        typ tmp; \
        tmp = x; \
        x = y; \
        y = tmp; \
    } while (0)

void max_heapify(int *arr, int i, int size) {
    int l, r, largest;

    l = (i+1) * 2 - 1;
    r = (i+1) * 2;

    if (l <= (size - 1) && arr[l] > arr[i]) {
        largest = l;
    } else {
        largest = i;
    }
    if (r <= (size - 1) && arr[r] > arr[largest]) {
        largest = r;
    }

    if (largest != i) {
        swap(int, arr[i], arr[largest]);
        max_heapify(arr, largest, size);
    }
}

void build_max_heap(int *arr, int size) {
    for (int i = (size / 2); i >= 0; i--) {
        max_heapify(arr, i, size);
    }
}

void insert_priority_queue(int *arr, int elem, int *size) {
    int index;
    arr[*size] = elem;
    (*size)++;

    index = *size - 1;
    while (arr[index] > arr[(index-1) / 2]) {
        swap(int, arr[index], arr[(index-1) / 2]);
        index = (index-1) / 2;
    }
}

int extract_priority_queue(int *arr, int *size) {
    int max_val = arr[0];
    swap(int, arr[0], arr[*size-1]);
    (*size)--;
    max_heapify(arr, 0, *size);
    return max_val;
}

int main(void) {
    int arr[2000000];
    int size = 0;
    char command[8];

    for (;;) {
        fgets(command, 7, stdin);
        if (strncmp(command, "end", 3) == 0) {
            break;
        } else if (strncmp(command, "insert", 7) == 0) {
            int val;
            scanf("%d", &val);
            insert_priority_queue(arr, val, &size);
            fgets(command, 8, stdin); // to consume newline
        } else if (strncmp(command, "extrac", 7) == 0) {
            int max_val = extract_priority_queue(arr, &size);
            printf("%d\n", max_val);
            fgets(command, 8, stdin); // to consume newline
        } else {
            fprintf(stderr, "illegal command: %s\n", command);
            exit(EXIT_FAILURE);
        }
    }

    return 0;
}



Measured memory_bytes: 5752
import java.util.*;
public class Main{
	static int Train(int[] s, int t){
		int count = 0;
		int x = 0;
      	int y = 0;
		for(int i=0; i<t; i++){
			count++;
			y = s[x];
          	x = y;
			if(x==1)return count;
		}
		return -1;
	}
			

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i=0; i<n; i++){
			a[i] = sc.nextInt() - 1;
		}
		System.out.println(Train(a, n));
	}
}

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

using namespace std;

int main(){
    string s;
    cin>>s;
    bool isgood =true;
    if (s[0]==s[1]) isgood = false;
    if (s[1]==s[2]) isgood = false;
    if (s[2]==s[3]) isgood = false;
    if(isgood){
        cout<<"Good"<<endl;
        return 0;
    }else{
        cout<<"Bad"<<endl;
        return 0;
    }
}


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

int main(){
  int N, M;
  cin >> N >> M;
  int days = 0 ;
  
  for (int i = 0; i < N; i++) {
      int take_days = 0;
      cin >> take_days;
      days += take_days;
    
  }
  if(days > N){cout << "-1" << endl;}
  
  else{
      std::cout << N - days << endl;
  }
  
}



Measured memory_bytes: 3636
// #includes {{{
#ifdef MY_DEBUG
#include "header/header.hpp"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

template<class T>
constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity():(numeric_limits<T>::max()/2);

int __inf_ignore(){
	int t = inf<int>;
	return t;
}

typedef pair<int,int> pii;

#ifdef MY_DEBUG
#include"print.hpp"
#include"debug.hpp"
#endif
// }}}

Int N;
Int L;

void solve(){
	vector<Int> A(N);
	REP(i,N){
		A[i] = L + i;
	}
	auto S = accumulate(ALL(A),0ll);
	Int ans = inf<Int>;
	Int ansT = -1;
	REP(i,N){
		auto p = L + i;
		auto T = S - p;
		Int d = abs(S-T);
		if(ans>d){
			ans = d;
			ansT = T;
		}
	}
	cout<<ansT<<endl;
}

//{{{ main fucnction
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> N;
    cin >> L;
	solve();
	return 0;
}

//}}}



Measured memory_bytes: 256
from itertools import groupby


s=input()
x,y=map(int,input().split())
data=[s[i] for i in range(0,len(s))]
data=groupby(data)
LR=[]
UD=[]
point='LR'
flag=0
checkx=2**8000
for key,group in data:
    g=len(list(group))
    if key=='F':
        if flag==0:
            checkx=checkx<<g
            flag=1
        else:
            if point=='LR':
                LR.append(g)
            else:
                UD.append(g)
    else:
        if g%2==1:
            if point=='LR':
                point='UD'
            else:
                point='LR'
        flag=1


for i in range(0,len(LR)):
    checkx=(checkx<<LR[i])|(checkx>>LR[i])

checky=2**8000
for i in range(0,len(UD)):
    checky=(checky<<UD[i])|(checky>>UD[i])


if checkx>>(x+8000) &1==1 and checky>>(y+8000) &1==1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 41692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;

    ll A;
    ll mx = 0;
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        cin >> A;
        mx = max(A, mx);
        ans += mx - A;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    ll A,B; cin>>A>>B;
    ll Gcd = __gcd(A,B);

    ll ans = 1;
    for (ll i = 2; i*i <= Gcd; ++i) {
        if(Gcd % i == 0){
            ans++;
            while(Gcd % i == 0){
                Gcd /= i;
            }
        }
    }
    if(Gcd!=1){
        ans++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

	for (int i = 1; i < 1000000000; i++)
	{
		a *= i;
		if (a%2==0)
		{
			break;
		}
	}
	cout << a;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long li;

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

const int maxn = 1000;

int n, m, a[maxn][maxn];
char buf[maxn + 1];

int dist[maxn][maxn];
typedef pair<int, int> pii;

queue<pii> que;

int main(void) {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%s", buf);
    for (int j = 0; j < m; ++j) {
      a[i][j] = buf[j] == '#';
    }
  }
  memset(dist, -1, sizeof dist);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m ;++j) {
      if (a[i][j]) {
        dist[i][j] = 0;
        que.push(pii(i, j));
      }
    }
  }
  int ans = 0;
  while (!que.empty()) {
    int x = que.front().first, y = que.front().second;
    que.pop();
    for (int d = 0; d < 4; ++d) {
      int x2 = x + dx[d], y2 = y + dy[d];
      if (x2 >= 0 && x2 < n && y2 >= 0 && y2 < m && dist[x2][y2] == -1) {
        dist[x2][y2] = dist[x][y] + 1;
        que.push(pii(x2, y2));
        ans = dist[x2][y2];
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 16272
#include<cstdio>
using namespace std;

int main(){
	int n,y;
	scanf("%d%d",&n,&y);
	for(register int i=0;i<=2000;i++){
		for(register int j=0;j<=2000;j++){
			int k=n-i-j;
				if(k<0)continue;
				if(i*10000+j*5000+k*1000==y){
					printf("%d %d %d",i,j,k);
					return 0;
				}
			}
		}
	printf("-1 -1 -1");
	return 0;
}

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

int N, K;
string S;

int main() {
    cin >> N >> K;
    cin >> S;

    S[K - 1] = tolower(S[K - 1]);

    cout << S << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <cstring>
//#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define de(x,y) cout<<#x<<" :"<<x<<y;
#define int long long
#define SZ(xx) ((int)xx.size())
#define lowbit(xx) (xx&(-xx))
#define pb push_back
typedef pair<int,int> pii;

const int maxn = 4e2+5;
int arr[maxn], pre[maxn];

int dp[maxn][maxn];

int dfs(int l,int r) {
	if (l == r) return dp[l][r] = 0;
	else if (dp[l][r] != -1) return dp[l][r];
	else {
		dp[l][r] = 1e18;
		for (int i = l; i < r; i++) {
			dp[l][r] = min(dp[l][r], dfs(l, i) + dfs(i + 1, r) + pre[r] - pre[l - 1]); 
		}
		return dp[l][r];
	} 
}

main() {
	IOS
	int n;
	cin >> n;
	pre[0] = 0;
	memset(dp, -1, sizeof(dp));
	for (int i = 1; i <= n; i++)
		cin >> arr[i], pre[i] = pre[i - 1] + arr[i];
	cout << dfs(1, n);
}


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

int main() {
  long long n;
  cin >> n;
  long long total = 0;
  for(int i=0; i <= n; i++) {
    if(!(i%3 ==0 || i%5 == 0)) total += i;
  }
  cout << total << endl;
}


Measured memory_bytes: 3620
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int n=gi();
        //String s=gs();
        
        int a= n%1000;
	    
	    System.out.println((1000-a)%1000);
//	    if (isNumber(s1) && isNumber(s2) && s.charAt(a) == '-') {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }



	}

	public static int d(int n) {
		int m=0;
		while(true) {
			if(n<1) {
				break;
			}
			int l= n%10;
			m+=l;
			n= (n-l)/10;
		}
		return m;
	}
	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

using namespace std;

#define MOD 1000000007

int main()
{
  int n,m;
  cin >> n >> m;
  vector<bool> can(n+1,true);
  for(int i=0;i<m;i++)
  {
    int a;
    cin >> a;
    can[a]=false;
  }
  
  vector<long long> dp(n+1,0);
  dp[0]=1;
  for(int i=0;i<=n;i++)
  {
    dp[i]%=MOD;
    if(can[i]==false)continue;
    if(i+2<=n)dp[i+2]+=dp[i];
    if(i+1<=n)dp[i+1]+=dp[i];
  }
  dp[n]%=MOD;
  cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
#include <chrono>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef tuple<ll,ll,ll> tll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//templete
int main() {
	int H,W;
	cin>>H>>W;
	int h,w;
	cin>>h>>w;
	cout<<H*W-h*W-(w)*(H-h)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
struct node
{
	int p,id;
}a[510];
bool cmp(node a,node b)
{
	if(a.p==b.p)return a.id>b.id;
	else return a.p<b.p;
}
int l[510],r[510],f[510][300];
int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n=read(),m=read();
    for(int i=0;i<2*n;i++)
    {
    	a[i].id=i;r[i]=min(2*n-1,(int)floor(sqrt(4*n*n-i*i)));
    	if(i>=n)l[i]=0,a[i].p=r[i];
    	else {l[i]=ceil(sqrt(n*n-i*i));a[i].p=l[i]-1;}
	}sort(a,a+2*n,cmp);
	int ans=0;
	for(int k=0;k<=n;k++)
	{
		int cnt=0;
		memset(f,0,sizeof(f));f[0][0]=1;
		for(int i=1;i<=2*n;i++)
		{
			if(a[i-1].id<n)cnt++;
			for(int j=0;j<=min(k,cnt);j++)
			{
				if(a[i-1].id<n)
				{
					f[i][j]=1LL*f[i-1][j]*(r[a[i-1].id]+1-(2*n-1-a[i-1].id+k-j))%m;
					if(j>0)(f[i][j]+=1LL*f[i-1][j-1]*(a[i-1].p+1-(i-1-(cnt-j)))%m)%=m;
				}
				else f[i][j]=1LL*f[i-1][j]*(a[i-1].p+1-(i-1-(cnt-j)))%m;
			}
		}
		if(k&1)(ans-=f[2*n][k]-m)%=m;
		else (ans+=f[2*n][k])%=m;
	}pr2(ans);
   	return 0;
}

Measured memory_bytes: 768
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}
#define int ll

void solve(){
	int n, t;
	cin >> n >> t;
	vector<int> inputs;
	REP(i, n) {
		int a;
		cin >> a;
		inputs.push_back(a);
	}
	int startTime = 0;
	int secondEndTime = 0;
	REP(i, n) {
		int cnt = 1;
		int nextTime = startTime + inputs[i];
		if (nextTime > t) {
			cout << 1 << endl;
			startTime += inputs[i];
			continue;
		}
		secondEndTime = max(nextTime, secondEndTime) + inputs[i];
		int hoge = secondEndTime - nextTime;
		cnt += (t - nextTime + hoge) / hoge;
		cout << cnt << endl;
		startTime += inputs[i];
	}
}

#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3952
s1 = input()
s2 = input()
l1 = len(s1)
l2 = len(s2)
mat = [[float('inf') for _ in range(l1 + 1)] for _ in range(l2 + 1)]

for i in range(l1+1):
    mat[0][i] = i
for j in range(l2+1):
    mat[j][0] = j

for i in range(l2):
    for j in range(l1):
        m = mat[i][j] + 1 if s1[j] != s2[i] else mat[i][j]
        mat[i+1][j+1] = min(m, mat[i][j+1] + 1, mat[i+1][j] + 1)
print(mat[l2][l1])



Measured memory_bytes: 42800
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

vector<int> v[11];
vector<bool> used(11,false);
int n,m;
int ans=0;

void dfs(int x, int cnt){
  if(cnt==n){ ans++; return; }
  for(auto to:v[x])if(!used[to]){
    used[to]=true;
    dfs(to, cnt+1);
    used[to]=false;
  }
}

int main(){
  cin >> n >> m;
  rep(i,m){ 
    int a,b; cin>>a>>b; a--; b--;
    v[a].emplace_back(b);
    v[b].emplace_back(a);
  }
  used[0]=true;
  dfs(0,1);
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

let main() =
    let N = read int
    let xls = Array.zeroCreate N
    for i in 0 .. N - 1 do
        let [| x; l |] = reada int64
        xls.[i] <- (x, l)
    let lrs = Array.zeroCreate N
    for i in 0 .. N - 1 do
        let x, d = xls.[i]
        let l, r = x - d, x + d
        lrs.[i] <- (l, r)
    let lrs = lrs |> Array.sortBy (fun (l, r) -> r)

    let mutable nr = Int64.MinValue
    let mutable cnt = 0
    for i in 0 .. N - 1 do
        let l, r = lrs.[i]
        if l < nr then
            ()
        else
            nr <- r
            cnt <- cnt + 1

    puts cnt
    ()

main()
writer.Close()


Measured memory_bytes: 27192