akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll occur[26];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    string t;
    cin>>s;
    cin>>t;
    vector<ll>alpha[26];
    for(ll i=0;i<s.length();i++)
    {
        occur[s[i]-'a']=1;
        alpha[s[i]-'a'].push_back(i);
    }
    ll flag=1;
    for(ll i=0;i<t.length();i++)
    {
        if(occur[t[i]-'a']==0)
        {
            flag=0;
        }
    }
    if(flag==0)
    {
        cout<<"-1";
        return 0;
    }
    ll ans=-1;
    ll count=0;
    for(ll i=0;i<t.size();i++)
    {
        auto it=upper_bound((alpha[t[i]-'a']).begin(),(alpha[t[i]-'a']).end(),ans);
        if(it==(alpha[t[i]-'a']).end())
        {
            count++;
            ans=*(alpha[t[i]-'a'].begin());
        }
        else
        {
            ans=*it;
        }
    }
    cout<<ans+1+count*s.length();
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int x = 0;
  REP(_,100000){
    x += a;
    if(x%b==c){
      puts("YES");return 0;
    }
  }
  puts("NO");
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func sum(a []int) int {
	ret := 0
	for _, v := range a {
		ret += v
	}
	return ret
}

func main() {
	a := make([]int, 3)
	for i := range a {
		fmt.Scan(&a[i])
	}
	if sum(a) >= 22 {
		fmt.Println("bust")
	} else {
		fmt.Println("win")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
using namespace std;
template <class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template <class T> bool chmin(T &a, const T &b) {if (b<a) {a = b; return 1;} return 0;}
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main() {
    double a,b;
    cin >> a >> b;
    cout << ceil((b-1)/(a-1)) << "\n";
}


Measured memory_bytes: 256
<?php

$S = str_split(trim(fgets(STDIN)));
$T = str_split(trim(fgets(STDIN)));

$collect_count = 0;
for ($i = 0; $i < count($S); ++$i) {
    if ($S[$i] == $T[$i]) {
        ++$collect_count;
    }
}

echo $collect_count, "\n";


Measured memory_bytes: 4728
#include <iostream>
#include <math.h>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)

int n;
int a, b, c;
int l[10];

int calccost(int bits, int goal) {
    int num = 0;
    int sum = 0;
    int one = 1;
    REP(i, n) {
        int check = bits&one;
        if (check != 0) {
            num ++;
            sum += l[i];
        }
        one = one<<1;
    }

    return 10*(num-1) + abs(sum-goal);
}

int main() {
    cin >> n >> a >> b >> c;

    REP(i, n) {
        cin >> l[i];
    }

    int output = 1000000000;
    int mx = pow(2, n);
    int check;
    for(int i=1; i<mx; i++) {
        for(int j=1; j<mx; j++) {
            check = i&j;
            if (check != 0) continue;
            for(int k=1; k<mx; k++) {
                check = j&k;
                if (check != 0) continue;
                check = k&i;
                if (check != 0) continue;
                
                int cost = 0;
                cost += calccost(i, a);
                cost += calccost(j, b);
                cost += calccost(k, c);
                output = min(cost, output);
            }
        }
    }
    cout << output << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
using namespace std;



int main(){
	int a,b,c,p,sum;
	while( scanf("%d %d %d",&a,&b,&c) != EOF){
		sum = a+b;
		p=0;
		for(int i=1;i<=10;i++){
			if(i!=a && i!=b && i!=c){
				if(sum+i<=20){
					p++;
				}
			}
		}
		if(p>=3.5) printf("YES\n");
		else printf("NO\n");
	}
			
	return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
int dp[3010][3010] = {0};
int main(){
    string s,t; cin >> s >> t;
    for(int i=0;i<s.size();++i){
        for(int j=0;j<t.size();++j){
            if(s[i] == t[j]) chmax(dp[i+1][j+1],dp[i][j] + 1);
            chmax(dp[i+1][j+1],dp[i][j+1]);
            chmax(dp[i+1][j+1],dp[i+1][j]);
        }
    }
    string res = "";
    int i = (int)s.size(), j = (int)t.size();
    while(i>0 && j>0){
        if(dp[i][j] == dp[i][j-1]){
            --j;
        } 
        else if(dp[i][j] == dp[i-1][j]){
            --i;
        }
        else {
            res = s[i-1] + res;
             --i; --j;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 35584
N, M = map(int, input().split())
l = [False]*N
for _ in range(M):
    a = list(map(int, input().split()))
    j = [1,N]
    for i in [0,1]:
        if a[i] == j[i]:
            if l[a[1-i]-1]:
                print('POSSIBLE')
                exit()
            else:
                l[a[1-i]-1] = True
print('IMPOSSIBLE')


Measured memory_bytes: 70508
#include <stack>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int a[n]; for (int i = 0; i < n; i++) cin >> a[i];
    int L[n], R[n];
    L[0] = -1; R[n-1] = n;
    stack<int> s;
    s.push(0);
    for (int i = 1; i < n; i++) {
        while (!s.empty() && a[s.top()] > a[i]) s.pop();
        L[i] = (s.empty() ? -1 : s.top());
        s.push(i);
    }
    s = stack<int>();
    s.push(n-1);
    for (int i = n-2; i >= 0; i--) {
        while (!s.empty() && a[s.top()] > a[i]) s.pop();
        R[i] = (s.empty() ? n : s.top());
        s.push(i);
    }
    long long ans = 0;
    for (int i = 0; i < n; i++)
        ans += (long long)a[i] * (R[i] - i) * (i - L[i]);
    cout << ans << endl;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
 
using namespace std;
 
#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL); cout.tie(NULL);}
#define f first
#define s second
#define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
typedef long long ll;
typedef long double lld;
typedef unsigned long long ull;
 
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
	cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
	cin >> p.first;
	return cin >> p.second;
}
 
mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(61378913);
/* usage - just do rng() */
 
void usaco(string filename) {
  // #pragma message("be careful, freopen may be wrong")
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}
 
const lld pi = 3.14159265358979323846;
const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;
 
namespace modop {
	ll madd(ll a, ll b) {
	  return (a + b) % mod;
	}
	ll msub(ll a, ll b) {
	  return (((a - b) % mod) + mod) % mod;
	}
	ll mmul(ll a, ll b) {
	  return ((a % mod) * (b % mod)) % mod;
	}
	ll mpow(ll base, ll exp) {
	  ll res = 1;
	  while (exp) {
		if (exp % 2 == 1){
			res = (res * base) % mod;
		}
		exp >>= 1;
		base = (base * base) % mod;
	  }
	  return res;
	}
	ll minv(ll base) {
	  return mpow(base, mod - 2);
	}
	ll mdiv(ll a, ll b) {
	  return mmul(a, minv(b));
	}
}

using namespace modop;
 
ll n, m, k, q, l, r, x, y, z;
const ll template_array_size = 1e6 + 1389;
ll a[template_array_size];
ll b[template_array_size];
ll c[template_array_size];
string s, t;
ll ans = 0;
 
ll fact[1000005], ifact[1000005];

ll nck(ll n, ll k) {
	ll dem = (ifact[n - k] * ifact[k]) % mod;
	return (fact[n] * dem) % mod;
}
 
void solve(int tc = 0) {
	cin >> n;
	
	fact[0] = fact[1] = ifact[0] = ifact[1] = 1;
	for (ll i = 2; i <= n; i++) {
		fact[i] = (i * fact[i - 1]) % mod;
		ifact[i] = minv(fact[i]);
	}
	
	ll ans = 0;
	
	for (ll n9 = 1; n9 <= n; n9++) {
		ll pos9 = nck(n, n9);
		ll tot = mpow(9, n - n9);
		ll invalid = mpow(8, n - n9);
		ans = (ans + pos9 * (tot - invalid)) % mod;
		ans = (ans + mod) % mod;
	}
	
	cout << ans << '\n';
}
 
int main() {
	#ifdef galen_colin_local
		auto begin = std::chrono::high_resolution_clock::now();
	#endif
	
	send help
 
	#ifndef galen_colin_local
		// usaco("moop");
	#endif
	
	// usaco("cowland");
	
	// freopen("tc.cpp", "r", stdin);
 
	int tc = 1;
	// cin >> tc;
	for (int t = 0; t < tc; t++) solve(t);
	
	#ifdef galen_colin_local
		auto end = std::chrono::high_resolution_clock::now();
		cout << setprecision(4) << fixed;
		// cout << "Execution time: " << std::chrono::duration_cast<std::chrono::duration<double>>(end - begin).count() << " seconds" << endl;
	#endif
} 

Measured memory_bytes: 19252
/*
C++14
iloveUtaha
seica
fumiphys
autumn_eel
FF256grhy


Python3 (3.4.3)
maspy

PyPy3 (2.4.0)
blcn
*/

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n, i;
  cin >> n >> i;
  cout << n - i + 1 << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int s,t;
  cin>>s>>t;
  cout<<(s+t+1)/2<<endl;
}

Measured memory_bytes: 256
/*
 * short          2^15-1 ~ 3e4
 * int, long x86  2^31-1 ~ 2e9
 * long long      2^63-1 ~ 9e18
 */
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define fr(a, b) for (int a = 0; a < b; ++a)
using namespace std; typedef long long ll; const int inf = numeric_limits<int>::max(); void print() {cerr << endl;}
template<typename T, typename... Ts> void print(T&&a, Ts&&...etc) {cerr << a << ' '; print(etc...);}
template<typename T, typename U> ostream& operator<<(ostream& s, const pair<T,U>&p) {s << "<" << p.x << ", " << p.y << ">"; return s;} // ver. 2020-02-17
template<typename T> ostream& operator<<(ostream& s, const vector<T>&v) {s << "["; for (auto &x : v) s << x << ", "; if (!v.empty()) s << "\b\b"; s << "]"; return s;}
struct io{io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}}io;

int main() {
    string s;
    cin >> s;
    int t, f, wtf;
    cin >> t;
    char c;
    vector<char> beg;
    vector<char> end;
    int rev = 0;
    while (t--) {
        cin >> wtf;
        if (wtf == 2) {
            cin >> f >> c;
            if (rev) {
                if (f == 1) {
                    end.pb(c);
                } else {
                    beg.pb(c);
                }
            } else {
                if (f == 1) {
                    beg.pb(c);
                } else {
                    end.pb(c);
                }
            }
        } else {
            rev = (1 - rev);
        }
    }
    if (rev) {
        for (int i = end.size()-1; i >= 0; --i) {
            cout << end[i];
        }
        reverse(s.begin(), s.end());
        cout << s;
        for (char c : beg) {
            cout << c;
        }
    } else {
        for (int i = beg.size()-1; i >= 0; --i) {
            cout << beg[i];
        }
        cout << s;
        for (char c : end) {
            cout << c;
        }
    }
    return 0;
}


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

typedef long long ll;

const ll kMod = 924844033;
const int kN = 2e3 + 5;

int n, k; ll f[kN << 1][kN][2], fac[kN];
bool bk[kN << 1];

int main() {
	scanf("%d%d", &n, &k);
	fac[0] = 1;
	for(int i = 1; i <= n; ++i) fac[i] = fac[i - 1] * i % kMod;
	for(int i = 0, cnt = 1; i < k; ++i) {
		bk[cnt += (n - i - 1) / k + 1] = true;
		bk[cnt += (n - i - 1) / k + 1] = true;
	}
	for(int i = 1; i <= n << 1; ++i) {
		f[i][0][0] = 1;
		for(int j = 1; j <= n; ++j) {
			f[i][j][0] = (f[i - 1][j][0] + f[i - 1][j][1]) % kMod;
			if(!bk[i]) f[i][j][1] = f[i - 1][j - 1][0];
		}
	}
	ll ans = 0, tmp = kMod - 1;
	for(int i = 1; i <= n; ++i) {
		ans = (ans + (f[n << 1][i][0] + f[n << 1][i][1]) % kMod * tmp % kMod * fac[n - i] % kMod) % kMod;
		tmp = tmp * (kMod - 1) % kMod;
	}
	printf("%lld", (fac[n] + ans) % kMod);
	return 0;
}

Measured memory_bytes: 125568
import sys
input = sys.stdin.readline

def find_ok( x , Oks ):
    for i in Oks:
        if int(i) > int(x):
            break
    return i

def main():
    n,k = map( int , input().split() )
    Nos = set(map( int , input().split() ))
    while(1):
        x = str(n)
        set_n= set()
        for digit in x:
            set_n.add( int(digit) )
        if len(set_n & Nos) == 0:
            break
        n += 1
    print(n)



main()

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, A;
    cin >> N >> A;
    vector<ll> x(N);
    REP(i, N) cin >> x[i];
    REP(i, N) x[i] -=  A;

    ll dp[55][6000];
    REP(i, 55)REP(j, 6000) dp[i][j] = 0;
    dp[0][3000] = 1;
    REP(i, N){
    	REP(j, 6000){
    		dp[i+1][j] += dp[i][j];
    		dp[i+1][j+x[i]] += dp[i][j];
    	}
    }
    cout << dp[N][3000] - 1 << endl;
    return 0;
}

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

long long pi[5][233333];

bool bj(long long a,long long b)
{
	return a>b;
}

int main()
{
	int x,y,a,b,c; scanf("%d%d%d%d%d",&x,&y,&a,&b,&c);
	for(int i=1; i<=a; i++) scanf("%lld",&pi[0][i]);
	for(int i=1; i<=b; i++) scanf("%lld",&pi[1][i]);
	for(int i=1; i<=c; i++) scanf("%lld",&pi[2][i]);
	sort(pi[0]+1,pi[0]+1+a,bj);
	sort(pi[1]+1,pi[1]+1+b,bj);
	sort(pi[2]+1,pi[2]+1+c,bj);
	for(int i=1; i<=x; i++) pi[3][i]=pi[0][i];
	for(int i=1; i<=y; i++) pi[3][i+x]=pi[1][i];
	sort(pi[3]+1,pi[3]+1+x+y,bj);
	for(int i=1; i<=c; i++) pi[2][i]+=pi[2][i-1];
	for(int i=1; i<=x+y; i++) pi[3][i]+=pi[3][i-1];
	long long sum=0;
	for(int i=0; i<=x+y; i++) sum=max(sum,pi[2][i]+pi[3][x+y-i]);
	printf("%lld",sum);
	return 0;
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(abs(a-c) <= d){
		puts("Yes");
	}else{
		if(abs(a-b) <= d && abs(b-c) <= d) puts("Yes");
		else puts("No");
	}
	return 0;
}

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

using std::cin;
using std::cout;
using std::endl;
using std::vector;

int main() {
  int64_t max = 1e+18;

  int N;
  cin >> N;

  vector<int64_t> nums(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> nums[i];
    if (nums[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  int64_t ans = 1;
  for (int i = 1; i <= N; i++) {
    if (max / nums[i] < ans) {
      ans = -1;
      break;
    } else {
      ans *= nums[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 4044
N = int(input())
res = 0
for i in range(1,N+1):
    div_cnt = 0
    for j in range(1,i+1):
        if i%j == 0:
            div_cnt += 1
    if div_cnt == 8 and i%2 == 1:
        res += 1
print(res)

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

using namespace std;

int main() {
  int D;
  cin >> D;
  if (D == 25) {
    cout << "Christmas" << endl;
  } else if (D == 24) {
    cout << "Christmas Eve" << endl;
  } else if (D == 23) {
    cout << "Christmas Eve Eve" << endl;
  } else {
    cout << "Christmas Eve Eve Eve" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SZ(a) (int)(a.size())
#define PB push_back
#define LL long long
const int mod = 1000 * 1000 * 1000 + 7;
int add(int a , int b)
{
	return a + b >= mod ? a + b - mod : a + b;
}
int sub(int a , int b)
{
	return a - b < 0 ? a - b + mod : a - b;
}
int mult(int a , int b)
{
	return a * (LL)b % mod;
}
int dp[105][100000];
int main()
{
    //getFacts();
	int N , K;
	cin >> N >> K;
	vector<int> segs;
	for(int i = 1; i * i <= N; i++)
	{
		segs.PB(i);
		segs.PB(N / i);
	}
	
	sort(segs.begin() , segs.end());
	
	dp[0][0] = 1;
	for(int j = 0; j < K; j++)
	{
		int ptr = SZ(segs) - 1;
		for(int i = 0; i < SZ(segs); i++)
		{
			while(segs[ptr] * (LL)segs[i] > N)
			{
				assert(ptr);
				ptr--;
			}
			dp[j + 1][0] = add(dp[j + 1][0] , dp[j][i]);
			dp[j + 1][ptr + 1] = sub(dp[j + 1][ptr + 1] , dp[j][i]);
			
		}
		
		
		for(int i = 1; i < SZ(segs); i++)
			dp[j + 1][i] = add(dp[j + 1][i - 1] , dp[j + 1][i]);
		
		for(int i = 0; i < SZ(segs); i++)
		{
			int len = segs[i] - (i ? segs[i - 1] : 0);
			dp[j + 1][i] = mult(len , dp[j + 1][i]);
		}
		
	}
	
	int ans = 0;
	for(int i = 0; i < SZ(segs); i++)
		ans = add(ans , dp[K][i]);
	cout << ans;
    return 0;
}


Measured memory_bytes: 40572
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let n=read::<i32>();
    let m=read::<i32>();
    let c=read::<i32>();
    let b=(0..m).map(|_|read::<i32>()).collect::<Vec<i32>>();
    let mut ans=0;
    for _ in 0..n{
        let mut s=c;
        for i in 0..m{
            let a=read::<i32>();
            s+=a*b[i as usize];
        }
        if s>0{ans+=1}
    }
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s,t;
    cin>>s>>t;
    int s_size=s.size();
    int t_size=t.size();
    vector<vector<int> > dp(s_size+1,vector<int>(t_size+1,0));
    for(int i=1;i<=s_size;++i){
        for(int j=1;j<=t_size;++j){
            if(s[i-1]==t[j-1]){
                dp[i][j]=1+dp[i-1][j-1];
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    string lcs;
    int i=s_size,j=t_size;
    while(i>0 and j>0){
        if(s[i-1]==t[j-1]){
            lcs=s[i-1]+lcs;
            i--;
            j--;
        }
        else{
            if(dp[i-1][j]>=dp[i][j-1]){
                i=i-1;
            }
            else{
                j=j-1;
            }
        }
    }
    cout<<lcs;
    cout<<endl;
}


Measured memory_bytes: 38892
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        for (int i = b - a + 1; i <= a + b - 1; i++) {
            System.out.println(i);
        }
    }
}


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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    ll N, M;
    cin >> N >> M;

    vector<ll> A(M);
    vector<ll> B(M);
    FOR(i, 0, M){
        cin >> A[i] >> B[i];
    }

    sort(ALL(A));
    sort(ALL(B));

    ll diff = B[0] - A.back();
    if(diff<0){
        p(0);
    }else{
        p(diff+1);
    }
    
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    ll n;cin>>n;
    vl a(n);rep(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    vl sum(n+1);
    rep(i,n) sum[i+1]=sum[i]+a[i];
    ll ans=0;
    drep(i,n){
        if(sum[i]*2>=a[i]) ans++;
        else break;
    }
    ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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);
        B81 solver = new B81();
        solver.solve(1, in, out);
        out.close();
    }

    static class B81 {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] hash = new int[101];
            for (int i = 1; i <= 9; i++) {
                for (int j = 1; j <= 9; j++) {
                    hash[i * j]++;
                }
            }
            int n = in.nextInt();
            if (hash[n] > 0)
                out.println("Yes");
            else
                out.println("No");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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


int main(){
    Int N;
    cin >> N;
    map<Int,Int> f;
    Int sum = 0;
    rep(i,N) {
        Int A;
        cin >> A;
        f[A]++;
        sum += A;
    }
    Int Q;
    cin >> Q;
    rep(i,Q) {
        Int B, C;
        cin >> B >> C;
        sum += (C - B) * f[B];
        cout << sum << endl;
        f[C] += f[B];
        f[B] = 0;
    }


}

Measured memory_bytes: 9452
# AGC011A - Airport Bus
def main():
    N, C, K, *T = map(int, open(0).read().split())
    T.sort()
    ans, cur, cnt = 0, T[0] + K, 0
    for i in T:
        if i > cur or cnt == C:  # need a new bus
            cur = i + K
            cnt = 1
            ans += 1
        else:  # ride on the current one
            cnt += 1
    print(ans + 1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14052
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m,x;
    cin>>n>>m>>x;
    vector<int> c(n);
    int a[15][15];
    for(int i=0;i<n;i++){
        cin>>c[i];
        for(int j=0;j<m;j++)cin>>a[i][j];
    }
    int res=mod;
    for(int bit=0;bit<(1<<n);bit++){
        int sum=0;
        vector<int> u(15,0);
        for(int i=0;i<n;i++){
            if(bit&(1<<i)){
                sum+=c[i];
                for(int j=0;j<m;j++){
                    u[j]+=a[i][j];
                }
            }
        }
        bool ok=true;
        for(int j=0;j<m;j++){
            if(u[j]<x)ok=false;
        }
        if(ok)res=min(res,sum);
    }
    cout<<(res==mod?-1:res)<<endl;
}

Measured memory_bytes: 3668
inputs = [(input()) for i in range(2)]

num_char = int(inputs[0])
char_list = list(map(str, inputs[1].split()))

S = char_list[0]
T = char_list[1]
new_str = ""

for i in range(0,num_char):
  str = (S + T)[i::num_char]
  new_str += str

print(new_str)

Measured memory_bytes: 3064
#include<stdio.h>   
int main(void)
{
   int a, b, c;
   scanf("%d %d %d", &a, &b, &c);
   if( a < b ) {
     if( b < c ) {
       printf("Yes\n");
     } else {
       printf("No\n");
     }
   } else {
     printf("No\n");
   }
   return 0;
}

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

using namespace std;

struct expand_type {
    template <typename... T>
    expand_type (T&&...) {}
};
template <typename... ArgTypes>
void print (ArgTypes... args) {
    expand_type {0, (cerr << args << ", ", 0)...};
    cerr << "\b\b \n";
}
#define printv(x) cerr << "["; for(auto i : (x)) cerr << i << ", "; cerr << "\b\b]\n";

typedef unsigned long long ull;
typedef long double ld;


int main () {
    std::ios::sync_with_stdio (false);
    cin.tie (nullptr);
    cout.tie (nullptr);
    int n;
    cin >> n;
    unordered_set <string> rep;
    while (n--) {
        string foo;
        cin >> foo;
        rep.insert (foo);
    }
    cout << rep.size() << endl;
    return 0;
}


Measured memory_bytes: 17684
#include <iostream>
#include <map>

using namespace std;

int main(){
    map<int, int> mp;
    int N;
    int ans = 0;
    cin >> N;
    mp[-1] = 1;
    for(int i = 0; i < N; i++){
        int A;
        cin >> A;
        auto ptr = mp.lower_bound(A);
        ptr--;
        if(ptr->first == -1){
            //cout << i << endl;
            if(mp.count(A) != 0){
                mp[A]++;
            }else{
                mp[A]=1;
            }
            ans++;
        }else{
            int m = ptr->first;
            mp[m]--;
            if(mp[m] == 0){
                mp.erase(m);
            }
            if(mp.count(A) != 0){
                mp[A]++;
            }else{
                mp[A] = 1;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4864
#include<stdio.h>
#define N 36

typedef struct{
  char mark;
  int num;
}Trump;
  

int isStable(Trump*,Trump*,int);

int main(){
  Trump C[N],C2[N];
  char y;
  int n,i,j,minj,x,f=0;
 
  scanf("%d",&n);
  if(n<1 || n>36) return 0;
  
  for(i=0 ; i<n ; i++){
    scanf(" %c%d",&C[i].mark,&C[i].num);
    C2[i] = C[i];
   
  }

  
  /*BubbleSort*/
  for(i=0 ; i<=n-1 ; i++){
    for(j=n-1 ; j>=i+1 ; j--){
      if(C[j].num < C[j-1].num){
	x = C[j].num;
	C[j].num = C[j-1].num;
	C[j-1].num = x;
	y = C[j].mark;
	C[j].mark = C[j-1].mark;
	C[j-1].mark = y;		
      }
    }
  }
  
  for(i=0 ; i<n ; i++){
    if(i == n-1)  printf("%c%d\n",C[i].mark,C[i].num);
    else printf("%c%d ",C[i].mark,C[i].num);
  }
  printf("Stable\n");
  
  /*SelectionSort*/
  for(i=0 ; i<=n-1 ; i++){
    minj = i;
    for(j=i+1 ; j<=n-1 ; j++){
      if(C2[j].num < C2[minj].num){
	minj = j;
	f = 1;
      }
    }
    if(f == 1){
      x = C2[i].num;
	C2[i].num = C2[minj].num;
	C2[minj].num = x;
	y = C2[i].mark;
	C2[i].mark = C2[minj].mark;
	C2[minj].mark = y;
      
  }
    f = 0;
  }
    
  for(i=0 ; i<=n-1 ; i++){
    printf("%c%d",C2[i].mark,C2[i].num);
    if(i < n-1) printf(" ");
  }
  printf("\n");

  

for(i = 0; i < n; i++){
      if(C[i].mark == C2[i].mark) continue;
      else{
      f = 1;
      break;
    }
    }
  if(f == 0) printf("Stable\n");
  else printf("Not stable\n");

  
 
  
  return 0;
}






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

int main() {
  string  a, b, c;
  cin >> a >> b >> c;
  int i = a.size();
  int j = b.size();
  if(a.at(i - 1) == b.at(0) && b.at(j - 1) == c.at(0)){
    cout <<"YES" <<endl;
  }
  else{
    cout << "NO" <<endl;
  }
}


Measured memory_bytes: 256
/*
    LEARNING DP:    Knapsack 1
        + CHOSE some of the N items have VALUES
        + THE CAPACITY of the knapsack is W.
        + MAXIMUM VALUES.
    CONSTRAINT:
        + 1 <= N <= 100
        + 1 <= WEIGHT <= 100,000
        + 1 <= VALUE <= 10^9 * N
    QUESTION:
        WHICH WEIGHT? and WHICH ITEMS?
    IF WE KNOW:
        so if we know if it is exist a WEIGHT x = VALUES at x
        we will loop all N items and find the answer for
        WEIGHT at x + Wi = max(VALUES at x + Vi, VALUES at x + Wi)

        NOTICE: we have to go from heighest WEIGHT to lowest WEIGHT i think
        this is a trick in DP
    PRE DP:
        ALL WEIGHT are -1e11;
        WEIGHT at 0 = 0;
    TIME COMPLEXITY:
        O(N*W)
*/
#include <bits/stdc++.h>
using namespace std;

#define DB(_x)      cout << #_x << " is " << (_x) << "\n";
#define FOR(_a,_b)  for (_a = 0; _a < _b; ++_a)
#define fs          first
#define sc          second
//#define IOFILE

using LL = long long;
using LD = long double;
using VI = vector<int>;
using PI = pair<int,int>;

void Excalibur(){
    int n, w, i, j;
    LL limit = -1e11;
    while (cin >> n >> w){
        vector<PI> a(n);
        for (auto &x: a) cin >> x.fs >> x.sc;
        vector<LL> dp(w+1,limit);
        dp[0] = 0;
        FOR (i, n){
            for (j=w; j>=0; --j){
                if (j-a[i].fs >= 0 && dp[j-a[i].fs] != limit){
                    dp[j] = max(dp[j], dp[j-a[i].fs] + a[i].sc);
                }
            }
        }

        LL ans = 0;
        for (auto x: dp) ans = max(x,ans);
        cout << ans << "\n";
    }
}

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

#ifdef  IOFILE
    freopen("INPUT.in", "r", stdin);
    freopen("OUTPUT.out", "w", stdout);
#endif

Excalibur();
return 0;}


Measured memory_bytes: 1024
N=int(input())
if N==1:
    print(1)
else:

    a=[]

    for i in range(N):
        d=list(map(str,input().split()))
        d.append(i+1)
        a.append(d)

    a.sort(key=lambda x:x[0])

    for i in range(N):
        a[i][1]=int(a[i][1])


    k=0
    b=[]
    c=[]
    c.append(a[0])
    for i in range(N-1):
        if a[i][0]==a[i+1][0]:
            c.append(a[i+1])
        else:
            c.sort(key=lambda x:x[1])
            c.reverse()
            k=len(c)

            for j in range(k):
                b.append(c[j][2])
            c=[]
            c.append(a[i+1])

    k=len(c)
    c.sort(key=lambda x: x[1])
    c.reverse()
    for j in range(k):
        b.append(c[j][2])


    for i in range(N):
        print(b[i])

Measured memory_bytes: 3064
import java.util.Scanner;
 
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        int b[] = new int[n-1];
        int sum = 0;
        for(int i = 0 ; i < n-1;i++){
            b[i] = sc.nextInt();
        }
        sum += b[0] + b[n-2];
        for(int i = 1; i < n-1; i++){
            if(b[i] < b[i-1]){
                sum += b[i];
            }else{
                sum += b[i-1];
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include<string.h>
int main(){
  char S[4];
  char T[4];
  int i;
  int count = 0;
  scanf("%s",S);
  scanf("%s",T);
  for (i=0;i<=2;i++){
    if(S[i] == T[i]){
      count = count+1;
    }
  }
  printf("%d",count);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;

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

int main() {
    int A,B,C;
    string S,T;
    cin>>S>>T;
    cout<<T<<S<<endl;


    return 0;
}


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 03.01.2020 00:07:33       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long a, b;
  cin >> a >> b;
  while (a > 0 && __builtin_clzll(a) == __builtin_clzll(b)) {
    long long x = 1LL << (63 - __builtin_clzll(a));
    a ^= x;
    b ^= x;
  }
  if (b == 0) {
    cout << 1 << '\n';
    return 0;
  }
  long long x = 1LL << (63 - __builtin_clzll(b));
  long long y = x | (x == b ? 0 : (1LL << (63 - __builtin_clzll(b ^ x))) * 2 - 1);
  long long z = x + a;
  long long ans = (2 * x - 1) - a + 1;
  if (z > y) {
    ans -= z - y - 1;
  }
  cout << ans << '\n';
  return 0;
}


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

list_a = [int(input()) for _ in range(N)]
sorted_list_a = sorted(list_a)

largest = sorted_list_a[-1]
second_largest = sorted_list_a[-2]

for a in list_a:
    if a == largest:
        print(second_largest)
    else:
        print(largest)


Measured memory_bytes: 14112
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    int cnt = 0;
    for (int i = 0; i < N - 2; i++)
    {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C')
        {
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const ll MOD = 1e9 + 7;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")


int main() {

    ll n,ans = 0; cin >> n;
    vector<ll> a(n),m(n);

    rep(i,n){
        cin >> a[i];
        m[i] = (a[i]-(i+1));
    }
    sort(m.begin(),m.end());

    rep(i,n){
        ans += abs(a[i]-m[n/2]-(i+1));
    }
    cout << ans;

}


Measured memory_bytes: 6348
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  string s;
  cin >> s;
  if(s=="AAA"||s=="BBB") cout << "No" << endl;
  else cout << "Yes" << endl;
}

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T>
vector<vector<T> > make_v(size_t a,size_t b){
  return vector<vector<T> >(a,make_v<T>(b));
}
template<typename T>
vector<vector<vector<T> > > make_v(size_t a,size_t b,size_t c){
  return vector<vector<vector<T> > > (a,make_v<T>(b,c));
}

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 T1,typename T2> void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> void chmax(T1 &a,T2 b){if(a<b) a=b;}


//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> s(n);
  for(Int i=0;i<n;i++) cin>>s[i];
  
  s.emplace(s.begin(),0);
  partial_sum(s.begin(),s.end(),s.begin());

  const Int INF = 1e16;
  auto dp=make_v<Int>(n+1,n+1);
  fill_v(dp,INF);
  for(Int i=0;i<n;i++) dp[i][i+1]=0;
  
  auto K=make_v<Int>(n+1,n+1);
  fill_v(K,0);
  for(Int i=0;i<n;i++) K[i][i+1]=i;

  for(Int w=2;w<=n;w++){
    for(Int i=0,j;(j=i+w)<=n;i++){
      for(Int r=K[i][j-1];r<=K[i+1][j];r++){
	Int c=dp[i][r]+dp[r][j]+(s[j]-s[i]);
	if(dp[i][j]>c) dp[i][j]=c,K[i][j]=r;
      }
    }
  }
  
  cout<<dp[0][n]<<endl;
  return 0;
}



Measured memory_bytes: 253416
#include<bits/stdc++.h>
using namespace std;
long long k,a,b;
int main()
{
	cin>>k>>a>>b;
	long long sumbis=1,sumyen=0;
	for(int i=1;i<=k;i++){
		if(sumyen>=1){
			sumyen--;
			sumbis+=b;
		}
		else if(sumbis>=a&&i<k)
		{
			sumbis-=a;
			sumyen++;
		}
		else
			sumbis++;
	}
	cout<<max(sumbis,k+1)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
   int N,V[20],C[20],i,cost[20],sum=0;
   scanf("%d",&N);
   for(i=0;i<N;i++){
   scanf("%d",&V[i]);
   }
   for(i=0;i<N;i++){
   scanf("%d",&C[i]);
   cost[i]=V[i]-C[i];
   if(cost[i]>0)
   sum+=cost[i];
   } 
   
   printf("%d",sum); 
    return(0);
}


Measured memory_bytes: 128
n,m,l = map(int,input().split())
g = [[1<<30]*n for _ in range(n)]
for _ in range(m):
  a,b,c = map(int,input().split())
  g[a-1][b-1] = c
  g[b-1][a-1] = c
for i in range(n):
  g[i][i] = 0

def bell(g,n):
  for k in range(n):
    for i in range(n-1):
      for j in range(i+1,n):
        if g[i][j] > g[i][k] + g[k][j]:
          g[i][j] = g[i][k] + g[k][j]
          g[j][i] = g[i][j]
  return g

g = bell(g,n)
for i in range(n):
  for j in range(n):
    if i == j:
      g[i][j] = 0
    elif g[i][j] <= l:
      g[i][j] = 1
    else:
      g[i][j] = 1<<30
g = bell(g,n)

q = int(input())
for _ in range(q):
  s,t = map(int,input().split())
  if g[s-1][t-1]>>30:
    print(-1)
  else:
    print(g[s-1][t-1]-1)

Measured memory_bytes: 58200
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<array<int, 3> > rewards(n), f(n);
    for (auto& day : rewards)
        cin >> day[0] >> day[1] >> day[2];
    f[0] = rewards[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)
                    f[i][j] = max(f[i][j], f[i - 1][k] + rewards[i][j]);
    cout << *max_element(f.back().begin(), f.back().end());
    return 0;
}


Measured memory_bytes: 2560
import sys
h,w,m = map(int,input().split())
hight = [0]*h
width = [0]*w
S = set()

for i in range(m):
    hi,wi = map(int,input().split())
    S.add((hi-1,wi-1))
    hight[hi-1] += 1
    width[wi-1] += 1

max_vh = max(hight)
max_vw = max(width)

max_h = [i for i in range(h) if hight[i] == max_vh]
max_w = [i for i in range(w) if width[i] == max_vw]
for i in max_h:
    for j in max_w:
        if not(i,j) in S:
            print(max_vh+max_vw)
            sys.exit()

print(max_vh+max_vw-1)



Measured memory_bytes: 83500
ll = list(input())

for i in range(len(ll)-1):
    ll.insert(i*2+1,"")

for i in range(8):
    for j in range(3):
        ins = "+" if ((i>>j) &1) else "-"
        ll[j*2+1] = ins
    ans = "".join(ll)
    if eval("".join(ll))==7:
        print(ans+"=7")
        break

Measured memory_bytes: 3060
x1,y1,x2,y2=map(int,input().split())
vec=[x2-x1,y2-y1]

x3,y3=x2-vec[1],y2+vec[0]
x4,y4=x3-vec[0],y3-vec[1]

print(str(x3)+" "+str(y3)+" "+str(x4)+" "+str(y4))

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

using namespace std;
long long x[10000010], y[10000010];
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i < (n)i++)
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define int long long
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   int n, a, b;
   cin >> n >> a >> b;

   cout << min(a, b) << '\n';

   if (n < a + b)
      cout << a + b - n << '\n';
   else
      cout << 0 << '\n';
}

Measured memory_bytes: 256
void main() {
	auto N = ri;
	generate_prime_list(2000);
	auto res = prime_list.filter!(a => a.to!string[$-1] == '1').array;
	foreach(i; 0..N) {
		if(i != N-1)
			"%d ".writef(res[i]);
		else
			res[i].writeln;
	}
}

int[] prime_list;

void generate_prime_list(int N) {
	prime_list = [2];
	bool not_prime = false;
	foreach(i; 3..N+1) {
		foreach(j; prime_list) {
			if(i % j == 0) {
				not_prime = true;
				break;
			}
		}
		if(!not_prime) prime_list ~= i;
		not_prime = false;
	}
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

T[] deepcopy(T)(T[] a) {
	static if(isArray!T) {
		T[] res;
		foreach(i; a) {
			res ~= deepcopy(i);
		}
		return res;
	} else {
		return a.dup;
	}
}

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

int N,M,A[333][333];
const int INF=INT_MAX/2;

int solve(vector<int> ng){
  int cnt=0;
  rep(i,M) if(ng[i]!=0) cnt++;
  if(cnt==M) return INF;
  vector<pair<int,int> > num(M);
  rep(i,M) num[i]=make_pair(0,i);
  int used[N]={};
  rep(i,M) rep(j,N){
    if(ng[A[j][i]]==0&&used[j]==0){
      num[A[j][i]].first++;
      used[j]=1;
    }
  }
  sort(num.rbegin(),num.rend());
  ng[num[0].second]=1;
  int tmp=solve(ng);
  return min(num[0].first,tmp);
}

int main(){
  cin>>N>>M;
  rep(i,N) rep(j,M){
    cin>>A[i][j]; A[i][j]--;
  }
  vector<int> ng(M,0);
  cout<<solve(ng)<<endl;
  return 0;
}


Measured memory_bytes: 2048
use std::io;
use std::str::FromStr;

fn main(){
    let stdin = io::stdin();
    let mut buf = String::new();

    loop {
        let _ = stdin.read_line(&mut buf);
        let vec : Vec<usize> = buf.split_whitespace().map( |x| usize::from_str(x).unwrap() ).collect();
        buf.clear();
        let (h, w) = (vec[0], vec[1]);

        if h == 0 && w == 0 {
            break;
        }

        for i in 0..h {
            for j in 0..w {
                print!("{}", if (i+j)%2 == 0 { '#' } else { '.' });
            }
            println!();
        }
        println!();
    }
}



Measured memory_bytes: 5028
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
    //string S; cin>>S;
    //int A,B; cin>>A>>B;
    int N; cin>>N;

    for (int i = 1; i <= N; ++i) {
        int tmp=floor((double)i*1.08);
        if(tmp==N){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<":("<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val (H, W) = readLine()!!.split(" ").map{it.toInt()}
    val f = Array<String>(H) { readLine()!! }
    val mp = TreeMap<Char, Int>()

    for (row in f) {
        for (c in row) {
            mp[c] = (mp[c] ?: 0) + 1
        }
    }

    val h: Int
    val w: Int

    if (H % 2 != 0) {
        h = W
        w = H
    } else {
        h = H
        w = W
    }

    val c2: Int
    val c1: Int

    if (h % 2 != 0) {
        c1 = 1
        c2 = h + w - 2
    } else if (w % 2 != 0) {
        c1 = 0
        c2 = h
    } else {
        c1 = 0
        c2 = 0
    }
    val c4 = h * w - (c1 + c2)

    if (c2 % 2 != 0 || c4 % 4 != 0) {
        System.exit(1)
    }

    val b = arrayOf(c1, c2, c4)

    for (i in 2 downTo 0) {
        val k = 1 shl i
        for(v in mp.keys) {
            val a = Math.min(b[i], mp[v]!! / k * k)
            b[i] -= a
            mp[v] = mp[v]!! - a
        }

        if (b[i] > 0) {
            println("No")
            return
        }
    }

    println("Yes")
}


Measured memory_bytes: 37864