akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ld long double

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repb(i,a,b) for(int i=a;i>b;i--)

#define pb push_back
#define mp make_pair
#define all(A) A.begin(),A.end()
#define allr(A) A.rbegin(),A.rend()
#define precise(i) fixed << setprecision(i)
#define fi first
#define se second

#define err() cout<<"\n==================================\n";
#define errA(A) for(auto i:A) cout<<i<<" "; cout<<"\n";
#define err1(a) cout<<#a<<" "<<a<<"\n";
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<"\n";
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<"\n";
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<"\n";

const int logN = 20;
const int M = 1000000007;
const int INF = 1e12;
#define PI 3.14159265;
const int N = 200005;

#define Pii pair<int,int>
#define Vi vector<int>
#define Vpii vector<Pii>

Vi adj[200001];
vector<bool> visited(200001, false);
int ma=0;
set<Pii> al;

void dfs(int s, int& sum)
{
       if (visited[s])
       {
              return;
       }
       visited[s] = true;
       sum++;
       for (auto u: adj[s])
       {
              dfs(u, sum);
       }
}

void solve()
{
       int n,m;
       cin>>n>>m;
       rep(c,0,m)
       {
              int x,y;
              cin>>x>>y;
              if(al.count(mp(x,y)))
              {
                     continue;
              }
              adj[x].pb(y);
              adj[y].pb(x);
              al.insert(mp(x,y));
              al.insert(mp(y,x));
       }
       rep(c,1,n+1)
       {
              if(visited[c])
              {
                     continue;
              }
              int sum=0;
              dfs(c, sum);
              ma=max(ma, sum);
       }
       cout<<ma;
}

int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)
    {
           solve();
    }
    return 0;
}


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

int main( void ) {


	for(int i=1;i<12345;i++){
		int temp;
		cin >>temp;
		if(temp!=0)printf("Case %d: %d\n",i,temp);
		else if(temp==0)break;
	}
    return 0;
}



Measured memory_bytes: 3124
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int a, b, c; cin >>a >> b >> c;
	int k; cin >> k;

	int ma = max(a, max(b, c));
	int ans = a + b + c - ma;

	rep(i, k){
		ma *= 2;
	}

	cout <<  ans + ma << endl;

	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#include <cassert>
#include <numeric>
#define ll long long int
#define LL unsigned long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;



int main() {
    int n, m; cin >> n >> m;
    vector<int> g[n];
    rep(i,m){
        int a, b; cin >> a >> b;
        a--; b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    rep(i,n){
        cout << g[i].size() << endl;
    }
}


Measured memory_bytes: 3500
#include<stdio.h>
#include<string.h>
int main(){
  int h,w,cnt = 0;
  scanf("%d %d",&h,&w);
  char s[w + 1];
  for(int i = 0;i < h;i++){
    scanf("%s",&s);
    for(int j = 0;j < w;j++){
      if(s[j] == '#'){
        cnt++;
      }
    }
  }
  if(cnt == h + w - 1){
    printf("Possible\n");
  }else{
    printf("Impossible\n");
  }
  return 0;
}

Measured memory_bytes: 128
N, K = (int(i) for i in input().split())
A = [int(i) for i in input().split()]

pos = A.index(1) + 1

if (N - 1) % (K - 1) == 0:
    ans = (N - 1) // (K - 1)
else:
    ans = ((N - 1) // (K - 1)) + 1

print(ans)

Measured memory_bytes: 13880
#include <stdio.h>
#include <math.h>

int main()
{
   long long int i,n,ans=1,b;
    scanf("%lld",&n);
   b=pow(10,9);
   b+=7;

   for(i=1;i<=n;i++)
   {
       ans=(ans*i)%b;
}
printf("%lld",ans);

return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ll)(1e9)+7)

ll pmod(ll n, ll p){
	ll m=n%mod;
	if(p==0) return 1;
	ll rtn=pmod((m*m)%mod, p/2)%mod;
	if(p%2==1) rtn=rtn*m%mod;
	return rtn;
}

ll binom(ll n, ll k){
	if(n<k || n<0 || k<0) return 0;
	ll a=1, b=1;
	for(ll i=0; i<k; i++){
		a=a*(n-i)%mod;
		b=b*(k-i)%mod;
	}
	return a*pmod(b, mod-2)%mod;
}

int main(){
	ll x, y;
	cin >> x >> y;
	if((2*x-y)%3!=0){
		cout << 0 << endl;
		return 0;
	}else{
		ll p=(-x+2*y)/3, q=(2*x-y)/3;
		cout << binom(p+q, p) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll h,w; cin >> h >> w;
    char a[h][w];
    rep(i,h) rep(j,w) cin >> a[i][j];
    char red[h][w];
    char blue[h][w];
    rep(i,h){
        rep(j,w){
            if(j==w-1) red[i][j] = '.';
            else if(i%2==0) red[i][j] = '#';
            else red[i][j] = '.';
        }
    }
    rep(i,h){
        rep(j,w){
            if(j==0) blue[i][j] = '.';
            else if(i%2==1) blue[i][j] = '#';
            else blue[i][j] = '.';
        }
    }
    rep(i,h){
        red[i][0] = '#';
        blue[i][w-1] = '#';
    }
    rep(i,h){
        rep(j,w){
            if(a[i][j] == '#'){
                red[i][j] = '#';
                blue[i][j] = '#';
            }
        }
    }
    
    rep(i,h){
        rep(j,w) cout << red[i][j];
        cout << endl;
    }
    cout << endl;
    rep(i,h){
        rep(j,w) cout << blue[i][j];
        cout << endl;
    }
}


Measured memory_bytes: 1536
n  =  int(input())
a  =  list(map(int, input().split()))
a.sort(reverse = True)
d  =  {}
count = 0

for x in a:
    if x not in d: d[x] = 0
    d[x] += 1
    
for i in range(len(a)):
    if d[a[i]] == 0:
        continue
        
    d[a[i]] -= 1
    
    y = 2**a[i].bit_length() - a[i]
    
    if y in d and d[y] > 0:
        count += 1
        d[y]  -= 1
        
print(count)

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

int n, m, k;

int main() {
	int i, j;
	
	cin >> n >> m >> k;
	for (i = 0; i <= n; i++) {
		for (j = 0; j <= m; j++) {
			int cnt = i * m + j * n - 2 * i * j;
			if (cnt == k) { cout << "Yes" << endl; return 0; }
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 760
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#define ll long long
#define INF 1000000000
#define mod 1000000007
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

int main(){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  string a,b,c,d;
  rep(i,ty-sy){a+="U";c+="D";}
  rep(i,tx-sx){b+="R";d+="L";}
  cout<<a<<b<<c<<d<<"L"<<a<<"U"<<b<<"RDR"<<c<<"D"<<d<<"L"<<"U"<<endl;
  return 0;
}  


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <chrono>
using namespace std::chrono;
using namespace std;
#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<int,int>
#define ll long long int
const int mod=1e9+7;
/*    auto start = high_resolution_clock::now();
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cout << "\nduration="<<duration.count()/1e6 << endl;
*/
const ll inf=1e18;
void solve(){
    int s,w;
    cin>>s>>w;
    if(w>=s){
        cout<<"unsafe"<<endl;
    }
    else cout<<"safe"<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 3660
#include<iostream>
#include<cstring>
#include<stdbool.h>
using namespace std;
bool strong1(char str[]) 
{ 
    int l = 0; 
    int h = (strlen(str)-1)/2 - 1; 
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
            return false; 
        } 
    } 
    return true;
}  
bool strong2(char str[]) 
{ 
    int l = (strlen(str)+3)/2 -1; 
    int h = strlen(str) -1; 
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
            return false; 
        } 
    } 
    return true;
}  
bool Palin(char str[]) 
{ 
    int l = 0; 
    int h = strlen(str) - 1; 
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
            return false; 
        } 
    } 
    return true;
}

int main()
{
    char str[100];
    cin >> str;
    if(strong1(str)&&strong2(str)&&Palin(str)){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
	double N;
	cin >> N;
	cout << setprecision(8) <<  ceil(N/2) / N << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200005;
int a[N],b[N];
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i],b[i]=a[i];
    sort(a+1,a+1+n);
    int x=a[n/2],y=a[n/2+1];
    for(int i=1;i<=n;i++)
    {
        if(b[i]<=x)cout<<y;
        else cout<<x;
        cout<<"\n";
    }
    return 0 ;
}


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

int main() {
  int N, K, out;
  
  cin >> N >> K;
  out = 1;
  
  for (int i = 0; i < N; i++) {
    if (out * 2 <= out + K) {
      out *= 2;
    }
    else {
      out += K;
    }
  }
  
  cout << out << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int takahashi = a;
		if(a > b) {
			takahashi--;
		}
		System.out.println(takahashi);
	}
}

Measured memory_bytes: 21844
/**
 *   @FileName	c.cpp
 *   @Author	kanpurin
 *   @Created	2020.09.19 21:04:55
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n;cin >> n;
    ll ans = 0;
    for (int i = 1; i < n; i++) {
        for (int j = 1; i * j < n; j++) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const int k = 10001,N = 2000001;
int main(){
  int n;
  cin >> n;
  vector < int > A(N),B(N),C(k,0);
  for(int i = 1 ; i <= n ; i++ ) cin >> A[i];
  for(int j = 1 ; j <= n ; j++ ){
    C[A[j]]++;
  }
  for(int i = 1 ; i <= k ; i++ ){
    C[i] += C[i- 1];
  }
  for(int j = n ; j >= 1 ; j-- ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  for(int i = 1 ; i <= n ; i++ ){
    cout << ( i == 1 ? "" : " " ) << B[i];
  }
  cout << endl;
}


Measured memory_bytes: 18392
N=int(input())
li=[]
A,B=map(int,input().split())

a=list(input().split())
a=[int(s) for s in a]
under=0
middle=0
upper=0


count=0
def hold(a):
    global under
    global middle
    global upper
    global A
    global B
    for i in range(len(a)):
        if a[i]<=A:
            under+=1
        elif a[i]>=B+1:
            upper+=1
        else:
            middle+=1
    return [under,middle,upper]                
d=hold(a)
#print(d)
print(min(d))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e4;
bool cmp(int s,int f){
    if(s>f)
    return true;

    return false;

}
int arr[N];
int main()
{
    int n;
    scanf("%d",&n);
    printf("%d\n",n/3);

}


Measured memory_bytes: 256
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())

    X = int(N/1.08)

    if int(X*1.08) == N:
        print(X)
    elif int(((X+1)*1.08)) == N:
        print(X+1)
    else:
        print(':(')


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define showmap(is, js, x) {rep(i, is){rep(j, js){cout << x[i][j] << " ";}cout << endl;}}
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    cout << ((1999-n)/200) + 1 << endl;

}



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

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

vector<int64_t> fact, fact_inv;

void create_mod_tables(int num){
    fact.assign(num+1, 1);
    fact_inv.assign(num+1, 1);
    for(int i=1; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
    fact_inv[num] = inv_mod(fact[num]);
    for(int i=num; i>0; i--) fact_inv[i-1] = fact_inv[i] * i % MOD;
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int main(){
    int K;
    string S;
    cin >> K >> S;
    int N = S.size();
    create_mod_tables(2e6);

    vector<int64_t> p26(1e6+1, 1), p25(1e6+1, 1);
    for(int i=1; i<=1e6; i++){
        p26[i] = p26[i-1] * 26 % MOD;
        p25[i] = p25[i-1] * 25 % MOD;
    }
    int64_t ans = 0;

    for(int t=0; t<=K; t++){
        int64_t res = comb_mod(N-1+K-t, K-t);
        mul(res, p26[t]);
        mul(res, p25[K-t]);
        add(ans, res);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 51200
import sys
from collections import Counter

read = sys.stdin.read


def min_factor(n):
    sieve = list(range(n + 1))
    sieve[2::2] = [2] * (n // 2)
    for i in range(3, int(n ** 0.5) + 2, 2):
        if sieve[i] == i:
            sieve[i * i::2 * i] = [i] * ((n - i * i - 1) // (2 * i) + 1)
    return sieve


# 素因数分解
def prime_factorize(n):
    a = []
    while n != 1:
        a.append(table[n])
        n //= table[n]
    return a


N, *A = map(int, read().split())
mod = 10 ** 9 + 7

table = min_factor(10 ** 6)
dic = {}

for i in A:
    if i == 1:
        continue

    tmp = Counter(prime_factorize(i))

    for key, value in tmp.items():
        # print(key, value)
        if dic.get(key):
            if dic[key] < value:
                dic[key] = value
        else:
            dic[key] = value


lcm = 1
for i, j in dic.items():
    if j == 0:
        continue
    lcm *= pow(i, j, mod)
    lcm %= mod

answer = 0
for i in A:
    answer += lcm * pow(i, mod - 2, mod)
    answer %= mod

print(answer)


Measured memory_bytes: 51700
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n, y;
  cin >> n >> y;
  int a10 = -1, a5 = -1, a1 = -1;
  rep(i, n + 1) rep(j, n - i + 1) {
    int k = n - i - j;
    int now = 10000 * i + 5000 * j + 1000 * k;
    if(now == y) {
      a10 = i;
      a5 = j;
      a1 = k;
    }
  }
  cout << a10 << ' ' << a5 << ' ' << a1 << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}


int main(){

  int n;
  cin >> n;
  long long a[n];
  for(int i = 0; i < n; i++) cin >> a[i];
  sort(a,a+n);
  long long line[2];
  line[0] = 0;
  line[1] = 0;
  int cnt = 0;
  for(int i = n-1; i >= 1; i--){
    if(a[i] == a[i-1] && cnt < 2){
      line[cnt] = a[i];
      cnt++;
      i--;
    }
  }
  cout << line[0] * line[1] << endl;
  return 0;
}


Measured memory_bytes: 1024
N,M = map(int,input().split())
A = list(map(int,input().split()))

#counter 辞書(改良版)
def counter_imp(A):
 dic = {}                
 for a in A:
    dic[a] = dic.get(a,0) + 1
 return dic
#counter 2次元リスト
def counter_list(A):
 dic = counter_imp(A)
 C = []
 for k in dic:
    C.append([k,dic[k]])
 return C

#（発想）数値を全部追加してソート、大きい順に「Aの要素数」分の要素をとってきて和を求める
A = counter_list(A) 
for i in range(M):
 B,C = map(int,input().split())
 A.append([C,B]) #[C(数値),B(個数)]
 
A.sort(reverse = True) #降順ソート

num,n_index = 0,0 #num:現在和をとった要素の個数,n_index:現在の要素のインデックス
ans = 0 #求める和 
while(1):
  if(num == N): break
  if((N-num) >= A[n_index][1]):
   #N-num :残り必要な要素数
   #A[n_index][1] : 要素A[n_index][0]の個数
   ans += A[n_index][0]*A[n_index][1]
   num += A[n_index][1]
  else:
   ans += A[n_index][0]*(N-num)
   num = N
  n_index += 1 #indexを1つ進める
  
print(ans)

Measured memory_bytes: 33960
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 4e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const long double PI = acosl(-1);
const int MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 200005;
const int MAXV = 60;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
char text[MAXN];
int cnt[MAXN];
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%s", text);
    int s = 0;
    for (int i = 0; text[i]; i++) {
        s = (s + text[i] - '0') % 9;
    }
    printf("%s\n", s ? "No" : "Yes");
    return 0;
}

Measured memory_bytes: 3872
using System;
using System.Linq;
using System.Collections.Generic;
namespace abc150a
{
    class Program
    {
        static void Main(string[] args)
        {
            //var vs = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            var ans = s.Split(new string[] { "ABC" }, StringSplitOptions.None).ToArray();
            if (ans[ans.Length-1] == "ABC")Console.WriteLine(ans.Length);
            else Console.WriteLine(ans.Length-1);
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<cstdio>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<vector>
#include<functional>
#include<string.h>
#include<limits.h>
#include<queue>
#include<deque>
#include<stack>
#include<stdlib.h>
#include<algorithm>
#include<cmath>
#define int long long
#define P pair<int,int>
using namespace std;

bool OK[100000];
struct A {
	int x, y, ID;
};
vector<P>rinsetu[100000];
A a[100000], b[100000];
signed main() {
	int c; scanf("%lld", &c);
	for (int d = 0; d < c; d++) {
		scanf("%lld%lld", &a[d].x, &a[d].y); a[d].ID = d;
		b[d] = a[d];
	}
	sort(a, a + c, [](A n, A m) {if (n.x != m.x)return n.x < m.x; return n.ID < m.ID; });
	sort(b, b + c, [](A n, A m) {if (n.y != m.y)return n.y < m.y; return n.ID < m.ID; });
	for (int i = 1; i < c; i++) {
		rinsetu[a[i - 1].ID].push_back({ a[i].x - a[i - 1].x,a[i].ID });
		rinsetu[a[i].ID].push_back({ a[i].x - a[i - 1].x,a[i-1].ID });
	}
	for (int i = 1; i < c; i++) {
		rinsetu[b[i - 1].ID].push_back({ b[i].y - b[i - 1].y,b[i].ID });
		rinsetu[b[i].ID].push_back({ b[i].y - b[i - 1].y,b[i-1].ID });
	}
	int ans = 0;
	priority_queue<P, vector<P>, greater<P>>Q;
	Q.push({ 0,0 });
	while (Q.size()) {
		P t = Q.top(); Q.pop();
		if (OK[t.second])continue;
		OK[t.second] = true;
		ans += t.first;
		for (P i : rinsetu[t.second]) {
			if (!OK[i.second]) {
				Q.push({ i.first, i.second });
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 18548
using System;
using System.Collections.Generic;
using System.Linq;
class Program {
    static void Main (string[] args) {
        // 整数の入力
        int N = int.Parse (Console.ReadLine ());
        // var s = Console.ReadLine ();
        // int[] numbers = new int[N];
        float ans = 0;
        string[] input = Console.ReadLine ().Split (' ');
        float[] numbers = input
            .Select (float.Parse)
            .ToArray ();

        for (int i = 0; i < N - 1; i++) {
            var min1 = numbers.Min ();
            var min1Index = Array.IndexOf (numbers, min1);
            numbers[min1Index] = 100000;
            var min2 = numbers.Min ();
            var min2Index = Array.IndexOf (numbers, min2);
            var newValue = (min1 + min2) / 2;
            numbers[min1Index] = newValue;

            numbers[min2Index] = 100000;
        }
        ans = numbers.Min();
        Console.WriteLine (ans);

        // int cnt = 1;
        // int tmp1 = numbers[0]; //見始め
        // int tmp = numbers[1];
        // for (int i = 1; i < N; i++) {
        //     if (numbers[i] < tmp) {
        //         cnt += 1;
        //         if (numbers[i] <= tmp1) {
        //             cnt += 1;
        //             tmp1 = numbers[i];
        //         }
        //         tmp = numbers[i];
        //     } else if (numbers[i] == tmp) {
        //         cnt += 1;
        //     } else {

        //     }
        // }
        // Console.WriteLine (cnt);
        // // int D = int.Parse (Console.ReadLine ());
        // string[] input = Console.ReadLine ().Split (' ');
        // int[] numbers = input
        //     .Select (int.Parse)
        //     .ToArray ();
        // int N = numbers[0];
        // int D = num[1];
        // int X = 2*D+1;
        // int cnt = 1;

        // while(true){
        //     if(cnt*X / N >= 1){
        //         break;
        //     }else{
        //         cnt += 1;
        //     }
        // }
        // スペース区切りの整数の入力
        // string[] input = Console.ReadLine ().Split (' ');

        // int[] numbers = input
        // .Select (int.Parse)
        // .ToArray ();
        // int count = 0;

        // while (true) {
        //     bool ck = cheCk (a, numbers);
        //     if (check) {
        //         numbers = Divide (a, numbers);
        //         count += 1;
        //     } else {
        //         break;
        //     }
        // }
        //出力
        // Console.WriteLine (cnt);
    }

    // public static bool Check (int a, int[] numbers) {
    //     bool check = true;
    //     for (int i = 0; i < a; i++) {
    //         if (numbers[i] % 2 != 0) {
    //             check = false;
    //         }
    //     }
    //     return check;
    // }

    // public static int[] Divide (int a, int[] num){ 
    //     for (int i = 0; i < a; i++) {
    //         numbers[i] /= 2;
    //     }
    //     return numbers;
    // }
}


Measured memory_bytes: 13396
"use strict";

function main(input) {
  var lines = input.split('\n');
  var N = parseInt(lines[0]);
  var as = splitNum(lines[1]).slice(0, N);
  var result = as.reduce(function (sum, a) {
    return sum + a - 1;
  }, 0);
  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function splitNum(line) {
  return line.split(/\s+/).map(function (n) {
    return parseInt(n);
  });
}


Measured memory_bytes: 20680
#include <iostream>
#include <vector>
//#include <algorithm>
#include <iomanip>

using namespace std;


int main()
{
	int W, H;
	int x, y;
	cin >> W >> H >> x >> y;

	bool isSplits = false;

	if (W % 2 == 0 && W / 2 == x &&
		H % 2 == 0 && H / 2 == y)
	{
		isSplits = true;
	}

	cout << fixed << setprecision(10);
	cout << ((double)W * H / 2.0) << " ";
	cout << (isSplits ? 1 : 0);

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int H,W,i,j;
  while(1)
           {
  scanf("%d%d",&H,&W);
  if(H==0&&W==0){
    break;
  }

  for(i=1;i<=H;i++)
    {
      for(j=1;j<=W;j++)
        {
          if(j%2==1)
            {
              if(i%2==1)printf("#");
              else printf(".");
            }
          else 
            {
              if(i%2==1)printf(".");
              else printf("#");
            }
        }
      printf("\n");
    }
  printf("\n");
    
           }
  return 0;
}



Measured memory_bytes: 2060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <random>

using namespace std;
constexpr int D = 365;
vector<int> c(26);
vector< vector<int> > s(D, vector<int>(26));
vector<int> num(D), num2(D), ans(D);

int score() {
    int sat = 0;
    vector<int> last(26);
    for (int d=0; d<D; d++) {
        int j = num[d] - 1;
        last[j] = d + 1;
        for(int i=0; i<26; i++) {
            sat -= (d + 1 - last[i]) * c[i];
        }
        sat += s[d][j];
    }
        // assert(1 <= out[d] and out[d] <= 26)
        // j = out[d] - 1
        // last[j] = d + 1
        // for i in range(26):
        //     sat -= (d + 1 - last[i]) * c[i]
        // sat += s[d][j]
    return sat;
}

int main(void) {
    int g;
    cin >> g;
    for(int i=0; i<26; i++) {
        cin >> c[i];
    }
    for(int i=0; i<D; i++) {
        for(int j=0; j<26; j++) {
            cin >> s[i][j];
        }
    }

    // for(int i=0; i<D; i++) {
    //     num[i] = num2[i] = (i%26) + 1;
    // }

    int temp = numeric_limits<int>::min();
    for(int zurasu=0; zurasu<26; zurasu++) {
        for(int i=0; i<D; i++) {
            num[i] = (i+zurasu)%26 + 1;
        }
        if(int sat = score(); sat > temp) {
            ans = num;
            temp = sat;
        }
    }
    // int temp = score();
    // int loop = 100000;
    // random_device seed_gen;
    // // mt19937 engine(seed_gen());
    // default_random_engine engine(seed_gen());
    // uniform_int_distribution<> dist(0, D-1);
    // while(loop--) {
    //     int l = dist(engine);
    //     int r = dist(engine);
    //     swap(num2[l], num2[r]);
    //     // shuffle(num2.begin(), num2.begin()+26, engine);
    //     if(int sat = score(); sat > temp) {
    //         num[l] = num2[l];
    //         num[r] = num2[r];
    //         temp = sat;
    //     } else {
    //         num2[l] = num[l];
    //         num2[r] = num[r];
    //     }
    // }
    // for(int a=0; a<100000; a++) {
    //     for(int i=0; i<D; i++) {
    //         num[i] = dist(engine);
    //     }
    //     if(int sat = score(); sat > temp) {
    //         ans = num;
    //         temp = sat;
    //     }
    // }
    
    ans = num;
    for(int i=0; i<D; i++) {
        cout << ans[i] << endl;
    }
    cerr << temp << endl;
    return 0;
}


Measured memory_bytes: 3676
#include <stdio.h>
#define MAX_NODE 100001

typedef int Item;

typedef struct node{
    Item item;
    int depth;
    struct node *parent;
    struct node *child;
    struct node *next;
} Node;

typedef struct tree{
    Node *root;
} Tree;

Node node[MAX_NODE];

int getId(Node *node){
    return node->item;
}

int getParent(Node *node){
    if(node->parent != NULL) return node->parent->item;
    else return -1;
}

Node* getRoot(Node *node){
    if(node->parent == NULL) return node;
    else return getRoot(node->parent);
}

void setDepth(Node *root){
    if(root->parent == NULL) root->depth = 0;
    else root->depth = root->parent->depth + 1;

    if(root->child != NULL){
        Node *next = root->child;
        while(next != NULL){
            setDepth(next);
            next = next->next;
        }
    }
}

int getDepth(Node *node){
    return node->depth;
}

void printNode(Node *node){
    printf("node %d: ", node->item);
    printf("parent = %d, ", getParent(node));
    printf("depth = %d, ", getDepth(node));
    if(node->child == NULL) {
        if(node->parent == NULL) printf("root, ");
        else printf("leaf, ");
        printf("[]");
    }
    else {
        if (node->parent == NULL) printf("root, ");
        else printf("internal node, ");
        
        printf("[");
        Node *child = node->child;
        while(child != NULL){
            if(child->next == NULL) printf("%d]", child->item);
            else printf("%d, ", child->item);
            child = child->next;
        }

    }
    printf("\n");
}

int main(void){
    int n;
    scanf("%d\n", &n);
    
    
    int i;
    for(i = 0; i < n; i++){
        int id, k, j;
        scanf("%d%*c%d%*c", &id, &k);           
        node[id].item = id;

        Node **tail = &node[id].child;
        for(j = 0; j < k; j++){
            int child;
            scanf("%d%*c", &child);
            
            node[child].parent =  &node[id];
            
            *tail = &node[child];
            tail = &node[child].next;
            /*
            if(node[id].child == NULL) node[id].child = &node[child];
            else {
                Node *tail = node[id].child;
                while(tail->next != NULL) tail = tail->next;
                tail->next = &node[child];
            }
            */
        }
    }
    
    Node *root = getRoot(&node[0]);
    setDepth(root);
    for(i = 0; i < n; i++){
        printNode(&node[i]);
    }


    return 0;
}

Measured memory_bytes: 4896
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	try {
    		final int N = sc.nextInt();
    		int [] A = new int[N];
    		for (int i=0; i<N; i++) {
    			A[i] = sc.nextInt();
    		}

    		for (int i=0; i<N; i++) {
    			if (A[i] % 2 == 0 && (A[i] % 3 != 0 && A[i] % 5 != 0)) {
    	    		System.out.println("DENIED");
    	    		return;
    			}
    		}
    		System.out.println("APPROVED");

    	} finally {
    		sc.close();
    	}
    }
}


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

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

    switch (N % 10) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon";
            return 0;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon";
            return 0;
        case 3:
            cout << "bon";
    }
}


Measured memory_bytes: 3528
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.20f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;



int main() {
	string s;
    cin >> s;

    if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') cout << 3 << endl;
    else if (s[0] == 'R' && s[1] == 'R' || s[1] == 'R' && s[2] == 'R') cout << 2 << endl;
    else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R') cout << 1 << endl;
    else cout << 0 << endl;

	return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int n, k;
 
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> k;
    ll ans = n / k;
    ans = ans * ans * ans;
    ll tmp = n / k + (n % k >= k / 2);
    if(k % 2 == 0) ans += tmp * tmp * tmp;
    cout << ans;
    return 0;
}

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

int main() {
  string s;
  int q;
  cin >> s >> q;
  vector<int> T(q), F(q);
  vector<char> C(q);
  rep(i, q) {
    cin >> T[i];
    if (T[i] == 2) cin >> F[i] >> C[i];
  } 
  bool hanten = false;
  string sentou, matsubi;
  rep(i, q) {
    if (T[i] == 1) {
      hanten = !hanten;
    } else {
      if (F[i] == 1) {
        if (hanten) matsubi.push_back(C[i]);
        else sentou.push_back(C[i]);
      } else {
        if (hanten) sentou.push_back(C[i]);
        else matsubi.push_back(C[i]);
      }
    }
  }
  reverse(sentou.begin(), sentou.end());
  s = sentou + s + matsubi;
  if (hanten) reverse(s.begin(), s.end());
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3140
fn main() {
    let ab = read_vec::<i32>();
    let d = ab[0] - 2 * ab[1];
    if d < 0 {
        println!("0");
    } else {
        println!("{}", d);
    }
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 4352
/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define ll long long
#define fir first
#define sz(a) int((a).size())

signed main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int r,c,sx,sy,ex,ey;
	cin>>r>>c>>sx>>sy>>ex>>ey;
	string s[r];
	for(int i=0;i<r;i++)
	{
		cin>>s[i];
	}
	vector< vector<int> > dist(r,vector<int>(c,-1));
	deque< tuple<int,int,int> > dq;
	dq.emplace_back(sx-1,sy-1,0);
	while(!dq.empty())
	{
		int x,y,d;
		tie(x,y,d)=dq.front();
		dq.pop_front();
		if(x<0||x>=r||y<0||y>=c||\
		dist[x][y]>=0||s[x][y]=='#')
			continue;
		dist[x][y]=d;
		for(int dx=-2;dx<3;dx++)
		{
			for(int dy=-2;dy<3;dy++)
			{
				if(dx*dx+dy*dy==1)
					dq.emplace_front(x+dx,y+dy,d);
				else if(dx*dx+dy*dy>1)
					dq.emplace_back(x+dx,y+dy,d+1);
			}
		}
	}
	cout<<dist[ex-1][ey-1]<<endl;
	return 0;
}


Measured memory_bytes: 11080
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("fma,avx,avx2")

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ld long double
#define sz(a) (int) (a).size()
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    string s;
    cin >> s;
    if (s[0] == 'R' && s[1] == 'R' && s[2] == 'R') {
        cout << 3;
    } else if ((s[0] == 'R' && s[1] == 'R') || (s[1] == 'R' && s[2] == 'R')) {
        cout << 2;
    } else if ((s[0] == 'R' || s[1] == 'R' || s[2] == 'R')) {
        cout << 1;
    } else {
        cout << 0;
    }
    return 0;
}

Measured memory_bytes: 3600
/**
**	author : Raghav
**	codechef:raghav_456
**	codeforces:raghavramola7
**/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void Raghav()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
bool isPrime(int n)
{
	for (int i = 2; i <= sqrt(n) + 1; i++)
	{
		if (n % i == 0)
		{
			return false;
		}
	}
	return true;
}
int32_t main()
{
	Raghav();
	int r;
	double c, pi = 3.14159;
	cin >> r;
	c = 2 * pi * r;
	cout << fixed << setprecision(6) << c;



	return 0;
}

Measured memory_bytes: 3716
n = int(input())
xs = [int(x) for x in input().split()]
xs.sort()

#print(xs)
acc = [0]
for i in range(n):
    acc.append(acc[-1] + xs[i])
#print(acc)

ans = 1
for i in range(n-2,-1,-1):
    if acc[i+1] * 2 >= xs[i+1]:
        ans += 1
    else: break
print(ans)


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

// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}

int main(){
  int n;
  int total = 0;
  int nmin = 101;
  cin >> n;
  int s[n];
  rep(i,n){
    cin >> s[i];
    nmin = min(s[i],nmin);
    total += s[i];
  }
  if(total % 10 != 0){
    cout << total << endl;
    return 0;
  }
  sort(s,s+n);
  rep(i,n){
    if(s[i] % 10 != 0){
      cout << total - s[i] << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}

Measured memory_bytes: 256
import sys
import bisect
input=sys.stdin.readline

N=int(input())
A=[-int(input()) for _ in range(N)]
l=[A[0]]
for x in A[1::]:
    tmp=bisect.bisect(l,x)
    if tmp==len(l):l.append(x)
    else: l[tmp]=x
print(len(l))

Measured memory_bytes: 49116
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <map>
#define PI 3.14159265358979323846
using namespace std;

int main()
{
    int n,sum=0;
    cin>>n;
    int arr[n-1];
    map<int,int> m1;
    for(int i=0;i<n-1;i++)
        {
            cin>>arr[i];
            m1[arr[i]]++;
        }
    for(int i=1;i<=n;i++)
    {
        cout<<m1[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 13756
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }
        long ap = 0;
        long bp = 0;
        for (int i = 0; i < n; i++) {
            if(b[i] < a[i]) bp += a[i] - b[i];
            if(a[i] < b[i]) ap += (b[i] - a[i]) /2;
        }
        System.out.println(bp <= ap ? "Yes" : "No");
        sc.close();
    }

}


Measured memory_bytes: 44004
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=998244353;
int a[1<<18],b[1<<18];
inline int pow(int x,int y){
	int z=1;
	while(y){
		if(y&1)z=1ll*z*x%mod;
		x=1ll*x*x%mod;
		y>>=1;
	}
	return z;
}
inline void fwt(int *a,int n,int opt){
	// for(int i=0;i<(1<<n);i++)printf("%d ",a[i]); puts("");
	int inv=pow(2,mod-2);
	for(int i=1;i<n;i<<=1){
		for(int j=0;j<n;j+=(i<<1)){
			for(int k=0;k<i;k++){
				int x=a[j+k],y=a[j+k+i];
				a[j+k]=1ll*(x+y)*(opt==-1?inv:1)%mod;
				a[j+k+i]=1ll*(x-y+mod)*(opt==-1?inv:1)%mod;
			}
		}
	}
	//for(int i=0;i<(1<<n);i++)printf("%d ",a[i]); puts("");
}
int main(){
	int n;
	scanf("%d",&n);
	int s=0;
	for(int i=0;i<(1<<n);i++)scanf("%d",&a[i]),s+=a[i];
	s=pow(s,mod-2);
	for(int i=0;i<(1<<n);i++)a[i]=mod-1ll*a[i]*s%mod;
	a[0]++;
	if(a[0]>=mod)a[0]-=mod;
	for(int i=0;i<(1<<n);i++)b[i]=1;
	b[0]=(b[0]-(1<<n)+mod)%mod;
	fwt(a,(1<<n),1);
	fwt(b,(1<<n),1);
	for(int i=0;i<(1<<n);i++)a[i]=1ll*pow(a[i],mod-2)*b[i]%mod;
	a[0]=0;
	for(int i=1;i<(1<<n);i++)a[0]=(a[0]-a[i]+mod)%mod;
	fwt(a,(1<<n),-1);
	for(int i=0;i<(1<<n);i++)printf("%d\n",a[i]);
	return 0;

}

Measured memory_bytes: 4736
import sys
sys.setrecursionlimit(10**7)

N = int(input())

claim = []

for _ in range(N):
    memo = []
    A = int(input())
    for _ in range(A):
        x, y = map(int, input().split())
        memo.append((x,y))
    claim.append(memo)

maximam = 0
for bit in range(2**N):
    flag = True
    count = 0
    for i in range(N):
        if bit & (1<<i):
            count+=1
            for x, y in claim[i]:
                if (bit & (1<<(x-1)) and y==0) or (not (bit & (1<<(x-1))) and y==1):
                    flag = False
    if flag:
        maximam = max(maximam,count)
print(maximam)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
set<int> s;
int main()
{
	int a, b, c;
	cin>>a>>b>>c;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	if(s.size() == 2)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

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

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > matA;
  matA.resize(n, vector<int>(m));
  vector<int> matB(m);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int x;
      cin >> x;
      matA[i][j] = x;
    }
  }

  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    matB[i] = x;
  }

  for (int i = 0; i < n; i++) {
    int x = 0;
    for (int j = 0; j < m; j++) {
      x += matA[i][j] * matB[j];
    }
    cout << x << endl;
  }

  return 0;
}



Measured memory_bytes: 3204
#include<iostream>
#include<math.h>
using namespace std;
main(){
    char s[100];
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    cin>>s[i];
    int ans=1;
    for(int i=1;i<n;i++){
        bool flag=1;
        for(int j=0;j<i;j++){
            if(s[i]==s[j])flag=0;
        }
        if(flag) ans++;
    }
    if(ans==1) cout<<"One";
    else if(ans==2) cout<<"Two";
    else if(ans==3) cout<<"Three";
    else cout<<"Four";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
using namespace std;

typedef unsigned long long ull;

const ull INF = ULLONG_MAX/3;

void add(int s, int t, ull x, vector<ull> &xList, vector<ull> &sxList, vector<ull> &ssxList){
    int nn = xList.size();
    int sn = sxList.size();
    int ss = s/sn;
    int tt = t/sn;
    if(ss == tt){
        for (int i=0;i<t-s+1;i++){
            xList[s+i] += x;
            ssxList[ss] += x;
        }
    }else{
        for(int i=s;i<(ss+1)*sn;i++){
            xList[i] += x;
            ssxList[ss] += x;
        }

        for(int i=tt*sn;i<t+1;i++){
            xList[i] += x;
            ssxList[tt] += x;
        }

        for(int i=ss+1;i<tt;i++){
            sxList[i] += x;
            ssxList[i] += x*sn;
        }
    }
}

void getSum(int s, int t, vector<ull> &xList, vector<ull> &sxList, vector<ull> &ssxList){
    int nn = xList.size();
    int sn = sxList.size();
    int ss = s/sn;
    int tt = t/sn;
    ull S = 0ull;
    if(ss == tt){
        for (int i=s;i<t+1;i++){
            S += (xList[i] + sxList[i/sn]);
        }
    }else{
        for(int i=s;i<(ss+1)*sn;i++){
            S += (xList[i] + sxList[i/sn]);
        }

        for(int i=tt*sn;i<t+1;i++){
            S += (xList[i] + sxList[i/sn]);
        }

        for(int i=ss+1;i<tt;i++){
            S += ssxList[i];
        }
    }
    cout << S << endl;
}

int main(){
    int n, q, qType, s, t;
    ull x;
    cin >> n >> q;
    int sn = sqrt(n)+1;

    vector<ull> xList(sn*sn, 0);
    vector<ull> sxList(sn, 0);
    vector<ull> ssxList(sn, 0);

    for (int i=0;i<q;i++){
        cin >> qType;
        if (qType == 0){
            cin >> s >> t >> x;
            add(s,t,x,xList,sxList, ssxList);
        }else{
            cin >> s >> t;
            getSum(s, t, xList, sxList, ssxList);
        }
/*
        for (int i=0;i<sn*sn;i++){
            cout << xList[i]  << " ";
        }
        cout << endl;
        for (int i=0;i<sn;i++){
            cout << sxList[i] << " ";
        }
        cout << endl;
*/
    }
    return 0;
}

Measured memory_bytes: 3564