akhauriyash/Code-Regression huggingface dataset:
import java.util.*;


public class Main {
    public static void main(String[] args) {
      
      Scanner sc = new Scanner(System.in);
      int n = Integer.parseInt(sc.next());
      int ary[] = new int[n];
      for (int i = 0; i < ary.length; i++) {
        ary[i] = Integer.parseInt(sc.next());
      }
      
      if (isAscendingOrder(ary)) {
        System.out.print("YES");
      } else {
        System.out.print("NO");
      }
    }
  
  public static boolean isAscendingOrder(int[] ary) {
    int x = 0;
    int y = 0;
    int k = 0;
        for (int i = 0; i < ary.length -1; i++) {
          if (ary[i] > ary[i + 1]) {
            if (x == 0) {
              x = ary[i];
            } else if (y == 0) {
              y = ary[i + 1];
            }
          }
        }
        for (int i = 0; i < ary.length -1; i++) {
          if (ary[i] > ary[i + 1]) {
            if (k == 0) {
              ary[i] = y;
              k += 1;
            } else if (k == 1) {
              ary[i +1] = x;
              k += 1;
            }
          }
        }
        for (int i = 0; i < ary.length -1; i++) {
          if (ary[i] > ary[i + 1]) {
            return false;
          }
        }
        return true;
      }
}

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

long long arr[100010];
int main()
{
    long long n;
    scanf("%lld", &n);
    for(long long i = 1;i <= n;++i)
        scanf("%lld", &arr[i]);
    long long ans = 0;
    long long cur = 1;
    for(long long i = 1;i <= n;++i)
    {
        if(arr[i] > cur)
        {
            if(arr[i] != cur)
            {
                ans += (arr[i] - 1) / cur;
                arr[i] = 1;
            }
        }
        cur = max(cur, arr[i] + 1);
    }
    printf("%lld\n", ans);
    return 0;
}


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

int main() {
  string date;
  cin >> date;
  if (date.at(5) == '0') {
    if (date.at(6) <= '4') {
      cout << "Heisei" << endl;
    }
    else {
      cout << "TBD" << endl;
    }
  }
  else {
    cout << "TBD" << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			int m = sc.nextInt();
			int[] x = new int[m];
			int[] y = new int[m];
			boolean[] a = new boolean[n];
			int[] num = new int [n];
			for(int i=0; i<m; i++){
				x[i] = sc.nextInt();
				y[i] = sc.nextInt();
			}
			
			a[0] = true;
			num[0] = 1;
			for(int i=1; i<n; i++){
				a[i] = false;
				num[i] = 1;
			}
			
			for(int i=0; i<m; i++){
				num[x[i]-1]--;
				num[y[i]-1]++;
				if(a[x[i]-1]){
					a[y[i]-1] = true;
				}
				if(num[x[i]-1]==0){
					a[x[i]-1] = false;
				}
			}
			int ans = 0;
			for(int i=0; i<n; i++){
				if(a[i]){
					ans++;
				}
			}
			System.out.println(ans);
	}

}


Measured memory_bytes: 61532
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
vector<vector<ll> >vec;
ll k,ans;
const ll M=1e9+7;
vector<vector<ll> >dp,tmp1,tmp2;
void go()
{
    tmp1=dp;
    for(int i=0;i<n;i++)
	{
        for(int j=0;j<n;j++)
		{
            dp[i][j]=0;
            for(int k=0;k<n;k++)
                dp[i][j]=(dp[i][j]+(tmp1[i][k]*tmp1[k][j]))%M;
        }
    }
}
void odd()
{
    tmp1=dp;
    tmp2=vec;
    for(int i=0;i<n;i++)
	{
        for(int j=0;j<n;j++)
		{
            dp[i][j]=0;
            for(int k=0; k<n; k++)
                dp[i][j]=(dp[i][j]+(tmp1[i][k]*tmp2[k][j]))%M;
        }
    }
}
void solve(ll k)
{
    if(k==1)return;
    solve(k/2);
    go();
    if(k%2)odd();
    return;
}
int main()
{
    cin>>n>>k;
    vec.resize(n);
    dp.resize(n);
    for(int i=0;i<n;i++)
	{
        for(int j=0;j<n;j++)
		{
            int x;
            cin>>x;
            vec[i].push_back(x);
            dp[i].push_back(x);
        }
    }
    solve(k);
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)
        ans+=(dp[i][j]%M);
    cout<<ans%M<<endl;
    return 0;
}

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

typedef long long lli;
typedef vector<int> Vi;
typedef vector<lli> Vl;
typedef pair<int, int> Pii;
typedef pair<lli, lli> Pll;


//===


int main() {
	int N;
	cin >> N;
	
	vector<vector<Pii>> to(N);
	for (int i = 0; i < N - 1; ++i) {
		int u, v, w;
		cin >> u >> v >> w;
		--u; --v;
		to[u].push_back(make_pair(v,w));
		to[v].push_back(make_pair(u,w));
	}

	Vi ans(N,-1);
	queue<int> q;
	ans[0] = 0;
	q.push(0);
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		for (int i = 0; i < to[v].size(); ++i) {
			int u = to[v][i].first;
			int w = to[v][i].second;
			if (ans[u] != -1) continue;
			ans[u] = (ans[v] + w) % 2;
			q.push(u);
		}
	}

	for (const auto& val : ans) {
		cout << val << endl;
	}
}

Measured memory_bytes: 6784
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
#define maxn 100005
#define INF 2123456789
typedef long long ll;

int main() {
	ll a, b, n, t;
	cin >> a >> b >> n;
	t = b > n ? n : b - 1;
	cout << a * t / b - a * (t / b) << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <ios>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

using i64 = long long;
using P = pair<i64, i64>;

int main(){
    i64 n;
    cin >> n;
    vector<i64> a(n);
    i64 s = 0;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
        if(i % 2 == 0) s += a[i];
        else s -= a[i];
    }
    vector<i64> ans(n);
    ans[0] = s;
    for(int i = 1; i < n; ++i) ans[i] = a[i - 1] * 2 - ans[i - 1];
    for(int i = 0; i < n; ++i) cout << ans[i] << endl;
}

Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int N = sc.nextInt();
        int M = sc.nextInt();

        System.out.println(solve(N, M));
    }

    private static int solve(int N, int M) {
        int count = 0;

        if (N >= 2) {
            count += N * (N-1)/2;
        }
        if (M >= 2) {
            count += M * (M-1)/2;
        }

        return count;
    }
}

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

vector < int > solve1(int len){
	if(len == -1) return {0};
	vector < int > tmp1 = solve1(len - 1) , tmp2 = tmp1;
	reverse(tmp2.begin() , tmp2.end());
	for(auto t : tmp2) tmp1.push_back(t + (1 << len));
	return tmp1;
}

vector < int > solve(int len){
	if(len == 0) return {0 , 1};
	if(len == 2) return {0 , 1 , 3 , 2 , 6 , 4 , 5 , 7};
	vector < int > tmp1 = solve(len - 2) , tmp2;
	for(int i = 0 ; i < tmp1.size() ; ++i){
		tmp2.push_back(tmp1[i]);
		tmp2.push_back(tmp1[i] | (1 << (len - 1)));
		tmp2.push_back(tmp1[++i] | (1 << (len - 1)));
		tmp2.push_back(tmp1[i]);
	}
	reverse(tmp1.begin() , tmp1.end());
	for(auto t : tmp1) tmp2.push_back(t | 1 << len);
	reverse(tmp1.begin() , tmp1.end());
	for(auto t : tmp1) tmp2.push_back(t | 1 << len | 1 << (len - 1));
	return tmp2;
}

int main(){
	int N , X , Y; cin >> N >> X >> Y; Y ^= X;
	if(!(__builtin_popcount(Y) & 1)){puts("NO"); return 0;}
	puts("YES"); vector < int > p , q;
	for(int i = 0 ; i < N ; ++i) Y >> i & 1 ? p.push_back(i) : q.push_back(i);
	vector < int > stp = solve(p.size() - 1) , tmp = solve1(q.size() - 1);
	for(auto t : stp){
		for(auto x : tmp){
			int val = 0;
			for(int i = 0 ; i < p.size() ; ++i)
				val |= (t >> i & 1) << p[i];
			for(int i = 0 ; i < q.size() ; ++i)
				val |= (x >> i & 1) << q[i];
			cout << (val ^ X) << ' ';
		}
		reverse(tmp.begin() , tmp.end());
	}
	return 0;
}

Measured memory_bytes: 1152
n = int(input())
from collections import defaultdict
s = defaultdict(int)
for i in range(n):
    si = input()
    s[si] += 1

m = int(input())
for i in range(m):
    ti = input()
    s[ti] -= 1
ans = 0
for k,v in s.items():
    ans = max(ans, v)

print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <functional>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
class UF{
    public:
        int par[100000];
        int ran[100000];

        UF(int n){
            for(int i = 0;i < n;i++){
                par[i] = i;
                ran[i] = 0;
            }
        }

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

            else return par[x] = find(par[x]);
        }

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

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

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

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    UF uf(n);//友達関係で連結かどうか.

    map<int,int> friends;//各頂点に対して友達関係にあるもの.
    map<pair<int,int>,bool> fri_mp;//後のために保存.
    for(int i = 0;i < m;i++){
        int a,b;
        cin >> a >> b;
        a--,b--;
        uf.unite(a,b);
        friends[a]++;
        friends[b]++;
        fri_mp[make_pair(a,b)] = true;
        fri_mp[make_pair(b,a)] = true;
    }

    vector<int> block(n,0);
    vector<int> plus(n,0);
    for(int i = 0;i < k;i++){
        int c,d;
        cin >> c >> d;
        c--,d--;
        if(uf.same(c,d)){
            block[c]++;
            block[d]++;
        }
        if(fri_mp[make_pair(c,d)]){
            plus[c]++;
            plus[d]++;
        }
    }

    map<int,int> uf_cnt;

    for(int i = 0;i < n;i++){
        int a = uf.find(i);
        uf_cnt[a]++;
    }

    for(int i = 0;i < n;i++){
        int cnt = uf.find(i);
        cout << uf_cnt[cnt] - 1 - friends[i] - block[i] + plus[i] << endl;
    }
}


Measured memory_bytes: 30080
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
 
 
int main(){
  int ans=0, maxn=0, n, a;
  
  cin >> n;

  for(int i=0; i<n; ++i){
    cin >> a;
    maxn = max(maxn, a);
    ans += a;
  }

  cout << ans - maxn/2 << endl;
}

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

#define  ll         long long
#define  llu        unsigned long long
#define  mod        1000000007
#define  pi         ((2.0)*acos(0.0))
#define  pb         push_back
#define  pf         push_front
#define  eb         emplace_back
#define  mp         make_pair
#define  all(x)     (x).begin(),(x).end()
#define  X          first
#define  Y          second

/*loop*/
#define  fr(i,m,n)   for(ll i=m;i<n;++i)

/*output shortcuts*/
#define  nl         "\n"
#define  Yes        cout<<"Yes\n"
#define  yes        cout<<"yes\n"
#define  YES        cout<<"YES\n"
#define  No         cout<<"No\n"
#define  no         cout<<"no\n"
#define  NO         cout<<"NO\n"

using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n;
    cin>>n;
    ll a[n][3];

    fr(i,0,n)
        fr(j,0,3)
            cin>>a[i][j];

    //ll r=1;
    ll dp[n][3]={-1};

    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];

    fr(r,1,n)
    {
    for(ll i=0;i<3 && r<n; i++)  // cur_row
    {
        for(ll j=0;j<3;j++) // pre_row
        {
            if(j==i)
                continue;
            dp[r][i]=max(dp[r][i], dp[r-1][j]+a[r][i] );
        }
    }
    }

    /*cout<<nl<<nl;
    fr(i,0,n)
        {
            fr(j,0,3)
            {cout<<dp[i][j]<<" ";}
            cout<<nl;
        }
    */
    cout<< max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));

return 0;
}



Measured memory_bytes: 8232
#include <stdio.h>

int A[50], n;

solve(int i, int m){
  if (m == 0)	 return 1;
  if (i >= n)    return 0;
  int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return res;
}

int main()
{
  int M ,q ,i;

  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d", &A[i]);
  }
  
  scanf("%d", &q);
  for(i=0;i<q;i++){
    scanf("%d", &M);
    if(solve(0, M)) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

// template from zscoder

int yen[3];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    ll a,b,c,x,ans(0);
    cin >> a >> b >> c >> x;
    for(int i = 0; i <= a; i++)
    {
        for(int j = 0; j <= b; j++)
        {
            for(int k = 0; k <= c; k++)
            {
                int tmp = i*500+j*100+k*50;
                if(tmp==x)ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// #pragma GCC optimize(3,"Ofast","inline")
// #pragma GCC optimize(2)
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <string>
#include <iostream>
#include <list>
#include <cstdlib>
#include <bitset>
#include <assert.h>
#include <time.h>
#include <iomanip>
// #define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
// char buf[(1 << 21) + 1], * p1 = buf, * p2 = buf;
// #define int long long
#define lowbit(x) (x & (-x))
#define lson root << 1, l, mid
#define rson root << 1 | 1, mid + 1, r
#define pb push_back
typedef unsigned long long ull;
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
#define bug puts("BUG")
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const double eps = 1e-6;
template <class T>
inline void read(T &x)
{
    int sign = 1;char c = getchar();x = 0;
    while (c > '9' || c < '0'){if (c == '-')sign = -1;c = getchar();}
    while (c >= '0' && c <= '9'){x = x * 10 + c - '0';c = getchar();}
    x *= sign;
}
#ifdef LOCAL
    FILE* _INPUT=freopen("input.txt", "r", stdin);
    // FILE* _OUTPUT=freopen("output.txt", "w", stdout);
#endif
using namespace std;
const int maxn = 110;
int cnt[maxn];
int main()
{
    int n, k, d, x;
    read(n), read(k);
    for (int i = 0; i < k; ++i)
    {
        for (read(d); d--;)
        {
            read(x);
            cnt[x]++;
        }
    }
    int res = 0;
    for (int i = 1; i <= n; ++i)
    {
        res += cnt[i] == 0;
    }
    printf("%d\n", res);
}

Measured memory_bytes: 3692
#include <iostream>
#include <algorithm>
#include <cmath>

int main()
{
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;

    int x = c - a;
    int y = d - b;

    int x1 = -y;
    int y1 = x;
    int x2 = x1 - y1;
    int y2 = y1 + x1;

    std::cout << (c+x1) << " " << (d+y1) << " " << (c+x2) << " " << (d+y2) << std::endl;
  
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
bool ok,ap[500010];
LL A,B,t,ans;
pa tmp[500010];
int ts,n,a[500010],b[500010];
int main(){
	cin>>n;
	FOR(i,1,n){
		getint(a[i]),getint(b[i]);
		tmp[++ts]=mp(a[i],i);
		tmp[++ts]=mp(b[i],i);
		A+=a[i];
		B+=b[i];
	}
	ans=min(A,B);
	sort(tmp+1,tmp+ts+1);
	FOR(i,1,n){
		if (ap[tmp[i].se]) ok=1;
		ap[tmp[i].se]=1;
	}
	t=0;
	FOR(i,1,n) t+=tmp[i].fi;
	if (ok) return cout<<t<<endl,0;
	FOR(i,1,n){
		LL tt=t-tmp[i].fi;
		FOR(j,n+1,n+n)
			if (tmp[j].se!=tmp[i].se){
				ans=min(ans,tt+tmp[j].fi);
				break;
			}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

#define LL long long


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

    if (b % a == 0) {
        cout << a + b << endl;
    } else {
        cout << b - a << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve(){
	vector<int> table(3,0);
	for(int i=0;i<3;i++){
		cin>>table[i];
	}
	sort(table.begin(),table.end());
	if(table[0]==table[1] && table[0] !=table[2]){
		cout<<"Yes"<<endl;
		return;
	}
	if(table[1]==table[2] && table[0] !=table[2]){
		cout<<"Yes"<<endl;
		return;
	}
	cout<<"No"<<endl;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


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


def main():
    a, b = map(int, input().split())
    start = a
    ans = a

    if a % 2 == 0:
        if b - (a - 1) >= 4:
            start = b - ((b - (a - 1)) % 4)
            ans = 0
    else:
        if b - a >= 4:
            start = b - ((b - a) % 4)
            ans = a

    for i in range(start + 1, b + 1):
        ans ^= i

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pq priority_queue
using namespace std; typedef pair<int, int> P; typedef pair<int, P> P2; typedef pair<int, P2> P3;
constexpr long long gcd(long long a, long long b){return b ? gcd(b, a % b) : a;}
constexpr long long lcm(long long a, long long b){return a / gcd(a, b) * b;}
constexpr int INF = 1e9, MOD = INF + 7, around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
constexpr int mod_pow(long long x, long long n, const int mod){long long ret=1;while(n){if(n&1)(ret*=x)%=mod;(x*=x)%=mod;n>>=1;}return ret;}
template<int n> struct Prime{bool arr[n+1];constexpr bool operator[](int k){return arr[k];}constexpr Prime():arr(){for(int i=2;i<n;i++){arr[i]=true;for(int j=2;j*j<=i;j++){if(!(i%j))arr[i]=false;}}}};
template<int n> struct Factorial{long long arr[n+1],ary[n+1];constexpr Factorial():arr(),ary(){arr[0]=1;ary[0]=1;for(int i=0;i<n;i++){arr[i+1]=arr[i]*(i+1)%MOD;ary[i+1]=mod_pow(arr[i+1],MOD-2,MOD);}}};
constexpr Factorial<1010> fact; constexpr Prime<10> prime;
constexpr long long comb(int a, int b){if(a < b) return 0LL;if(!a or !b) return 1LL; long long pos = fact.arr[a], pot = fact.ary[a - b], por = fact.ary[b]; return pos * pot % MOD * por % MOD;}
template<int n> struct Bernoulli{long long arr[n+1];constexpr Bernoulli():arr(){arr[0]=1;for(int i=1;i<=n;i++){long long sum=0;for(int j=0;j<i;j++){(sum+=comb(i+1,j)*arr[j]%MOD)%=MOD;}arr[i]=(MOD-mod_pow(i+1,MOD-2,MOD))%MOD*sum%MOD;}}};
constexpr int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
constexpr long double PI = abs(acos(-1));
constexpr int sqrtN = 512, logN = 32;
constexpr long long LINF=1e18;

int main(){
	int a, b, k; cin >> a >> b >> k;
	
	vector<int> vec;
	for(int i = a; i < a + k and i <= b; i++) vec.push_back(i);
	for(int i = b; i > b - k and i >= a; i--) vec.push_back(i);
	sort(begin(vec), end(vec));
	vec.erase(unique(begin(vec), end(vec)), end(vec));
	
	for(auto v : vec) cout << v << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 10000
#define nil -1

typedef struct{
    int p;
    int left;
    int right;
}Node;

Node Tree[MAX];
int n, Depth[MAX], Height[MAX];

void setDepth(int u, int d){
    if(u == nil) return;
    Depth[u] = d;
    setDepth(Tree[u].left, d+1);
    setDepth(Tree[u].right, d+1);
}

int setHeight(int u){
    int h1=0, h2=0;
    if(Tree[u].left != nil) h1 = setHeight(Tree[u].left) + 1;
    if(Tree[u].right != nil) h2 = setHeight(Tree[u].right) + 1;
    return Height[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){
    if(Tree[u].p == nil) return nil;
    if(Tree[Tree[u].p].left != u && Tree[Tree[u].p].left != nil) return Tree[Tree[u].p].left;
    if(Tree[Tree[u].p].right != u && Tree[Tree[u].p].right != nil) return Tree[Tree[u].p].right;
    return nil;
}

void print(int u){
    printf("node %d: ",u);
    printf("parent = %d, ",Tree[u].p);
    printf("sibling = %d, ",getSibling(u));
    int deg=0;
    if(Tree[u].left != nil) deg++;
    if(Tree[u].right != nil) deg++;
    printf("degree = %d, ",deg);
    printf("depth = %d, ",Depth[u]);
    printf("height = %d, ",Height[u]);

    if(Tree[u].p == nil) printf("root\n");
    else if(Tree[u].left == nil && Tree[u].right == nil) printf("leaf\n");
    else printf("internal node\n");
}

int main(){
    int a, v, l, r, root=0;
    
    scanf("%d",&n);
    for(a = 0; a < n; a++) Tree[a].p = nil;
    for(a = 0; a < n; a++){
        scanf("%d%d%d",&v,&l,&r);
        Tree[v].left = l;
        Tree[v].right = r;
        if(l != nil) Tree[l].p = v;
        if(r != nil) Tree[r].p = v;
    }
    for(a = 0; a < n; a++) if(Tree[a].p == nil) root = a;

    setDepth(root, 0);
    setHeight(root);

    for(a = 0; a < n; a++) print(a);

    return 0;
}


Measured memory_bytes: 2144
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順

using namespace std;
using ll = long long int;

int main(){
    int N,M;cin>>N>>M;
    int sum = 0;
    for(int i=0;i<M;i++){
        int a;cin>>a;
        sum += a;
    }
    if(N-sum>=0){
        cout << N-sum << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
n, k = map(int, input().split())
A = [0 for i in range(n)]
for i in range(k):
    di = int(input())
    B = list(map(int, input().split()))
    for j in range(di):
        A[B[j] - 1] += 1

ans = 0
for i in range(n):
    if A[i] == 0:
        ans += 1
    else:
        pass
print(ans) 

Measured memory_bytes: 9212
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k = 0;
    string s;
    cin >> s;
    for(int i = 0; i <= 2; i++){
        if(s[i] == '7'){
            k = 1;
        }
    }
    if(k == 1){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 3560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while (true) {
			String inputA = br.readLine();
			if (inputA == null || inputA.isEmpty()) {
				break;
			}

			String inputB = br.readLine();
			if (inputB == null || inputB.isEmpty()) {
				break;
			}

			String[] inputAstr = inputA.split(" ");
			String[] inputBstr = inputB.split(" ");

			int blow = 0;
			int hit = 0;

			// blow?????¢???
			for (int i = 0; i < 4; ++i) {
				for (int j = 0; j < 4; ++j) {

					if (inputAstr[i].equals(inputBstr[j])) {
						// ??????????????¢???
						if (i == j) {
							++hit;
						} else {
							++blow;
						}
					}
				}
			}

			System.out.println(hit + " " + blow);

		}
	}
}

Measured memory_bytes: 24052
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;

void print(const vector<int> v)
{
	rep(i, v.size())
	{
		if (i) cout << " ";
		cout << v[i];
	}
	cout << endl;
}

int main(void)
{
	int n;
	cin >> n;
	vector<int> a;
	vector<int> b(n);
	vector<int> c(n);
	rep(i, n)
	{
		int in;
		cin >> in;
		a.push_back(in);
	}
	
	copy(a.begin(), a.end(), b.begin());
	copy(a.begin(), a.end(), c.begin());
	
	if (prev_permutation(a.begin(), a.end()))
	{
	    print(a);
	}
	
	print(b);
	
	if (next_permutation(c.begin(), c.end()))
	{
	    print(c);
	}
}


Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
double dis(pair<int,int>p,pair<int,int>q){
    double d=((p.first-q.first)*(p.first-q.first))+((p.second-q.second)*(p.second-q.second));
    return sqrt(d);
}
int main()
{
        int n;
    cin>>n;
    pair<int,int>p;
    vector<pair<int,int>>v;
    for(int i=0;i<n;i++){
        cin>>p.first>>p.second;
        v.push_back(p);
    }

    double d=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<i+1;j++){
            d+=dis(v[i],v[j]);
        }
    }
    cout<<setprecision(10)<<d/double(n) *2.0<<endl;
    return 0;

} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>

using namespace std;
typedef int status;
typedef long long ll;
typedef unsigned long long ull;
const ull base = 343;
const int INF = int(1e9);
const ll INF1 = ll(1e18);
const int MAX = 200002;

ll a,b,c;
ll x,y;

int main()
{
    ll sum = 0;
    cin>>a>>b>>c>>x>>y;
    ll t = x<y?x:y;
    if(a+b>=c*2){
        sum += c*2*t;
        x -= t;
        y -=t;
    }
    if(a>c*2){
        sum += c*2*x;
    }else{
        sum += a*x;
    }
    if(b>c*2){
        sum += c*2*y;
    }else{
        sum += b*y;
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 256
L,R = list(map(int,input().split()))
a = L%2019
b = R%2019
ans = 30000
if R-L>=2019:
  print(0)
elif a<b:
  for i in range(a,b):
    for j in range(i+1,b+1):
    	ans = min(ans,(i*(j))%2019)
  print(ans)
elif a>=b:
  print(0)

Measured memory_bytes: 3064
#include<stdio.h>

int main(){
	int n;
	scanf("%d",&n);
	int keta=1, n_cp=n;
	while(n_cp>=10){
		n_cp = n_cp/10;
		keta++;
	}
	if(keta==1){
		printf("%d",n);
	}
	else if(keta==2){
		printf("9");
	}
	else if(keta==3){
		printf("%d",n-90);
	}
	else if(keta==4){
		printf("909");
	}
	else if(keta==5){
		printf("%d",n-9090);
	}
	else if(keta==6){
		printf("90909");
	}
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);
			String s = sc.next();
			char  [] c = s.toCharArray();
						
			if(c[0] == c[1] && c[1] != c[2] && c[2] == c[3]) {
				System.out.println("Yes");
			}else if(c[0] == c[2] && c[2] != c[1] && c[1] == c[3]) {
				System.out.println("Yes");
			}else if(c[0] == c[3] && c[3] != c[1] && c[1] == c[2]){
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}							
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a-1);i>=(b);i--)
#define all(x) (x).begin(), (x).end()
const int INF = 1e18;
const int MOD = 1e9+7;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef string str;
typedef vector<str> vstr;
void print() {cout<<endl;}template<class Head,class...Tail>void print(Head&&head,Tail&&...tail){cout<<head;if(sizeof...(tail)!=0)cout<<" ";print(forward<Tail>(tail)...);}template<class T>void print(vector<T>&vec){for(auto&a:vec){cout<<a;if(&a!=&vec.back())cout<<" ";}cout<<endl;}template<class T>void print(vector<vector<T>>&df){for(auto&vec:df){print(vec);}}
template<class T=int>T in() {T x;cin>>x;return(x);}
template<class T=int>vector<T> input_to_vector(int n) {vector<T>x;rep(i,n){T a;cin>>a;x.push_back(a);}return(x);}

signed main(){
    int n = in();
    if(n==1){
        print("Hello World");
    } else {
        int a = in(), b = in();
        print(a+b);
    }
}

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

int main() {
	int N, A, B, countA=0, countB=0;
	string S;

	cin >> N >> A >> B;
	cin >> S;

	for (int i = 0; i < N; i++) {
		if (S[i] == 'a' && countA + countB < A + B) {
			cout << "Yes\n"; countA++; continue;
		}
		else if (S[i] == 'b' && countB < B && countA + countB < A + B) {
			cout << "Yes\n"; countB++; continue;
		}
		else { 
			cout << "No\n";
		}
	}

	return 0;
}


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

int main() {
  string s1,s2,s3; cin >> s1 >> s2 >> s3;
  char a = toupper(s1[0]);
  char b = toupper(s2[0]);
  char c = toupper(s3[0]);
  string ans = "";
  cout << a << b << c << endl;
  

  return 0;
}


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

int main(){
  int n;
  cin >> n;
  int x = 0;
  
  for(int i=1 ; i <= n ; i++){
    if ( i % 3 == 0 ){
       cout << " " << i;
    }else{
        x = i;
        while(1){
            if(x % 10 == 3){
              cout << " " << i;
              break;
            }
            x /= 10;
            if(x == 0){
                break;
            }
        }
        
    }
  }
  cout << endl;
  return(0);
}



Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define REP(i,n) for (int i = 0; i < n; ++i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORE(x,xs) for (auto& x : xs)

const int MAX = 1e5+10;
const ll MOD = 1e9+7;
int N;
ll dp[MAX][2];
vi G[MAX];
int parent[MAX];

ll solve(int n, int c) {
	if (dp[n][c] > -1) return dp[n][c];

	// c = 0 -> white , c = 1 -> black
	ll ret = 1;
	if (c == 1) {
		FORE (v, G[n]) if (v != parent[n])
			(ret *= solve(v, 0)) %= MOD;
	} else {
		FORE (v, G[n]) if (v != parent[n])
			(ret *= solve(v, 0) + solve(v, 1)) %= MOD;
	}
	return dp[n][c] = ret;
}

int main () {
	cin >> N;
	REP (i, N-1) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	REP (i, N) dp[i][0] = dp[i][1] = -1;

	parent[0] = -1;
	REP (i, N) parent[i+1] = MAX;
	queue<int> q;
	q.push(0);
	while (!q.empty()) {
		int n = q.front(); q.pop();
		FORE (v, G[n]) {
			if (v != parent[n]) {
				parent[v] = n;
				q.push(v);
			}
		}
	}

	cout << (solve(0, 0) + solve(0, 1)) % MOD << endl;
}

Measured memory_bytes: 14592
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
#define ll  long long 
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  string a;cin>>a;
  sort(a.begin(),a.end());
  if(a[0]==a[1]&&a[2]==a[3]&&a[0]!=a[3])cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 23680
#リング的な文（a）の中に入力した文（b）を入っているか確認するプログラム
sentence=gets.chomp
keyword=gets.chomp
ring = "#{sentence}"*2             #リングになるために二つくつける
if ring.include?("#{keyword}")
    puts "Yes"   
else
    puts "No"   
end



Measured memory_bytes: 8892
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
//#define int long long
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;
#define X first
#define Y second
#define all(o) o.begin(), o.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0), cin.tie(0)

int gcd(int x,int y){ return (!y ? x : gcd(y, x%y)); }
const int maxn = 1e6;
int a[maxn];
void fin(){
	cout << -1 << endl;
	exit(0);
}
int32_t main(){
	IOS;
	int n;
	cin >> n;
	for(int i=0; i<n; i++)
		cin >> a[i];
	if(a[0])
		fin();
	ll ans = 0;
	for(int i=1; i<n; i++){
		if(a[i] > a[i - 1] + 1)
			fin();
		if(a[i] == a[i - 1] + 1)
			ans++;
		else
			ans += a[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 3e18 + 8;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 1e9;

const int maxn = 1e5 + 7;

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

    int n;
    cin >> n;
    vector<int> cnt(n+1, 0);
    for(int i = 2; i <= n; i++)
    {
        int a;
        cin >> a;
        cnt[a]++;
    }
    for(int i = 1; i <= n; i++)
        cout << cnt[i] << endl;
    return 0;
}

Measured memory_bytes: 4756
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007 
#define pb push_back
//#define mp make_pair
#define INF 2000000011LL
#define INFLL 1000000000000000011LL
#define eps 1e-9
#define pp pair < pair<ll,ll> , ll> 
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define foll(i,j,k) for(ll i=j;i<=k;i++)
#define clr(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vll vector<ll>
#define sz(a) a.size()
#define len(a) a.length()
#define all(a) a.begin(),a.end()
#define io_file freopen("Contest/input_file.in", "r", stdin); freopen("Contest/output_file.in", "w", stdout)

const int MAXN = 2e5+5;
using namespace std;
ll power(ll x, ll y)
{
  ll res = 1;
  while(y>0)
  {
    if(y&1)
       {
         res = (res*x)%mod;
        }
     x = (x*x)%mod;
     y = y>>1;
  }
    return res;
}
// std::vector<ll> divi[100004];
// void divisor(int n)
// {
//    for(ll i=1;i<=n;i++)
//    {
//      for(ll j=i;j<=n;j+=i)
//      {
//        divi[j].pb(i);
//      }
//    }
// }
ll n,m;
ll a[100005];

vector<pair<ll,ll>>v;
multiset<ll>s;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
      cin>>a[i];
      s.insert(a[i]);
    }
    for(int i=1;i<=m;i++)
    {
      ll b,c;
      cin>>b>>c;
      v.pb({c,b});
    }
    sort(all(v));
    reverse(all(v));
    ll ans = 0;
    // for(auto x : v)
    // {
    //   cout<<x.first<<" "<<x.second<<endl;
    // }
    for(int i=0;i<m;i++)
    {
      ll b= v[i].second;
      ll c = v[i].first;


      int cnt = b;
      while(cnt > 0 && s.size() > 0 && *(s.begin()) < c)
      {
        cnt--;
        s.erase(s.begin());
        ans = ans + c;
      }
    }
    while(s.size() > 0)
    {
      ans = ans + *s.begin();
      s.erase(s.begin());
    }
    cout<<ans<<endl;
    return 0;

}



Measured memory_bytes: 7928
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

int main(){
	
	int N, K;
	cin >> N >> K;
	int X[N];
	for(int i=0;i<N;i++) cin >> X[i];
	
	int tot = 0;
	for(int i=0;i<N;i++){
		tot += 2 * min(abs(X[i] - 0), abs(X[i] - K));
	}
	cout << tot << endl;
	
	
	
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;

	if (A > 8 || B > 8)
	{
		cout << ":(" << endl;
	}
	else
	{
		cout << "Yay!" << endl;
	}
	return 0;
}

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

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key   = k;
	z->left  = NIL;
	z->right = NIL;
	
	while(x != NIL) {
		y = x;
		if(z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	
	z->parent = y;
	if(y == NIL) {
		root = z;
	} else {
		if( z->key < y->key) {
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

void inorder(Node *u) {
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}
	
int main(void) {
	int n, i, x;
	string com;
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		cin >> com;
		if(com == "insert") {
			scanf("%d",&x);
			insert(x);
		} else if(com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}



Measured memory_bytes: 26748
import itertools
N = int(input())
nums = list(map(int, input().split()))

ans = 0
for x, y, z in itertools.combinations(range(N), 3):
    if nums[x] != nums[y] and nums[x] != nums[z] and nums[z] != nums[y]:
        if nums[x] > nums[y] and nums[x] > nums[z]:
            if nums[x] < nums[y]+nums[z]:
                ans += 1
        elif nums[y] > nums[x] and nums[y] > nums[z]:
            if nums[y] < nums[x]+nums[z]:
                ans += 1
        elif nums[z] > nums[x] and nums[z] > nums[y]:
            if nums[z] < nums[x]+nums[y]:
                ans += 1
print(ans)

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

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

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	vector<PLL> ba(n);
	for (int i = 0; i < n; i++) {
		int a,b;
		cin >> a >> b;
		ba[i] = {b,a};
	}
	SORT(ba);
	LL t = 0;
	for (int i = 0; i < n; i++) {
		t += ba[i].second;
		if (t > ba[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector< int > A;
bool rec(int now,int sum){
  if(!sum) return true;
  else if(now == A.size() || sum < 0 || sum < A[now]) return false;
  return rec( now + 1, sum - A[now]) || rec( now + 1, sum);
}
int main(){
  int n;
  cin >> n;
  A.resize(n);
  for(int i = 0 ; i < n ; i++ ) cin >> A[i];
  sort(A.begin(),A.end());
  int q;
  cin >> q;
  for(int i = 0 ; i < q ; i++ ){
    int M;
    cin >> M;
    cout << ( rec(0,M) ? "yes" : "no" ) << endl;
  }
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   /// https://ideone.com/Fd5s8n
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  ll ans =0;
  if(k<a)
    ans+= k;
  else if(k==a)
    ans +=a;
  else{
    ans +=a;
    k-=a;
    if(k>b){
    k-=b;

    ans += -k;
  }
  }
 cout << ans << endl;
    return 0;

}


Measured memory_bytes: 3576
import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n = int(input())

a = [int(input()) for i in range(n)]

print(lcm_list(a))



Measured memory_bytes: 5076
//#include <ext/pb_ds/assoc_container.hpp> 
 //#include <ext/pb_ds/tree_policy.hpp>
// #include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=998244353;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power(((((a)%mod)*((a)%mod))%mod),b/2)%mod;
    else return (((a)%mod)*(power(((((a)%mod)*((a)%mod))%mod),b/2)%mod))%mod;
}
inline ll inverse(ll a,ll md) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}
  
  
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution
const int ce=998244353;
ll fast_mod(ll input)
{
    return input < ce ? input : input%ce;
}
#define pi acos(-1)

int32_t main()
{
    IOS
   
    
    string s;
    cin>>s;
    int n=s.length();
    int dp[2][2019];
    memset(dp,0,sizeof(dp));

    dp[0][s[0]-'0']++;
    int ans=0;
    for(int i=1;i<n;i++)
    {
        int num=s[i]-'0';
        if(i%2!=0)
        {
            for(int j=0;j<2019;j++)
            {
                dp[1][j]=0;
            }
        }
        else
        {
            for(int j=0;j<2019;j++)
            {
                dp[0][j]=0;
            }   
        }
        for(int j=0;j<2019;j++)
        {
            if(i%2!=0)
            dp[1][(j*10+num)%2019]+=dp[0][j];
            else
            dp[0][(j*10+num)%2019]+=dp[1][j];

        }
        if(i%2!=0)
        dp[1][num]++;
        else
        dp[0][num]++;
        if(i%2!=0)
        ans+=dp[1][0];
        else
        ans+=dp[0][0];
    }
    cout<<ans<<endl;

}       


Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define error(x) cerr << #x << " = " << x << endl


int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n,m,i,j,k,sum=0;
	int a,b;
	cin>>a>>b;
	for(i=1;i<100000;i++){
		int o = i*8/100;
		int e = i*10/100;
		if(o==a&&e==b){
			cout<<i<<'\n';
			return 0;
		}
	}
	cout<<-1<<'\n';
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline int readint()
{
    char c;int tmp=0,x=1;c=getchar();
    while(!isdigit(c)){if(c=='-') x=-1;c=getchar();}
    while(isdigit(c)){tmp=tmp*10+c-'0';c=getchar();}
    return tmp*x;
}
const int maxn=500000+5;
int p[maxn],q[maxn],deg[maxn],ans[maxn],n,k;
set<int > ss;
typedef set<int >::iterator seto;
vector<int > g[maxn];
void addedge(int from,int to)
{
    g[from].push_back(to);
    deg[to]++;
}
priority_queue<int ,vector<int >,greater<int > > pq;
int main()
{
    n=readint();k=readint();
    for(int i=1;i<=n;i++) q[p[i]=readint()]=i;
    seto ite;
    for(int i=1;i<=n;i++){
        if(i-k>=1) ss.erase(p[i-k]);
        ite=(ss.insert(p[i])).first;
        if(++ite!=ss.end()) addedge(i,q[*ite]);
    }
    ss.clear();
    for(int i=n;i>=1;i--){
        if(i+k<=n) ss.erase(p[i+k]);
        ite=(ss.insert(p[i])).first;
        if(++ite!=ss.end()) addedge(i,q[*ite]);
    }
    for(int i=1;i<=n;i++) if(deg[i]==0) pq.push(i);
    int res=0;
    while(!pq.empty()){
        int tp=pq.top();pq.pop();
        ans[tp]=++res;
        for(int j=0;j<(int)g[tp].size();j++) {
            deg[g[tp][j]]--;
            if(deg[g[tp][j]]==0) pq.push(g[tp][j]);
        }
    }
    for(int i=1;i<=n;i++) printf("%d\n",ans[i]);
    return 0;
}


Measured memory_bytes: 62208
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int NIL = -1;
static const int MOD = 1000000007;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue

int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }

//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

int main() {
	char c;
	int ans = 0;
	REP(i, 3) {
		cin >> c;
		if (c == '1') {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 764