akhauriyash/Code-Regression huggingface dataset:
N, M, K = map(int, input().split())
friend = [[] for _ in range(N)]
block = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    friend[a - 1].append(b - 1)
    friend[b - 1].append(a - 1)

for _ in range(K):
    a, b = map(int, input().split())
    block[a - 1].append(b - 1)
    block[b - 1].append(a - 1)

vst = [0] * N
SIZE = []
C = 0
for i in range(N):
    if not vst[i]:
        C += 1
        vst[i] = C
        q = [i]
        cnt = 0
        for u in q:
            cnt += 1
            for v in friend[u]:
                if not vst[v]:
                    vst[v] = C
                    q.append(v)
        SIZE.append(cnt)

for i in range(N):
    ret = SIZE[vst[i] - 1] - 1
    ret -= len(friend[i])
    for b in block[i]:
        if vst[i] == vst[b]:
            ret -= 1
    print(ret, end=' ')
print()


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

using namespace std;

int main(){
char A;
cin >> A;
if(A == 'A'){
    cout <<"T";
}
if(A == 'T'){
    cout <<"A";
}
if(A == 'C'){
    cout <<"G";
}
if(A == 'G'){
    cout <<"C";
}
return 0;
}


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

const int N = 100;

int A, B;
string s[105];

signed main(){
  
  cin>>A>>B;
  
  for(int i=0;i<N;i++){
    
    for(int j=0;j<N;j++){
      
      if( i < N/2 ) s[i] += '#';
      else s[i] += '.';
      
    }
    
  }
  
  A--, B--;

  for(int i=0;i<N;i++){

    for(int j=0;j<N;j++){

      if( !A ) break;

      if( i%2 && j%2 ){
	s[i][j] = '.';
	A--;
      }
    }
    
    if( !A ) break;
    
  }

  for(int i=N-1;i>=0;i--){

    for(int j=0;j<N;j++){

      if( !B ) break;

      if( i%2 && j%2 ){
	s[i][j] = '#';
	B--;
      }
    }
    
    if( !B ) break;
    
  }
  
  cout<<N<<' '<<N<<endl;
			  
  for(int i=0;i<N;i++) cout<<s[i]<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pi 3.14159265358979323846
#define fr(i,a,b) for (ll i=a; i<(b);++i)
#define frr(i,a,b) for(ll i=(a-1);i>=(b);--i)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define pii pair<int,int>
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.begin(),a.end(),greater<int>())
#define removeDuplicates(a) a.resize(unique(all(a))-a.begin())
#define lsOne(S) (S & (-S))
#define isbitset(S, i) ((S >> i) & 1)
#define sz(a) (ll)a.size()
#define po(a,b) (ll)(pow(a,b)+0.5)
#define double long double
#define print(a) for(auto x:a)cout<<x<<" ";cout<<endl;

ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;

        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
const ll M=1e18+7;
const ll MOD=1e9+7;
const int MX=2e5+5;



void solve()
{
	int x;
	cin>>x;
	
   if(x==1)
   {
   	cout<<0<<endl;
   }
   if(x==0)
   {
   	cout<<1<<endl;
   }
   
}




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

	int t=1;
    //cin >> t;
    while(t--) {

        solve();
    }
    return 0;
}









Measured memory_bytes: 3584
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,a[1000005];
long long sum;
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		scanf("%d",&a[i]);
		sum+=a[i];
		if(sum>n){
			cout<<-1;
			return 0;
		}
	}
	cout<<n-sum;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main(){
  int a,b;
  cin >> a >> b;
  
  if (a+b < 24) cout << a+b << endl;
  if (a+b >= 24) cout << a+b-24 << endl;
}


Measured memory_bytes: 256
w,h,n = map(int,input().split())
l = [[int(i) for i in input().split()] for i in range(n)]
start,end = [0,0],[w,h]

for i in range(n):
    if l[i][2]==1 and start[0]<l[i][0]:
        start[0] = l[i][0]
    elif l[i][2]==2 and end[0]>l[i][0]:
        end[0] = l[i][0]
    elif l[i][2]==3 and start[1]<l[i][1]:
        start[1] = l[i][1]
    elif l[i][2]==4 and end[1]>l[i][1]:
        end[1] = l[i][1]

ans = (end[0]-start[0])*(end[1]-start[1]) if start[0]<end[0] or start[1]<end[1] else -1
print(ans if ans > 0 else 0)


Measured memory_bytes: 38256
#include<bits/stdc++.h>
#define LL long long
#define MEM(x,y) memset(x,y,sizeof(x))
#define MOD(x) ((x)%mod)
#define mod 1000000007
#define pb push_back
#define STREAM_FAST ios::sync_with_stdio(false)

using namespace std;
const int maxn = 2e5+7;
LL A,B,hp[maxn];
int n;
int check(LL x)
{
    LL cnt=0;
    for (int i=1;i<=n;i++)
    {
        LL tmp=hp[i]-B*x;
        if (tmp>0)
        {
            cnt+=tmp/(A-B);
            if (tmp%(A-B)!=0) cnt++;
        }
    }
    return cnt<=x;
}

int main()
{
    scanf("%d%lld%lld",&n,&A,&B);
    for (int i=1;i<=n;i++) scanf("%lld",&hp[i]);

    LL l=1,r=1e10;
    while (l<r)
    {
        LL mid=(l+r)/2;
        if (check(mid)) r=mid;
        else l=mid+1;
    }
    printf("%lld\n",l);
    return 0;
}


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

using namespace std ;

int main () {

   long long n , i, nas=0  ,a[70]={};

   cin >> n ;



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

   for(i=1;i<n-1;i++){
    if ((a[i]>a[i-1] and a[i]<a[i+1]) or (a[i]<a[i-1] and a[i]>a[i+1]) )
        nas++ ;
   }
   cout << nas ;

    return 0 ;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = -float('inf')
for s in range(N):
    S = []

    S.append(C[s])
    i = P[s] - 1

    while i != s:
        S.append(S[-1] + C[i])
        i = P[i] - 1
    if K <= len(S):
        score = max(S[:K])
    elif S[-1] <= 0:
        score = max(S)
    else:
        score1 = S[-1] * (K // len(S) - 1)
        score1 += max(S)
        score2 = S[-1] * (K // len(S))
        r = K % len(S)
        if r != 0:
            score2 += max(0, max(S[:r]))
        score = max(score1, score2)
    ans = max(ans, score)
print(ans)


Measured memory_bytes: 81096
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

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

ll lcm(ll a, ll b){
  return a * b / gcd(a,b);
}

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll n = b - a + 1;

  ll nc = b/c - (a-1)/c;
  ll nd = b/d - (a-1)/d;
  ll ncd = lcm(c, d);
  ll ncandd = b/ncd - (a-1)/ncd;
  ll ncord = nc + nd - ncandd;
  ll ans = n - ncord;

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

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set> 
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>
using namespace std;
#define assem99 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define ld long double
#define f(i,a,b) for(int i=a; i<b; i++)
#define F first
#define S second
#define sz(a) (int)(a).size()
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
int x[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int y[] = { -1, 0, 1, -1, 1, -1, 0, -1 };
const int MOD = 1e9 + 7, N = 1e6 + 5;
const double pi = acos(-1);

int arr[N];

int main()
{
	assem99;

	ull ans = 0;
	ull n; cin >> n;
	if (n % 2 == 1) cout << '0';
	else
	{
		for (ull i = 10; i <= n; i *= 5)
		{
			ans += n / i;
		}
      cout << ans;
	}
	

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <limits>

using namespace std;

#define ll long long

#define in(x) cin >> x
#define out(x) cout << x << endl

#define PI acos(-1)
#define pp push_back

#define Yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define No cout << "No" << endl
#define NO cout << "NO" << endl

#define vec2(type) vector<vector<type>>
#define vec3(type) vector<vector<vector<type>>>

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

template<typename T> void input(T *data, int n){
	For(i, n){
		cin >> data[i];
	}
}

template<typename T> void input(vector<T> &vec, int n){
	T temp;
	For(i, n){
		cin >> temp;
		vec.push_back(temp);
	}
}

template<typename T> void sort(vector<T> &ary){
	sort(ary.begin(), ary.end());
}

template<typename T> void rsort(vector<T> &ary){
	sort(ary.rbegin(), ary.rend());
}

void rstring(string &str){
	string temp = str;

	For(i, (int)str.size()){
		str[i] = temp[(str.size() - 1) - i];
	}
}

struct Vec{
	int x, y;
	Vec():
	x(0), y(0){}
	Vec(int _x, int _y):
	x(_x), y(_y){}
};

template<typename T> void print(T *x, int n){
	For(i, n){
		cout << x[i] << " ";
	}
	cout << endl;
}

template<typename T> void print(vector<T> &x){
	For(i, (int)x.size()){
		cout << x[i] << " ";
	}
	cout << endl;
}

int gcd(int n, int m){
	if(n % m == 0){
		return m;
	}
	else{
		return gcd(m, n % m);
	}
}

int main(){

	char b;
	in(b);
	char c;

	switch(b){
		case 'A':
			c = 'T';
			break;
		case 'T':
			c = 'A';
			break;
		case 'G':
			c = 'C';
			break;
		case 'C':
			c = 'G';
			break;
	}
	out(c);

	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    string s[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string temp;
    cin >> temp;
    for(int i=0; i<7; i++){
        if(s[i]==temp){
            cout << 7-i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
const int MAX_N_Int = 1000000000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
#define rep(i,a,n) for(Int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(Int (i)=(a); (i)<=(n); (i)++)

template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}


Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}


Int fact_mod(Int n, Int mod) {
    Int f = 1; repq(i,2,n) f = f * (i % MOD) % MOD;
    return f;
}

// 繰り返し二乗法 (modの世界での累乗)
Int mod_pow(Int x, Int n, Int mod) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

// 組み合わせ nCr を求める
Int combination_mod(Int n, Int r, Int mod) {
    if(r > n-r) r = n-r;
    if(r == 0) return 1;
    Int a = 1;
    rep(i, 0, r) a = a * ((n-i) % mod) % mod;
    Int b = mod_pow(fact_mod(r, mod), mod-2, mod);
    return (a % mod) * (b % mod) % mod;
}

bool rev(string s){
    string t=s;
    reverse(s.begin(),s.end());
    return s==t;
}
int main() {
    //COMinit();
    IOS;
    prec;
    Int a=0,b=0,n,m,k,x,y=0,ans=0;
    string str,s,t,u;
    cin>>n;
    vector<int>aa(n);
    for (int i = 0; i < n; ++i) {
        cin>>aa[i];
    }
    rsort(aa);
    for (int j = 0; j < n; ++j) {
        if(j%2==0)a+=aa[j];
        else b+=aa[j];
    }
    cout<<a-b;






    cout<<endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
n, m = map(int, input().split())

left = 1
right = n

for i in range(m):
    a, b = map(int, input().split())
    if a > left:
        left = a
    if b < right:
        right = b
    
    if left > right:
        print(0)
        exit()

print(right-left+1)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long int lli;
const lli inf = 1e9;

lli modadd(lli a, lli b, lli mod){
    lli res = (a+b)%mod;
    while(res<0) res+=mod;
    return res;
}

bool numlex(lli a, lli b){
    if(a > b) return false;
    return to_string(a) < to_string(b);
}

lli binsearch(lli a, lli lb, lli ub){
    if(!numlex(a, ub)) return ub+1;
    while(lb < ub){
        lli mid = (lb +ub)/2;
        if(numlex(a, mid)){
            ub = mid;
        }else{
            lb = mid+1;
        }
    }
    return lb;
}

lli solve(lli a, lli b, lli p){
    vector<lli> dp(b-a+2, 0);
    lli res = 0;
    for(lli i=0; i<b-a+1; i++){
        dp[i+1] += dp[i];
        dp[i]++;
        res = modadd(res, dp[i], p);
        lli low=1, up=10;
        for(; low<=inf; low*=10, up*=10){
            if(up < a || low > b) continue;
            lli ret = binsearch(a+i, low, up-1);
            if(ret == up) continue;
            if(ret <= b) dp[ret-a] = modadd(dp[ret-a], dp[i], p);
            if(up <= b) dp[up-a] = modadd(dp[up-a], -dp[i], p);
        }
        
    }
    return res;

}

int main(){
    while(1){
        int a,b,p;
        cin >> a >> b >> p;
        if(a==0) break;
        cout << solve(a,b,p) << endl;
    }
    return 0;
}



Measured memory_bytes: 3900
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int h, n, sum = 0; cin>>h>>n;
    int a[n];
    for(int i = 0; i < n; i++) cin>>a[i], sum += a[i];
    if(sum >= h) cout<<"Yes"<<'\n';
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 640
//
//  0583.cpp
//  
//
//  Created by Yoshida Satoshi on 2018/11/13.
//

#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

int gcd(int x,int y)
{
    if(x<y) swap(x,y);
    if(x%y==0) return y;
    return gcd(y,x-(x/y)*y);
}

int main()
{
    int n;
    int a,b,c;
    cin>>n;
    int g;
    if(n==2)
    {
        cin>>a>>b;
        g=gcd(a,b);
    }
    if(n==3)
    {
        cin>>a>>b>>c;
        g=gcd(a,b);
        g=gcd(g,c);
    }
    for(int i=1;i<=g;i++)
    {
        if(g%i==0) cout<<i<<endl;
    }
    
    return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define senor_SR ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
typedef long long ll;
typedef long double ld;
typedef int32_t i32;
 
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define pf push_front
 
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>=b;i--)
#define FILL(a,b,c) for(ll i=0;i<c;i++) a[i]=b;
 
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
 
#define endl "\n"
#define setpri(x) setprecision(x)
#define vp(x) cout<<#x<<" : "<< (x)<<" | "
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define farr(a,n) for(long long i=0;i<n;i++) cin>>a[i];
#define fvec(vec,n) for(long long i=0;i<n;i++) {ll tmp;cin>>tmp;vec.pb(tmp);}
#define parr(a,n) for(long long i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define prvec(v) for(long long i=v.size()-1;i>=0;i--) cout<<v[i]<<" "; cout<<endl;
#define pvecpair(v) for(long long i=0;i<v.size();i++) cout<<v[i].first<<" "<<v[i].second<<endl;
 
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define MAX_INT 100000
#define MOD 1000000007

const int N=1e6+2;
vector<int> adj[N+1];
ll vis[N+1]={0};
double tot=0,dis=0,leaf=0;
map<pair<int,int>,vector<int>> mv;

int col[N]={0},len;

ll dfs(ll cur)
{
    if(vis[cur]==1) return 0;
    vis[cur]=1;
    ll ans=1;
    for(auto x:adj[cur])
    {
        if(vis[x]==0)
        {
            ans+=dfs(x);                    
        }
    }
    return ans;
}

long long moduloExpo(long long X,long long N,long long M=1000000007)
{
    if(X==0) return 0;
    long long RES=1;
    while(N>0) { if(N%2==1) RES=(RES*X)%M;X=(X*X)%M;N=N/2;}
    return RES;
}

void solve()
{
    //ll n;cin>>n;
    //ll m;cin>>m;
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        yes;
    else 
        no;
}
    
int main()
{
    senor_SR;
    
    //ll t;cin>>t;while(t--)
        solve();
 
    return 0;
}

Measured memory_bytes: 27264
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;


int main() {
	vector<int> x(4), y(4);
	cin >> x[0] >> y[0] >> x[1] >> y[1];

	vector<int> a(2), b(2);
	a[0] = x[0] - x[1];
	a[1] = x[1] - x[0];
	b[0] = y[0] - y[1];
	b[1] = y[1] - y[0];

	if (x[0] > x[1]) {
		if (y[0] > y[1]) {
			x[2] = x[1] + b[0];
			y[2] = y[1] - a[0];
			x[3] = x[2] + a[0];
			y[3] = y[2] + b[0];
		}
		else if (y[0] < y[1]) {
			x[2] = x[1] - b[1];
			y[2] = y[1] - a[0];
			x[3] = x[2] + a[0];
			y[3] = y[2] - b[1];
		}
		else {
			x[2] = x[1];
			y[2] = y[1] - a[0];
			x[3] = x[2] + a[0];
			y[3] = y[2];
		}
	}
	else if (x[0] < x[1]) {
		if (y[0] > y[1]) {
			x[2] = x[1] + b[0];
			y[2] = y[1] + a[1];
			x[3] = x[2] - a[1];
			y[3] = y[2] + b[0];
		}
		else if (y[0] < y[1]) {
			x[2] = x[1] - b[1];
			y[2] = y[1] + a[1];
			x[3] = x[2] - a[1];
			y[3] = y[2] - b[1];
		}
		else {
			x[2] = x[1];
			y[2] = y[1] + a[1];
			x[3] = x[2] - a[1];
			y[3] = y[2];
		}
	}
	else {
		if (y[0] > y[1]) {
			x[2] = x[1] + b[0];
			y[2] = y[1];
			x[3] = x[2];
			y[3] = y[2] + b[0];
		}
		else if (y[0] < y[1]) {
			x[2] = x[1] - b[1];
			y[2] = y[1];
			x[3] = x[2];
			y[3] = y[2] - b[1];
		}
	}

	cout << x[2] << ' ' << y[2] << ' ' << x[3] << ' ' << y[3] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);



int main() {

    int n,q;
    cin>>n>>q;
    vector<tuple<int,int,int>> stx(n);
    rep(i,n){
        cin>>get<1>(stx[i])>>get<2>(stx[i])>>get<0>(stx[i]);
    }
    sort(stx.begin(),stx.end());

    set<pair<int,int>> d;
    rep(i,q){
        int x;cin>>x;
        //d.insert({x,i});
        d.emplace(x,i);
    }
    vector<ll> tm(q,-1);
    rep(i,n){
        auto first = d.lower_bound(make_pair(get<1>(stx[i])-get<0>(stx[i]),0));
        auto end = d.upper_bound(make_pair(get<2>(stx[i])-get<0>(stx[i])-1,q));
        for(auto itr=first;itr!=end;itr++)tm[itr->second]=get<0>(stx[i]);
d.erase(first,end);




    }
    rep(i,q)cout<<tm[i]<<endl;






    return 0;
}


Measured memory_bytes: 15232
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, m;
  cin >> n >> m;
  
  vector<int> city(n);
  vector<int> road(2);
  
  for (int i = 0; i < m; i++) {
    cin >> road.at(0) >> road.at(1);
    city.at(road.at(0) - 1)++;
    city.at(road.at(1) - 1)++;
  }
  
  for (int i = 0; i < n; i++) {
    cout << city.at(i) << endl;
  }
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>

int N, W;
long long dp[100001];

long long to(long long *x, long long y) {
    if (*x > y) *x = y;
}

int main() {
    scanf("%d %d", &N, &W);
    for (int i = 0; i <= 100000; i++) {
        dp[i] = 2e18;
    }
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        int w, v;
        scanf("%d %d", &w, &v);
        for (int j = 100000 - v; j >= 0; j--) {
            to(&dp[j + v], dp[j] + w);
        }
    }
    for (int i = 100000; i >= 0; i--) {
        if (dp[i] <= W) {
            printf("%d\n", i);
            return 0;
        }
    }
    return 0;
}


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

int main(){
    int a,b;
    cin>>a>>b;
    if(a>b){
        cout<<"a > b\n";
    }
    else if(a<b){
        cout<<"a < b\n";
    }
    else{
        cout<<"a == b\n";
    }
    return 0;
}


Measured memory_bytes: 3096
#include<stdio.h>

int main(void){
  int a,b,c,d,win;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);
  
  while(1){
    c = c - b;
    if(c<=0){
      win = 1;
      break;
    }
    a = a - d;
    if(a<=0){
      win = 0;
      break;
    }
  }
  if(win == 1)
    printf("Yes");
  else
    printf("No");
  return 0;
}

Measured memory_bytes: 1728
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using System.IO;

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
		var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
		Console.SetOut(sw);

		var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int A = input[0];
		int B = input[1];
		Console.WriteLine((A * B) % 2 != 0 ? "Yes" : "No");
		
		Console.Out.Flush();
	}
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
 using namespace std;
 int main()
 {
     int n;
     cin>>n;
     int a[n+1][3];
     for(int i=0;i<n;i++)
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    int dp[n+1][3];
    dp[0][0]=0;dp[0][1]=0;dp[0][2]=0;
    dp[1][0]=a[0][0];dp[1][1]=a[0][1],dp[1][2]=a[0][2];
    for(int i=2;i<=n;i++)
    {
        dp[i][0]=a[i-1][0]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=a[i-1][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=a[i-1][2]+max(dp[i-1][0],dp[i-1][1]);
    }
    int ans=max(dp[n][0],(max(dp[n][1],dp[n][2])));
    cout<<ans<<endl;
 }

Measured memory_bytes: 5952
#include <iostream>
        using namespace std;
         
        int N, M, Q, p[509][509];
        int main() {
        	cin >> N >> M >> Q;
        	for (int i = 1; i <= M; i++) { int L, R; cin >> L >> R; p[L][R]++; }
        	for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) p[i][j] += p[i][j - 1]; }
        	for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) p[i][j] += p[i - 1][j]; }
         
        	for (int i = 1; i <= Q; i++) {
        		int L, R; cin >> L >> R;
        		cout << p[R][R] + p[L - 1][L - 1] - p[L - 1][R] - p[R][L - 1] << endl;
        	}
        	return 0;
    }

Measured memory_bytes: 1920
/**
 * 
 */
import java.util.*;
/**
 * @author akira
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		while(true){
			int h, m, s;
			h = scan.nextInt();
			m = scan.nextInt();
			s = scan.nextInt();
			if(h == -1 && m == -1 && s == -1){
				break;
			}
			int trl1 = 2 * 3600 - (h * 3600 + m * 60 + s);
			int trl2 = 3 * trl1;
			int[] t = {3600,60,1};
			for(int i = 0;i < 3;i++){
				if(i != 0){
					System.out.print(":");
				}
				System.out.format("%02d", trl1 / t[i]);
				trl1 -= (trl1 / t[i]) * t[i];
			}
			System.out.println("");

			for(int i = 0;i < 3;i++){
				if(i != 0){
					System.out.print(":");
				}
				System.out.format("%02d", trl2 / t[i]);
				trl2 -= (trl2 / t[i]) * t[i];
			}
			System.out.println("");
		}
	}

}

Measured memory_bytes: 19076
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define inf 0x7f
#define pii pair<int,int>
#define pdd pair<double,double>
#define pdi pair<double,int>
#define mp(u,v) make_pair(u,v)
#define sz(a) a.size()
#define ull unsigned long long
#define ll long long
#define pb push_back
#define PI acos(-1.0)
const int mod = 1e9+7;
const int maxn = 1e3+5;
const double EPS = 1e-6;
using namespace std;
int gcd(int a,int b){
	return b==0?a:gcd(b,a%b);
}
int main()
{
	ll a,b,c,d;
	scanf("%lld",&a);
	for(b=1;b<=3500;b++){
		for(c=1;c<=3500;c++){
			double d=(double)(a*b*c)/(4*b*c-a*c-a*b);
			if((int)d==d&&d>0){
				return printf("%lld %lld %d",b,c,(int)d),0;
			}
		}
	} 
	return 0;	
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL A, B, N;
  cin >> A >> B >> N;
  
  if(B-1<=N){
    cout << A - (A+ B -1 ) / B << endl;
  }else{
    cout << (A * N) / B - A * (N / B) << endl;
    // LL mx = 0;

    // FOR(i,0,N+1){
    //   if(i>=200000){
    //     break;
    //   }
    //   LL c = (A * i) / B - A * (i / B);
    //   if(c>mx){
    //     mx = c;
    //     // cout << mx SP c SP i << endl;
    //   }
    // }
    
    // FOR(i,1,200001){
    //   LL x = B * i - 1;
    //   if(x>N){
    //     break;
    //   }
    //   LL c = (A * x) / B - A * (x / B);
    //   if(c>mx){
    //     mx = c;
    //     // cout << mx SP c SP i << endl;
    //   }
    // }
    // cout << mx << endl;
  }
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<vector>
#include<map>
using namespace std;

int a,b,c,d,n;
string a1,a2,a3;

int main(){
	cin>>n;
	a=n/1000;
	n-=a*1000;
	b=n/100;
	n-=b*100;
	c=n/10;
	n-=c*10;
	d=n;
	for(int i=0;i<=1;i++){
		for(int j=0;j<=1;j++){
			for(int k=0;k<=1;k++){
				int e=a;
				if(i==0) e+=b;
				else e-=b;;
				if(j==0) e+=c;
				else e-=c;
				if(k==0) e+=d;
				else e-=d;
				if(e==7){
					if(i==0) a1="+";
					else a1="-";
					if(j==0) a2="+";
					else a2="-";
					if(k==0) a3="+";
					else a3="-";
				}
			}
		}	
	}
	cout<<a<<a1<<b<<a2<<c<<a3<<d<<"=7"<<endl;
}

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}



int main(){
  vector<ll> x(5);
  rep(i,5) cin >> x[i];
  ll k; cin >> k;

  if(x[4]-x[0]>k){
    cout << ":(" << endl;
    return 0;
  }

  cout << "Yay!" << endl;

  return 0;
} 



Measured memory_bytes: 3540
n = int(input())
a = list(map(int, input().split()))
res = 0
for i in range(n-1):
    if a[i+1] < a[i]:
        s = abs(a[i+1]-a[i])
        a[i+1] += s
        # print(a[i+1])
        res += s
print(res)


Measured memory_bytes: 32156
# 190622_sat_B

N, L = map(int,input().split())

a = []
b = []

for i in range(1, N+1):
    a.append(L+i-1)
    b.append(abs(L+i-1))

# print("a: ", a)
# print("b: ", min(b))

# print("answer:", sum(a) - a[b.index(min(b))])
print(sum(a) - a[b.index(min(b))])

Measured memory_bytes: 2940
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val (S, T) = readLine()!!.split(" ")
    val sb = StringBuilder()

    for (i in S.indices) {
        sb.append(S[i])
        sb.append(T[i])
    }

    println(sb.toString())
}


Measured memory_bytes: 37692
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<string>
#include<map>

using namespace std;
const int INF = 1<<30;
typedef long long int ll;

int main(){
  map<int, int> count;
  for(int i=0;i<3;i++){
  	int a, b;cin>>a>>b;
    count[a]++;count[b]++;
  }
  bool ans=true;
  for(auto itr=count.begin();itr!=count.end();itr++){
  	if(itr->second>=3)ans=false;
  }
  cout<<(ans?"YES":"NO")<<endl;
}


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

int main() {
	// your code goes here
	int N, M ,C;
	cin >> N >> M >> C;
	int B[M], A[N][M];
	for(int i=0; i<M; i++)
	    cin >> B[i];
	for(int i=0; i<N; i++){
	    for(int j=0; j<M; j++)
	        cin >> A[i][j];
	}
	int sum = 0, count = 0;
	for(int i=0; i<N; i++){
	    sum = 0;
	    for(int j=0; j<M; j++){
	        sum += A[i][j]*B[j];
	    }
	    if(sum > -1*C)
	        count++;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>

using namespace std;

int main() {
    long long l, r;
    cin >> l >> r;

    long long min_value = INT_MAX;
    long long limit = min(l + 2019, r + 1);
    for (long long i = l; i < limit - 1; ++i) {
        for (long long j = i + 1; j < limit; ++j) {
            long long mod = i * j % 2019;
            if (mod < min_value)
                min_value = mod;
        }
    }
    cout << min_value << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = 10000000;
const long long INFL = (1LL<<50);
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

template< typename T >
using Edges =vector< edge<T> >;
template< typename T >
using WeightedGraph =vector< Edges<T> >;
using UnWeightedGraph =vector< vector<int> >;
template< typename T >
using Matrix =vector< vector<T> >;


template< typename T >
///与えられた隣接行列を用いてワーシャルフロイド法によりノード間最短距離を求める。閉路がある場合、ループ後にg[k][k] < 0なるノードkが存在
///gでエッジのない部分をINFにしておくことを忘れないように！
void warshall_floyd(Matrix< T > &g, T INF) {
    for(int k = 0; k < g.size(); k++) {
        for(int i = 0; i < g.size(); i++) {
            for(int j = 0; j < g.size(); j++) {
                if(g[i][k] == INF || g[k][j] == INF) continue;
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
}

vector<int> r;

int main() {
    int n,m,R;cin>>n>>m>>R;
    Matrix<ll> d(n,vector<ll>(n,INFL));
    r.resize(R);cin>>r;
    rep(i,m){
        int a, b, c;
        cin>>a>>b>>c;
        a--;b--;
        d[a][b] = c;
        d[b][a] = c;
        d[a][a] = 0;
        d[b][b]=0;
    }
    
    warshall_floyd(d,INFL);
    
    ll ans = INFL;
    sort(all(r));
    
    do{
 
        ll temp = 0;
        for(auto i = 1;i<R;i++){
            temp += d[r[i-1]-1][r[i]-1];
        }
        ans = min(ans,temp);
        
    }while(next_permutation(all(r)));
    
    cout<<ans<<endl;
    
    
    
    
    return 0;
}










Measured memory_bytes: 512
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.util.ArrayList;
import java.io.InputStream;

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

    static class DKi {
        public void dfs(int root, int p, long ans[], long[] quer, long extra, ArrayList<Integer> a[]) {
            ans[root] += quer[root] + extra;
            for (int c : a[root]) {
                if (c != p)
                    dfs(c, root, ans, quer, ans[root], a);
            }
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int q = in.nextInt();
            ArrayList<Integer> a[] = new ArrayList[n];
            for (int i = 0; i < n; i++) a[i] = new ArrayList<>();
            long ans[] = new long[n];
            long quer[] = new long[n];
            for (int i = 0; i < n - 1; i++) {
                int u = in.nextInt() - 1;
                int v = in.nextInt() - 1;
                a[u].add(v);
                a[v].add(u);
            }
            for (int i = 0; i < q; i++) {
                quer[in.nextInt() - 1] += in.nextInt();
            }
            dfs(0, -1, ans, quer, 0, a);
            for (int i = 0; i < n; i++) {
                out.print(ans[i] + " ");
            }
        }

    }

    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: 157288
#include<stdio.h>
#include<string.h>
#include<math.h>

/*#define min(a,b)((a)<(b)?(a):(b))*/

int main(){
  int m[101][101],p[101],n,i,j,k,l,f,q,o;
  

  scanf("%d",&n);
 
  for(f=0;f<n;f++){
    scanf("%d %d",&p[f],&p[f+1]);
  }
  for(i = 1;i<=n;i++){
    m[i][i] = 0;
  }

  for(l = 2;l<=n;l++){
    for(i = 1;i<=n-l+1;i++){
      j = i+l-1;
      m[i][j] = 100000000;
      for(k = i;k<=j-1;k++){
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	m[i][j] = ((m[i][j])<(q)?(m[i][j]):(q));
      }
    }
  }
  printf("%d\n",m[1][n]);
  return 0;
}

  



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define ll long long int
#define sd(x) scanf("%d",&x)
#define F first
#define S second
#define sz(x) (int)(x.size())
#define sd2(x,y) scanf("%d%d",&x,&y);
#define mp make_pair
#define pb push_back
#define pi pair <int, int > 
#define pl pair <ll, int >
#define infl (1ll << 60)
#define inf (1 << 30)
#define nax  100020
#define MOD 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
vector< pair <int, int > > v;
int arr[nax];
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n, m, a, b;
    sd2(n, m);

    ll sum = 0;
    for(int i = 0; i < n; i++)
    {
        sd(arr[i]);
        sum += arr[i];
    }
    sort(arr, arr + n);

    for(int i = 1; i <= m; i++)
    {
        sd2(a, b);
        v.pb(mp(-b, a));
    }
    sort(v.begin(), v.end());

    int ptr = 0;
    for(int i = 0; i < m; i++)
    {
        int cnt = v[i].S;
        int val = -v[i].F;
        while(cnt > 0 && ptr < n && arr[ptr] < val)
        {
            sum += val - arr[ptr];
            ptr++;
            cnt--;
        }
    }

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


Measured memory_bytes: 1784
N=int(input())
S=input()
ans=0
for i in range(10):
  for j in range(10):
    for k in range(10):
      p,q,r=str(i),str(j),str(k)
      if p in S:
        x=S.index(p)
        S_=S[x+1:]
        if q in S_:
          y=S_.index(q)
          S__=S_[y+1:]
          if r in S__:
            ans+=1
print(ans)

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

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

  string s;
  cin >> s;
  int ans = INT_MAX;
  for (size_t i = 0; i < s.size() - 2; ++i) {
    string t(&s[i], 3);
    ans = min(ans, abs(stoi(t) - 753));
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
 
using namespace std;
 
const int N=2e5+10;
 
int n,A[N],now[N];
 
void Init()
{
	scanf("%d",&n);
	n=2*n-1;
	for (int i=1;i<=n;++i) scanf("%d",&A[i]);
}
 
int len[N],op[N];
bool Check(int x)
{
	for (int i=1;i<=n;++i) if (A[i]>=x) now[i]=1;else now[i]=0;
	int top=0,cnt=0;
	for (int i=1;i<=n;)
	{
		int pos=i;
		while (now[pos]==now[i] && i<=n) ++i;
		if (i-pos>1)
		{
			if (top && now[pos]==op[top]) len[top]+=i-pos+cnt;
			else 
			{
				++top; len[top]=i-pos;
				if (top-1) len[top-1]+=cnt>>1,len[top]+=cnt>>1;else len[top]+=cnt;
				op[top]=now[pos];
			}
			cnt=0;
		}else cnt++;
	}
	if (!top) return now[1];
	len[top]+=cnt;cnt=0;
	int sum=0;
	for (int i=1;i<=top;++i) sum+=len[i];
	int l=1,r=top;
	while (l!=r)
	{
		int del=min(len[l],len[r]);
		len[l]-=del; len[r]-=del;
		if (!len[l]) ++l;
		if (!len[r]) --r;
	}
	return op[l];
}
 
void Solve()
{
	int l=1,r=n;
	while (l<=r)
	{
		int mid=(l+r)>>1;
		if (Check(mid)) l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",r);
}
 
int main()
{
	Init();
	Solve();	
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <queue>
 
int main(){
    std::priority_queue<u_int> prices;
    u_int num_of_item, size_of_bag, price;
    
    while(1){
        std::cin >> num_of_item >> size_of_bag;
        if(num_of_item == 0 && size_of_bag == 0)
            break;
            
        for(u_int i = 0; i < num_of_item; ++i){
            std::cin >> price;
            prices.push(price);
        }
        
        u_int sum = 0;
        while(!prices.empty()){
            for(u_int i = 0; i < size_of_bag; ++i){
                if(i != size_of_bag - 1){
                    sum += prices.top();
                }
                prices.pop();
                if(prices.empty())
                    break;
            }
        }
        std::cout << sum << std::endl;
    }
 
    return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int qmax(int &x,int y) {if (x<y) x=y;}
int qmin(int &x,int y) {if (x>y) x=y;}
inline int read()
{
    char s;int k=0,base=1;
    while((s=getchar())!='-'&&s!=EOF&&!(isdigit(s)));
    if(s==EOF)exit(0);if(s=='-')base=-1,s=getchar();
    while(isdigit(s)){k=k*10+(s^'0');s=getchar();}
    return k*base;
}
inline void write(int x)
{
    static char cnt,num[15];cnt=0;
    if (!x) {putchar('0'); return;}
    for (;x;x/=10) num[++cnt]=x%10;
    for (;cnt;putchar(num[cnt--]+48));
    putchar('\n');
}
const int maxn=2010;
int n,k;
int a[10];
bool check(int x)
{
	if (x==0) return a[0]!=1;
	while (x)
	{
		if (a[x%10]) return false;
		x/=10;
	}
	return true;
}
int main()
{
	n=read();k=read();
	for (int i=1;i<=k;i++) a[read()]=1;
	for (int j=n;j<=n*100;j++)
	{
		if (check(j))
		{
			printf("%d\n",j);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>


long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){
int N;
cin>>N;
long long  A[N];
int ans=0;
for(int i=0;i<N;i++){
    cin>>A[i];
}
long long h=A[0];
int tmp=0;
for(int i=0;i<=N;i++){
    if(A[i]>=A[i+1]){
        tmp++;
    }
    else{
        ans=max(ans,tmp);
        tmp=0;
    }
}
cout<<ans<<endl;
 return 0;
}

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

struct card{
  char c;
  int num;
};

struct card a[100001];
struct card b[100001];

bool operator<(const card &s, const card &t){
  return s.num < t.num;
}

int partition(int p, int r){
  int x = a[r].num;
  int idx = p-1;
  for(int i = p; i < r; i++){
    if(a[i].num <= x){
      idx++;
      swap(a[idx], a[i]);
    }
  }
  swap(a[idx+1], a[r]);
  return idx+1;
}

void quicksort(int p, int r){
  if(p < r){
    int q = partition(p, r);
    quicksort(p, q-1);
    quicksort(q+1, r);
  }
}

int main(){

  int n, v;
  char ch;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> ch >> v;
    a[i].c = b[i].c = ch;
    a[i].num = b[i].num = v;
  }
  stable_sort(b, b+n);
  quicksort(0, n-1);

  int stable = 1;
  for(int i = 0; i < n; i++){
    if(a[i].c != b[i].c) stable = 0;
  }
  if(stable) cout << "Stable" << endl;
  else cout << "Not stable" << endl;
  for(int i = 0; i < n; i++){
    cout << a[i].c << " " << a[i].num << endl;
  }
  return 0;
}


Measured memory_bytes: 4720
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,c=0;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    c+=a[i]%2;
  }
  cout<<(c%2==0?"YES":"NO")<<endl;
}

Measured memory_bytes: 640
// Problem : Lucas Number
// Contest : Virtual Judge - AtCoder
// URL : https://vjudge.net/problem/AtCoder-abc079_b
// Memory Limit : 262 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")  // disable
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define lll __int128
#define lp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define vec(v, type, sz) vector<type> v(sz)
#define in(v) \
    for (auto &i : v) cin >> i
#define all(v) v.begin(), v.end()
#define prv(v)                         \
    for (auto i : v) cout << i << " "; \
    cout << "\n"
#define MOD 1000000007
#define INF 1000000000
#define INFL 1000000000000000000ll
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define vi vector<int>
#define vl vector<ll>
#define vii(v, n, m, val) vector<vector<int>> v(n, vector<int>(m, val))
#define viii(v, i, j, k, val)        \
    vector<vector<vector<int>>> v(i, \
                                  vector<vector<int>>(j, vector<int>(k, val)))
#define pii pair<int, int>
#define pb push_back
#define file_io                       \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define testcases \
    int tcc;      \
    cin >> tcc;   \
    for (int tc = 1; tc <= tcc; tc++)
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while (!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
    cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if (idx > 0)
        cerr << ", ";
    else
        cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss;
    ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef DB
#define debug(...) \
    debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
    fast_io;
    ll a = 2, b = 1, c = 0;
    int n;
    cin >> n;
    if (n == 1) {
        cout << "1";
        return 0;
    }
    for (int i = 2; i <= n; i++) {
        c = a + b;
        a = b;
        b = c;
    }
    cout << c;
}

Measured memory_bytes: 3560
# -*- coding: utf-8 -*-
# if x < y:
#     z = x
# elif True:
#     z = y
# else:
#     z = 100
import sys,os,math
from collections import Counter, defaultdict
import bisect
from sys import stdin, stdout
from itertools import repeat


# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())

def main():
    n, m = map(int, raw_input().split())
    bf, af = [10000000 for i in range(1<<n)], [10000000 for i in range(1<<n)]
    bf[0] = 0
    for i in range(m):
        a, b = map(int, raw_input().split())
        ad = 0
        for st in map(int, raw_input().split()):
            ad |= 1<<(st-1)
        for st in range(1<<n):
            af[st|ad] = min(bf[st]+a, af[st|ad])
            af[st] = min(af[st], bf[st])
        bf, af = af, bf
    if bf[(1<<n)-1] == 10000000:
        print -1
    else:
        print bf[(1<<n)-1]


main()


Measured memory_bytes: 35176
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};
string s, t;

signed main(){
    cin >> s >> t;
    vector<ll> as, at;
    ll tmp = 0;
    as.push_back(0);
    at.push_back(0);
    rep((int)s.length()){
        tmp += (s[i] == 'A')? 1:2;
        as.push_back(tmp);
    }
    tmp = 0;
    rep((int)t.length()){
        tmp += (t[i] == 'A')? 1:2;
        at.push_back(tmp);
    }
    
    int n;
    cin >> n;
    rep(n){
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        cout << ((abs(as[b] - as[a-1]) % 3 == abs(at[d] - at[c-1]) % 3)?"YES":"NO") << endl;
    }
}


Measured memory_bytes: 2872
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

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

    Int sum = 0;

    for(Int i = 1;i <= N;i++) {
        if(i % 3 != 0 && i % 5 != 0)
            sum += i;
    }

    cout<<sum<<endl;

    return 0;
}



Measured memory_bytes: 3192