akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int calcGcd(int n, int m) {
  if (n < m) {
    int tmp = n;
    n = m;
    m = tmp;
  }
 
  int r = n%m;
  while (r!=0) {
    n=m;
    m=r;
    r=n%m;
  }
  return m;
}
 
int main() {
  int n, k;
  cin >> n >> k;
 
  vector<int> a;
  for (int i=0; i<n; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
 
  int gcd=a[0];
  int maxNum=a[0];
 
  for (int i=0; i<n; i++) {
    gcd = calcGcd(gcd, a[i]);
    maxNum = max(maxNum, a[i]);
  }
 
  if (k%gcd==0 && k<=maxNum) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
ll bpow(ll,ll,ll);
typedef vector<int> vec;
typedef vector<vec> mat;
mat mul(mat &A,mat &B);
mat pow(mat A,ll n);
int dx[3] = {1,0,-1};
int dy[3] = {1,0,-1};
const int MOD = 1000000007;

bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  string A,B;
  cin >> A >> B;
  if(A.size() > B.size()){
    cout << "GREATER" << endl;
    return 0;
  }else if(A.size() < B.size()){
    cout << "LESS" << endl;
    return 0;
  }else if(A == B){
    cout << "EQUAL" << endl;
    return 0;
  }
  for(int i=0;i<A.size();i++){
    if(A[i] > B[i]){
      cout << "GREATER" << endl;
      return 0;
    }else if(A[i] < B[i]){
      cout << "LESS" << endl;
      return 0;
    }
  }
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

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

ll bpow(ll a, ll n,ll mod){
  int i = 0;
  ll res=1;
  while(n){
    if(n & 1)
      res = (res*a) % mod;
    a = (a*a) % mod;
    n >>= 1;
  }
  return res;
}
mat mul(mat &A, mat &B){
  mat C(A.size(),vec(B[0].size()));
    REP(i,A.size())REP(k,B.size())REP(j,B[0].size()){
    C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  }
  return C;
}

mat pow(mat A,ll n)
{
  mat B(A.size(),vec(A.size()));
  REP(i,A.size()){
    B[i][i] = 1;
  }
  while(n > 0){
    if ( n & 1) B = mul(B,A);
    A = mul(A,A);
    n >>= 1;
  }
  return B;
}


Measured memory_bytes: 256
//
// Created by yamunaku on 2019/07/14.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

struct edge{
    int to;
    ll d;
};

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    vector<ll> a(n),c(n),b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> c[i],c[i]--;
    rep(i,n) cin >> b[i];
    vector<vector<edge>> e(n);
    int u,v,ds;
    rep(i,m){
        cin >> u >> v >> ds;
        e[u-1].push_back({v-1,ds});
        e[v-1].push_back({u-1,ds});
    }
    vector<ll> dist(n,LINF);
    priority_queue<pair<ll,int>> pq;
    pq.push({0,0});
    while(!pq.empty()){
        auto now=pq.top();
        pq.pop();
        if(dist[now.second]!=LINF) continue;
        dist[now.second]=-now.first;
        for(auto nx:e[now.second]){
            if(dist[nx.to]!=LINF) continue;
            pq.push({now.first-nx.d,nx.to});
        }
    }
    vector<ll> ans(k,-LINF);
    rep(i,n) pq.push({a[i]-dist[i],i});
    vector<ll> deli(n,-LINF);
    while(!pq.empty()){
        auto now=pq.top();
        pq.pop();
        if(deli[now.second]!=-LINF) continue;
        deli[now.second]=now.first;
        ans[c[now.second]]=max(ans[c[now.second]],now.first+b[now.second]-dist[now.second]);
        for(auto nx:e[now.second]){
            if(deli[nx.to]!=-LINF) continue;
            pq.push({now.first-nx.d,nx.to});
        }
    }
    rep(i,k) cout << ans[i] << endl;
    return 0;
}




Measured memory_bytes: 23756
import java.util.*;
import static java.lang.System.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] c =sc.next().toCharArray();
		boolean flag = false;
		if ( c[0] == c[1] && c[2] == c[3] && c[0] != c[2])
			flag = true;
		if (c[0] == c[2] && c[1] == c[3] && c[0 ] != c[1])
			flag = true;
		if (c[0] == c[3] && c[1] == c[2] && c[0] != c[1])
			flag = true;
		if(flag)
			out.println("Yes");
		else
			out.println("No");
		
	}
}

Measured memory_bytes: 23124
#include<stdio.h>

int kyouyaku(int a,int b){
  int tmp;
  if(a<b){
    tmp=a;
    a=b;
    b=tmp;
  }
  if(a%b==0)
    return b;
  return kyouyaku(b,a%b);
}

int main(){
  int i,j,k,n,gcd;
  int sum=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      for(k=1;k<=n;k++){
        gcd=kyouyaku(kyouyaku(i,j),k);
        sum+=gcd;
      }
    }
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 1736
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int[] box = new int[101];
		int i = 0, tmp;
		while (scanner.hasNext()) {
			tmp = scanner.nextInt();
			if (tmp == 0) {
				i--;
				System.out.println(box[i]);
			} else {
				box[i] = tmp;
				i++;
			}
		}
		scanner.close();
	}

}



Measured memory_bytes: 25796
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		String s = scn.next();
		int b = s.replaceAll("0", "").length();
		int r = s.length()-b;
		System.out.println(s.length()-Math.abs(b-r));
		scn.close();
	}
}

Measured memory_bytes: 32484
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
 int a[20];
 for (int i = 0;i <= 19;i++){
 	cin >> a[i];
 }
 int w = 0;int k = 0;
 for(int i = 3;i <= 9;i++){
 int p = a[i];
 for(int ii =0;ii <= 2;ii++){
 	if(p > a[ii]){
 		swap(a[ii],p);
 	}
 }
 }
w = a[0] + a[1] + a[2];
for(int i = 13;i <= 19;i++){
 int p = a[i];
 for(int ii =10;ii <= 12;ii++){
 	if(p > a[ii]){
 		swap(a[ii],p);
 	}
 }
 }
 k = a[10] + a[11] + a[12];
 cout << w <<" " << k << endl;
	return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> l(n);
    rep(i,n) cin >> l.at(i);
    sort(all(l));
    ll ans = 0;
    for(i = 0;i < n-1;++i){
        for(j = i+1;j < n;++j){
            ll tmp = l.at(i) + l.at(j);
            ll ind = lower_bound(all(l), tmp) - l.begin();
            ans += ind - j - 1;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
f=lambda:map(int,input().split())
n,m=f()
g=[set() for _ in range(n)]
for i in range(m):
  a,b=f()
  g[a-1].add(b-1)
  g[b-1].add(a-1)
import itertools as it
c=0
for t in it.permutations(range(1,n)):
  p=0
  for q in t:
    if q not in g[p]: break
    p=q
  else: c+=1
print(c)

Measured memory_bytes: 3064
loop {
    n = gets.to_i
    break if n == 0

    a = (1..n).map{ gets.to_i }
    sum = max = 0
    a.each{|x|
        sum = [sum + x, 0].max
        max = sum if sum > max
    }
    p a.all?{|x| x < 0} ? a.max : max
}

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

ll calc(string s, int idx) {
    ll sum = 0;
    int n = s.size();
    for (int bit = 0; bit < (1 << s.size() - 1); ++bit) {
        vector<int> st;
        for (int i = 0; i < n; ++i) {
            if (bit & (1 << i)) {
                st.push_back(i);
            }
        }
        vector<int> nums;
        int size = st.size();
        if (0 < size) {
            int current_idx = 0;
            int temp_sum = 0;
            for (int i = 0; i < size; ++i) {
                int next_idx = st.at(i);
                ll n = stoll(s.substr(current_idx, next_idx + 1 - current_idx), nullptr, 0);
                temp_sum += n;
                current_idx = next_idx + 1;
            }
            ll n = stoll(s.substr(current_idx), nullptr, 0);
            sum += temp_sum + n;
        } else {
            sum += stoll(s, nullptr, 0);
        }
    }
    return sum;
}

void solve() {
    string S;
    cin >> S;
    ll x = calc(S, 0);
    cout << x << endl;
}

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


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

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int n,m,num[MX];
bool posi[MX];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    FOR(i,1,n+1) num[i] = 1;
    posi[1] = 1;
    F0R(i,m) {
        int x,y; cin >> x >> y;
        if (posi[x]) {
            if (num[x] == 1) posi[x] = 0;
            posi[y] = 1;
        }
        num[x] --, num[y] ++;
    }
    int ans = 0;
    FOR(i,1,n+1) if (posi[i]) ans ++;
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int n; cin >> n;
    map<string,int> mp;
    rep(i,n) {
        string s;
        cin >> s;
        mp[s]++;
    }
    int mx = 0;
    for (auto p : mp) mx = max(mx, p.second);
    for (auto p : mp) {
        if (p.second != mx) continue;
        cout << p.first << endl;
    }

    return 0;
}

Measured memory_bytes: 19148
""" AtCoder """

S = list(input())
T = list(input())

s = len(S)
t = len(T)
p = []

check = True
for i in range(s - t + 1):
    for j in range(t):
        if S[i + j] != T[j] and S[i + j] != '?':
            check = False
            break
    if check:
        p.append(i)
    check = True

if len(p) == 0:
    print("UNRESTORABLE")
    exit()

ans = S[:p[0]] + T + S[p[0] + t:]
for j in range(s):
    if ans[j] == '?':
        ans[j] = 'a'

for i in range(len(p)):
    tmp = S[:p[i]] + T + S[p[i] + t:]
    for j in range(s):
        if tmp[j] == '?':
            tmp[j] = 'a'
    if tmp < ans:
        ans = tmp

print("".join(ans))


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

using namespace std;
using ll = long long;

#define MOD 998244353
template<int mod>
struct ModInt{
   int x;
   ModInt():x(0){}
   ModInt(long long y):x(y>=0?y%mod:(mod-(-y)%mod)%mod){}
   ModInt &operator+=(const ModInt &p){
       if((x+=p.x)>=mod)x-=mod;
       return *this;
   }
   ModInt &operator-=(const ModInt &p){
       if((x+=mod-p.x)>=mod)x-=mod;
       return *this;
   }
   ModInt &operator*=(const ModInt &p){
       x=(int)(1LL*x*p.x%mod);
       return *this;
   }
   ModInt &operator/=(const ModInt &p){
       *this*=p.inverse();
       return *this;
   }
   ModInt &operator^=(long long p){
       ModInt res = 1;
       for (; p; p >>= 1) {
           if (p & 1) res *= *this;
           *this *= *this;
       }
       return *this = res;
   }
   ModInt operator-()const{return ModInt(-x);}
   ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
   ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
   ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
   ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
   ModInt operator^(long long p)const{return ModInt(*this)^=p;}
   bool operator==(const ModInt &p)const{return x==p.x;}
   bool operator!=(const ModInt &p)const{return x!=p.x;}
   explicit operator int() const { return x; }
   ModInt operator=(const int p) {x = p; return ModInt(*this);}
   ModInt inverse()const{
       int a=x,b=mod,u=1,v=0,t;
       while(b>0){
           t=a/b;
           a-=t*b;
           std::swap(a,b);
           u-=t*v;
           std::swap(u,v);
       }
       return ModInt(u);
   }
   friend std::ostream &operator<<(std::ostream &os,const ModInt<mod> &p){
       return os<<p.x;
   }
   friend std::istream &operator>>(std::istream &is,ModInt<mod> &a){
       long long x;
       is>>x;
       a=ModInt<mod>(x);
       return (is);
   }
};
typedef ModInt<MOD> mint;
 
/* originally written by QCFium */
struct MComb {
   std::vector<mint> fact;
   std::vector<mint> inversed;
   MComb(int n) { // O(n+log(mod))
       fact = std::vector<mint>(n+1,1);
       for (int i = 1; i <= n; i++) fact[i] = fact[i-1]*mint(i);
       inversed = std::vector<mint>(n+1);
       inversed[n] = fact[n] ^ (MOD-2);
       for (int i = n - 1; i >= 0; i--) inversed[i]=inversed[i+1]*mint(i+1);
   }
   mint ncr(int n, int r) {
       return (fact[n] * inversed[r] * inversed[n-r]);
   }
   mint npr(int n, int r) {
       return (fact[n] * inversed[n-r]);
   }
   mint nhr(int n, int r) {
       assert(n+r-1 < (int)fact.size());
       return ncr(n+r-1, r);
   }
};
 
mint ncr(int n, int r) {
   mint res = 1;
   for (int i = n - r + 1; i <= n; i++) res *= i;
   for (int i = 1; i <= r; i++) res /= i;
   return res;
}

int main()
{
    int N, M, K; cin >> N >> M >> K;
    mint ans = 0;
    MComb comb(1000000);
    mint m = mint(M);//, n = mint(N);

    for(int i = 0; i <= K; i++) {
        int curn = N - i;
        mint cur = m;
        cur *= (m - 1)^(curn - 1);
        cur *= comb.ncr(N - 1, i);
        ans += cur;
    }
    cout << ans << endl;


}

Measured memory_bytes: 11180
def nyu():
    N = int(input())
    A = list(map(int,input().split()))
    return N,A


def check(N,A):
    flg = True

    for n in range(N):
        if A[n] % 2 == 0:
            if A[n] % 3 != 0 and A[n] % 5 != 0:
                flg = False
                break

    if flg == True:
        print("APPROVED") 
    else :
        print("DENIED")
    



            

N,A = nyu()
check(N,A)



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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, M;
  cin >> N >> M;
  vector<string> A(N), B(M);
  rep(i, N)cin >> A[i];
  rep(i, M)cin >> B[i];

  bool find = false;
  rep(i, N-M+1){
    rep(j, N-M+1){
      if(A[i].substr(j, M)==B[0]){
        find = true;
        rep(k, M){
          if(A[i+k].substr(j, M)!=B[k]){
            find = false;
            break;
          }
        }
        if(find)break;
      }
      if(find)break;
    }
    if(find)break;
  }

  if(find)cout << "Yes"<<endl;
  else cout << "No"<<endl;
  return 0;
}


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

#define rep(i,j,n) for(int i=(j);i<(n);++i)
#define erep(i,j,n) for(int i=(j);i<=(n);++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	string s, t;
	cin >> s >> t;
	rep(i, 0, s.size()) {
		if (s == t) {
			cout << "Yes\n";
			return 0;
		}
		s = s[s.size() - 1] + s.substr(0, s.size() - 1);
	}
	cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
//find_by_order(k) - k is the kth element of the multiset
//order_of_key(k) - Number of elements striclty samller than k
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<min(a*b,c);
}

Measured memory_bytes: 256
#include<iostream>
#include <iomanip>
using namespace std;
int main(){
    int W,H,x,y;
    cin>>W>>H>>x>>y;
    double res = (double)W*H/2;
    int tmp = 0;
    if(W==x*2 && H==y*2)tmp = 1;
    printf("%.6f %d\n",res,tmp);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
 
int main(void){
	int N,tmp,result=0;
	map<int,int> mp;
	cin>>N;
	REP(i,N){
		cin>>tmp; mp[tmp]++;
	}
	for(auto itr=mp.begin();itr!=mp.end();itr++){
		int number=itr->first;
		int count=itr->second;
		if(number>count) result+=count;
		else result+=(count-number);
	}

	print(result);


	

	return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

struct UnionFind {
  vector<ll> data;
  UnionFind(ll size) : data(size, -1) { }
  bool unionSet(ll x, ll y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(ll x, ll y) {
    return root(x) == root(y);
  }
  ll root(ll x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  ll size(ll x) {
    return -data[root(x)];
  }
};


int32_t main()
{
//整数値の入力
ll n,m;
cin >> n>>m;
ll ans[m];
//行列の入力
ll aaa,bbb;
pair<ll, ll> table[m];
for (ll i = 0; i < m; ++i) {
  
  cin >> aaa>>bbb;
  table[i] = make_pair(aaa-1, bbb-1);
}

UnionFind arr(n);

ll an=n*(n-1)/2;
ans[m-1]=an;
for (ll i = 0; i < m-1; ++i) {
  if(arr.findSet(table[m-1-i].first,table[m-1-i].second)){ans[m-2-i]=an;}
  else{
    an=an-(arr.size(table[m-1-i].first)*arr.size(table[m-1-i].second));
    ans[m-2-i]=an;
    arr.unionSet(table[m-1-i].first,table[m-1-i].second);

  }
   //cout << arr.size(table[m-1-i].first) << endl;
}


for (ll i = 0; i < m; ++i) {
  
  cout << ans[i] << endl;
}
//回答

return 0;
}



Measured memory_bytes: 4480
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K; cin >> N >> K;
	string S; cin >> S;

	int c = 0;
	rep(i, 0, N) {
		if (i > 0 && S[i] == S[i - 1] && S[i] == 'L')
			c++;
		if (i < N - 1 && S[i] == S[i + 1] && S[i] == 'R')
			c++;
	}

	cout << min(N - 1, c + K * 2) << endl;

	return 0;
}

Measured memory_bytes: 512
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n,w,d = LI()
        if n == 0 and w == 0 and d == 0:
            break
        a = [LI() for _ in range(n)]
        r = [(w,d)]
        for p,s in a:
            ww, dd = r.pop(p-1)
            u = ww + dd
            s %= u
            tr = []
            if s < ww:
                tr.append((s,dd))
                tr.append((ww-s,dd))
            else:
                s -= ww
                tr.append((ww,s))
                tr.append((ww,dd-s))
            r.extend(sorted(tr,key=lambda x: x[0]*x[1]))

        rr.append(' '.join(map(lambda x: str(x[0]*x[1]), sorted(r,key=lambda x: x[0]*x[1]))))
    return '\n'.join(map(str,rr))


print(main())




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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
string S,T;
ll ansr = INF;
cin >> S >> T;
REP(i, S.size()-T.size()+1){
  ll ans = 0;
  REP(j, T.size()){
    if(S[i+j]!=T[j]) ans++;
  }
  ansr = min(ans, ansr);
}
    cout << ansr;
}

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

int main() {
  int N; cin >> N;
  vector<int> P(N); vector<int> Q(N);
  for (int i =0; i<N; i++) cin >> P[i];
  for (int i =0; i<N; i++) cin >> Q[i];
  
  vector<int> numN(N);
  for (int i =0; i<N; i++) numN[i] = i+1;
  int kaijouN = 1;
  for (int i =0; i<N; i++) kaijouN *= i+1;
  
  int numP =0,numQ =0;
  while(next_permutation(P.begin(),P.end())) {
    numP++;
  }
  while(next_permutation(Q.begin(),Q.end())) {
    numQ++;
  }
  
  int ans = abs(numP - numQ);
  cout << ans << endl;  
}

Measured memory_bytes: 3632
s = input()
# ls = [i for i in s]
ls = list(s)
# ils = [map(int, ls)] ・・・✖
ils = list(map(int, ls))
# print(ils)
# print(len(s))
n = len(s)
cnt = 0
for i in range(1, n):
    if ils[i] == ils[i-1] and ils[i] == 0:
        cnt += 1
        ils[i] = 1
    elif ils[i] == ils[i-1] and ils[i] == 1:
        cnt += 1
        ils[i] = 0
print(cnt)

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

signed main() {
  int n,k; string s;
  cin >> n >> k >> s;

  int ans = 1;
  int l=0, r=0;

  while(r<n && s[r] == '1') r++;

  while(k > 0 && r < n) {
    while(r<n && s[r] == '0') r++;
    while(r<n && s[r] == '1') r++;
    k--;
  }

  ans = max(ans, r - l); 

  while(r<n) {
    ans = max(ans, r - l); 
    while(l<r-1 && s[l] == '1') l++;
    while(l<r-1 && s[l] == '0') l++;

    while(r<n && s[r] == '0') r++;
    while(r<n && s[r] == '1') r++;
    ans = max(ans, r - l); 
  }
  cout << ans << endl;
}


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

using namespace std;

int main(){
    int n, num, max, cont = 0;

    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> num;
        if(!i){
            max = num;
            cont++;
        }else if(num >= max){
            max = num;
            cont++;
        }
    }

    cout << cont << endl;


    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using P=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

string s;
int q;
bool isReverse;
int main(){
	cin >> s >> q;
	rep(_, 0, q){
		int t; cin >> t;
		if(t-1){
			int f; char c; cin >> f >> c;
			if(isReverse){
				if(f-1) s = c + s;
				else s += c;
			}
			else{
				if(f-1) s += c;
				else s = c + s;
			}
		}
		else isReverse = !isReverse;
	}
	if(isReverse) s = string(ALLR(s));
	cout << s << endl;
    return 0;
}


Measured memory_bytes: 4184
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
    ll x, y; cin >> x >> y;
    ll ans = 0;
    if (x >= 0) {
        if (y >= x) ans = abs(abs(x) - abs(y));
        else if (0 < y && y < x) ans = abs(abs(x) - abs(y)) + 2;
        else if (y <= 0) ans = abs(abs(x) - abs(y)) + 1;
    }
    else {
        if (x<=y&&y<=0) ans = abs(abs(x) - abs(y));
        else if (y < x) ans = abs(abs(x) - abs(y)) + 2;
        else if (0 < y) ans = abs(abs(x) - abs(y)) + 1;
    }
    cout << abs(ans) << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
int kol[300000],red[300000],n,m,k;
map<pair<int,int>,bool> x;
vector<int> q,w;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>m;
	for(int i=0;i<n;i++)red[i]=0;
	for(int j=0;j<m;j++)kol[j]=0;
	cin>>k;
	for(int i=0;i<k;i++){
		int a,b;
		cin>>a>>b;--a;--b;
		x[mp(a,b)]=1;
		kol[b]++;
		red[a]++;
	}
	int ma=red[0],mb=kol[0];
	for(int i=1;i<n;i++)ma=max(ma,red[i]);
	for(int i=1;i<m;i++)mb=max(mb,kol[i]);
	for(int i=0;i<n;i++)
		if(red[i]==ma)
			q.pb(i);
	for(int i=0;i<m;i++)
		if(kol[i]==mb)
			w.pb(i);
	if(q.size()*w.size()>k){
		cout<<ma+mb;
		return 0;
	}
	for(int i=0;i<q.size();i++)
		for(int j=0;j<w.size();j++)
			if(!x[mp(q[i],w[j])]){
				cout<<ma+mb<<endl;
				return 0;
			}
	cout<<ma+mb-1;
	return 0;
}

Measured memory_bytes: 28460
let switch c =
  let uc = Char.uppercase c in
  let lc = Char.lowercase c in
  if uc = c && lc <> c then lc
  else if uc <> c && lc = c then uc
  else c ;;
let () =
  let s = read_line() in 
  for i = 0 to (String.length s) - 1 do
    Printf.printf "%c" (switch s.[i])
  done;
  print_newline();;



Measured memory_bytes: 2220
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  bool b[1000001];
  for(int i=0;i<1000001;i++){
    b[i]=true;
  }
  int ans=0;
  for(int i=0;i<n;i++){
      bool temp=true;
      if(n!=n-1){
          if(a[i]==a[i+1]) temp=false;
      }
      if(b[a[i]] and temp) ans++;
      if(!b[a[i]]) continue;
      for(int j=a[i];j<=1000000;j+=a[i]){
          b[j]=false;
      }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5392
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  string n;cin>>n;
  string ans="No";
  if(n[0]==n[2])ans="Yes";
  cout(ans);
  
  return 0;
}

Measured memory_bytes: 125568
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(void)
{
    long long int sum=0;
    int n,k,i;
    cin>>n>>k;
    vector<int> h;
    h.resize(n+1);
    for(i=0;i<n;i++)
    {
        cin>>h[i];
    }
    sort(h.begin(),h.end());
    if(n-k>0){
    for(i=0;i<=n-k;i++)
    {
        sum+=h[i];
    }
    cout<<sum<<endl;
    }
    else
    {
        cout<<0<<endl;
    }
return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i<N;i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int sum = 1;
  for(int i = 1;i<N;i++){
    if(vec.at(i-1) >vec.at(i)){
      sum += 1;
    }
  }
  cout << sum <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <set>
#include <map>

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()

#define X first
#define Y second

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 0x3fffffff;

struct UnionFind{
	std::vector<int> data;
	UnionFind(int size): data(size, -1){ }
	
	// 集合を併合する
	bool unite(int x, int y){
		x=root(x); y=root(y);
		if( x != y ) data[y] = x;
		return x!=y;
	}

	// 同じ集合かどうか判定
	bool find(int x, int y){
		return root(x) == root(y);
	}

	// 集合の識別番号を返す
	int root(int x){
		return (data[x] < 0)? x : data[x]=root(data[x]);
	}
};


UnionFind uf(1200005);
vector<pii> edge[400005];
vector<pii> v[100005];
int d[400005];
map<int,int> mp[100005];
int main(){
	int N, M, ans=0;

	cin >> N >> M;
	rep(i,M){
		int p, q, c;
		scanf(" %d %d %d", &p, &q, &c);
		p--; q--;
		v[p].emplace_back(c,i);
		if( !mp[p].count( c ) ){
			mp[p][c] = i;
		}else{
			uf.unite( i, mp[p][c] );
		}
		v[q].emplace_back(c,i);
		if( !mp[q].count( c ) ){
			mp[q][c] = i;
		}else{
			uf.unite( i, mp[q][c] );
		}
	}
//	int s = M+1;
//	int g = M+2;
	int s = 0;
	int g = N-1;
//	v[0].emplace_back( -1, s );
//	v[N-1].emplace_back( -1, g );
//	rep(i,N){
//		rep(j,v[i].size()) rep(k,j){
//			if( v[i][j].X == v[i][k].X ){
//				uf.unite( v[i][j].Y, v[i][k].Y );
//			}
//		}
//	}
	rep(i,N){
		rep(j,v[i].size()){
			int vj = uf.root(v[i][j].Y) + N;
			edge[ i  ].emplace_back( vj, 1 );
			edge[ vj ].emplace_back( i, 1 );
		}
	}

	queue<pii> que;
	Fill(d, INF);
	d[s] = 0;
	que.emplace(0,s);
	while( !que.empty() ){
		pii p = que.front(); que.pop();
		if( d[p.Y] < p.X ) continue;
		for(auto e: edge[p.Y]){
			if( d[e.X] > d[p.Y] + e.Y ){
				d[e.X] = d[p.Y] + e.Y;
				que.emplace( d[e.X], e.X );
			}
		}
	}

	if( d[g] == INF ) d[g] = -2;

	cout << (d[g]/2) << endl;

	return 0;
}


Measured memory_bytes: 59776
import scala.io.StdIn.readInt

object Main extends App {

  def getMax(i:Int,minv:Int,maxv:Int,r:Int):Int = {
    val m = r-minv
    if(i==1) m.max(maxv)
    else getMax(i-1,r.min(minv),m.max(maxv),readInt)
  }

  println(getMax(readInt-1,readInt,Int.MinValue,readInt))

}

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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

int main()
{
	LL A, B, C, D;
	cin >> A >> B >> C >> D;

	for (;;) {
		C -= B;
		if (C <= 0) {
			cout << "Yes" << endl;
			break;
		}

		A -= D;
		if (A <= 0) {
			cout << "No" << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define F first
#define S second
#define ld long douroote
#define pb push_back
#define sz size
#define ll long long
#define ull unsigned long long
#define INF 0x7f7f7f7f
#define sc(a) scanf("%d",&a)
#define scll(a) scanf("%lld",&a)
#define scd(a) scanf("%lf",&a)
#define scc(a) scanf(" %c",&a)
#define scs(a) scanf(" %s",a)
#define me(a,b) memset(a,b,sizeof a)
#define all(a) a.begin(),a.end()
#define allr(a,n) a,a+n
#define loop(a,s,e) for(ll a=s;a<=e;a++)
#define read_arr(a,s,n) for(int i=s;i<n+s;i++){sc(a[i]);}
#define read_arr_ll(a,s,n) for(int i=s;i<n+s;i++){scll(a[i]);}
#define err(a,s) cerr<<a<<s;
#define err_arr(a,s,n) for(int i=s;i<n+s;i++){cerr<<a[i]<<" ";}cerr<<endl;
#define prtll(x) printf("%lld",x);
#define prt(x) printf("%d",x);
using namespace std;
const int N=(1<<22)+10;
int a[N],mem[23][N],n,tmp,mod=1e9+7;
int dp(int ind,int mask){
if(ind==n){return 1;}
int &ret=mem[ind][mask];
if(ret!=-1){return ret;}
int inter=mask&a[ind];
ret=0;
loop(i,0,n-1){
    if(inter&(1<<i)){
     ret+=dp(ind+1,mask-(1<<i))%mod;
     ret%=mod;
   }
}
return ret%mod;
}
int main(){
me(mem,-1);
sc(n);
loop(i,0,n-1){
  loop(j,0,n-1){sc(tmp);a[i]+=tmp*(1<<j);}
}
int mask=(1<<n)-1;
int ans=dp(0,mask);
printf("%d\n",ans);
}

/**
**/


Measured memory_bytes: 379136
N=int(input())
T=[int(x) for x in input().split()]
M=int(input())
P=[]
X=[]
for i in range(M):
    p1,x1=(int(d) for d in input().split())
    P.append(p1)
    X.append(x1)
sum1=0
for i in range(N):
    sum1+=T[i]
for i in range(M):
    temp=sum1
    temp=temp-T[P[i]-1]+X[i]
    print(temp)

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

const LL M1 = 1000000007;
const LL M2 = 1000000009;
LL R1, R2;
map<PLL,LL> memo;
PLL thash(int u, int p, VVI& G){
  PLL res(1, 1);

  for(int v: G[u]){
    if(v == p) continue;
    PLL x = thash(v, u, G);
	(res.FF += R1 * x.FF % M1) %= M1;
	(res.SS += R2 * x.SS % M2) %= M2;
  }

  memo[res]++;
  return res;
}

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

  mt19937 mt;
  R1 = mt() % M1, R2 = mt() % M2;

  int N;
  cin >> N;
  VVI G(N);
  REP(i,N-1){
	int u, v;
	cin >> u >> v;
	--u;
	--v;
	G[u].PB(v);
	G[v].PB(u);
  }
  thash(0, -1, G);

  LL ans = 0;
  for(auto&& p: memo)
	ans += p.SS * (p.SS - 1) / 2;
  cout << ans << endl;

  return 0;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int x; cin >> x;
	for (int i = 1;; i++) {
		if (i * (i + 1) / 2 >= x) {
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double area = r*r*Math.PI;
        double cir = 2*r*Math.PI;
        System.out.printf("%.6f %.6f",area,cir);
    }
}



Measured memory_bytes: 28376
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long d = sc.nextLong();
		int ans = 0;
		long dd = d * d;
		// System.out.println("d: " + d);
		// System.out.println("dd: " + dd);
		for (int i = 0; i < n; i++) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			long aa = a * a;
			if (aa <= dd) {
				if (aa + b * b <= dd) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
}








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

using namespace std;
long long ans(int x,int y,int z){
  long long ans;
  ans=x*x;
  ans+=y*y;
  ans+=z*z;
  ans+=y*x;
  ans+=z*x;
  ans+=y*z;
  return ans;
}

int main()
{
  int N;
  int A[1000000];
  cin>>N;
  for(int l=1;l<=N;l++){
    A[l]=0;
  }
  for(int i=1;i<N;i++){
    for(int j=i;j<N;j++){
      for(int k=j;k<N;k++){
        long long l=ans(i,j,k);
        if(l>10000)break;
        if(i==j&&i==k){
              A[l]++;
        }else if(i==j||i==k||k==j){
              A[l]+=3;
        }else{
              A[l]+=6;
        }        
      }
    }
  }
  for(int l=1;l<=N;l++){
    cout<<A[l]<<"\n";
  }
  return 0;
}





Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int M=0;
  int L=0;
  cin>>N;
  vector<int>vec(N);
  for(int X=0;X<N;X++){
    cin>>vec.at(X);
    if(M<vec.at(X)){
      L=M;
      M=vec.at(X);
    }
    else if(L<vec.at(X)){
      L=vec.at(X);
    }
  }
  for(int X=0;X<N;X++){
    if(vec.at(X)==M){
      cout<<L<<endl;
    }
    else{
      cout<<M<<endl;
    }
  }
}

Measured memory_bytes: 3968
/*
	Name:
	Author: xiaruize
	Date:
*/

#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 ll long long
#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

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int n,tree[26][500005];

int lowbit(int x)
{
	return x&(-x);
 } 
 
void add(int x,int k,int tr)
{
	while(x<=n)
	{
		tree[tr][x]+=k;
		x+=lowbit(x);
	}
}

int sum(int x,int tr)
{
	int ans=0;
	while(x>0)
	{
		ans+=tree[tr][x];
		x-=lowbit(x);
	}
	return ans;
}

signed main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<n;i++)
	{
		add(i+1,1,s[i]-'a');
	}
	int t;
	cin>>t;
	int x,y,z;
	char c;
	while(t--)
	{
		cin>>x;
		if(x==1)
		{
			cin>>y>>c;
			add(y,-1,s[y-1]-'a');
			add(y,1,c-'a');
			s[y-1]=c;
		}
		else if(x==2)
		{
			cin>>y>>z;
			int ans=0;
			for(int i=0;i<26;i++)
			{
				if(sum(z,i)>sum(y-1,i))
				{
					ans++;
				}
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 51740
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;
const int maxn=1e5+5;
map<pair<int,int>,bool> friends,blocks;
int type[maxn],deg[maxn],num[maxn],ans[maxn];
int find(int a)
{
    return type[a]==a?a:type[a]=find(type[a]);
}
int main()
{
    blocks.clear();
    friends.clear();
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    for(int i=1;i<=n;i++)
        type[i]=i;
    while(m--)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        if(u>v) swap(u,v);
        if(!friends.count(make_pair(u,v)))
        {
            friends[make_pair(u,v)]=true;
            deg[u]++;
            deg[v]++;
        }
        int u_=find(u),v_=find(v);
        type[u_]=v_;
    }
    memset(num,0,sizeof(num));
    for(int i=1;i<=n;i++)
        num[find(i)]++;
    for(int i=1;i<=n;i++)
        ans[i]=num[find(i)]-1-deg[i];
    while(k--)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        if(u>v) swap(u,v);
        if(find(u)==find(v))
            if(!blocks.count(make_pair(u,v)))
            {
                blocks[make_pair(u,v)]=true;
                if(!friends.count(make_pair(u,v)))
                {
                    ans[u]--;
                    ans[v]--;
                }
            }
    }
    for(int i=1;i<=n;i++)
        printf("%d%c",ans[i],i==n?'\n':' ');
    return 0;
}


Measured memory_bytes: 15872
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let mut ans = a - if b < a { 1 } else { 0 };
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <stack>
#include <iomanip>

using namespace std;


// 入力を読み込み, 扱いやすい形式に変換する
// 例 : "10 2 12 - /" -> ["10", "2", "12", "-", "/"]
vector<string> read_input()
{
    string line;
    getline(cin, line);
    istringstream ss(line);
    
    vector<string> parsed_str;
    while (!ss.eof()) {
        string tmp; ss >> tmp;
        parsed_str.push_back(tmp);
    }

    return parsed_str;
}


double solve(vector<string> input_strs)
{
    stack<double> st;

    for (string S : input_strs) {
        if (isdigit(S[0]) || S.size() > 1) {
            int num = stoi(S);
            st.push(num);
        } else {
            double b = st.top(); st.pop();
            double a = st.top(); st.pop();
            if (S == "-") st.push(a - b);
            if (S == "+") st.push(a + b);
            if (S == "*") st.push(a * b);
            if (S == "/") st.push(a / b);
        }
    }

    return st.top();
}


int main()
{
    while (true) {
        vector<string> input_strs = read_input();
 
        // 全てのテストケースを処理し終わったらループを抜ける
        if (cin.eof()) break;

        double ans = solve(input_strs);
        cout << fixed << setprecision(10) << ans << endl;
   }
}

Measured memory_bytes: 3132