akhauriyash/Code-Regression huggingface dataset:
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-02-19 07:21:30
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  string s; cin >> s;
  int64 ans = 0;
  int cnt = 0;

  int n = s.size();

  for (int i = 0; i < n; ++i) {
    if (s[i] == 'B') {
      ++cnt;
    } else {
      ans += cnt;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 720
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for (int i=1;i<n+1;i++)
    {
        cin>>a[i];
    }
       
    for(int u=n;u>0;u--)
    {
        if(u!=n){cout<<" ";}
        cout<<a[u];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    int A,B,C;
    cin >> A >> B >> C;
    if(A == 5 && B == 5 && C == 7){
        cout << "YES" << endl;
    }else if(A == 5 && B == 7 && C == 5){
        cout << "YES" << endl;
    }else if(A == 7 && B == 5 && C == 5){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 384
a = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
h, w = map(int, input().split())
for i in range(h):
  s = input().split()
  for j in range(w):
    if s[j] == 'snuke':
      print('{}{}'.format(a[j], i + 1))

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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int N;
	double ans = 0;
	
	cin >> N;
	
	for(int i=0; i<N; i++){
		double x;
		string u;
		cin >> x >> u;
		if(u == "JPY")
			ans += x;
		else
			ans += 380000 * x;
	}
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

#define abs(x)  ((x) > 0 ? (x) : -(x))
#define MOD		1000000007

typedef long long ll;

/* -----------------------------------------------------------------------------
	型とクラス定義
----------------------------------------------------------------------------- */

ll inv(ll a, ll p) {

	ll res = 1, pow = a;
	int n = p - 2;

	while(n > 0) {
		if(n & 1) { res *= pow; res %= p; }
		pow = pow * pow % p;
		n >>= 1;
	}
	return res;
}


/* -----------------------------------------------------------------------------
	大域データ
----------------------------------------------------------------------------- */
int X, Y;	

int main () {

	int a, b;
	ll ans = 1, d = 1;

	// 個数と長さの読込み
	scanf("%d %d", &X, &Y);

	a = 2 * Y - X; b = 2 * X - Y;

	if(abs(a) % 3 > 0 || a < 0 || b < 0) {
		printf("%d\n", 0);
		return 0;
	}

	a /= 3; b /= 3;

	for(int i = 1; i <= b; i++) {
		ans *= (a + b + 1 - i);
		d *=  i;
		ans %= MOD;
		d %= MOD;
	}

	ans = ans * inv(d, MOD) % MOD;
	printf("%lld\n", ans);

	return 0;
}


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

int main(){
  string s; cin >> s;
  string emp1 = "";
  string emp2 = "";

  int ans1 = 0;
  int ans2 = 0;

  for(int i = 0;i < s.size();i++){
    if(i % 2 == 0){
      emp1 += "0";
      emp2 += "1";
      if(emp1[i] != s[i])ans1++;
      if(emp2[i] != s[i])ans2++;
    }
    else{
      emp1 += "1";
      emp2 += "0";
      if(emp1[i] != s[i])ans1++;
      if(emp2[i] != s[i])ans2++;
    }
  }

  cout << min(ans1,ans2) << endl;


}

Measured memory_bytes: 768
#include<iostream>
#include<fstream>
#include<string>

int main(){
  //std::ifstream in("input.txt");
  //std::cin.rdbuf(in.rdbuf());

  std::string S, S1, S2;
  std::cin >> S;

  if(S.size() % 2 == 0){
    int num = S.size() / 2;
    S1 = S.substr(0, num);
    S2 = S.substr(num, num); 
  }else{
    int num = (int)(S.size() / 2);
    S1 = S.substr(0, num);
    S2 = S.substr(num + 1, num); 
  }
  int cnt = 0;
  int size = S1.size();
  for(int i = 0; i < size; i++){
    if(S1[i] != S2[size -1 - i]){ 
      cnt++;
    }
  }
  std::cout << cnt << std::endl;


  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long a = 100;
		int count = 0;
		while(a < x) {
			a *= (1 + 0.01);
			count++;
		}
		System.out.println(count);
    }
}

Measured memory_bytes: 35724
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007


int main(){
	ll a, b;
	cin >> a >> b;
	if (a == 0 or b == 0)cout << "Zero" << endl;
	else if (a < 0 and b > 0)cout << "Zero" << endl;
	else if (a > 0 and b > 0)cout << "Positive" << endl;
	else if((abs(min(a,0ll) - min(b,0ll) ) + 1) % 2 == 0)cout << "Positive"<<endl;
	else cout << "Negative" <<endl;

}



Measured memory_bytes: 764
#include <bits/stdc++.h>
     
typedef long long LL;
     
#define FOR(i, a, b) for (LL i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (LL i = (a), i##_END_ = (b); i >= i##_END_; i--)
     
template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}
     
template <typename Tp> void out(Tp x) {
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
	return;
}
     
template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}
     
const LL MAXN = 52;
     
LL n, M, D;
LL sz[MAXN], fa[MAXN];
LL head[MAXN], data[MAXN], nxt[MAXN], cnt;
     
LL c[MAXN], v[MAXN];
LL f[MAXN][MAXN * MAXN * MAXN];
     
void add(LL x, LL y)
{
	nxt[cnt] = head[x]; data[cnt] = y; head[x] = cnt++;
}
     
void dfs(LL now)
{
	c[now] = 1; v[now] = sz[now];
	for (LL i = head[now]; i != -1; i = nxt[i]) {
		dfs(data[i]); c[now] += c[data[i]]; v[now] += v[data[i]];
	}
}
     
LL to[MAXN], num[MAXN];
LL que[2][MAXN][MAXN * MAXN * MAXN]; LL front[MAXN], tail[MAXN];
     
bool cmp(const LL &i, const LL &j) {return c[i] * 1ll * v[j] < c[j] * 1ll * v[i];}
     
int main()
{
	in(n); in(M); in(D);
     
	memset(head, -1, sizeof head);
    	
	in(sz[1]);
	FOR(i, 2, n) in(sz[i]), in(fa[i]), add(fa[i], i);
     
	dfs(1);
     
	memset(f, 0x3f, sizeof f);
     
	LL all = 50 * 50 * n;
    	
	f[0][0] = 0;
	FOR(i, 1, n) {
		FOR(k, 0, c[i] - 1) front[k] = 1, tail[k] = 0;
		LL lim = Min(D, 50ll); if (i == 1) lim = 50;
		FOR(j, 0, all) {
			LL b = j % c[i];
			LL pre = f[i - 1][b + (j / c[i]) * c[i]] - (j / c[i]) * v[i];
			while (tail[b] >= front[b] && que[0][b][tail[b]] >= pre) tail[b]--;
			++tail[b]; que[0][b][tail[b]] = pre; que[1][b][tail[b]] = j / c[i];
			while (tail[b] >= front[b] && que[1][b][front[b]] < (j / c[i]) - lim) front[b]++;
			f[i][j] = que[0][b][front[b]] + (j / c[i]) * v[i];
		}
	}
     
	num[1] = M; FOR(i, 2, n) num[i] = Max(0ll, D - 50);
	FOR(i, 1, n) to[i] = i;
     
	std::sort(to + 1, to + n + 1, cmp);
     
	LL ans = 0;
    	
	FOR(i, 0, all) {
		if (f[n][i] > M) continue;
		LL need = f[n][i], sum = i;
		DNF(j, n, 1) {
			LL can = Min(num[to[j]], (M - need) / v[to[j]]);
			sum += can * c[to[j]]; need += can * v[to[j]];
		}
		chkmax(ans, sum);
	}
     
	printf("%lld\n", ans);
    	
	return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n;
    cin >> n;
    ll a[n];
    rep(i, n) { cin >> a[i]; }
    sort(a, a + n);
    ll diff = a[n - 1] - a[0];
    if (diff > 1) {
        cout << "No" << endl;
        return 0;
    } else if (diff == 0) {
        if (a[0] == n - 1 || 2 * a[0] <= n) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else if (diff == 1) {
        ll num0 = 0, num1 = 0;
        rep(i, n) {
            if (a[i] == a[0])
                num0++;
            else
                num1++;
        }
        if (num0 < a[n - 1] && 2 * (a[n - 1] - num0) <= num1)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 4388
while True:
    a, op, b = map(str, raw_input().split())

    if op in "+":
        print int(a)+int(b) 
    elif op in "-":
        print int(a)-int(b)
    elif op in "*":
        print int(a)*int(b)
    elif op in "/":
        print int(a)/int(b)
    else :
        break;

Measured memory_bytes: 6436
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

struct dice
{
  vector<int> num;

  dice(int t[]) : num(7){
    for(int i=0;i<6;++i)num[i+1]=t[i];
  };
  int state(){return num[1];}
  void s()
  {
    vector<int> tmp(7);
    tmp[1] = num[5];
    tmp[2] = num[1];
    tmp[3] = num[3];
    tmp[4] = num[4];
    tmp[5] = num[6];
    tmp[6] = num[2];
    num = tmp;
  }
  void n()
  {
    vector<int> tmp(7);
    tmp[5] = num[1];
    tmp[1] = num[2];
    tmp[3] = num[3];
    tmp[4] = num[4];
    tmp[6] = num[5];
    tmp[2] = num[6];
    num = tmp;
  }
  void e()
  {
    vector<int> tmp(7);
    tmp[1] = num[4];
    tmp[2] = num[2];
    tmp[3] = num[1];
    tmp[4] = num[6];
    tmp[5] = num[5];
    tmp[6] = num[3];
    num = tmp;
  }
  void w()
  {
    vector<int> tmp(7);
    tmp[4] = num[1];
    tmp[2] = num[2];
    tmp[1] = num[3];
    tmp[6] = num[4];
    tmp[5] = num[5];
    tmp[3] = num[6];
    num = tmp;
  }
};

int main()
{
  int n[6];
  for(int i=0;i<6;++i)cin>>n[i];
  dice d(n);
  string s;
  cin >> s;
  for(int i=0;i<s.size();++i)
  {
    if(s[i]=='S')d.s();
    else if(s[i]=='N')d.n();
    else if(s[i]=='W')d.w();
    else d.e();
  }
  cout<<d.state()<<endl;

  return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define lli long long int
#define pb push_back
#define mod 1000000007
#pragma GCC optimize ("-O3")
#define mod2 998244353
#define MAXN 1000000000
#define v32 vector<int>
#define v64 vector<lli>
#define v1024 vector <vector <int>>
#define v4096 vector <vector <lli>>
#define vt vector
#define f(x, y, z) for (lli x = y; x < z; x++)
#define fd(x, y, z) for (lli x = y; x > z; x--)
#define lb lower_bound
#define ld long double
#define m64 map<lli,lli>
#define m32 map<int,int>
#define m64it map<lli,lli>::iterator
#define m32it map<int,int>::iterator
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ist insert
#define endl "\n"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define p_q priority_queue 
#define min_p_q priority_queue <int,vt <int>,greater <int>>
using namespace std;
using namespace __gnu_pbds; 

template <typename T> 
void DEBUG_ARR(vt<T> a,char c)
{
	f(i,0,a.size())cout<<a[i]<<c;
	cout<<"\n";
}

//USE AT YOUR OWN RISK
lli tmod(lli x,lli m=mod){return (x%m+m)%m;}

//make sure x is below mod
lli power(lli x, lli y,lli m=mod) 
{
    lli res = 1;  
   
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x)%m; 
        y = y>>1; 
        x = (x*x)%m;  
    }
    if(res<0)
       res+=m; 
    return res; 
}
//rank is equal to number of vertices in a connected component
class UnionFind 
{
  public: v32 p, rank;
  // remember: vi is vector<int>
  UnionFind(int N) { rank.assign(N, 1);
  p.assign(N, 0); for (int i = 0; i < N; i++) p[i] = i; }
  int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
  bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
  void unionSet(int i, int j) 
  {
  if (!isSameSet(i, j)) {
  // if from different set
  int x = findSet(i), y = findSet(j);
  if (rank[x] > rank[y]) p[y] = x,rank[x]+=rank[y];
  // rank keeps the tree short
  else 
     {
     p[x] = y;
     rank[y]+=rank[x]; 
     }
  
  } 
 
  }   
};
// lli fact[2000009];
// lli ncr(lli n,lli r){
//     lli ans=fact[n];
//     if(r>n)return 0;
//     ans=(ans*power(fact[n-r],mod-2))%mod;
//     ans=(ans*power(fact[r],mod-2))%mod;
//     return ans;
// }
// int mat[][]
v1024 v;
int main() 
{ 
    // fact[0]=1;
    // f(i,1,2000001)fact[i]=(i*fact[i-1])%mod;
    fastio;
    int t;
    // cin>>t;
    t=1;
    int temp=t;
	while(t--){
        // cout<<"Case #"<<temp-t<<": ";
        int n,m;cin>>n>>m;
        int a[n];f(i,0,n)cin>>a[i];
        sort(a,a+n);
        reverse(a,a+n);
        int sum=0;
        f(i,0,n)sum+=a[i];
        bool flag=true;
        f(i,0,m)if(a[i]*4*m<sum)flag=false;
        if(flag)cout<<"Yes";
        else cout<<"No";
    }   
    return 0; 	
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char * argv[]) {
    int n ,d, ans, i;
    scanf("%d%d", &n, &d);
    ans = 0;
    for(i = 0;i < n;){
        i += 2*d + 1;
        ans++;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
def main():
    N = int(input())
    A = list(map(int, input().split()))
    MOD = 10 ** 9 + 7

    b = A[0]
    ans = 0
    for i in range(1, N):
        ans = (ans + b * A[i]) % MOD
        b = (b + A[i]) % MOD
    
    print(ans)

if __name__ == '__main__':
    main()

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

using namespace std;

int main(void) {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector< vector<int> > g(N+1, vector<int>(N+1));

    while(M--) {
        int L, R;
        cin >> L >> R;
        --L; --R;
        g[0][R]++;
        g[0][N]--;
        g[L+1][R]--;
        g[L+1][N]++;
    }

    for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++) {
            g[i][j+1] += g[i][j];
        }
    }
    for(int j=0; j<N; j++) {
        for(int i=0; i<N; i++) {
            g[i+1][j] += g[i][j];
        }
    }

    while(Q--) {
        int p, q;
        cin >> p >> q;
        --p; --q;
        cout << g[p][q] << endl;
    }
    return 0;
}


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

using namespace std;

#define MOD 1000000007

int main() {
	int n;
	scanf("%d", &n);
	long long a[n];
	for (int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
	}
	
	long long sums[n];
	sums[n - 1] = a[n - 1];
	for (int i = n - 2; i >= 0; i--) {
		sums[i] = sums[i + 1] + a[i];
		sums[i] %= MOD;
	}
	
	long long ans = 0;
	for (int i = 0; i < n - 1; i++) {
		sums[i] -= a[i];
		if (sums[i] < 0) {
			sums[i] += MOD;
		}
		ans += (a[i] * sums[i]) % MOD;
		ans %= MOD;
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 6948
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

X = get_int

if X >= 30
  puts 'Yes'
else
  puts 'No'
end


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

typedef pair<ll,int> pli;

struct BIT{
    vector<int> node;
    int n;

    BIT(int x) : n(x){
        node.resize(n+1, 0);
    }

    void add(int x, int val){
        while(x <= n){
            node[x] += val;
            x += x & -x;
        }
    }

    int sum(int x){
        int ret = 0;
        while(x > 0){
            ret += node[x];
            x -= x & -x;
        }
        return ret;
    }
};

int main(){
    int n, c;
    cin >> n >> c;
    vector<pli> vp;
    vector<ll> score(n, 0);
    for(int i = 0; i < n; i++)  vp.push_back({-score[i], i});
    vector<int> x(c), y(c), z(c);
    for(int i = 0; i < c; i++){
        cin >> x[i];
        if(x[i] == 0){
            cin >> y[i] >> z[i];
            y[i]--;
            score[y[i]] += z[i];
            vp.push_back({-score[y[i]], y[i]});
        }else{
            cin >> y[i];
        }
    }
    sort(vp.begin(), vp.end());
    auto f = [&](pli p)->int{
        return lower_bound(vp.begin(),vp.end(),p)-vp.begin();
    };
    int siz = vp.size();

    BIT bit(siz);
    for(int i = 0; i < n; i++){
        bit.add(1+f({-0,i}),1);
    }

    fill(score.begin(), score.end(), 0);

    for(int i = 0; i < c; i++){
        if(x[i] == 0){
            bit.add(1+f({-score[y[i]],y[i]}), -1);
            score[y[i]] += z[i];
            bit.add(1+f({-score[y[i]],y[i]}), 1);
        }else{
            int l = -1, r = siz;
            while(r-l > 1){
                int mid = (l+r)/2;
                if(bit.sum(1+mid) < y[i]) l = mid;
                else                    r = mid;
            }
            cout << vp[r].second+1 << " " << -vp[r].first << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 8872
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;

using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n, m, K;
	char memo[102][102] = {};
	string s;
	string s1, s2;
	//IntStack yStack;
	//charStack Stack;
	//vector<pair<int, int> > pairs(a);
	cin >> s;
	for (int i = s.length()-1; i >=0; i--)
	{
		if (i<4)
		{
			cout << "NO" << endl;
			return 0;
		}
		else if (i>3&&s[i - 4] == 'd'&&s[i - 3] == 'r'&&s[i - 2] == 'e'&&s[i - 1] == 'a'&&s[i] == 'm')
		{
			i -= 5;
		}
		else if (i>5 && s[i - 6] == 'd'&&s[i - 5] == 'r'&&s[i - 4] == 'e'&&s[i - 3] == 'a'&&s[i-2] == 'm'&&s[i - 1] == 'e'&&s[i] == 'r')
		{
			i -= 7;
		}
		else if (i>3 && s[i - 4] == 'e'&&s[i - 3] == 'r'&&s[i - 2] == 'a'&&s[i - 1] == 's'&&s[i] == 'e')
		{
			i -= 5;
		}
		else if (i>4 && s[i - 5] == 'e'&&s[i - 4] == 'r'&&s[i - 3] == 'a'&&s[i - 2] == 's'&&s[i - 1] == 'e'&&s[i] == 'r')
		{
			i -= 6;
		}
		else
		{
			cout << "NO" << endl;
			return 0;
		}
		i++;
	}

	cout <<"YES" << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

Measured memory_bytes: 512
n = int(input())
a_arr = []
# key = a, val = (len, nC2 - n-1C2)
a_map = {}
total = 0

def comb(x):
  return (x*(x-1)/2)

for x in input().split():
  a = int(x)
  a_arr.append(a)
  if a in a_map.keys():
    a_map[a][0] = a_map[a][0] + 1

    thiscomb = comb(a_map[a][0])
    prevcomb = comb(a_map[a][0]-1)
    a_map[a][1] = thiscomb - prevcomb
    total = total - prevcomb + thiscomb
  else:
    a_map[a] = [1, 0]


for a in a_arr:
  print(int(total - a_map[a][1]))



Measured memory_bytes: 44192
#include<bits/stdc++.h>                
using namespace std;
int arr[3][3], key[2], i, j;
bool answer;/* true時No*/

int main(void){
	for(i = 0; i < 3; i++){
		for(j = 0; j < 3; j++){
			scanf("%d", &arr[i][j]);
		}
	}

	int dif;
	for(i = 0; i < 3; i++){
		for(j = 0; j < 2; j++){
			dif = arr[i][j+1] - arr[i][j];
			if(0 == i) key[j] = dif; 
			else if(key[j] != dif) answer = true;
		} 
  }
	for(i = 0; i < 3; i++){
		for(j = 0; j < 2; j++){
			dif = arr[j+1][i] - arr[j][i];
			if(0 == i) key[j] = dif; 
			else if(key[j] != dif) answer = true;
		} 
  }
	if(answer)cout << "No\n";
	else cout << "Yes\n";
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < 3; ++i)
        if (s[i] == t[i])
            ans++;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <assert.h>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
  ll x,y;
  cin>>x>>y;
  ll flag = 0;
  rep(i,0,x+1){
    ll a = i;
    ll b = x-i;
    if(a*2+b*4==y)flag = 1;
  }
  if(flag==1){
      cout << "Yes" << endl;
  }
  else{
      cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
/*input 
20 100000
14309 -32939
-56855 100340
151364 25430
103789 -113141
147404 -136977
-37006 -30929
188810 -49557
13419 70401
-88280 165170
-196399 137941
-176527 -61904
46659 115261
-153551 114185
98784 -6820
94111 -86268
-30401 61477
-55056 7872
5901 -163796
138819 -185986
-69848 -96669
*/ 
#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;
typedef long long int ll;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#define ld double
#define pii pair<int,int>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=2e5+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e16;
const int INF=0x3f3f3f3f;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    int n;
    ll d;
    cin>>n>>d;
    int ans=0;
    REP(i,n){
        ll x,y;
        cin>>x>>y;
        if((x*x+y*y)<=d*d){
            ++ans;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;


int main(){
    vector<int> A;
    int a;
    for (int i = 0; i < 5; i++) {
        cin >> a;
        A.push_back(a);
    }
    int ans = 1<<30;
    vector<int> P = {0,1,2,3,4};
    do{
        int time = 0;
        for (int i = 0; i < 5; i++) {
            time += A[P[i]];
            if(i==4)break;
            while(time%10!=0)time++;
        }
        ans = min(ans,time);
    }while(next_permutation(P.begin(), P.end()));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
 
t = int(input())

a = list(map(int,input().split()))
b = list(map(int,input().split()))

b = b[::-1]

el = -(10**99)
ok = 1

pref, aft = -1,9999999999
pos = set()

for i in range(t):
  if a[i]==b[i]:
    pos.add(i)
    el = a[i]
    ok = 0

for i in range(t):
  if a[i]==el or b[i]==el:
    break
  pref = i
  
for i in range(t):
  if a[i]>el and b[i]!=el:
    aft = i
    break

if ok==1:
  print('Yes')
  print(*b)
  exit()
  
else:
  if len(pos)> 1+pref +(t-aft):
    print('No')
    
  else:
    try:
      for i in range(pref+1):
        x = pos.pop()
        b[i], b[x] = b[x], b[i]

      for i in range(aft,t):
        x = pos.pop()
        b[i], b[x] = b[x], b[i]
    except:
      pass
      
    print('Yes')
    print(*b)
  


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

int main(){
	int N, D, ans = 0;
	cin >> N >> D;
	double x[N][D];
	for(int i = 0 ; i < N ; i++){
		for(int j = 0 ; j < D ; j++){
			cin >> x[i][j];
		}
	}
	
	for(int i = 0 ; i < N ; i++){
		for(int j = i+1 ; j < N ; j++){
			int sum = 0.0;
			for(int k = 0 ; k < D ; k++){
				sum += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			}
			if((double)sqrt(sum)-(int)sqrt(sum) == 0) ans++;
		}
	}
	
	cout << ans << endl;
	 
	return 0;
}


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

using namespace std;

const int MAX_N = 8005;

vector<int> _dp;
vector<int> _ldp;

int& dp (int x) {
  return _dp[MAX_N + x];
}

int& ldp (int x) {
  return _ldp[MAX_N + x];
}

bool knapsack (vector<int> v, int t) {
  _dp = vector<int> (2 * MAX_N + 5);
  dp(0) = 1;

  for (int u : v) {
    _ldp = _dp;
    for (int i = -MAX_N; i <= MAX_N; i++) {
      dp(i) = 0;
    }

    for (int i = -MAX_N; i <= MAX_N; i++) {
      if (ldp(i)) {
        dp(i - u) = 1;
        dp(i + u) = 1;
      }
    }
  }

  return dp(t);
}

int main () {
  ios::sync_with_stdio(false);

  string s;
  cin >> s;
  
  int x, y;
  cin >> x >> y;

  vector<int> xs;
  vector<int> ys;
  int cur = -1;

  for (char c : s) {
    if (c == 'F') {
      if (cur == -1) x--;
      else if (cur == 0) xs.back()++;
      else if (cur == 1) ys.back()++;
    } else {
      if (cur == 1) {
        xs.push_back(0);
        cur = 0;
      } else {
        ys.push_back(0);
        cur = 1;
      }
    }
  }

  if (knapsack(xs, x) && knapsack(ys, y)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using ll = long long;
using PAIR = pair<int, int>;
using Graph = vector<vector<int>>;
const double pi=acos(-1.0);
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/**************************************/
/******** User-defined Function *******/

/**************************************/
/********** Main()  function **********/
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin >> n >> m;
    if(n==m) cout << "Yes" << endl;
    else cout << "No" << endl;
}
/********  Main() Ends Here *************/


Measured memory_bytes: 3632
a = list(map(int, input().split()))
ans = 0
prise = {1: 300000, 2: 200000, 3: 100000}
for i in a:
  if i not in prise:
    continue
  ans += prise[i]
if a[0] == a[1] == 1:
  ans += 400000
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
bool sort_greater(const ll & lhs , const ll & rhs)
{
    return lhs>rhs;
}
int main()
{
    ll x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    ll p[a],q[b],r[c];
    for(ll i=0;i<a;i++)
    {
        cin>>p[i];
    }
    for(ll i=0;i<b;i++)
    {
        cin>>q[i];
    }
    for(ll i=0;i<c;i++)
    {
        cin>>r[i];
    }
    ll ans=0;
    sort(p,p+a,sort_greater);
    sort(q,q+b,sort_greater);
    sort(r,r+c,sort_greater);
    ll pos_a=0,pos_b=0;
    ll cc=0;
    while(cc<x)
    {
        if(pos_b==c)
        {
            ans += p[pos_a];
            pos_a++;
            cc++;
        }
        else
        {
            if(p[pos_a]>=r[pos_b])
            {
                ans += p[pos_a];
                pos_a++;
                cc++;
            }
            else
            {
                ans+=r[pos_b];
                pos_b++;
                cc++;
            }
        }
    }
    pos_b=0;
    for(;pos_a<x;pos_a++)
    {
        r[pos_b]=p[pos_a];
        pos_b++;
    }
    sort(r,r+c,sort_greater);
    cc=0;
    pos_b=0;
    pos_a=0;
    while(cc<y)
    {
        if(pos_b==c)
        {
            ans += q[pos_a];
            pos_a++;
            cc++;
        }
        else
        {
            if(q[pos_a]>=r[pos_b])
            {
                ans += q[pos_a];
                pos_a++;
                cc++;
            }
            else
            {
                ans+=r[pos_b];
                pos_b++;
                cc++;
            }
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"

using namespace std;

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

  int R;

  cin>>R;

  if(R<1200){
    cout<<"ABC"<<endl;
  }else if(R<2800){
    cout<<"ARC"<<endl;
  }else{
    cout<<"AGC"<<endl;
  }

  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#define rep(index,num) for(int index=0;index<num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
typedef vector<int> vint;
int dp[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
int INF=2e+9;
int main(){
	int H,W;
	char s[52][52];
	int dismin=INF;
	int sironum=0;
	scan(H);scan(W);
	for(int i=1;i<=H;i++){
		scanf("%s",s[i]+1);
	}
	rep(i,W+2){
		s[0][i]='#';
		s[H+1][i]='#';
	}
	rep(j,H+2){
		s[j][0]='#';
		s[j][W+1]='#';
	}
	rep(i,H+2){
		rep(j,W+2){
			if(s[i][j]=='.') sironum++;
		}
	}
	pint inizahyo;
	inizahyo.first=1;
	inizahyo.second=1;
	vector<pint> zahyonow;
	vector<pint> zahyorecord;
	vint disnow;
 	zahyonow.push_back(inizahyo);
	zahyorecord.push_back(inizahyo);
	disnow.push_back(1);
	for(int count=1;;count++){
		if(count>=H*W) break;
		vector<pint> zahyobefore=zahyonow;
		vint disbefore=disnow;
		zahyonow.clear();
		disnow.clear();
		rep(i,zahyobefore.size()){
			if(disbefore[i]+1>=dismin) continue;
			rep(j,4){
				pint zahyoto=zahyobefore[i];
				int disto=disbefore[i]+1;
				int x=zahyoto.first;
				int y=zahyoto.second;
				if(s[x+dp[j][0]][y+dp[j][1]]=='.'){
					zahyoto.first+=dp[j][0];
					zahyoto.second+=dp[j][1];
				}
				int flag=1;
				rep(j,zahyorecord.size()){
					if(zahyoto==zahyorecord[j]){
						flag=0;
						break;
					}
				}
				if(zahyoto.first==H&&zahyoto.second==W&&disto<dismin){
					dismin=disto;
					break;
				}
				else if(flag){
					zahyorecord.push_back(zahyoto);
					zahyonow.push_back(zahyoto);
					disnow.push_back(disto);
				}
			}
		}
	}
	if(dismin==INF){
		prin(-1);
	}
	else{
		prin(sironum-dismin);
	}

	return 0;
}


Measured memory_bytes: 256
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    x = i_input()
    if x == 1:
        print(0)
    else:
        print(1)


if __name__=="__main__":
    main()


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

int main() {
  int i, N, count=0;
  vector<bool> num(26);
  string S;
  
  cin >> S;
  
  rep(i,26) num[i] =false;
  
  rep(i,S.size()){
    num[S[i]-'a'] = true;
  }
  
  rep(i,26) {
    if(num[i]==false) {
      cout << (char)(i+'a');
      count =1;
      break;
    }
  }
  
  if(!count) cout << "None";
}

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

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

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
	int n,ans=0;
	cin>>n;
	while(n){
		if(n>=3){
			n-=3;
			ans++;
			continue;
		}
		break;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int N = I.nextInt();
		int ans = 0;
		for (int i = 1; i <= N; i++) {
			int x = I.nextInt();
			if (x%2==1&&i%2==1) ans++;
		}
		O.pln(ans);
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 25500
#include<cstdio>
int main()
{
	int a[105]={0},n,k,d,aa;
	scanf("%d%d",&n,&k);
	for(int i=0;i<k;i++)
	{
		scanf("%d",&d);
		for(int j=1;j<=d;j++)
		{
			scanf("%d",&aa);
			a[aa]++;
		}
	}
	int sum=0;
	for(int i=1;i<=n;i++)
	if(a[i]==0) sum++;
	printf("%d",sum);
}

Measured memory_bytes: 3228
package main

import "fmt"

const mod = 998244353

var memo [3005][3005]int
var visited [3005][3005]bool

func solve(n, s int, a []int) int {
	if s < 0 {
		return 0
	}
	if visited[n][s] {
		return memo[n][s]
	}
	if n == 1 {
		if s == a[0] {
			memo[n][s] = 1
			visited[n][s] = true
			return 1
		} else if s == 0 {
			memo[n][s] = 2
			visited[n][s] = true
			return 2
		}
		memo[n][s] = 0
		visited[n][s] = true
		return 0
	}
	memo[n][s] = (solve(n-1, s-a[n-1], a) + solve(n-1, s, a)*2) % mod
	visited[n][s] = true
	return memo[n][s]
}

func main() {
	var n, s int
	fmt.Scan(&n, &s)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	fmt.Println(solve(n, s, a))
}


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

int main()
{
    int n;
    cin >> n;
    map<int, int> A;
    int cnt = 0;
    rep(i, n)
    {
        int a;
        cin >> a;
        if (A[a] == 1)
            cnt++;
        else
            A[a]++;
    }
    cout << n - 2 * ((cnt + 1) / 2) << endl;
}

Measured memory_bytes: 4992
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int Q = sc.nextInt();
		int N = 100_001;
		boolean[] prime = new boolean[N+1];
		Arrays.fill(prime, true);
		prime[0] = prime[1] = false;
		for(int x = 4; x <= N; x+=2)
			prime[x] = false;
		for(int i = 3; i <= Math.sqrt(N); i+=2)
			if(prime[i])
				for(int x = i * i; x <= N; x+=i)
					prime[x] = false;
		int[] S = new int[N];
		for(int i = 1; i < N; i++) {
			S[i] = S[i-1];
			if(i % 2 != 0 && prime[i] && prime[(i+1)/2])
				S[i]++;
		}
		for(int q = 0; q < Q; q++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			System.out.println(S[r] - S[l-1]);
		}
	}

}

Measured memory_bytes: 72048
'use strict';
function main(input) {
  const arr = input.trim().split('\n');
  const a = arr[1].split(' ').map(x => Number(x));
  const b = a.concat().sort((a, b) => {return a - b});
  let count = 0;

  for (let i = 0; i < a.length; i ++) {
    if (a[i] !== b[i]) {
      count ++;
    }
  }
  
  console.log(count === 2 || count === 0 ? 'YES' : 'NO');
}

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

Measured memory_bytes: 7372
#include<stdio.h>
int main(void)
{
	int n, m;
	while(scanf("%d %d", &n, &m))
	{
		if(n == 0 && m == n)
		{
		    break;
        }
        int i =0;
	    for( i= 0; i < n; i++)
	    {
	    	int j = 0;
		    for( j= 0; j < m; j++)
		    {
			    printf("#");
		    }
		    printf("\n");
	    }
	    printf("\n");
    }
}


Measured memory_bytes: 2564
#include <bits/stdc++.h>
using namespace std;
long long n,h[200001],a[2000001],c[200001],ans=0,t;
long long lowbit(int x)
{
	return x&-x;
}
void update(long long index,long long max_value)
{
	while(index<=n)
	{
		c[index]=max(c[index],max_value);
		index+=lowbit(index);
	}
	
}
long long  maxrange(long long index)
{
	long long ret=0;
	while(index)
	{
		ret=max(c[index],ret);
		index-=lowbit(index);
	}
	return ret;
}
int main()
{
	long long i,j;
	scanf("%lld",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&h[i]);
	}
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		t=maxrange(h[i]-1);
		update(h[i],t+a[i]);
		ans=max(ans,t+a[i]);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 6656
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class K
{
	static void Main()
	{
		var I = ReadLine().Split().Select(int.Parse).ToArray();
		int N = I[0], A = I[1], B = I[2];
		if (BitCount(A ^ B) % 2 == 0) { WriteLine("NO"); return; }
		WriteLine("YES");
		WriteLine(string.Join(" ", Generate(N, A, B)));
	}
	static IEnumerable<int> Generate(int N, int A, int B)
	{
		if (N == 1) return new[] { A, B };
		B ^= A;
		var c = BitCount(B);
		int[] p = new int[N];
		int o = N - 1, z = 0;
		for (var i = 0; i < N; i++) p[i] = (B & (1u << i)) != 0 ? o-- : z++;
		B = ((1 << c) - 1) << (N - c);
		var l = new List<int>();
		var M = 1 << (N - 1);
		for (var i = 0; i < M; i++) l.Add(i ^ (i >> 1));
		foreach (var i in Generate(N - 1, 1 << (N - 2), B ^ M)) l.Add(i ^ M);
		return l.Select(x =>
		{
			var s = 0;
			for (var j = 0; j < N; j++) if ((x & (1u << p[j])) != 0) s |= 1 << j;
			return s ^ A;
		});
	}
	static int BitCount(int n)
	{
		n = (n & 0x55555555) + ((n >> 1) & 0x55555555);
		n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
		n = (n & 0x0f0f0f0f) + ((n >> 4) & 0x0f0f0f0f);
		n = (n & 0x00ff00ff) + ((n >> 8) & 0x00ff00ff);
		return (n & 0x0000ffff) + ((n >> 16) & 0x0000ffff);
	}
}


Measured memory_bytes: 24924
# 2020/01/26
# AtCoder Beginner Contest 098 - B

# Input
n = int(input())
s = input()

clist_d = [[0] * 27 for i in range(len(s) + 1)]

for i in range(len(s)):
    idx = ord(s[i]) - 97
    clist_d[i][idx] = clist_d[i][idx] + 1

    for j in range(26):
        clist_d[i+1][j] = clist_d[i][j]

maxcnt = 0
for i in range(len(s)):
    cnt = 0
    for j in range(26):
        if clist_d[i][j] > 0 and clist_d[i][j] < clist_d[len(s)-1][j]:
            cnt = cnt + 1
        
        if maxcnt < cnt:
            maxcnt = cnt
    
ans = maxcnt

# Output
print(ans)

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

int main()
{
        int h, m, s;
        cin >> s;
        h=s/3600;
        s=s-h*3600;
        m=s/60;
        s=s-m*60;
        cout<<h<<":"<<m<<":"<<s<<endl;
        return(0);
}



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

//{ SFT
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bit(n) (1 << (n))
#define bits(n) bitset(n)
#define pcnt(x) __builitin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end());
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).flont_back(a)
#define eb(x, a) (x).emplaes_back(a)
#define F first
#define S second
#define cauto (const auto &)
template <class A, class B>
using pii = vector<pair<A, B>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long mod1 = 1e9 + 7;
constexpr long long mod2 = 998244353;
//} END

int counter(int x){
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> a(n + 1);
    int x[20][20], y[20][20];
    int cnt = 0;

    rep(i, 1, n + 1)
    {
        cin >> a[i];
        rep(j, 1, a[i] + 1)
        {
            cin >> x[i][j] >> y[i][j];
        }
    }

    rep(b,1,bit(n)){
        bool jud = true;
        rep(i,1,n+1){
            if(!(b & bit(i-1))) continue;
            rep(j,1,a[i]+1){
                if(((b >> (x[i][j]-1)) & 1 ) ^ y[i][j]){
                    jud = false;
                }
            }
        }
        if(jud == true){
            cnt = max(cnt,counter(b));
        }
    }
    cout<<cnt<<'\n';
}

Measured memory_bytes: 256
H,W,h,w=map(int,raw_input().split())
ans=[[1000]*W for _ in xrange(H)]
for i in xrange(h-1,H,h):
    for j in xrange(w-1,W,w):
        ans[i][j]=-(h*w-1)*1000-1
s=0
for i in xrange(H):
    for j in xrange(W):
        s+=ans[i][j]
if s>0:
    print "Yes"
    for i in xrange(H):
        for j in xrange(W):
            print ans[i][j],
        print
else:
    print "No"


Measured memory_bytes: 8836