akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e10;
const ll MOD = 100000000;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 100;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    ll n,a,b;
    cin >> n >> a >> b;
    vector<ll> v(n),u(a);
    vector<vector<ll>> dp(51,vector<ll>(51,0));
    dp[0][0] = 1;
    rep(i,1,51){
        for(ll j = 0;j <= i;j++){
            dp[i][j] += dp[i-1][j];
            if (j > 0) dp[i][j] += dp[i-1][j-1];
        }
    }
    cins(all(v));
    RSORT(v);
    bool f = 1;
    double avg = 0;
    rep(i,a){
        u[i] = v[i];
        avg += v[i];
        if (u[i] != u[0]) f = 0;
    }
    ll ans = 0;
    if (f){
        ll c = 0;
        rep(i,n) if (v[i] == u[0]) c++;
        ll k = min(c,b);
        rep(i,a,k+1) ans += dp[c][i];
    }
    else{
        ll c1 = 0,c2 = 0;
        rep(i,a) if (u[i] == u[a-1]) c1++;
        rep(i,n) if (v[i] == u[a-1]) c2++;
        ans = dp[c2][c1];
    }
    double s = avg/a;
    cout << setprecision(20) << s << endl;
    PRINT(ans);
}


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

ll N, K, AI, A[200005];

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

	cin >> N >> K;
	for (ll i = 0; i < N; i++) {
		cin >> AI;
		A[AI]++;
	}
	sort(A, A+200005);
	ll cnt = 0;
	for (ll i = 0; i < 200005; i++) {
		if (A[i] > 0) cnt++;
	}
	ll ans = 0;
	for (ll i = 0; i < 200005; i++) {
		if (A[i] > 0 && cnt > K) {
			ans += A[i];
			cnt--;
		}
	}

	cout << ans << "\n";

}

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

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);   cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    int a, b, c;
    cin >> a >> b >> c;
    cout << (a / b + ((a % b)? 1 : 0)) * c;
}


Measured memory_bytes: 3644
#!/usr/bin/env python3
import sys
from itertools import groupby

def solve(S: str):
    return max(map(len, map(lambda x: tuple(x[1]), filter(lambda x: x[0], groupby(S, lambda x: x in 'ATGC')))), default=0)

                          


# 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()
    S = next(tokens)  # type: str
    print(solve(S))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
s=str(input())
s=list(s)
temp=[]
i=0
for i in range(0,len(s)):
  if s[i]=="1":
    temp.insert(0,"1")
  elif s[i]=="0":
    temp.insert(0,"0")
  else:
    if len(temp)!=0:
      del temp[0]
temp.reverse()
temp="".join(temp)
print(temp)

Measured memory_bytes: 3064
#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;
 
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
 
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)


const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

int main() 
{

    fast();
      
    // #ifndef ONLINE_JUDGE
    //         freopen("input.txt", "r", stdin);
    //         freopen("output.txt","w",stdout);
    // #endif
    cout<<setprecision(5)<<fixed;
    ll n;
    cin>>n;
    vec q(n);
    ldb s=0;
    f(i,0,n)
    {
      cin>>q[i];
      s+=1.0/q[i];
    }
    cout<<1.0/s;




  

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
	int n;
	scanf("%d", &n);

	int A[n];
	for (int i = 0; i < n; ++i) {
		int v;
		scanf("%d", &v);
		A[i] = v;
	}
//	4
//	1
//	6
//	2
//	8
//	5
//	7
//	3

//	5 length=1
//	1 length=1
//	3 length=2
//	2 length=2
//	4 length=3
	int L[n];
	L[0] = A[0];
	int length = 1;
	for (int i = 1; i < n; ++i) {
		if (L[length - 1] < A[i]) {
			L[length++] = A[i];
		} else {
// L[j] (j ??? 0 ?????? lengh-1) ????????§ A[i] ??\?????¨??????????????? j ????????? = A[i]
			for (int j = 0; j < length; ++j) {
				if (L[j] >= A[i]) {
					L[j] = A[i];
					break;
				}
			}
		}
	}

	cout << length << endl;

	return 0;
}

Measured memory_bytes: 3904
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define SORT(v) sort(v.begin(),v.end())
#define fori(i,a,b) for(ll i=a;i<b;i++)
#define M 1000000007
#define deb(x) cout<< #x << " " << x << endl;

double pi=3.14159265358979323846;

typedef pair<int,int> pii;
typedef pair<long long int, long long int>pll;
typedef vector<int>vi;
typedef vector<long long int>vl;
#define M 1000000007



int main ()
{
    ll T;
  T=1;
   //cin>>T;
    while(T--)
    {	
   ll n,k;
   cin>>n>>k;
   vl t(n);
   fori(i,0,n)cin>>t[i];
   vi dp(k+1,0);
   for(int i=1;i<k+1;i++){
   	int f=1;
   	for(int j=0;j<n;j++){
   		if(i-t[j]>=0)f*=dp[i-t[j]];
   	}
   	dp[i]=!f;
   //	deb(dp[i])
   }
   if(dp[k]==1)cout<<"First"<<endl;
   else cout<<"Second"<<endl;
   
    
    
   
    
    }
    return 0;
}


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

using namespace std;
//const int INF=0x3f3f3f3f;

int main(){
	long int n;
	
	cin>>n;
	vector<long int> a(n);
	for(long int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	long int res=0;

	res+=a[0];
 
    for(int i=2;i<n;i++)
    {
    	res+=a[i/2];
 
    	
	}
        
 
    cout<<res<<"\n";
	return 0;
}

Measured memory_bytes: 4820
n = str(input())

if len(n) == 1:
    nd = n
else:
    nd = n[-1:]

if nd == "2" or nd == "4" or nd == "5" or nd == "7" or nd == "9":
    print('hon')
elif nd == "0" or nd == "1" or nd == "6" or nd == "8":
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9120
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std;

int n;
double dp[310][310][310];

double dfs(int x3, int x2, int x1) {
    if(x3==0 && x2==0 && x1==0)
        return 0.0;
    else if(dp[x3][x2][x1]> 0)
        return dp[x3][x2][x1];
    else {
        double sum = (double)(x3 + x2 + x1);
        double ret = (double)n / sum;
        if(x3 > 0) ret += dfs(x3 - 1, x2 + 1, x1) * (double) x3 / sum;
        if(x2 > 0) ret += dfs(x3, x2 - 1, x1 + 1) * (double) x2 / sum;
        if(x1 > 0) ret += dfs(x3, x2, x1 - 1) * (double) x1 / sum;
        return dp[x3][x2][x1] = ret;
    }
}

int main() {
    cin >> n;
    int a[n], x1 = 0, x2 = 0, x3 = 0, x;
    for(size_t i = 0; i < n; i++) {
        cin >> x;
        if(x == 3) x3++;
        if(x == 2) x2++;
        if(x == 1) x1++;
    }
    dp[0][0][0] = 0;
    int i, j, k, h;
    printf("%.12f\n", dfs(x3, x2, x1));
    return 0;
}

Measured memory_bytes: 225536
// 求组合数的几种方法:(求组合数要用到逆元)
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<stack>
#include<deque>
#include<queue>
#include<map>
#include<set>
using namespace std;
typedef long long LL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 10;
LL fac[maxn];               //存储阶乘
int main(void) {
	void init();
	init();
	LL Com(LL n,LL m);
	int x,y;
	scanf("%d%d",&x,&y);
	bool flag = false;
	LL k,t;
	for(int i = 0; i <= x; i ++) {   // i是可以为 0 的
		if(2 * y - 3 * i == x) {
			t = y - 2 * i;
			k = i;
			flag = true;
			break;
		}
	}
	if(flag)
		printf("%lld\n",Com(k + t,k));
	else
		printf("0\n");
	return 0;
}
void init() {
	fac[0] = 1;
	for(LL i = 1; i < maxn; i ++) {
		fac[i] = fac[i - 1] * i % MOD;
	}
	return;
}
LL exgcd(LL a,LL b,LL &x, LL &y) {
	if(!b) {
		x = 1;
		y = 0;
		return a;
	}
	LL d = exgcd(b,a%b,x,y);
	LL z = x;
	x = y, y = z - a / b * y;
	return d;
}
LL inv(LL a,LL mod) {
	LL x,y;
	exgcd(a,mod,x,y);
	return (x % mod + mod) % mod;  // 这里是 求解的 x 就是 a 的逆元
}
LL Com(LL n,LL m) {
	return fac[n] % MOD * inv(fac[m] * fac[n - m] % MOD,MOD) % MOD;
}

Measured memory_bytes: 8064
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> res(n, 0);
    for (int i = 0; i < n - 1; ++i) {
        int x;
        cin >> x;
        res[x - 1] += 1;
    }

    for (int i = 0; i < n; ++i) {
        cout << res[i] << "\n";
    }

    return 0;
}

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

typedef long long int ll;

int main(){
	ll N, ans=0, temp;
	cin>>N;
	vector <ll> a, b, c;
	for(int i=0; i<N; i++){
		cin>>temp;
		a.push_back(temp);
	}

	for(int i=0; i<N; i++){
		cin>>temp;
		b.push_back(temp);
	}

	for(int i=0; i<N-1; i++){
		cin>>temp;
		c.push_back(temp);
	}
	
	for(int i=0; i<N; i++){
		if(i==0){
			ans+= b[a[i]-1];
		}

		else{
			ans+= b[a[i]-1];
			if(a[i]-a[i-1]==1){
				ans+= c[a[i-1]-1];
			}
		}
		//cout<<ans<<endl;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;

signed main() {
  int h,w,a,b;
    scanf("%d%d%d%d",&h,&w,&a,&b);
    	string s(a,'0');
    	string t(w-a,'1');
        s+=t;
  		string S(a,'1');
  		string T(w-a,'0');
  		S+=T;
  for(int i=0;i<h;i++){
    if(i<b){
    	//printf("%s\n",ans);
        cout<<s<<endl;
    }
    else{
    	//printf("%s\n",ans);
        cout<<S<<endl;
    }
  }
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vec(a) vector<int>a
using namespace std;
//fibonacci
int binet(int n)
{
	return (pow((1+sqrt(5)),n-1)-pow((1-sqrt(5)),n-1))/(pow(2,n-1)*sqrt(5));
}


int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	fastio
	string str,str1,str2;
	cin>>str1>>str2>>str;
	cout<<str1[0]<<str2[0]<<str[0];
	return 0;
}
	

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int A,B,K;
    cin >> K;
    cin >> A >> B;
    bool flg=false;
    for(int i=A;i<=B;i++){
        if(i%K==0){
            flg=true;
            break;
        }
    }
    if(flg==true){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
using namespace std;
int a[100010];
int main(){
	int k,n,i,x=-1;
	cin >> n >> k;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a+n);
	for(i=0;i<=n-k;i++){
		if(a[i+k-1]-a[i]<x || x==-1){
			x=a[i+k-1]-a[i];
		}
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int h, w, m, colmax=0, rowmax=0;
    cin >> h >> w >> m;
    vector<int> col(h, 0), row(w, 0);
    set<int> tmph, tmpw;
    vector<set<int>> collist(h, tmph), rowlist(w, tmpw);
    rep(i, m){
        int x, y;
        cin >> x >> y;
        col[x-1]++;
        row[y-1]++;
        colmax = max(colmax, col[x-1]);
        rowmax = max(rowmax, row[y-1]);
        collist[x-1].insert(y-1);
        rowlist[y-1].insert(x-1);
    }
    vector<int> cind, rind;
    vector<set<int>> cmax, rmax;
    rep(i, h){
        if(col[i]==colmax){
            cind.push_back(i);
            cmax.push_back(collist[i]);    
        }
    }
    rep(i, w){
        if(row[i]==rowmax){
            rind.push_back(i);
            rmax.push_back(rowlist[i]);
        }
    }
    int dis=1;
    int clen=cmax.size(), rlen=rmax.size();
    rep(i, clen){
        rep(j, rlen){
            if(cmax[i].count(rind[j])==0){
                dis = 0;
                break;
            }
        }
        if(dis==0){
            break;
        }
    }
    cout << colmax + rowmax - dis << endl;
    return 0;
}

Measured memory_bytes: 132968
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void) {
	long long int a, b, c, d;
	int i, fin;
	long long int p[4], temp;
	char buf[128], *ch;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	a = atoi(ch);
	ch = strtok(NULL, " ");
	b = atoi(ch);
	ch = strtok(NULL, " ");
	c = atoi(ch);
	ch = strtok(NULL, " ");
	d = atoi(ch);

	p[0] = a * c;
	p[1] = a * d;
	p[2] = b * c;
	p[3] = b * d;

	fin = 0;
	while(fin < 3) {
		for(i = 0; i < 3; i += 1) {
			if(p[i] < p[i + 1]) {
				fin = 0;
				temp = p[i];
				p[i] = p[i + 1];
				p[i + 1] = temp;
			} else {
				fin += 1;
			}
		}
	}

	printf("%lld\n", p[0]);

	return 0;
}


Measured memory_bytes: 2136
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int K = scan.nextInt();
		String S = scan.next();

		if (S.length() <= K) System.out.println(S);
		else System.out.println(S.substring(0, K) + "...");

 	}
}

Measured memory_bytes: 38644
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin>>n;
  VEC<int>t(n+1,0),x(n+1,0),y(n+1,0);
  REP(i,1,n+1){
    cin>>t[i]>>x[i]>>y[i];
  }
  VEC<int>tdiff(n,0),dist(n,0);
  bool ok = 1;
  REP(i,0,n){
    tdiff[i]=t[i+1]-t[i];
    dist[i]=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
    if(tdiff[i]<dist[i] || tdiff[i]%2!=dist[i]%2)ok=false;
  }
  //DUMP(tdiff,dist);
  Yes(ok);

  return 0;
}


Measured memory_bytes: 2176
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

		Scanner scan = new Scanner(System.in);

		int L = scan.nextInt();

		double hen = L / 3.0;

		System.out.println(hen * hen * hen);

	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 22736
# -*- coding: utf-8 -*-
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

ab.sort(reverse=True, key=lambda c:c[0]+c[1])

t = 0
a = 0
for i in range(n):
    if i%2==0:
        t += ab[i][0]
    else:
        a += ab[i][1]

print(t-a)


Measured memory_bytes: 32224
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
typedef struct node{
	int key;
	int pri;
	struct node *right , *left;
}Node;

Node * Delete(Node **,int);
Node * del(Node **,int);

int find(Node *p,int x)
{
	while(p!=NIL)
	{
		if(p->key==x)return 1;
		else if(p->key > x)p = p->left;
		else p = p->right;
	}
	return 0;
}

void inorder(Node *a)
{
	if(a->left!=NIL) inorder(a->left);
	printf(" %d",a->key);
	if(a->right!=NIL) inorder(a->right);
	return;
}

void preorder(Node *p)
{
	printf(" %d",p->key);
	if(p->left!=NIL) preorder(p->left);
	if(p->right!=NIL) preorder(p->right);
	return;
}

void print(Node *p)
{
	inorder(p);
	printf("\n");
	preorder(p);
	printf("\n");
	return;
}

Node * makenode(int x , int y)
{
	Node *new = malloc(sizeof(Node));
	new->key = x;
	new->pri = y;
	new->left = NIL;
	new->right = NIL;
	return new;
}

Node *rightRotate(Node *p)
{
	Node *q = p->left;
	p->left = q->right;
	q->right = p;
	return q;
}

Node *leftRotate(Node *p)
{
	Node *q = p->right;
	p->right = q->left;
	q->left = p;
	return q;
}

Node* insert(Node **t , int key, int pri)
{
	Node *new;
	if((*t)==NIL)
	return new = makenode(key,pri);
	if((*t)->key == key)
	return *t;
	
	if(key < (*t)->key)
	{
		(*t)->left = insert(&(*t)->left,key,pri);
		if((*t)->pri < (*t)->left->pri)
		(*t) = rightRotate(*t);
	}
	else{
		(*t)->right = insert(&(*t)->right,key,pri);
		if((*t)->pri < (*t)->right->pri)
		(*t) = leftRotate((*t));
	}
	return *t;
}

Node * Delete(Node **t , int key)
{
	if((*t)==NIL)
	return NIL;
	
	if(key < (*t)->key)
	(*t)->left = Delete(&((*t)->left),key);
	
	else if(key > (*t)->key)
	(*t)->right = Delete(&((*t)->right),key);

	else return del(t,key);
	return *t;
}

Node * del(Node **t , int key)
{
	if((*t)->left == NIL && (*t)->right == NIL)
	{
		return NIL;
	}
	else if((*t)->left == NIL)
	{
		(*t) = leftRotate(*t);
	}
	else if((*t)->right ==NIL)
	{
		(*t) = rightRotate(*t);
	}
	else{
		if((*t)->left->pri > (*t)->right->pri)
		(*t) = rightRotate(*t);
		else
		(*t) = leftRotate(*t);
	}
	return Delete(t,key);
}

int main(void)
{
	int num ,  x, y;
	char com[8];
	Node *root = NIL;
	scanf("%d",&num);
	
	for(int i = 0; i < num; i++)
	{
		scanf("%s",com);
		switch(com[0])
		{
			case 'i':scanf("%d %d",&x,&y);
			root = insert(&root,x,y);
			break;
			case 'd':scanf("%d",&x);
			root = Delete(&root,x);
			break;
			case 'f':scanf("%d",&x);
			if(find(root,x))printf("yes\n");
			else printf("no\n");
			break;
			case 'p':print(root);
			break;
		}
	}
	return 0;
}




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

using namespace std;



int mat[3][105];
int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= 2; i++)
        for(int j = 1; j <= n; j++) cin >> mat[i][j];


    int tmp = -1;
    for(int i= 1; i <= n; i++){
        int cnt = 0;
        for(int j = 1; j <= i; j++) cnt += mat[1][j];

        for(int j = i; j <= n; j++) cnt += mat[2][j];
        tmp = max(tmp, cnt);
    }
    cout << tmp << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int a, b;
	while (cin >> a >> b) {
		if (a == 0 && b == 0) {
			break;
		}
		if (a < b) {
			cout << a << " " << b << endl;
		} else {
			cout << b << " " << a << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
long millenium(int y, int m, int  d) {
	long sum = 0;
	y -= 1; m -= 1;
	int w = y % 3;
	sum += (y - w) / 3 * (20 * 30 - 10);
	sum += w*((19 + 20) * 5);
	if ((y + 1) % 3 == 0){
		sum += m * 20;
	}
	else{
		w = m % 2;
		if (w == 0) sum += m * 39 / 2;
		else sum += (m - 1) * 39 / 2 + 20;
	}
	sum += d;
	return sum;
}
int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++){
		int y, m, d; cin >> y >> m >> d;
		cout << millenium(1000, 1, 1) - millenium(y, m, d) << endl;
	}
	return 0;
}

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

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vector<vector<t>>;
typedef long long ll;
typedef vc<int> vi;
typedef vvc<int> vvi;
typedef pair<int, int> pi;

#define uset unordered_set
#define umap unordered_map

#define endl "\n"

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()

#define all(a) a.bg, a.ed

template <class t, class u>
ostream &operator<<(ostream &os, const pair<t, u> &p) {
    return os << "( " << p.first << ", " << p.second << " )";
}

template <class t>
ostream &operator<<(ostream &os, const vc<t> &v) {
    os << "[ ";
    for (int i = 0; i < v.size(); i++) {
        os << v[i];
        if (i != v.size() - 1) {
            os << ", ";
        }
    }
    return os << " ]";
}

void compSameLength(string a, string b) {
    if (a < b) {
        cout << "LESS";
    } else if (a > b) {
        cout << "GREATER";
    } else {
        cout << "EQUAL";
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // cout << fixed << setprecision(18);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution

    // Numbers are too small
    string a, b;
    cin >> a >> b;
    if (a.length() < b.length()) {
        cout << "LESS";
    } else if (a.length() > b.length()) {
        cout << "GREATER";
    } else {
        compSameLength(a, b);
    }
}


Measured memory_bytes: 3564
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str1=Console.ReadLine().Split(' ');
      int N=int.Parse(str1[0]);
      int K=int.Parse(str1[1]);
      string[] str2=Console.ReadLine().Split(' ');
      int[] arr=new int[N];
      for(int i=0;i<N;i++){
        arr[i]=int.Parse(str2[i]);
      }
      int ans=0;
	Array.Sort(arr);
    for(int j=0;j<K;j++)  {
    ans+=arr[j];
    }
      Console.WriteLine(ans);
    }
    
  }

}

Measured memory_bytes: 27856
use proconio::input;

fn solve(d: &usize, c: &Vec<usize>, s: &Vec<Vec<usize>>, t: &Vec<usize>) -> isize {
    let mut result: isize = 0;
    let mut contested: Vec<usize> = vec![0; 26];
    for i in 0..*d {
        result += s[i][t[i]] as isize;
        contested[t[i]] = i + 1;
        result -= contested.iter()
            .enumerate()
            .map(|pair| ((i + 1 - pair.1) * c[pair.0]) as isize)
            .sum::<isize>();
    }
    result
}

fn main() {
    input! {
        d: usize,
        c: [usize; 26],
        s: [[usize; 26]; d],
    }
    let mut t: Vec<usize> = vec![0; d];
    for i in 0..d {
        input! { temp: usize, }
        t[i] = temp - 1;
    }
    input! { m: usize }
    for _ in 0..m {
        input! {
            dq: (usize, usize)
        }
        t[dq.0-1] = dq.1 - 1;
        let result = solve(&d, &c, &s, &t);
        println!("{}", result);
    }
}

Measured memory_bytes: 2844
#include <iostream>
using namespace std;
int main(){
    int a, b, c, d, max, min;
    
    while(1){c = 0;
        max = 0;
        min = 2000000000;
        cin >> a;
        if(a == 0){break;}
        for(int i=0;i<a;i++){
            cin >> b;
            if(b>max){
                max = b;
            }
            if(b<min){
                min = b;
            }
            c = c + b;
        }
        c = c - max - min;
        d = c / (a-2);
        cout << d << endl;
    }
    
    
    
    
    
    
    return 0;

}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
typedef vector<int> vi;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];
int gcd(int a,int b)
{
    if(b==0){
      return a;
     }
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    int res=(a*b)/gcd(a,b);
    return res;
}
int po(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b%2!=0)
        {
            res*=a;
            b--;
        }
        else
        {
            a*=a;
            b/=2;
        }
    }
    return res;
}

lln modMul(lln  a, lln b,lln mod){
    lln ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}
lln powerMod(lln a,lln b,lln mod){
	if(b==0)return 1LL%mod;
	lln x=powerMod( a,b/2,mod );
	x = ( x%mod * x%mod ) % mod;
	if( b%2==1 )x = ( x%mod * a%mod ) % mod;
	return x%mod;
}

int main()
{
   string a,b,c;
   cin>>a>>b>>c;
   int len=a.size();
   int len2=b.size();
   int len3=c.size();
   if(a[len-1]==b[0] && b[len2-1]==c[0] )cout<<"YES\n";
   else cout<<"NO";

}






Measured memory_bytes: 3584
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(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()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

n, k = MAP()
arr = [1 for _ in range(n)]
for i in range(k):
    d = INT()
    a = LIST()
    for j in a:
        arr[j - 1] = 0
print(sum(arr))

Measured memory_bytes: 68648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int gcd(int a, int b) {
  if(b == 0) return a;
  else return gcd(b, a%b);
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;++i) {
    cin >> a[i];
  }
  for(int i=1;i<n;++i) {
    a[i] = gcd(a[i], a[i-1]);
  }
  cout << a[n-1] << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
int n, c, s, a[100005];
int main() {
	int i, j;
	scanf("%d", &n);
	for(i=0; i<n; i++) scanf("%d", &a[i]);
	sort(a, a+n);
	for(i=0; i<n; i=j) {
		for(j=i, c=0; a[j]==a[i]; j++, c++);
		if(c>a[i]) s += c-a[i];
		else if(c<a[i]) s += c;
	}
	printf("%d", s);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using P = pair<int,int>;

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main() {
    ll N;
    cin >> N;
    Sieve sieve = Sieve(N);
    ll ans =0;
    for(int i=1;i<=N;i++){
        if(i%2==0){
            continue;
        }
        vector<P> factors = sieve.factor(i);
        ll fNum = 1;
        for(P f:factors){
            fNum *= (f.second+1);
        }
        if(fNum ==8){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

puts a*" "

for i in 1..n-1
  key = a[i]
  j = i - 1
  while j >= 0 && a[j] > key
    a[j],a[j+1] = a[j+1],a[j]
    j -= 1
  end
  puts a*" "
end

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ALibra solver = new ALibra();
        solver.solve(1, in, out);
        out.close();
    }

    static class ALibra {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int t = in.ints() + in.ints() - in.ints() - in.ints();
            if (t == 0) {
                out.println("Balanced");
            } else if (t < 0) {
                out.println("Right");
            } else {
                out.println("Left");
            }

        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



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

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

  int tasu = A + B;
  int hiku = A - B;
  int kake = A * B;

  if (tasu >= hiku && tasu >= kake) {
    cout << tasu << endl;
  }
  else if (hiku >= kake && hiku >= tasu) {
    cout << hiku << endl;
  }
  else {
    cout << kake << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll 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 MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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; }

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

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

int main(){
  int m; cin >> m;
  ll sum = 0LL;
  ll ans = 0LL;
  rep(i,m) {
    ll d,c; cin >> d >> c;
    sum += d*c;
    ans += c;
  }
  ans += (sum-1)/9 - 1;

  cout << ans << 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, a[], count[];
		count = new int[2];
		n = sc.nextInt();
		a = new int[n];
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextInt();
			if (a[i] % 4 == 0)
				count[1]++;
			else if (a[i] % 2 == 0)
				count[0]++;
		}
		sc.close();

		int tmp = n - count[1];
		boolean ans = false;

		if (count[1] >= tmp - 1)
			ans = true;
		else {
			tmp = n - 2 * count[1];
			if(count[0] >= tmp)ans = true;
		}

		if (ans)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 30;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};



int main()
{
  string s; cin >> s;
  int n = s.size();
  int ans = 0;
  rep(i, n-1) if(s[i] != s[i+1])++ans;
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

//For nCk
const int MAX = 5100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
    ll n, m; cin >> n >> m;
    vector<ll> a(n);
    rep(i, n){
        cin >> a.at(i);
    }

    vector<ll> dif;
    dif.push_back(0);

    rep(i, n){
        ll tmp = dif.at(i);
        tmp += a.at(i);
        tmp %= m;
        dif.push_back(tmp);
    }

    int now = 0;
    ll cnt = 0;
    map<ll, ll> mp;
    for(int i=0; i<=n; i++){
        mp[dif.at(i)]++;
    }

    for(auto x:mp){
        cnt += (x.second*(x.second-1))/2LL;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 8712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3005;
int n,mod,c[N][N];
ll g[N][N],f[N];
ll qpow(ll a,ll n,ll mod)
{
    ll ans=1;
    while(n)
    {
       if(n&1) ans=ans*a%mod;
       a=a*a%mod;
       n>>=1;
    }
    return ans;
}
ll C(int n,int m)
{
    if(m==0||n==m) return 1;
    if(m==1) return n;
    if(c[n][m]) return c[n][m];
    return c[n][m]=(C(n-1,m-1)+C(n-1,m))%mod;
}
int main()
{
    scanf("%d%d",&n,&mod);
    g[0][0]=1;
    for(int i=1;i<=n;i++)
        for(int j=0;j<=i;j++)
    {
        g[i][j]=g[i-1][j]*(j+1)%mod;
        if(j-1>=0)
            (g[i][j]+=g[i-1][j-1])%=mod;
    }
    for(int i=0;i<=n;i++)
    {
        ll s=qpow(2,n-i,mod-1);
        s=qpow(2,s,mod);
        ll t=qpow(2,n-i,mod),x=1;
        for(int j=0;j<=i;j++)
        {
            g[i][j]=g[i][j]*s%mod*x%mod;
            (f[i]+=g[i][j])%=mod;
            x=x*t%mod;
        }
    }
    ll ans=0;
    for(int i=0,t=1;i<=n;i++,t*=-1)
        ans=(ans+t*f[i]*C(n,i))%mod;
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 104576
import java.util.Scanner;
class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ct=0;  Boolean isPN;
        for(int i = 0; i<n;i++)
        {
            isPN=true;  
            int num = sc.nextInt();
            for(int j = 2; j<=Math.sqrt(num);j++)
            {
                if(num%j==0)
                {
                    isPN=false;
                    break;
                }  
            }
            if(isPN==true) ct++;
        }
        System.out.println(ct);
    }
}   



Measured memory_bytes: 41064
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<char, vector<int> > m;
    char c; int a;
    while(cin >> c >> a) {
        map<char, vector<int> >::iterator it = m.find(c);
        if (it == m.end()) {
            vector<int> v;
            v.push_back(a);
            m.insert(make_pair(c, v));
        }
        else
            m.at(c).push_back(a);
    }
    sort(m.at('S').begin(), m.at('S').end());
    sort(m.at('H').begin(), m.at('H').end());
    sort(m.at('C').begin(), m.at('C').end());
    sort(m.at('D').begin(), m.at('D').end());
    vector<int>::iterator it = m.at('S').begin();
    for (int i = 1; i <= 13; i++) {
        if (i == *it) ++it;
        else cout << "S " << i << "\n";
    }
    it = m.at('H').begin();
    for (int i = 1; i <= 13; i++) {
        if (i == *it) ++it;
        else cout << "H " << i << "\n";
    }
    it = m.at('C').begin();
    for (int i = 1; i <= 13; i++) {
        if (i == *it) ++it;
        else cout << "C " << i << "\n";
    }
    it = m.at('D').begin();
    for (int i = 1; i <= 13; i++) {
        if (i == *it) ++it;
        else cout << "D " << i << "\n";
    }
}

Measured memory_bytes: 3104
#include <iostream>

using namespace std;

int main()
{   int a, b, c;
   cin >> a >> b >> c ;
   if ( a <= b && b <= c )
   cout << a << " " << b << " " << c << endl;
   else if ( a <= c && c <= b )
   cout << a << " " << c << " " << b << endl;
   else if ( b <= c && c <= a )
   cout << b << " " << c << " " << a << endl;
   else if ( b <= a && a <= c )
   cout << b << " " << a  << " " << c << endl;
   else if ( c <= a && a <= b )
   cout << c << " " << a  << " " << b << endl;
   else if ( c <= b && b <= a )
   cout << c << " " << b  << " " << a << endl;
}



Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int A,B;

int main(){
    cin>>A>>B;
    if(A%2==B%2){
        cout<<(A+B)/2<<endl;
    }else{
        cout<<"IMPOSSIBLE"<<endl;
    }
}

Measured memory_bytes: 256
#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;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}

int main() {
	fast();

    /*NA – JEONG – MO – SA – JI – MI – DA – CHAE – TZU*/
    
    inp(h);
    ll ans = 0;
    ll lev = 0;
    ll x = 1;
    while(x<=h){
        x*=2;
        lev++;
    }
    ll z = xpow(2ll, lev);
    z--;
    out(z);
}

Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  rep(i,3){
    if(s[i]=='1'){
      s[i]='9';
    }
    else{
      s[i]='1';
    }
  }
  cout<<s;
  return(0);
}


Measured memory_bytes: 256
# 累積和
n, q = map(int, input().split())
s = input()
arr = [0] * (2 * 10**5 + 10)
idx = 1
while idx < len(s):
    if s[idx - 1] == "A" and s[idx] == "C":
        arr[idx] += 1
    idx += 1
for i in range(1, len(arr)):
    arr[i] += arr[i - 1]
for _ in range(q):
    l, r = map(int, input().split())
    print(arr[r - 1] - arr[l - 1])


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

int main(){
    int n;
    cin >> n;
    vector <int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    int cnt = 0;
    for(int i = 1; i < n; i++){
        if(a[i-1] > a[i]) cnt++;
    }
    cout << cnt+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#54 ABC134E

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

def LIS(L):
    from bisect import bisect
    seq=[]
    for i in L:
        pos=bisect(seq,-i)
        if len(seq)<=pos:
            seq.append(-i)
        else:
            seq[pos]=-i
    return len(seq)

print(LIS(a))

Measured memory_bytes: 54744