akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <stdexcept>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>

using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define fill(x, y) memset(x, y, sizeof(x))
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define itn int
#define re return
#define prev PREV
#define next NEXT

#define sz(x) ((int)x.size())

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int MAXN = 1e5 + 10;
#define FILENAME ""

const ll maxn = 500000 + 10;




int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    vector <ll> a;
    ll r = 0;
    bool f = true;
    ll temp = inf;
    for (int i = 0; i < n; i++) {
        ll x;
        cin >> x;
        a.pb(x);
        if (x == 0) {
            f = false;
        }
        else if (x < 0) {
            r++;
        }
        temp = min(temp, abs(x));
    }
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        sum += abs(a[i]);
    }
    if (!f || r % 2 == 0) {
        cout << sum;
    }
    else {
        cout << sum - 2*temp;
    }
    return 0;
}

Measured memory_bytes: 1400
h,w=map(int,input().split())
s=[input()for _ in range(h)]
x=[0,-1,-1,-1,0,1,1,1]
y=[1,1,0,-1,-1,-1,0,1]
for i in range(h):
    z=[]
    for j in range(w):
        if s[i][j]=='.':
            c=0
            for k in range(8):
                if 0<=i+x[k]<=h-1 and 0<=j+y[k]<=w-1:
                    if s[i+x[k]][j+y[k]]=='#':
                        c+=1
            z.append(c)
        else:
            z.append('#')
    print(*z,sep='')

Measured memory_bytes: 3444
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FIO ios_base::sync_with_stdio(false); cin.tie(0);
#define trav(x,a) for (auto& x: a)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define mem(a,v) memset((a), (v), sizeof (a))
#define endl "\n"
#define case(t) cout << "Case #" << (t) << ": "
#define reada(a, n) for (int _i = 0; _i < (n); _i++) read(a[_i])
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;
const double eps = 1e-9;

template<class T> void read(T& x) { cin >> x; }
template<class X, class Y> void read(pair<X,Y>& a) { read(a.first), read(a.second); }
template<class T> void read(vector<T>& x) { trav(y, x) read(y); }
template<class T, class... O> void read(T& x, O&... y) { read(x), read(y...); }

string to_string(const char& x) { return string(1,x); }
string to_string(const char*& x) { return (string)x; }
string to_string(const string& x) { return x; }
template<class T, class U> string to_string(const pair<T,U>& x) { return to_string(x.first) + " " + to_string(x.second); }
template<class T> string to_string(const vector<T>& x) { string ret = ""; bool f = 0; trav(y, x) ret += (!f ? "" : " ") + to_string(y), f = 1; return ret; }
void print() { cout << endl; }
template<class T> void pr(const T& x) { cout << to_string(x); }
template<class T, class... O> void print(const T& x, const O&... y) { pr(x); if (sizeof...(y)) pr(" "); print(y...); }

int a[N];

int main() {
  FIO
  string s; read(s); int n = sz(s)+1;
  a[0] = 0;
  for (int i = 0; i+1 < n; i++) {
    if (s[i] == '<')
      a[i+1] = a[i] + 1;
    else
      a[i+1] = a[i] - 1;
  }
  for (int i = 0, j = 0; i+1 < n; i = j) {
    for (; j+1 < n && s[i] == s[j]; j++);
    if (s[i] == '<') {
      a[i] = 0;
      for (int l = i; l < j; l++)
        a[l+1] = a[l] + 1;
    } else {
      a[i] = max(a[i], j - i);
      for (int l = i; l < j; l++)
        a[l+1] = j - l - 1;
    }
  }
  ll ans = 0, mn = 0;
  for (int i = 0; i < n; i++)
    mn = min(mn, (ll)a[i]);
  for (int i = 0; i < n; i++)
    ans += a[i] - mn;
  print(ans);
  return 0;
}


Measured memory_bytes: 5868
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_B&lang=jp
sentinel = pow(10,9) + 1
def merge(target_list, left_index, mid_index,right_index):
    
    l = target_list[left_index:mid_index] + [sentinel]
    r = target_list[mid_index:right_index] + [sentinel]
    l_target, r_target, count = 0, 0, 0
    #print(left_index, right_index, mid_index, l,r)
    for k in range(left_index, right_index):
        count += 1
        if l[l_target] < r[r_target]:
            target_list[k] = l[l_target]
            l_target += 1
        else:
            target_list[k] = r[r_target]
            r_target += 1

    return count
    #print(target_list)
            
def merge_sort(target_list, left_index, right_index):
    count = 0
    if left_index + 1 < right_index:
        mid_index = (left_index + right_index) // 2

        count += merge_sort(target_list, left_index, mid_index)
        count += merge_sort(target_list, mid_index, right_index)
        count += merge(target_list, left_index, mid_index,right_index)
        
    return count
if __name__ == "__main__":
    l = input()
    target_list = [int(a) for a in input().split()]
    count = merge_sort(target_list, 0, len(target_list))
    print(" ".join([str(n) for n in target_list]))
    print(count)

Measured memory_bytes: 69040
#include <bits/stdc++.h>
using namespace std;
#define array_input int n;cin>>n;int a[n+1],i;for(i=1;i<=n;i++){cin>>a[i];}
#define array_output for(i=1;i<=n;i++){cout<<a[i]<<" ";}cout<<endl;
#define INF 2147483647
#define long_INF 18446744073709551615
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
const double pi=acos(-1);
const double eps=1e-6;

int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	cout<<n/3<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define debug(x) cout << #x << " = " << (x) << endl;
#define MOD 1000000007
//#define MOD 998244353
#define EPS (1 >> 30)
#define INF (1 << 30)
//#define INF (1LL << 60)
#define ff first
#define se second
//#define int long long
const int dx[]={0,-1,0,1};
const int dy[]={1,0,-1,0};

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    int a,b;
    cin>>a>>b;
    if(a>=10||b>=10){
        cout<<-1<<endl;
    }
    else{
        cout<<a*b<<endl;
    }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
color = {}
f = 0
for a in A:
    if 1 <= a <= 399:
        color['g'] = 1
    elif 400 <= a <= 799:
        color['br'] = 1
    elif 800 <= a <= 1199:
        color['gr'] = 1
    elif 1200 <= a <= 1599:
        color['m'] = 1
    elif 1600 <= a <= 1999:
        color['b'] = 1
    elif 2000 <= a <= 2399:
        color['y'] = 1
    elif 2400 <= a <= 2799:
        color['o'] = 1
    elif 2800 <= a <= 3199:
        color['r'] = 1
    else:
        f += 1
print(max(1, len(color)), len(color)+f)


Measured memory_bytes: 3064
import itertools
N=int(input())
X=[str(i) for i in range(1,N+1)]
# X="1234"
s1="".join(input().split())
s2="".join(input().split())
perm=list(map("".join,itertools.permutations(X)))
print(abs(perm.index(s1)-perm.index(s2)))

Measured memory_bytes: 6052
import java.util.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        double A = sc.nextDouble();
        double B = sc.nextDouble();
        
        BigDecimal C = new BigDecimal(String.valueOf(A));
        BigDecimal D = new BigDecimal(String.valueOf(B));
		//BigDecimal E = C.setScale(0, RoundingMode.DOWN);
		        BigDecimal G = new BigDecimal(String.valueOf(C.multiply(D)));

		BigDecimal F = G.setScale(0, RoundingMode.DOWN);
		//System.out.println(ans2);
		//System.out.println(max2);
        System.out.println(F.toPlainString());
    }
}


Measured memory_bytes: 37752
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>

const long long MOD = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    llong N;
    cin >> N;
    pair<llong, llong> element;
    llong X, L;
    llong ans=0;
    llong prev;
    vector<pair<llong, llong> > Table(N);
    for(int i=0; i<N; i++){
        cin >> X >> L;
        element.first  = X+L;
        element.second = X-L; 
        Table[i] = element;
    }
    sort(Table.begin(), Table.end());
    prev = Table[0].first;
    ans++;

    for(int i=1; i<Table.size(); i++){
        if(prev<=Table[i].second){
            prev = Table[i].first;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4464
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long ans = 0;
		for(int j=0;j<60;j++){
			long c = 0;
			for(int i=0;i<N;i++){
				c += (A[i] >> j) & 1;
			}
			if(c == 0) continue;
			if(c % 2 == 1){
				ans += (1L << j);
				for(int i=0;i<N;i++){
					A[i] &= ~(1L << j);
				}
			}
		}
		
		int rank = 0;
		for(int j=60;j>=0;j--){
			int idx = -1;
			for(int i=rank;i<N;i++){
				if((A[i] >> j) % 2 == 1){
					idx = i;
					break;
				}
			}
			if(idx == -1) continue;
			var t = A[rank]; A[rank] = A[idx]; A[idx] = t;
			for(int i=0;i<N;i++){
				if(i == rank) continue;
				if((A[i] >> j) % 2 == 1){
					A[i] ^= A[rank];
				}
			}
			rank++;
		}
		
		//Console.WriteLine(String.Join(" ",A));
		
		long xtot = 0;
		for(int i=0;i<N;i++) xtot ^= A[i];
		ans += xtot * 2;
		
		Console.WriteLine(ans);
		
		
		
		
	}
	int N;
	long[] A;
	public Sol(){
		N = ri();
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 34140
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
  int ans = 0;
  string s; cin>>s;
  char c = s[0];
  for(int i = 1; i < s.length(); i++) {
    if(c != s[i]) {
      ans++;
      c = s[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
N,A,B,C=list(map(int,input().split()))
l=[]
for i in range(N):
    l.append(int(input()))
    
def three_value(l,N,i,s0,s1,s2,A,B,C,sig):
    if i!=N:
        if sig[i]:
            return min(three_value(l,N,i+1,s0+l[i],s1,s2,A,B,C,sig),three_value(l,N,i+1,s0,s1+l[i],s2,A,B,C,sig),three_value(l,N,i+1,s0,s1,s2+l[i],A,B,C,sig))
        else:
            return three_value(l,N,i+1,s0,s1,s2,A,B,C,sig)
    else:
        if s0 == 0 or s1==0 or s2==0:
            return 10**27
        else:
            return min(abs(s0-A)+abs(s1-B)+abs(s2-C),abs(s0-A)+abs(s2-B)+abs(s1-C),abs(s1-A)+abs(s0-B)+abs(s2-C),
                   abs(s1-A)+abs(s2-B)+abs(s0-C),abs(s2-A)+abs(s0-B)+abs(s1-C),abs(s2-A)+abs(s1-B)+abs(s0-C))
def two_value(l,N,i,A,B,C,sig,num):
    if i!=N:
        sig1 = list(sig)
        sig2=list(sig)
        sig1[i]=True
        return min(two_value(l,N,i+1,A,B,C,sig1,num+1),two_value(l,N,i+1,A,B,C,sig2,num))
    else:
        if num>2:
            return three_value(l,N,0,0,0,0,A,B,C,sig)+(num-3)*10
        else:
            return 10**27
sig=[False for i in range(N)]
print(two_value(l,N,0,A,B,C,sig,0))
        

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

int main() {
    int a,b;
    cin >> a >> b;
    for(int i = 0; i <= 1010; i++){
        int eight = 0.08 * (double)i;
        int ten = 0.1 * (double)i;
        if(eight == a && ten == b){
            cout << i << endl;
            return 0;
        }
    }
    puts("-1");
}

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

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		int period = Integer.parseInt(new BufferedReader(new InputStreamReader(System.in), 128).readLine());
		int val = 100;//壱百千円
		for (; 0 < period; period--) {
			val = (int) Math.ceil(val * 1.05);
		}
		System.out.println(val * 1000);
	}
}

Measured memory_bytes: 17020
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int a,b,c,n,ans; 
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	in(a);in(b);in(c);in(n);
	for(int i=0;i<=a;i++)
	for(int j=0;j<=b;j++)
	for(int k=0;k<=c;k++)
	if(i*500+j*100+k*50==n)ans++;
	printf("%lld\n",ans);
	return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    int s = b - a;
    int sum = 0;
    for (int i = s; i >= 1; i--) {
        sum += i;
    }
    cout << sum - b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; k < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
ll gcd(ll a, ll b) { // a > b
  if(a<b) swap(a,b);
  ll c = -1;
  while(c != 0){
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}

int main() {
  ll N,M;
  cin >> N >> M;
  string s,t;
  cin >> s;
  cin >> t;
  ll l = ((N * M) / gcd(N,M));
  int g = gcd(N,M);
  int n = l / N;
  int m = l / M;
  rep(i,g) {
    if(s[m*i] != t[n*i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << l << endl;
  return 0;
}

Measured memory_bytes: 512
#pragma comment(linker, "/STACK:1000000000")
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <memory>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <ctime> 
#include <stack>
#include <iostream>

#define mp make_pair
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

const int MAXN = 200010;

const int LG = 22;
int x[MAXN];
int p[MAXN][LG];
int f[MAXN * 3];
int v[MAXN], vs = 0;
int f2[MAXN * 3];
int p2[MAXN][LG];

int main() {
	ios_base::sync_with_stdio(0);
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	int n;
	scanf("%d%d", &n, v);
	vs = 0;
	while (v[vs] > 0) {
		v[vs + 1] = v[vs] / 2;
		vs++;
	}
	vs++;
	for (int i = 0; i < n; i++) {
		scanf("%d", x + i);
	}
	for (int i = 0; i < vs; i++) {
		p[n][i] = p[n - 1][i] = n;
		for (int j = n - 2; j >= 0; j--) {
			if (x[j + 1] - x[j] > v[i]) p[j][i] = j + 1;
			else p[j][i] = p[j + 1][i];
		}
	}
	for (int i = 0; i < vs; i++) {
		p2[0][i] = p2[1][i] = 0;
		for (int j = 2; j <= n; j++) {
			if (x[j - 1] - x[j - 2] > v[i]) p2[j][i] = j - 1;
			else p2[j][i] = p2[j - 1][i];
		}
	}
	memset(f, 0, sizeof(f));
	for (int i = 0; i < (1 << vs); i++) {
		for (int j = 0; j < vs; j++) {
			if (i & (1 << j)) continue;
			int nv = i + (1 << j);
			f[nv] = max(f[nv], p[f[i]][j]);
		}
	}
	for (int i = 0; i < (1 << vs); i++) f2[i] = n;
	for (int i = 0; i < (1 << vs); i++) {
		for (int j = 0; j < vs; j++) {
			if (i & (1 << j)) continue;
			int nv = i + (1 << j);
			f2[nv] = min(f2[nv], p2[f2[i]][j]);
		}
	}
	int msk = (1 << vs) - 1;
	if (f[msk] < n) {
		for (int i = 0; i < n; i++) printf("Impossible\n");
		return 0;
	}
	int l, r;
	for (l = 0; l != n; l = r) {
		r = p[l][0];

		bool ok = false;
		for (int i = 0; i < (1 << vs); i++) {
			if (i & 1) continue;
			if ((f[i] >= l) && (f2[msk - 1 - i] <= r)) 
				ok = true;
		}
		for (int i = l; i < r; i++) {
			if (!ok) printf("Impossible\n");
			else printf("Possible\n");
		}
	}
	return 0;
}

Measured memory_bytes: 43008
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
#A = [LIST() for i in range(3)]
A = LIST()
B = LIST()
C = LIST()
A.sort()
B.sort()
C.sort()
ans = 0
for b in B:
    a = bisect_left(A, b)
    c = bisect_right(C, b)
    right = N - c
    ans += a * right
print(ans)




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

int main() {
  int n;
  cin >> n;
  vector<long long>data(n);
  for(int i = 0;i < n;i++){
    cin >> data[i];
  }
  if(n%2 == 0){
    for(int i = n-1;i >= 1;i -= 2){
      cout << data[i] << " ";
    }
    for(int i = 0;i < n;i += 2){
      cout << data[i] << " ";
    }
    cout << "" << endl;
    return 0;
  }
  else{
    for(int i = n-1;i >= 0;i -= 2){
      cout << data[i] << " ";
    }
    for(int i = 1;i < n;i += 2){
      cout << data[i] << " ";
    }
    cout << "" << endl;
    return 0;
  }
}


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

 using namespace std;

 int main() {
   int N, M, X, i;

   cin >> N >> M >> X;

   vector<int> A(M + 1);

   for (i = 1; i <= M; i++) cin >> A.at(i);

   int left, right;
   left = 0;

   for (i = 1; i <= M; i++) {
      if (A.at(i) < X) left++;
      else break;
   }
   cout << min(left, M - left) << endl;
}


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

//#define int long long
typedef pair<int, int> P;

int T[111111];
int N;
int K;

signed main() {   
    string s;
    cin >> s;
    cin >> K;
    N = s.size();
    for(int i = 0; i < N; ++i) {
        T[i] = s[i] - 'a';
    }

    int kk = K;
    for(int i = 0; i < N-1; ++i) {
        if(T[i] != 0 && 26 - T[i] <= kk) {
            kk -= (26 - T[i]);
            T[i] = 0;
        }
    }

    T[N-1] = (T[N-1] + kk) % 26;

    for(int i = 0; i < N; ++i) {
        char c = T[i] + 'a';
        cout << c;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 896
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define y1 Y1
using namespace std;
const int maxn=200005,inf=1e8;
const double qarc=acos(-1)*5.0;
int n,cnt,x1,x2,y1,y2;
int f[maxn],g[maxn],b[maxn];
struct p{int x,y;}a[maxn];
inline int read(){
    int x=0,f=1;char ch=getchar();
    for(;ch<'0'||ch>'9';f=ch=='-'?-1:1,ch=getchar());
    for(;ch>='0'&&ch<='9';x=x*10+ch-48,ch=getchar());
    return x*f;
}
bool cmp(p a,p b){return a.x<b.x;}
int main(){
    x1=read();y1=read();x2=read();y2=read();n=read();
    for(int i=1;i<=n;i++)a[i].x=read(),a[i].y=read();
    if(x1>x2){
        x1=inf-x1;x2=inf-x2;
        for(int i=1;i<=n;i++)a[i].x=inf-a[i].x;
    }
    if(y1>y2){
        y1=inf-y1;y2=inf-y2;
        for(int i=1;i<=n;i++)a[i].y=inf-a[i].y;
    }
    sort(a+1,a+n+1,cmp);
    int tot=0,ans1=0;
    for(int i=1;i<=n;i++)
        if(a[i].x>=x1&&a[i].x<=x2&&a[i].y>=y1&&a[i].y<=y2)
            b[++tot]=a[i].y;
    for(int i=1;i<=tot;i++){
        f[i]=lower_bound(g+1,g+ans1+1,b[i])-g;
        if(f[i]>ans1)ans1=f[i],g[ans1]=b[i];
        else g[f[i]]=min(g[f[i]],b[i]);
    }
    double ans=(double)(x2+y2-x1-y1)*100.0;
    ans-=ans1*(20-qarc);
    if(ans1==min(y2-y1+1,x2-x1+1))ans+=qarc;
    printf("%.15lf",ans);
    return 0;
}

Measured memory_bytes: 4096
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#define RG register
#define IL inline
#define inf 2147483640
#define LL long long
#define pi acos(-1.0)
#define db double
using namespace std;
IL int gi()
{
	RG int res=0,w=1;
	RG char ch;
	for(ch=getchar();(ch<'0'||ch>'9')&&ch!='-';ch=getchar());
	if(ch=='-') w=-1,ch=getchar();
	for(;ch>='0'&&ch<='9';ch=getchar()) res=10*res+ch-48;
	return res*w;
}
int n,k;LL ans=0;
LL a[100005],b[100005],dep[100005*50];
int ch[100005*50][2],num;LL sum[100005*50];
IL void ins(RG int p,RG LL x,RG LL v) {
	if(dep[p]==-1) {sum[p]+=v;return;}
	if(x&(1<<dep[p])) {
		if(ch[p][1]) ins(ch[p][1],x,v);
		else ch[p][1]=++num,dep[num]=dep[p]-1,ins(num,x,v);
	}
	else {
		if(ch[p][0]) ins(ch[p][0],x,v);
		else ch[p][0]=++num,dep[num]=dep[p]-1,ins(num,x,v);
	}
	sum[p]=sum[ch[p][0]]+sum[ch[p][1]];
}
IL int merge(RG int r1,RG int r2) {
	if(!r1||!r2) return r1+r2;
	ch[r1][0]=merge(ch[r2][0],ch[r1][0]);
	ch[r1][1]=merge(ch[r2][1],ch[r1][1]);
	sum[r1]+=sum[r2];
	return r1;
}
IL void dfs(RG int p,RG LL k) {
	if(dep[p]==-1) {ans=max(ans,sum[p]);return;}
	if(k&(1<<dep[p])) {
		ans=max(ans,sum[ch[p][0]]);
		RG int rt=merge(ch[p][0],ch[p][1]);
		dfs(rt,k);
	}
	else dfs(ch[p][0],k);
}
IL void work()
{
	num++; dep[num]=30; dep[0]=-1;
	for(RG int i=1;i<=n;++i) ins(1,a[i],b[i]);
	dfs(1,k);
	printf("%lld",ans);
}
int main()
{
	//freopen("2.in","r",stdin);
	//freopen("2.out","w",stdout);
	n=gi(),k=gi();
	for(RG int i=1;i<=n;++i) a[i]=gi(),b[i]=gi();
	work();
	//fclose(stdin);fclose(stdout);
	return 0;
}

Measured memory_bytes: 38656
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>
 
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    
    if(k>=n){
        cout << "unsafe" << endl;
    }
    
    else cout << "safe" << endl;
    
    return 0;
}



Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
  int N;
  while (cin >> N) {
    vector<ll> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
    vector<int> ind(N);
    iota(ind.begin(), ind.end(), 0);
    sort(ind.begin(), ind.end(), [&](int a, int b) {
      return A[a] + B[a] > A[b] + B[b];
    });
    ll res = 0;
    for (int i = 0; i < N; i++) {
      int j = ind[i];
      if (i % 2 == 0) {
        res += A[j];
      } else {
        res -= B[j];
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define pr        pair<int,int>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define mape map<int,int>
const ll mod=1e9+7;
const int N=2e5+5;
//cout << fixed << setprecision(6) <<
using namespace std;
int main()
{
    int ans,temp;
    FOR(i,1,5)
    {
     cin>>temp;
     if(temp==0)
     ans=i;
    }
    cout<<ans;
}

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

int n, m;
string s;

int cnt[3005];
int mx[3005], mn[3005];
int dp[3005][3005];
signed main()
{
	cin>>n>>m>>s;
	for(int i=1; i<=n; i++)
	{
		cnt[i]=cnt[i-1]+(s[i-1]=='1');
		mx[i]=cnt[i], mn[i]=cnt[i];
	}
	for(int i=1; i<=m; i++)
	{
		int l, r;
		cin>>l>>r;

		int lol=mn[r]-mn[l-1], lel=mx[r]-mx[l-1];

		for(int j=l; j<=r; j++)
		{
			mn[j]=min(mn[j], mn[l-1]+max(0ll, lol-(r-j)));
			mx[j]=max(mx[j], mx[l-1]+min(j-l+1, lel));
		}
	}
	// for(int i=1; i<=n; i++)
	// {
	// 	cout<<mx[i]<<" "<<mn[i]<<endl;
	// }
	dp[0][0]=1;
	for(int i=1; i<=n; i++)
	{
		for(int j=mn[i]; j<=mx[i]; j++)
		{
			if(j>0)
			{
				dp[i][j]=dp[i-1][j-1]+dp[i-1][j];
			}
			else
			{
				dp[i][j]=dp[i-1][j];
			}
			dp[i][j]%=1000000007;
		}
	}
	cout<<dp[n][cnt[n]];
}

Measured memory_bytes: 68352
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    n, m = map(int, readline().split())
    div = []
    for i in range(1, int(m**0.5)+1): 
        if m%i == 0:
            div.append(i)
            div.append(m//i)

    ans = 0
    for d in div:
        if m//n >= d:    
            ans = max(ans, d)
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, x[105], ans = 1e9;
int main(){
	scanf("%d", &n);
	rep(i,n) scanf("%d", x+i);
	rep(p,101){
		int cost = 0;
		rep(i,n) cost += (x[i] - p) * (x[i] - p);
		ans = min(ans,cost);
	}
	printf("%d\n",ans);
}

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

long long N;
long long Q;
long long A[100000];
long long X[100000];

bool lt(int x, int a, int b){
	if(b < 0 || b >= N) return true;
	if(a < 0 || a >= N) return false;
	long long d1 = abs(x - A[a]);
	long long d2 = abs(x - A[b]);
	if(d1 < d2) return true;
	if(d1 == d2) return a < b;
	return false;
}

int main(){
	scanf("%lld",&N);
	scanf("%lld",&Q);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	for(int i = 0 ; i <= Q-1 ; i++){
		scanf("%lld",&X[i]);
	}

	long long sumN[N+1], sum[N+1];
	sumN[0] = 0;
	sumN[1] = A[0];
	for (int i = 2; i <= N; i++) {
		sumN[i] = sumN[i-2] + A[i-1];
	}
	sum[0] = 0;
	for (int i = 1; i <= N; i++) sum[i] = sum[i-1]+A[i-1];
	for (int q = 0; q < Q; q++) {
		long long ok = 1, ng = N+1;
		long long mid;
		while (ng - ok > 1) {
			mid = (ng + ok) / 2;
			long long midDivTwo = mid / 2;
			if (midDivTwo*2 < mid) midDivTwo++;
			if ((abs(A[N-midDivTwo]-X[q])>abs(A[N-mid]-X[q])) || (abs(A[N-midDivTwo]-X[q])==abs(A[N-mid]-X[q]) && N-midDivTwo > N-mid)) {
				ok = mid;
			} else {
				ng = mid;
			}
	 	}
		long long res = 0;
		long long okDivTwo = ok / 2;
		if (okDivTwo*2 < ok) okDivTwo++;
		res += sum[N]-sum[N-okDivTwo];
		if (ok % 2 == 0 && N-ok >= 0) {
			res += sumN[N-ok];
		} else if (N-ok-1 >= 0) {
			res += sumN[N-ok-1];
		}
		printf("%lld\n",res);
	}


	return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 2000000000
typedef long long ll;
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}



int main() {
    int A,B ,ans= 1;
    string S,T;

    cin >> A >> B;
    if(B==1){
        cout << 0 << endl;
        return 0;
    }
    while(1){
        B-=A;
        if(B <= 0) break;
        ans++;
        B+=1;
    }
    cout << ans << endl;
    
    
    return 0;
    

}

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

int main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n; vector <int> v(n + 1);
	int ans = 0, cnt= 0;
	for(int i = 1; i <= n; i++) {
	 	int x; cin >> x;
	 	if((i & 1) && (x & 1)) {
	 		++cnt;
	 	}
	}
	cout << cnt << endl;
}

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

Measured memory_bytes: 580
#!/usr/bin/env python3
import sys


def solve(M: int, D: int):
    ans = 0

    for i in range(1,M+1):
        for j in range(22, D+1):
            d10 = j//10
            d1 = j%10
            if d10 >= 2 and d1 >= 2 and d10*d1 == i:
                ans += 1

    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    M = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(M, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
a = list(map(int,input().split()))
results = [int(input()) for i in range(a[2])]

points = [a[1]] * a[0]
points = list(map(lambda x: x - a[2], points))

for result in results:
    points[result - 1] = points[result - 1] + 1


for point in points:
    if point > 0:
        print('Yes')
    else:
        print('No')
    

Measured memory_bytes: 11820
#include <iostream>
using namespace std;
void BubbleSort(int *pa,int n){
	bool flag=true;
	int b=0,c=0;
	while(flag){
		flag=false;
		for(int i=n-1;i>=1;i--){
			if(*(pa+i)<*(pa+i-1)){
				b=*(pa+i); *(pa+i)=*(pa+i-1); *(pa+i-1)=b;
				flag=true;
				c++;
			}
		}
	}
}
int main(){
	int n=0,m=0,sum=0;
	cin>>n>>m;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	BubbleSort(a,n);
	for(int i=n-1;i>=(n-m);i--)sum+=a[i];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
ans = []
i = 1
while True:
    if N > 26 ** i:
        N -= 26 ** i
        i += 1
    else:
        break

N = N-1


for j in range(i):
    a = N // (26 ** (i-j-1))
    ans.append(a)
    N -= (26 ** (i-j-1)) * a

ch = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
dic = {}
for i in range(26):
    dic[i+1] = ch[i]

for i in range(len(ans)):
    ans[i] = dic[ans[i]+1]

print(''.join(ans))

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

int main(void) {
    int n, m;
    int popular_items = 0;
    int sum = 0;
    std::vector<int> a;

    std::cin >> n >> m;

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

    for(int i = 0; i < n; i++) {
        if(m > 0 && a[i] >= ((double)sum/(4*m))) {
            popular_items++;
        }
    }

    if(m > 0 && popular_items >= m) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


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

max_cakes = N // 4
max_donuts = N // 7

Found = False

for i in range(max_cakes + 1):
    for j in range(max_donuts + 1):
        if i * 4 + j * 7 == N:
            Found = True
            break
    else:
        continue
    break

print('Yes' if Found else 'No')



Measured memory_bytes: 2940
#include <stdio.h>
#include <iostream>

using namespace std;

int main(){
  int A,B,C,temp;
  scanf("%d %d %d",&A,&B,&C);
  
  temp=C-(A-B);
  if(temp<=0){
    printf("0");
  }
  else{
    printf("%d",temp);
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define MAXI(vec)                                                              \
  std::distance(vec.begin(), *std::max_element(vec.begin(), vec.end()));
#define MINI(vec)                                                              \
  std::distance(vec.begin(), *std::min_element(vec.begin(), vec.end()));
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define MATMUL(a, b, c)                                                        \
  REP(i, a.size())                                                             \
  REP(j, b[0].size()) REP(k, a[0].size()) c[i][j] += a[i][k] * b[k][j];
#define CLA2(a) REP(i, a.size()) REP(j, a[0].size()) a[i][j] = 0;
#define REV(T) greater<T>()

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

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

ll factorial(int n) {
  ll ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll P(int n, int m) {
  ll ans = 1;
  for (int i = m + 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll power(int n, int m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = power(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * power(n, m - 1)) % MOD;
  }
}
ll C(int n, int m) {
  return (P(n, n - m) * power(factorial(m), MOD - 2)) % MOD;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ll N, ans = 0;
  vector<ll> A, B, C;
  ll count = 0;
  cin >> N;
  ll a, b;
  REP(i, N) {
    cin >> a;
    A.push_back(a);
  }
  REP(i, N) {
    cin >> b;
    B.push_back(b);
  }
  REP(i, N) {
    if (B[i] - A[i] > 0) {
      count += B[i] - A[i];
      ans++;
    }
    C.push_back(A[i] - B[i]);
  }
  sort(ALL(C));
  for (ll i = N - 1; i >= 0; i--) {
    if (C[i] <= 0 || count <= 0)
      break;
    else {
      count -= C[i];
      ans++;
    }
  }
  if (count > 0)
    cout << -1 << endl;
  else
    cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	int cur = 0;
	int tmp = 0;
	int res = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'C') {
			res += cur;
			cur = 0;
			tmp = 0;
		}
		else if (S[i] == 'A') {
			tmp++;
		}
		else if (S[i] == 'B') {
			if (i + 1 < (int)S.size() && S[i + 1] == 'C') {
				cur += tmp;
				i++;
			}
			else {
				res += cur;
				cur = 0;
				tmp = 0;
			}
		}
	}
	res += cur;
	cout << res << endl;
}

Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> L(N,0);

    for(int i=0;i<N;i++){
        cin >> L[i];
    }

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

    int sum=0;
    
    for(int i=0;i<N-1;i++){
        sum += L[i];
    }

    cout << (sum>L[N-1] ? "Yes" : "No") <<endl;

    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
 
using namespace std;
 
typedef long long ll;

#define FOR(i, a) for (int i = 0; i < a; i++)
#define PB push_back
#define ff first
#define se second
#define all(a) begin(a),end(a)
typedef vector<int> VI;
const ll mod = 1e9 + 7;
void solve() {
    string s;
    cin >> s;
    if (s >= "A" && s <= "Z") {
        cout << "A";
    } else {
        cout << "a";
    }
    return;
}

// int Depth(BitTree T) {
//     int l_depth = 0, r_depth = 0;
//     // if (root == NULL) return 0;
//     else {
//         l_depth = Depth(T.lrchild) + 1;
//         r_depth = Depth(T.rchild) + 1;
//     }
//     return l_depth > r_depth ? l_depth : r_depth;
// }

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


Measured memory_bytes: 3128
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    if(a <= 8 && b <= 8) cout << "Yay!" << endl;
    else cout << ":(" << endl;

    return 0;
}


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

#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;

int main(void){

  ll N;
  cin >> N;
  vector<string> kehin;
  kehin.clear();
  
  rep(i,N){
    string s;
    cin >> s;
    kehin.push_back(s);
  }
  
  sort(kehin.begin(),kehin.end());
  
  ll counter=0;
  string STR="";
  
  rep(i,kehin.size()){
    if(kehin[i]!=STR){
      counter++;
      STR = kehin[i];
    }
  }
  
  cout << counter;

  return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  char c[2*h][w];
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> c[i*2][j];
      c[i*2+1][j] = c[i*2][j];
    }
  }
  
  for(int i = 0; i < 2*h; i++){
    for(int j = 0; j < w; j++){
      cout << c[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#include<iostream>
#include<algorithm>
using namespace std;

bool p[1000100];

void erato(){
    fill(p, p+1000100, true);
    p[0] = p[1] = false;

    for(int i=0; i < 1000100; i++){
        if(!p[i]) continue;
        for(int j=i+i; j < 1000100; j += i){
            p[j] = false;
        }
    }
}

int main(){
    erato();
    int n;
    while(cin >> n){
        for(int i=n-1; ; i--)if(p[i]){cout << i << " ";break;}
        for(int i=n+1; ; i++)if(p[i]){cout << i << endl; break;}
    }
}

Measured memory_bytes: 2132
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#define ll long long
#define maxn 500010
inline ll read()
{
    ll x=0; char c=getchar(),f=1;
    for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
    for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
    return x*f;
}
inline void write(ll x)
{
    static int buf[20],len; len=0;
    if(x<0)x=-x,putchar('-');
    for(;x;x/=10)buf[len++]=x%10;
    if(!len)putchar('0');
    else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
struct Data{
	ll v,w;
	friend bool operator < (Data a,Data b){return a.v!=b.v?a.v<b.v:a.w<b.w;}
}a[maxn],b[maxn],t1[maxn],t2[maxn];
int v[maxn],w[maxn];
int n,q;
ll solve(int now,int L)
{
	static int x[20],y[20],cnt;
	cnt=0;
	while(now){
		x[++cnt]=v[now]; y[cnt]=w[now];
		now>>=1;
	}
	// for(int i=1;i<=cnt;i++)
	// 	printf("P %d : %d %d\n",i,x[i],y[i]);
	int k=(cnt+1)/2;
	a[0]=(Data){0,0};
	for(int i=1;i<=k;i++){
		for(int j=0;j<1<<(i-1);j++){
			t1[j]=a[j];
			t2[j]=(Data){a[j].v+x[i],a[j].w+y[i]};
		}
		// for(int j=0;j<1<<(i-1);j++)
		// 	printf("T1 : %d %d\n",t1[j].v,t1[j].w);
		// for(int j=0;j<1<<(i-1);j++)
		// 	printf("T2 : %d %d\n",t2[j].v,t2[j].w);
		int p1=0,p2=0;
		while(p1<1<<(i-1)&&p2<1<<(i-1)){
			if(t1[p1]<t2[p2])a[p1+p2]=t1[p1],++p1;
			else a[p1+p2]=t2[p2],++p2;
		}
		while(p1<1<<(i-1))a[p1+p2]=t1[p1],++p1;
		while(p2<1<<(i-1))a[p1+p2]=t2[p2],++p2;
		// for(int j=0;j<1<<i;j++)
		// 	printf("%d %d\n",a[j].v,a[j].w);
	}
	b[0]=(Data){0,0};
	for(int i=k;i<=cnt;i++){
		for(int j=0;j<1<<(i-k-1);j++){
			t1[j]=b[j];
			t2[j]=(Data){b[j].v+x[i],b[j].w+y[i]};
		}
		int p1=0,p2=0;
		while(p1<1<<(i-k-1)&&p2<1<<(i-k-1)){
			if(t1[p1]<t2[p2])b[p1+p2]=t1[p1],++p1;
			else b[p1+p2]=t2[p2],++p2;
		}
		while(p1<1<<(i-k-1))b[p1+p2]=t1[p1],++p1;
		while(p2<1<<(i-k-1))b[p1+p2]=t2[p2],++p2;
	}
	int tot1=-1,tot2=-1;
	for(int i=0;i<1<<k;i++)
		if(tot1==-1||a[i].w>a[tot1].w)a[++tot1]=a[i];
	for(int i=0;i<1<<(cnt-k);i++)
		if(tot2==-1||b[i].w>b[tot2].w)b[++tot2]=b[i];
	int p=tot2;
	ll ans=0;
	for(int i=0;i<=tot1;i++){
		while(p>=0&&a[i].v+b[p].v>L)--p;
		if(p>=0)ans=std::max(ans,a[i].w+b[p].w);
		// printf("%d %d %lld %lld\n",i,p,a[i].v+b[p].v,a[i].w+b[p].w);
	}
	// for(int i=0;i<=tot1;i++)
	// 	printf("A %d : %lld %lld\n",i,a[i].v,a[i].w);
	// for(int i=0;i<=tot2;i++)
	// 	printf("B %d : %lld %lld\n",i,b[i].v,b[i].w);
	return ans;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		w[i]=read(),v[i]=read();
	q=read();
	for(int i=1;i<=q;i++){
		int x=read(),L=read();
		writeln(solve(x,L));
	}
	return 0;
}

Measured memory_bytes: 3612
n=int(input())
l=[0]*(6*n)
for x in range(1,int((n+1)**0.5)):
    for y in range(1,int((n+1)**0.5)):
        for z in range(1,int((n+1)**0.5)):
            l[(x**2 + y**2 + z**2 + x*y + y*z + z*x )-1]+=1
for i in range(n):
    print(l[i])

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

#define all(x) (x).begin(),(x).end()
#define fastio ios_base::sync_with_stdio(false)

typedef double db;
typedef long long ll;
typedef unsigned long long ull;

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

int main() {
	fastio;
	string s; cin >> s;
	string ans = ((s[2] == s[3]) and (s[4] == s[5])) ? "Yes" : "No";	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N,K = map(int,input().split())

    res = 1

    while True:
        temp1 = K ** res
        temp2 = K ** (res-1)
        if (N >= temp2) & (N < temp1):
            break
        res += 1

    print(res)



main()


Measured memory_bytes: 2940
import java.util.regex.*;class Main{public static void main(String[]z)throws Exception{String r;for(byte[]x=new byte[12];System.in.read(x)>11;System.out.println(r)){r="NA";for(String y:"b w".split(" "))for(int i=0;i<5;++i)if(i!=1&&Pattern.compile(String.format(".*%1$s.{%2$s}%1$s.{%2$s}%1$s.*",y,i),Pattern.DOTALL).matcher(new String(x)).matches())r=y;}}}

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

int main(void){
  int N;
  cin >> N;
  int X[N];
  for(int i = 0; i < N; i++)
    cin >> X[i];
  int M;
  cin >> M;
  int A[M];
  for(int i = 0; i < M; i++)
    cin >> A[i];
  for(int i = 0; i < M; i++){
    if(X[A[i]-1]+1 == X[A[i]]){
      continue;
    }
    else{
      if(X[A[i]-1] == 2019){
	continue;
      }
      else{
	X[A[i]-1] += 1;
      }
    }
  }
  for(int i = 0; i < N; i++){
    cout << X[i] << "\n";
  }
  return 0;
}


Measured memory_bytes: 3120
def gcd(m, n):
  while n:
    m, n = n, m%n
  return m

def ans():
  N = int(input())
  A = list(map(int,input().split()))
  tmp = A[0]
  for i in range(1,N):
    tmp = gcd(A[i], tmp)
  print(tmp)
ans()

Measured memory_bytes: 14252