akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion
template <typename T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n)
    {
        cin >> h[i];
    }

    vector<ll> dp(n, LONG_LONG_MAX);
    dp[0] = 0;
    for (int i = 1; i < n; i++)
    {
        rep(j, min(k, i))
        {
            int idx = i - (j + 1);
            ll cost = dp[idx] + abs(h[i] - h[idx]);
            chmin(dp[i], cost);
        }
    }

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

    return 0;
}

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

#define each(i, c) for (auto& i : c)

typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9+7;

class modint {
  private:
    ll m_val;
    ll m_mod;
  public:
    constexpr modint() noexcept : m_val(0), m_mod() { m_mod = MOD; }
    constexpr modint(const ll x) noexcept : m_val(0), m_mod(0) { m_mod = MOD; m_val = x % m_mod; }
    constexpr modint(const ll x, const ll mod) noexcept : m_val(0), m_mod(0) { m_mod = mod; m_val = x % m_mod; }
    constexpr ll val() noexcept { return m_val; }
    constexpr const ll val() const noexcept { return m_val; }
    constexpr modint operator+(const modint rhs) const noexcept { return modint(*this) += rhs; }
    constexpr modint operator-(const modint rhs) const noexcept { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint rhs) const noexcept { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint rhs) const noexcept { return modint(*this) /= rhs; }
    constexpr modint &operator+=(const modint rhs) noexcept {
      m_val += rhs.m_val;
      if (m_val >= m_mod) m_val -= m_mod;
      return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
      if (m_val < rhs.m_val) m_val += m_mod;
      m_val -= rhs.m_val;
      return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
      m_val = m_val * rhs.m_val % m_mod;
      return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
      ll exp = m_mod - 2;
      while (exp) {
        if (exp % 2) *this *= rhs;
        rhs *= rhs;
        exp /= 2;
      }
      return *this;
    }
};

ll modpow(ll x, ll n) {
  ll res = 1;
  while (n != 0){
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n = n >> 1;
  }
  return res;
}

const ll FAC_MAX = 100010;
vector<ll> fac(FAC_MAX);
vector<ll> invfac(FAC_MAX);
void init_fac() {
  fac[0] = 1;
  invfac[0] = 1;
  for (ll i = 0; i < FAC_MAX; i++) {
    fac[i+1] = fac[i] * (i+1) % MOD;
    invfac[i+1] = invfac[i] * modpow(i+1, MOD-2) % MOD;
  }
}

ll comb(ll n, ll r) { // nCr
  if (n == 0 && r == 0) return 1;
  if (n < r || n < 0) return 0;
  ll res = invfac[n-r] * invfac[r] % MOD;
  return res * fac[n] % MOD;
}

int main() {
  ll n, k;
  cin >> n >> k;

  vector<ll> a(n, 0);
  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());

  init_fac();
  modint ans = 0;
  for (ll i = 0; i < n; ++i) {
    ans -= a[i] * comb(n-(i+1), k-1);
    ans += a[i] * comb(i, k-1);
  }

  cout << ans.val() << endl;
  
  return 0;
}

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

void solve()
{
    string a, b;
    cin >> a >> b;
    int maxsize = max(a.size(), b.size());
    if (a.size() != maxsize)
    {
        int addsize = maxsize - a.size();
        rep(i, addsize)
        {
            a = '0' + a;
        }
    }
    if (b.size() != maxsize)
    {
        int addsize = maxsize - b.size();
        rep(i, addsize)
        {
            b = '0' + b;
        }
    }
    if (a > b)
        cout << "GREATER" << endl;
    else if (a < b)
        cout << "LESS" << endl;
    else
        cout << "EQUAL" << endl;
}

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

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#define N 55
using namespace std;

typedef long long ll;
ll n, mx, ans, a[N], b[N], x[N];
bool v[N];
bool f() {
	ll i, j, k;
	for (i = 0; i < n; i++) {
		for (j = 0; j <= mx; j++) x[j] = 0;
		x[a[i]] = 1;
		for (j = a[i]; j >= 1; j--) {
			if (!x[j]) continue;
			for (k = 1; k <= j; k++) {
				if (!v[k]) continue;
				x[j % k] = 1;
			}
		}
		if (!x[b[i]]) return 0;
	}
	return 1;
}
int main()
{
	ll i, j;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf ("%lld", &a[i]);
		mx = max(mx, a[i]);
	}
	for (i = 1; i <= mx; i++) v[i] = 1;
	for (i = 0; i < n; i++) scanf ("%lld", &b[i]);
	for (i = mx; i >= 1; i--) {
		v[i] = 0;
		if (!f()) {
			v[i] = 1;
			ans += 1LL << i;
		}
	}
    if (ans == (1LL << (mx + 1)) - 2) {
		cout << -1;
		return 0;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
//BISMILLAHHIR RAHMANIR RAHIM
#include<bits/stdc++.h>
using namespace std;
typedef long long int            ll;
typedef unsigned long long int   ull;
#define min3(a,b,c)              min(a,min(b,c))
#define F                        first
#define S                        second
#define PB                       push_back
#define MP                       make_pair
#define PI                       2*acos(0.0)
#define MOD                      998244353
int main()
{
   ll n,sum=0,m,ans;
   cin>>m>>n;
   int ara[n];for(int i=0; i<n; i++)cin>>ara[i];
   for(int i=0; i<n; i++){
    sum+=ara[i];
   }
   ans=m-sum;
   if(ans>=0){
    cout<<ans<<endl;
   }
   else cout<<-1<<endl;
   return 0;
}


Measured memory_bytes: 3672
#!/usr/bin/ruby
require 'prime'
h={};2.step(36){|i|h[i]=i.prime_division}
while(l=gets.chomp)!="0 0"
	l=l.split
	n=l[0].to_i;m=l[1].to_i(n)
	p h[n].map{|a,b|
		z=m;r=0
		while z>0 do r+=(z/=a) end
		r/=b
	}.min
end

Measured memory_bytes: 6252
#include <stdio.h>
int main(void){
   int a[]={1,5,10,50,100,500};
   int b[5],x=0,i;
   scanf("%d %d %d %d %d %d",&b[0],&b[1],&b[2],&b[3],&b[4],&b[5]);
   for(i=0;i<6;i++){
      x+=a[i]*b[i];
   }
   if(x>=1000)
      printf("1\n");
   else
      printf("0\n");

   return 0;
}

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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arr(a,n);

  bool win_first=false;
  rep(i,n){
    if(a[i]%2==1) win_first=true;
  }

  prt(win_first ? "first" : "second");
}


Measured memory_bytes: 3784
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		sc.close();

		int n = x / 99;
		for (int i = 1; i <= n; i++) {
			int a = x - 100 * i;
			if (0 <= a && a <= 5 * i) {
				System.out.println(1);
				return;
			}
		}
		System.out.println(0);
	}
}


Measured memory_bytes: 23636
N = int(input())
x = 9
order = 0
for i in range(16):
    if x > N:
        break
    x = x*10+9
    order = i+1
ans = x
for i in range(10):
    ans -= 10**order
    if  ans <= N:
        break
ret = 0
while True:
    if ans == 0:
        break
    ret += ans % 10
    ans = ans//10
print(ret)

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

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


void solve() {
   char wyn;
   cin>>wyn;
   if(wyn=='A') {
      cout<<'T';
      return ;
   }
   else if(wyn=='T') {
	      cout<<'A';
	      return;
	   }
     else if(wyn=='C') {
	      cout<<'G';
	      return;
	   }
	     else if(wyn=='G') {
	      cout<<'C';
	      return;
	   }	   
 	   
 
}


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

  return 0;
}


Measured memory_bytes: 256
local n = io.read("*n")
local t = {}
for i = 1, n do t[i] = i end
for i = 1, n do
  local a = io.read("*n")
  t[a] = i
end
local f = {}
for i = 1, n - 1 do
  f[i] = t[i] < t[i + 1]
end
f[n] = false
local len = 0
local mma = math.max
local mlen = 0
for i = 1, n do
  if f[i] then
    len = len + 1
  else
    mlen = mma(mlen, len)
    len = 0
  end
end
print(n - 1 - mlen)


Measured memory_bytes: 9072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

vector<ll>par(2e5+10);
map<ll,ll> si;
void init(ll n) {
  for(ll i=0;i<n;i++) {
    par[i]=i;
    si[i]++;
  }
}

ll root(ll x) {
  if(par[x]==x) {
    return x;
  }
  else {
    return par[x]=root(par[x]);
  }
}

ll size(ll x) {
  return si[root(x)];
}

bool same(ll x, ll y) {
  return root(x)==root(y);
}

void unite(ll x, ll y) {
  if(same(x,y)) return;
  ll temp=size(x);
  si[root(y)]+=temp;
  si[root(x)]=0;
  par[root(x)]=root(y);
}

int main() {
  ll n,m;
  cin >> n >> m;
  init(n);
  vector<pll> v(m);
  for(ll i=0;i<m;i++) {
    ll a,b;
    cin >> a >> b;
    v[m-1-i]=pll(a,b);
  }
  ll ans=n*(n-1)/2;
  vector<ll> out(m);
  for(ll i=0;i<m;i++) {
    out[m-1-i] =  ans;
    if(!same(v[i].first,v[i].second)) {
      ans-=size(v[i].first)*size(v[i].second);
      unite(v[i].first,v[i].second);
    }
  }
  for(ll i=0;i<m;i++) {
    cout << out[i] << endl;
  }
}

Measured memory_bytes: 13056
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

template <class... Args>
struct tuple_input_impl;
template <std::size_t i, std::size_t... tail>
struct tuple_input_impl<std::index_sequence<i, tail...>>
{
    template <class... Args>
    static void f(std::tuple<Args...>& x)
    {
        std::cin >> std::get<i>(x);
        tuple_input_impl<std::index_sequence<tail...>>::f(x);
    }
};
template <>
struct tuple_input_impl<std::index_sequence<>>
{
    static void f(...) {}
};

template <class... Args>
std::istream& operator>>(std::istream& in, std::tuple<Args...>& x)
{
    tuple_input_impl<std::index_sequence_for<Args...>>::f(x);
    return in;
}

template <class T>
T read()
{
    T res;
    std::cin >> res;
    return res;
}
template <class T>
std::vector<T> read(std::size_t n)
{
    std::vector<T> res(n);
    for (std::size_t i = 0; i < n; ++i) std::cin >> res[i];
    return res;
}

template <class T>
void out_impl(T&& v) { std::cout << std::forward<T>(v); }
template <class T, class... Args>
void out_impl(T&& v, Args&&... args)
{
    std::cout << std::forward<T>(v) << ' ';
    out_impl(std::forward<Args>(args)...);
}
template <class... Args>
void out(Args&&... args)
{
    out_impl(std::forward<Args>(args)...);
    std::cout << '\n';
}
template <class... Args>
void out_noreturn(Args&&... args) { out_impl(std::forward<Args>(args)...); }

template <class T>
void print(const T& container)
{
    bool first = true;
    for (auto&& x : container) {
        if (!first) std::cout << ' ';
        std::cout << x;
        first = false;
    }
    std::cout << '\n';
}

void prog()
{
    auto s = read<std::string>();
    int o = 0, i = 0;
    for (auto c : s) {
        if (c == '0')
            ++o;
        else
            ++i;
    }
    out(i + o - std::abs(i - o));
}

int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    prog();
    return 0;
}


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

using namespace std;

int ans, n, h[100];

int main(){
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> h[i];
	
	bool isremoved;
	while(true){
		isremoved = false;
		for(int i = 0; i < n; ++i){
			if(isremoved && h[i] == 0) break;
			if(h[i] > 0){
				isremoved = true;
				h[i]--;
			}
		}
		if(!isremoved) break;
		else ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

inline ll f(ll b, ll n) {
  ll ans = 0;
  while(n) {
    ans += n % b;
    n /= b;
  }
  return ans;
}

ll solve(ll n, ll s) {
  if (n < s) {
    return -1;
  }
  if (n == s) {
    return n + 1;
  }

  ll b = 2;
  for (; b * b <= n; ++b) {
    if (f(b, n) == s) return b;
  }

  for (ll p = b - 1; p >= 1; --p) {
    b = (n - s) / p + 1;
    if (b <= 1) continue;
    if (f(b, n) == s) return b;
  }
  return - 1;
}


int main(){
  ll n, s;
  cin >> n >> s;

  cout << solve(n, s) << endl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    for(auto& e : a){
        cin >> e;
        sum ^= e;
    }
    for(auto& e : a){
        cout << (sum ^ e) << endl;
    }
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; ++i) cin >> arr[i];
  int cont = 0;
  for (int i = 1; i < n-1; ++i) {
    if (arr[i] > min(arr[i-1], arr[i+1]) && arr[i] < max(arr[i-1], arr[i+1]) ) cont++;
  }
  cout << cont;
}

Measured memory_bytes: 256
NM=list(map(int,input().split()))
list1=[[0 for i in range(2)] for j in range(NM[0])]

for i in range(NM[0]):
 A=list(map(int,input().split()))
 list1[i]=A

list1.sort()
flag=NM[1]
i=0
count=0
while flag>0:
 if flag>list1[i][1]:
   count=count+list1[i][0]*list1[i][1]
   flag=flag-list1[i][1]
 else:
   count=count+list1[i][0]*flag
   flag=0
 i=i+1

print(count)

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

using namespace std;

#define INF 1001001001  //int32_t
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n;
    cin >>n;
    vector<ll> a(n),rsum(n);

    for (int i = 0; i < n; i++){
        cin >>a[i];
        sum += a[i];
    }

    rsum[0] = a[0];
    for (int i = 1; i < n; i++){
        rsum[i] = rsum[i-1] + a[i];
    }

    ll diff=LINF;
    for (int i = 0; i < n; i++){
        diff = min(diff,abs((rsum[i]) - (sum-rsum[i])));
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << diff << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 3456
import java.util.*;
class Main {
    static int[] w, v;
    static long[][] table;
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int W = sc.nextInt();
	w = new int[N+1];
	v = new int[N+1];
	table = new long[N+1][W+1];

	for(int i = 1; i<N+1; i++) {
	    w[i] = sc.nextInt();
	    v[i] = sc.nextInt();
	}

	for(int i = 1; i <= N; i++) {
	    for(int j = 0; j <= W; j++) {
		if(j < w[i]) {
		    table[i][j] = table[i-1][j];
		} else {
		    table[i][j] = Math.max(table[i-1][j], table[i-1][j-w[i]] + v[i]);
		}
	    }
	}

	long total = table[N][W];
	System.out.println(total);
    }
}

Measured memory_bytes: 127572
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	a = zeros(Int,3,3)
	for i in 1:3
		a[i,:] = readline() |> split |> parseMap
	end
	chk = zeros(Int,3,3)
	f = 0
	n = readline() |> parseInt
	for i in 1:n
		b = readline() |> parseInt
		for i in 1:3
			for j in 1:3
				if a[i,j] == b
					chk[i,j] = 1
				end
			end
		end
	end
	for i in 1:3
		if sum(chk[i,:])==3
			f = 1
		end
		if sum(chk[:,i])==3
			f = 1
		end
	end
	if chk[1,1]+chk[2,2]+chk[3,3]==3
		f = 1
	end
	if chk[3,1]+chk[2,2]+chk[1,3]==3
		f = 1
	end
	println(f==1?"Yes":"No")
end

main()

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

using namespace std;

int main()
{
  int n, a, b;
  scanf("%d %d %d", &n, &a, &b);
  if(a > b) swap(a, b);
  int sum = 0;
  for(int i = 1; i <= n; i++){
    int temp = i, su = 0;
    for(; temp > 0; temp /= 10) su += (temp % 10);
    if(su >= a && su <= b){
      sum += i;
    }
  }
  printf("%d\n", sum);
  
  return 0;
}

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

#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000000
#define ll long long
#define db double
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define all(v) v.begin(),v.end()
#define vll vector<ll>
#define vs vector<string>

#define mapll map<ll,ll>
#define mapss map<string,string>
#define mapsl map<string,ll>
#define mapls map<ll,string>

#define pll pair<ll,ll>
#define pss pair<string,string>
#define psl pair<ll,string>
#define pls pair<string,ll>

#define minheap priority_queue<ll>
#define maxheap priority_queue<ll,vector<ll> ,greater<ll>>

#define ff first
#define ss second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
const ll mod=1e9 + 7;


ll takemod(ll a) {
    return ((a%mod)+mod)%mod;
}

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

ll fast_exp(ll base, ll expo) {
    ll res=1;
    while(expo>0) {
        if(expo&1) res=(res*base)%mod;
        base=(base*base)%mod;
        expo>>=1;}
    return res;
}

ll modinv(ll a) {
    return takemod(fast_exp(takemod(a), mod-2));
}


signed main() 
{
    fast_cin();
    ll arr[5],k;
    For(i,0,5)
        cin>>arr[i];
    cin>>k;
    if(arr[4]-arr[0]>k)
        cout<<":("<<endl;
    else
        cout<<"Yay!"<<endl;
    return 0;    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define m3(a, b, c) min(c, min(a, b))
#define m4(a, b, c, d) min(d, min(c, min(a, b)))
#define test long long t; cin>>t; while(t--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const int maxn=1e6+100;


 int main()
 {
   int n;
   cin>>n;
   vector<vector<int>>a(n,vector<int>(3));
    vector<vector<int>>dp(n,vector<int>(3));
    
    for(int i=0;i<n;i++)
    for(int j=0;j<3;j++)
    cin>>a[i][j];
   
   dp[0]=a[0];
   
   for(int i=1;i<n;i++)
   for(int j=0;j<3;j++)
   for(int k=0;k<3;k++)
   {
       if(j!=k)
       {
           dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
       }
   }
  
   int ma=*max_element(dp[n-1].begin(),dp[n-1].end());
   cout<<ma;
 }

Measured memory_bytes: 14056
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    int a,b;
    cin >> a >> b;
    string s;
    cin >> s;
    s[b-1]=s[b-1]-'A'+'a';
    pr(s);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  v(string) history;
  rep(i,N) {
    string x;
    cin >> x;
    if(i > 0) {
      if(history.back().back() != x[0] || find(rng(history),x) != history.end()) {
        cout << "No" << endl;
        return 0;
      }
    }
    history.push_back(x);
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n, l;
  cin >> n >> l;
  int s = 0, m = 2e9;
  for (int i = 0; i < n; i++) {
    s += l + i;
    if (abs(m) > abs(l + i)) m = l + i;
  }
  cout << s - m << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

using namespace std;

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

    vector<int> A(n);

    for (int i = 0; i < n; i++) cin >> A[i];

    int prev = -1'000'000'001;

    for (int i = 0; i < n; i++) {
        if (A[i] != prev) {
            cout << (i == 0 ? "" : " ");
            cout << A[i];
            prev = A[i];
        }
    }
    cout << endl;
}


Measured memory_bytes: 3088
import os, sys, re, math

(N, M, C) = [int(n) for n in input().split()]
B = [int(n) for n in input().split()]
count = 0
for i in range(N):
    A = [int(n) for n in input().split()]
    s = sum([A[j] * B[j] for j in range(M)]) + C
    count += 1 if s > 0 else 0

print (count)


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

#define ll long long int
#define endl "\n"
#define mod 1000000007


int main()
{

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	{
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
#endif
	ll k;
	ll a, b;
	cin >> k;
	cin >> a >> b;
	bool flag = false;
	for (ll i = a; i <= b; i++) {
		if (i % k == 0) {
			flag = true;
			break;
		}
	}
	if (flag) {
		cout << "OK" << endl;
	} else {
		cout << "NG" << endl;
	}
	return 0;
}

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

using namespace std;

int main(int, char**) {
        int n;
        string s;
        cin >> n;
        n = n%10;
        if (n==3) {
                s = "bon";
        } else if (n==0 || n==1 || n==6 || n==8) {
                s = "pon";
        } else {
                s = "hon";
        }
        cout << s << endl;
        return 0;
}


Measured memory_bytes: 3624
#include <iostream>
    using namespace std;
     
    int main()
    {
      int n, i, s;
      s = 0;
      int answer = -1;
      cin >> n;
      int a[n];
      int b[n];
      for(i = 0; i < n; i++)
        {
          cin >> a[i];
        }
      while(s == 0)
        {
        for(i = 0; i < n; i++)
          {
            b[i] = a[i] / 2;
            if((b[i] * 2) != a[i])
              {
                s = 1;
              }
            a[i] = b[i];
          }
        answer = answer + 1;
      }
      cout << answer << endl;
      return 0;
    }

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    A, B, C, K = map(int, input().split())
    if A >= K:
        print(K)
    elif A < K <= A + B:
        print(A)
    else:
        rest = K - A - B
        print(A - rest)


if __name__ == "__main__":
    main()


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

bool f(const pair<int,int>&x, const pair<int,int>&y){
    return x.second < y.second;
}

int main(){
    int n,m; cin >> n >> m;
    vector<pair<int,int> > ab(m);
    for(int i=0;i<m;i++){
        int a,b; cin >> a >> b;
        ab[i] = make_pair(a,b);
    }
    vector<bool> c(m,false);
    int res = 1;
    sort(ab.begin(),ab.end(),f);
    int left = ab[0].second;
    for(int i=1;i<m;i++){
        if(left <= ab[i].first){
            res ++;
            left = ab[i].second;
        }
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

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

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int H, W, h, w;
	cin >> H >> W >> h >> w;

	cout << (H - h) * (W - w) << endl;
	return 0;
}


Measured memory_bytes: 256
from math import sqrt, ceil


def digit_num(n: int)->int:
    ret = 0
    while n > 0:
        ret += 1
        n //= 10
    return ret


def F(A: int, B: int)->int:
    return digit_num(max(A, B))


def digits_in_multiplication(N: int)->int:
    sq = ceil(sqrt(N))

    for n in range(sq, 0, -1):
        if N % n == 0:
            return F(N//n, n)
    return F(N, 1)


if __name__ == "__main__":
    N = int(input())
    ans = digits_in_multiplication(N)
    print(ans)


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

#define x first
#define y second
#define pb push_back
#define mp make_pair

#define all(a) (a).begin(), (a).end()
#define sz(a) (int) (a).size()

#define int long long

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = sz(s);
    vector<int> l(n);
    l[0] = 1;
    for (int i=1; i<n; i++) {
        l[i] = (s[i] == s[i-1] ? l[i-1]+1 : 1);
    }
    vector<int> r(n);
    r[n-1] = 1;
    for (int i=n-2;i>-1;i--) {
        r[i] = (s[i] == s[i+1] ? r[i+1]+1 : 1);
    }
    int ans = 0;
    if (s[0] == '>') {
        ans += r[0];
    }
    if (s[n-1] == '<') {
        ans += l[n-1];
    }
    for (int i=1; i<n; i++) {
        int mx = 0;
        if (s[i-1] == '<') {
            mx = max(mx, l[i-1]);
        }
        if (s[i] == '>') {
            mx = max(mx, r[i]);
        }
        ans += mx;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 8732
import java.util.Scanner;

public class Main {
	Scanner scan;
	int n;
	int m;

	int[] a;
	int[] b;

	boolean[] judge;
	int count;
	boolean[][] connect;

	public static void main(String args[]){
		new Main().compute();
	}
	void compute() {
		scan=new Scanner(System.in);

		n=scan.nextInt();
		m=scan.nextInt();

		a=new int[m];
		b=new int[m];

		for(int i=0;i<m;i++) {
			a[i]=scan.nextInt();
			b[i]=scan.nextInt();
		}
		judge=new boolean[n];
		count=0;
		connect=new boolean[n][n];


		for(int i=0;i<m;i++) {
			connect[a[i]-1][b[i]-1]=true;
			connect[b[i]-1][a[i]-1]=true;
		}

		for(int i=0;i<m;i++) {
			for(int j=0;j<n;j++) {
				judge[j]=false;
			}
			connect[a[i]-1][b[i]-1]=false;
			connect[b[i]-1][a[i]-1]=false;
			dfs(0);
			connect[a[i]-1][b[i]-1]=true;
			connect[b[i]-1][a[i]-1]=true;
			for(int j=0;j<n;j++) {
				if(!judge[j]) {
					count++;
					break;
				}
			}
		}
		System.out.println(count);
	}
	void dfs(int x) {
		judge[x]=true;
		for(int i=0;i<n;i++) {
			if((connect[x][i])&&(!judge[i])) {
				dfs(i);
			}
		}
	}
}


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

public class Main {
  private static int solve(int n, int k, int[] xs) {
    int answer = 0;
    for (int x : xs) {
      answer += 2 * Math.min(x, k - x);
    }
    return answer;
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    int k = reader.nextInt();
    int[] xs = reader.nextInt(n);
    out.println(solve(n, k, xs));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 21204
#include "bits/stdc++.h"
using namespace std;

using ll = long long;

int main(int argc, char const *argv[])
{
  ll d, s, t;
  scanf("%lld %lld %lld", &d, &s, &t);
  if(s * t >= d){
    printf("Yes\n");
  }else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 3680
#include <stdio.h>
#include <string.h>
int main(void){
    char s[100];
    scanf("%s",s);
    int n;
    if(strlen(s)%2==1) n=strlen(s)/2+1;
    else n=strlen(s);
    for(int i=0;i<strlen(s)/2;i++){
        if(s[i]!=s[strlen(s)-i-1] || s[i]!=s[n+i]){
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 128
s = input()
for i in range(1,len(s)):
    if s[i] == s[i-1]:
        print(i, i+1)
        exit()

for i in range(2,len(s)):
    if s[i]==s[i-2]:
        print(i-1, i+1)
        exit()

print("-1 -1")


Measured memory_bytes: 3188
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func small(N, X, M int) {
	a := X
	ans := X
	for i := 2; i <= N; i++ {
		a *= a
		a %= M
		ans += a
	}
	out(ans)
}

type countMod struct {
	mod int
	m   []int
	pat []int
	sum int
}

func newCounter(n, mod int) *countMod {
	var ret countMod
	ret.mod = mod
	ret.m = make([]int, mod)
	ret.pat = make([]int, 0)
	ret.sum = 0
	return &ret
}

func (c *countMod) append(v, N int) (int, bool) {
	// a := v % c.mod
	a := v
	if c.m[a] == 0 {
		c.m[a]++
		c.pat = append(c.pat, a)
		c.sum += a
		if len(c.pat) == N {
			return c.sum, true
		}
		return c.sum, false
	}
	start := 0
	ret := 0
	tot := c.sum
	for i := 0; i < len(c.pat); i++ {
		if c.pat[i] == a {
			start = i
			break
		}
		ret += c.pat[i]
		tot -= c.pat[i]
	}
	N -= start
	loop := len(c.pat) - start
	n := N / loop
	ret += n * tot
	rest := N % loop
	for i := 0; i < rest; i++ {
		ret += c.pat[start+i]
	}
	return ret, true
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N, X, M := getInt(), getInt(), getInt()

	c := newCounter(N, M)
	for {
		sum, flg := c.append(X, N)
		// out(sum, flg, X, N)
		if flg {
			out(sum)
			return
		}
		X *= X
		X %= M
	}

}


Measured memory_bytes: 4928
#include<bits/stdc++.h>
#define int long long

using namespace std;

int dp[1005][1005];

signed main(){
    int q=1;
    // cin>>q;
    while(q--){
        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++) cin>>a[i];
        sort(a,a+n);
        reverse(a,a+n);
        if(n == 0 || n==1){
            cout<<0;
            return 0;
        }
        if(n==2){
            cout<<a[0];
            return 0;
        }   
        int ans = a[0];
        for(int i=2;i<n;i++){
            ans += a[i/2];
        }
        cout<<ans;
    }
}

Measured memory_bytes: 5164
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    string s; cin >> s;
    if(n % 2 == 0){
        n /= 2;
        bool judge = true;
        REP(i, n) if(s[i] != s[i + n]) judge = false; 
        if(judge) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	ll k, a, b;
	cin >> k >> a >> b;
	if (a+1 >= b) cout << k + 1 << endl;
	else cout << b*((k-a+1)/2) - a*((k-a+1)/2-1) + (k-a+1)%2 << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

// Testimony x:person, y:is honest
type Testimony struct {
	x int
	y int
}

func makePattern(n, t int) []int {
	pattern := make([]int, n)
	for i := 0; i < n; i++ {
		pattern[i] = t & 1
		t = t >> 1
	}
	return pattern
}

func validate(n int, a, pattern []int, testimonies [][]Testimony) bool {
	for i := 0; i < n; i++ {
		if pattern[i] == 0 {
			continue
		}

		t := testimonies[i]
		for j := 0; j < a[i]; j++ {
			if t[j].y != pattern[t[j].x] {
				return false
			}
		}
	}
	return true
}

func main() {
	n, _ := strconv.Atoi(input())
	a := make([]int, n)
	testimonies := make([][]Testimony, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(input())
		t := make([]Testimony, a[i])
		for j := 0; j < a[i]; j++ {
			x, _ := strconv.Atoi(input())
			y, _ := strconv.Atoi(input())
			t[j] = Testimony{x - 1, y}
		}
		testimonies[i] = t
	}

	ans := 0
	patternNum := 1 << uint(n)
	for i := 1; i < patternNum; i++ {
		pattern := makePattern(n, i)
		if validate(n, a, pattern, testimonies) {
			sum := 0
			for j := 0; j < n; j++ {
				sum += pattern[j]
			}
			ans = max(ans, sum)
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

typedef long long ll;

int main() {
  ll n, k;
  cin >> n;
  cin >> k;

  vector< pair<int, ll> > v;
  for (int i = 0; i < n; i++) {
    pair<int, ll> p;
    cin >> p.first, cin >> p.second;
    v.push_back(p);
  }

  sort(v.begin(), v.end());

  ll start = 0;
  for (int i = 0; i < n; i++) {
    ll end = start + v[i].second;
    if (start <= k - 1 && k - 1 < end) {
      // cout << start << endl;
      // cout << end << endl;
      cout << v[i].first << endl;
      return 0;
    }

    start = end;
  }

  return 0;
}

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

bool primeNumber(int n){
    if(n < 2) return false;
    else{
        for(int i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}

int main() {
  int X;
  cin >> X;
  int res;
  for (int i = X; ; ++i) {
    if(primeNumber(i)) {
      res = i;
      break;
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    ll u;
    ll ans = 0;
    rep(i, n) {
        ll a;
        cin >> a;
        if(i == 0) {
            ans += a-1;
            u = 2;
            continue;
        }
        if(a == u) {
            u++;
        }
        else if(a > u) {
            ans += (a-1)/u;
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int a=n/10;
    int b = n - a*10;
    if (a==9 || b==9){
        std::cout << "Yes";
        return 0;
    }
    std::cout << "No";

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [0] * (n + 1)

for i in range(1, n+1):
    a[i] = int(input())

cnt = 0
light = 1
push = [0] * (n+1)

for i in range(1, len(a) + 1):
    if push[light] == 0:
        push[light] = 1
        light = a[light]
        cnt += 1
        if light == 2:
            print(cnt)
            exit()
    else:
        print(-1)
        exit()


Measured memory_bytes: 13468
package main

import "fmt"

func main() {
	var m, d, sum int
	fmt.Scan(&m, &d)
	for i := 1; i <= m; i++ {
		for j := 1; j <= d; j++ {
			if 2 <= j/10 && 2 <= j%10 && i == j/10*(j%10) {
				sum++
			}
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = []
i = 0
B.append(1)
for n in range(N):
  B.append(A[i])
  i = A[i]-1
if K>N:
  start = 0
  num = 0
  for j in range(len(B)):
    if B[len(B)-1] == B[j]:
      start = j
      break
  for j in range(1,len(B)-start):
    if B[start+j] == B[start]:
      num = j
      break
  print(B[((K-start)%num)+start])
else:
  print(B[K])

Measured memory_bytes: 32380
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (A <= C && C <= B) cout << min(B, D) - C << endl;
	else if (C <= A && A <= D) cout << min(B, D) - A << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define WHITE 0
#define GRAY 1
#define BLACK 2

void dfs(void);
void visit(int);

int n, A[101][101], color[101], d[101], f[101], t = 0;

int main(){
  int u, k, v, i, j;
  
  scanf("%d", &n);

  for(i = 1; i <= n; i++){
    color[i] = WHITE;
    for(j = 1; j <= n; j++){
      A[i][j] = 0;
    }
  }

  for(i = 1; i <= n; i++){
    scanf("%d%d", &u, &k);
    for(j = 1; j <= k; j++){
      scanf("%d", &v);
      A[u][v] = 1;
    }
  }

  dfs();

  for(i = 1; i <= n; i++) printf("%d %d %d\n", i, d[i], f[i]);
  
  return 0;
}

void dfs(void){
  int u;

  for(u = 1; u <= n; u++) if(color[u] == WHITE) visit(u);
}

void visit(int u){
  int v;
  
  color[u] = GRAY;
  d[u] = ++t;

  for(v = 1; v <= n; v++) if(color[v] == WHITE && A[u][v] == 1) visit(v);
  
  color[u] = BLACK;
  f[u] = ++t;
}

Measured memory_bytes: 640
n=int(input())
chr=[]
dig=[]
Snumber,Hnumber,Cnumber,Dnumber=[],[],[],[]
a,b,c,d=[1,2,3,4,5,6,7,8,9,10,11,12,13],[1,2,3,4,5,6,7,8,9,10,11,12,13],[1,2,3,4,5,6,7,8,9,10,11,12,13],[1,2,3,4,5,6,7,8,9,10,11,12,13]
S_s,H_s,C_s,D_s=[],[],[],[]
for l in range(n):
   card=list(map(str,input().split(" ")))
   chr.append(card[0])
   dig.append(card[1])
for l in range(n):
    if chr[l]=='S':
        Snumber.append(dig[l])
    elif  chr[l]=='H':
        Hnumber.append(dig[l])
    elif chr[l]=='C':
        Cnumber.append(dig[l])
    else:
        Dnumber.append(dig[l])
s=list(map(int,Snumber))
s.sort()
h=list(map(int,Hnumber))
h.sort()
c2=list(map(int,Cnumber))
c2.sort()
d2=list(map(int,Dnumber))
d2.sort()
k=0           
for i in range(len(Snumber[:])):
    n=int(i)
    m=int(s[n])-1
    del a[m-k]
    k=k+1
k=0           
for i in range(len(Hnumber[:])):
    n=int(i)
    m=int(h[n])-1
    del b[m-k]
    k=k+1
k=0           
for i in range(len(Cnumber[:])):
    n=int(i)
    m=int(c2[n])-1
    del c[m-k]
    k=k+1
k=0           
for i in range(len(Dnumber[:])):
    n=int(i)
    m=int(d2[n])-1
    del d[m-k]
    k=k+1

for i in range(len(a)):
    print('S '+str(a[i]))
for i in range(len(b)):
    print('H '+str(b[i]))
for i in range(len(c)):
    print('C '+str(c[i]))
for i in range(len(d)):
    print('D '+str(d[i]))


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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

typedef pair<ll, ll> P;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, m, nmax = 8;
int graph[8][8] = {0};

int dfs(int now, bool* visited) {
    bool all_visited = true;
    for (int i = 0; i < n; i++) {
        if (!visited[i]) all_visited = false;
    }

    if (all_visited) return 1;

    int ret = 0;

    for (int i = 0; i < n; i++) {
        if (!visited[i] and graph[now][i]) {
            visited[i] = true;
            ret += dfs(i, visited);
            visited[i] = false;
        }
    }
    return ret;
}


int main()
{
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        graph[a-1][b-1] = graph[b-1][a-1] = 1;
    }

    bool visited[n] = {false};
    visited[0] = true;

    cout << dfs(0, visited) << endl;

    return 0;
}



Measured memory_bytes: 256