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

using namespace std;

typedef long long ll;

#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define read freopen("in.txt", "r", stdin)
#define write freopen("out.txt", "w", stdout)
#define mem(x, n) memset(x, n, sizeof(x))
#define all(x) x.begin(), x.end()
#define endl "\n"

const ll limit = 1e4;

bool isprime[limit + 10];
vector<ll> prime;

void sieve() {
	mem(isprime, true);
	isprime[0] = isprime[1] = false;
	for (ll i = 0; i < limit; i++) {
		if (isprime[i]) {
			prime.push_back(i);
			for (ll j = i * i; j < limit; j += i) {
				isprime[j] = false;
			}
		}
	}
}
map<ll, ll> cnt;

void pf(ll k) {
	for (ll i = 0; i < prime.size(); i++) {
		ll p = prime[i];
		if (p * p > k)
			break;
		if (k % p == 0) {
			while (k % p == 0) {
				k /= p;
			}
			cnt[p]++;
		}
	}
	if (k != 1) {
		cnt[k]++;
	}
}

int main() {
	faster;
	sieve();
	ll n;
	cin >> n;

	vector<ll> a(n);

	for (int i = 0; i < n; i++) {
		cin >> a[i];
		pf(a[i]);
	}

	bool flag = true;

	for (auto x : cnt) {
		if (x.second != 1) {
			flag = false;
			break;
		}
	}

	if (flag) {
		cout << "pairwise coprime" << endl;
	} else {
		ll g = a[0];
		for (ll i = 1; i < n; i++) {
			g = __gcd(g, a[i]);
		}
		if(g == 1){
			cout << "setwise coprime" << endl;
		}else {
			cout << "not coprime" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 15704
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int mh=0,mw=0,h,w,m; cin>>h>>w>>m;
  vector<int> ch(m),cw(m),bh(h,0),bw(w,0);
  for(int i=0; i<m; ++i){
    cin>>ch[i]>>cw[i]; --ch[i]; --cw[i];
    mh=max(mh,++bh[ch[i]]);
    mw=max(mw,++bw[cw[i]]);
  }
  set<int> a,b;
  for(int i=0; i<m; ++i){
    if(bh[ch[i]]==mh) a.insert(ch[i]);
    if(bw[cw[i]]==mw) b.insert(cw[i]);
  }
  int cnt=0;
  for(int i=0; i<m; ++i){
    if(bh[ch[i]]==mh&&bw[cw[i]]==mw) ++cnt;
    if(cnt==(a.size()*b.size())){ cout<<mh+mw-1; return 0;}
  }
  cout<<mh+mw;
  return 0;
}

Measured memory_bytes: 35920
import java.util.Arrays;
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
	     Scanner sc = new Scanner(System.in);
	     
	     int n = sc.nextInt();
	     int m = sc.nextInt();
	     
	     int []a = new int [m];
	     int []d = new int [m-1];
	     
	    if(n < m) {
	     for(int i = 0 ; i< m ; i++) {
	    	 a[i] = sc.nextInt();
	     }
	     Arrays.sort(a);
	     int sum = 0;
	     
	     for(int i = 0 ; i < m-1 ; i++) {
	    	 d[i] = Math.abs(a[i+1] - a[i]);
	    	 sum += d[i];
	     }
	     Arrays.sort(d);
	     
	     int i = m-2;
	     while(n > 1) {
	    	 
	    	 sum -= d[i];
	    	 i--;
	    	 n--;
	     }
	     System.out.println(sum);
	    }
	   if(n >= m) {
		   System.out.println(0);
	   }
	}

}


Measured memory_bytes: 57776
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int cnt4 = 0;
		int oddcnt = 0;
		int even = 0;
		int a[] = new int[n];
		for(int i=0; i<n; i++) {
			a[i]=sc.nextInt();
		}
		for(int i=0; i<n; i++) {
			if(a[i]%2==1) {
				oddcnt++;
			}else if(a[i]%4==0) {
				cnt4++;
			}else {
				even++;
			}
		}
		if(even == 0 && cnt4+1>=oddcnt) {
			System.out.println("Yes");
		}else if(cnt4<oddcnt) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
		sc.close();
	}





}


Measured memory_bytes: 59456
#include<iostream>
#include<string>
using namespace std;
int main()
{
  string A,B,C;
  cin>>A>>B>>C;
  int a,b,c;
  a=A.size();
  b=B.size();
  c=C.size();
  if(A[a-1]==B[0] && B[b-1]==C[0])
    {
      cout<<"YES"<<endl;
    }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


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

int main() {
  string a, b;
  cin >> a >> b;
  string tasu = a + b;
  int number = stoi(tasu);
  float s = sqrt(number);
  int si = s;
  if (si < s) {
  	cout << "No" << endl;
  } else {
  	cout << "Yes" << endl;
  }
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define MAX_V 105
#define INF 1000000001
typedef pair< double ,int> P;

struct edge {
  int to;
  int cap;
  int rev;
  double cost;
};

int V;
vector<edge> G[MAX_V];
double h[MAX_V];
double dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];

void init_edge(){
  for(int i=0;i<MAX_V;i++)G[i].clear();
}

void add_edge(int from,int to,int cap,double cost){
  G[from].push_back((edge){to,cap,(int)G[to].size(),cost});
  G[to].push_back((edge){from,0,(int)G[from].size()-1,-cost});
}

double min_cost_flow(int s,int t,int f){
  double eps = 1e-5;
  double res = 0;
  fill(h,h+V,0.0);
  
  while(f>0){
    
    priority_queue< P, vector<P>, greater<P> >  que;
    fill( dist, dist+V , (double)INF );
    dist[s]=0;
    que.push(P(0,s));

    fill ( prevv , prevv + V , s );
    
    while(!que.empty()){
      P p = que.top(); que.pop();
      int v = p.second;
      if(dist[v]+eps < p.first)continue;
      for(int i=0;i<(int)G[v].size();i++){
        edge &e = G[v][i];
        if(e.cap>0&&dist[e.to] > eps+dist[v]+e.cost+h[v]-h[e.to]){
          dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
          prevv[e.to]=v;
          preve[e.to]=i;
          que.push(P(dist[e.to],e.to));
        }
      }
    }

        
    if(dist[t] == INF){
      return -1;
    }
    for(int v=0;v<V;v++)h[v]+=dist[v]; 

    int d=f;
    for(int v=t;v!=s;v=prevv[v]){
      d=min(d,G[prevv[v]][preve[v]].cap);
    }
    assert( d > 0 );
    f-=d;

    res+=d*h[t];

    for(int v=t;v!=s;v=prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }

  }
  return res;
}

typedef vector< double > vec;
typedef vector<vec> mat;


vec gauss_jordan(const mat&A,const vec&b){
  int n=A.size();
  mat B(n,vec(n+1));
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)B[i][j]=A[i][j];
  for(int i=0;i<n;i++)B[i][n]=b[i];
  for(int i=0;i<n;i++){
    int pivot=i;
    for(int j=i;j<n;j++)
      if(abs(B[j][i])>abs(B[pivot][i]))pivot=j;
    swap(B[i],B[pivot]);
    if(abs(B[i][i])< 0.0000001 )return vec();
    for(int j=i+1;j<=n;j++)B[i][j]/=B[i][i];
    for(int j=0;j<n;j++){
      if(i!=j)
        for(int k=i+1;k<=n;k++)B[j][k]-=B[j][i]*B[i][k];
    }
  }
  vec x(n);
  for(int i=0;i<n;i++)x[i]=B[i][n];
  return x;
}

int N,si,ti,F;
int M;

int main(){
  int T;
  cin>>T;
  while(T--){

    init_edge();
    cin>>N>>si>>ti>>F;
    
    mat A( N , vec(N) );
    vec B( N );
    
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++)scanf("%lf",&A[i][j]);
      scanf("%lf",&B[i]);
    }
    
    vec C=gauss_jordan(A,B);
    
    for(int i=0;i<N;i++){
      
      cin>>M;
      vector<int> d(M);
      vector<int> f(M);
      for(int j=0;j<M;j++)scanf("%d",&d[j]);
      for(int j=0;j<M;j++)scanf("%d",&f[j]);
      
      for(int j=0;j<M;j++){
        add_edge(i,d[j],f[j], abs(C[i]-C[d[j]]) );
        
      }
    }
    V=N;
    double ans=min_cost_flow(si,ti,F);
    if(ans<=-1.0){
      cout<<"impossible"<<endl;
    }else{
      printf("%.10f\n",ans);
    }
  }
  return 0;
}

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

using namespace std;


void solve() {
    int n,m;
    cin >> n >> m;
    int cost[10] = {2048, 2,5,5,4,5,6,3,7,6};
    vector<int> a;
    while (m--) {
        int x; cin >> x;
        a.push_back(x);
    }
    sort(a.begin(), a.end(), greater<int>());
    vector<int> dp(n+20, -111);
    dp[0] = 0;
    for (int i = 0; i <= n; i++) {
        for (int x: a) {
            int k = i + cost[x];
            dp[k] = max(dp[k], dp[i]+1);
        }
    }
    string res;
    while (n) {
        for (int x: a) {
            if (n < cost[x]) continue;
            if (dp[n - cost[x]] + 1 == dp[n]) {
                res += ('0'+x);
                n -= cost[x];
                break;
            }
        }
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
loop do
  n, x = gets.split.map(&:to_i)
  break if n.zero? && x.zero?
  cnt = 0

  for a in 1..(x / 3)
    for b in (a + 1)..(x / 2)
      c = x - a - b
      cnt += 1 if b < c && c <= n
    end
  end
  puts cnt
end


Measured memory_bytes: 6868
N = int(input())
S = input()
ans = S.count("R") * S.count("G") * S.count("B")

for i in range(N-2):
    for d in range(1, (N-i-1)//2+1):
        if {S[i], S[i+d], S[i+2*d]} == {"R", "G", "B"}:
            ans -= 1

print(ans)


Measured memory_bytes: 9132
import math
S = list(map(int, input()))
K = int(input())
count = 0
after_S = 0
days = 5000000000000000-1
for n in S:
    if n == 1:
        count += 1
    else:
        break
if count > 0 and math.log(count) >= math.log(K):
    print(1)
else:
    for n in S:
        after_S += days * math.log(n)
        if after_S >= math.log(K):
            print(n)
            break


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;
int main(void){
    // Your code here!
    int n; cin >> n;
    vector <int> A(n);
    rep(i,n) cin >> A[i];
    int minv=A[0];
    int maxv=A[1]-A[0];
    
    for (int i=1; i<n; i++){
        maxv=max(maxv,A[i]-minv);
        minv=min(minv,A[i]);
    }
    
    cout << maxv << endl;
    return 0;
}



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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


class UnionFind {
private:
    VI par;

public:
    UnionFind(int num_of_v) {
        REP(i, num_of_v) par.push_back(i);
    }

    int root(int x) {
        if(par[x] == x) return x;
        else return par[x] = this->root(par[x]);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return;
        par[x] = y;
    }

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

ll comb2(ll n) {
    return n * (n - 1) / 2;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    VI a(m), b(m);
    REP(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    UnionFind uf(n);
    VL graph_cnt(n, 1);
    VL ans(m);
    ans[m - 1] = comb2(n);
    FORR(i, m - 1, 1) {
        if(!uf.same(a[i], b[i])) {
            ll before_comb = comb2(graph_cnt[uf.root(a[i])]) + comb2(graph_cnt[uf.root(b[i])]);
            ll cnt = graph_cnt[uf.root(a[i])] + graph_cnt[uf.root(b[i])];
            uf.unite(a[i], b[i]);
            graph_cnt[uf.root(a[i])] = cnt;
            graph_cnt[uf.root(b[i])] = cnt;
            ll after_comb = comb2(graph_cnt[uf.root(a[i])]);
            ans[i - 1] = ans[i] - (after_comb - before_comb);
        } else {
            ans[i - 1] = ans[i];
        }
    }

    REP(i, m) cout << ans[i] << ln;
    return 0;
}


Measured memory_bytes: 4216
from sys import stdin
from collections import deque
def main():
    readline=stdin.readline
    N=int(readline())
    G=[[] for _ in range(N)]
    a=[0]*(N-1)
    b=[0]*(N-1)
    c=[0]*(N-1)
    for i in range(N-1):
        a[i],b[i],c[i]=map(int,readline().split())
        a[i]-=1
        b[i]-=1
        G[a[i]].append([b[i],c[i]])
        G[b[i]].append([a[i],c[i]])
    Q,K=map(int,readline().split())
    K-=1
    x=[0]*Q
    y=[0]*Q
    for i in range(Q):
        x[i],y[i]=map(int,readline().split())
        x[i]-=1
        y[i]-=1

    que=deque([[K,0]])
    l=[0]*N
    is_searched=[False]*N
    is_searched[K]=True
    while len(que)>=1:
        now=que.popleft()
        l[now[0]]=now[1]
        for nex in G[now[0]]:
            if is_searched[nex[0]]==False:
                is_searched[nex[0]]=True
                que.append([nex[0],l[now[0]]+nex[1]])

    for i in range(Q):
        print(l[x[i]]+l[y[i]])

if __name__=="__main__":
    main()

Measured memory_bytes: 94128
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
  int i;
  int N, T;
  int t[200010], diff[200010];
  scanf("%d %d", &N, &T);
  long long ans = 0;
  for (i = 0; i < N; i++) {
    scanf("%d", &t[i]);
  }
  for(i = 1; i < N; i++) {
    diff[i] = t[i] - t[i-1];
    ans += min(diff[i], T);
  }
  ans += T;
  printf("%lld", ans);
  return 0;
}


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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

int main() {
    Int n, x, t;
    cin >> n >> x >> t;
    Int res = n / x;
    if (n % x > 0) res++;
    print(res * t);
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sll set<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
using namespace std;

int main(){
	IOS;
	int q=1,c=1;
	//cin>>q;
	while(q--){
		string s;
		cin>>s;

		if(s[1]=='B')
			cout<<"ARC";
		else
			cout<<"ABC";
		
	}
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> vec){ return (ll)vec.size(); }
ll sz(string s){ return (ll)s.size(); }

int main(){
    
    string s,t;
    cin >> s >> t;
    ll ans = LINF;
    rep(i,0,sz(s)-sz(t)+1){
        ll memo = 0;
        rep(j,0,sz(t)){
            if(s[i+j] != t[j]) memo++;
        }
        ans = min(ans,memo);
    }
    cout << ans << endl;
    
    return 0;
}




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

#define fir first
#define sec second
using namespace std;
typedef long long LL;
typedef unsigned long long u64;

template <typename T> inline bool cmin(T & a, const T & b) { return a > b ? a = b, 1 : 0;}
template <typename T> inline bool cmax(T & a, const T & b) { return a < b ? a = b, 1 : 0;}
int inp() {
	int x = 0, f = 1;char ch;
	for(ch = getchar(); !isdigit(ch); ch = getchar())
		if(ch == '-') f = -1;
	for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
	return x * f;
}

const int MaxN = 201234;
char a[MaxN]; int n;
int b[MaxN];
int main() {
	int i;
	scanf("%s", a + 1); n = strlen(a + 1); 
	LL ans = (LL) n * (n + 1) / 2;
	
	for(i = 1; i <= n; i++) 
		b[a[i] - 'a']++;
	for(i = 0; i < 26; i++) ans -= (LL) b[i] * (b[i] + 1)/2;
	cout << ans + 1;
	return 0;
}




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

using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;
    unordered_set<int> st;
    int wrong[n+1];
    memset(wrong,0,sizeof(wrong));
    for(int i=0; i<m; i++){
        int p;
        string s;
        cin >> p >> s;
        if(s == "WA"){
            if(st.find(p) == st.end()) wrong[p] += 1;
        }

        if(s == "AC"){
            st.insert(p);
        }
    }

    int twrong = 0;

    for(int i=1; i<=n; i++){
        if(st.find(i) != st.end()){
            twrong += wrong[i];
        }
    }

    cout << st.size() << " " << twrong << endl;
    return 0;
}


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

int main() {
    int a, b, ans;
    cin >> a >> b;
    ans = max({a+b, a-b, a*b});

    cout << ans;
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author jignesh1604
 */

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define debugg(x) out << #x << " is " << x << "\n" ;
#define gcd(a , b) __gcd(a,b) ;
#define lssetbitindex(x) __builtin_ffs(x)-1 ;           // __builtin_ffs(x) = 1 + least significant 1-bit of x

using namespace std;

class ATheNumberOfEvenPairs {
public:
	void solve(std::istream& in, std::ostream& out) {
	    long long int n , m , i , j ;
	    in >> n >> m ;
	    out << n*(n-1) / 2 + m*(m-1)/2<<"\n";

	}
};


int main() {
	ATheNumberOfEvenPairs solver;
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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


int main(){
	int n;
	char s[100];
	bool flag=false;

	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i];
		if(s[i]=='Y')flag=true;
	}
	if(flag)cout<<"Four"<<endl;
	else cout<<"Three"<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
N, M= map(int, input().split())
ans = set(range(1, M+1)) # it would be a list!?
for i in range(N):
	a, *b = map(int, input().split()) # b=[A11, A12, ...]
	ans &= set(b) # intersection
print(len(ans))

Measured memory_bytes: 3060
N,K=map(int,input().split())
from math import factorial
mod=(10**9)+7
space = N-K+1
def comb(n,k):
  ret = 1
  mod=(10**9)+7
  ret*=factorial(n)%mod
  ret*=pow(factorial(k),mod-2,mod)
  ret*=pow(factorial(n-k),mod-2,mod)
    
  ret%=mod
  return ret

for i in range(1,K+1):
  if space<i:
    print(0)
    continue
  ans = 1
  ans*=comb(space,i)
  ans*=comb(K-1,i-1)
  ans%=mod
  print(ans)

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;


int getKey(int r) {
	if(r <= 0) return 0;
	else if(r >= 1    && r <=  399) return 1;
	else if(r >= 400  && r <=  799) return 2;
	else if(r >= 800  && r <= 1199) return 3;
	else if(r >= 1200 && r <= 1599) return 4;
	else if(r >= 1600 && r <= 1999) return 5;
	else if(r >= 2000 && r <= 2399) return 6;
	else if(r >= 2400 && r <= 2799) return 7;
	else if(r >= 2800 && r <= 3199) return 8;
	else return 9;
}

int main(int argc, char* argv[]){
	int N;
	map<int, int> mp;

	cin >> N;

	int f = 0;
	for(int i=1; i<=N; i++){
		int r, k;
		cin >> r;
		k = getKey(r);
		if(k == 9){
			f++;
			continue;
		}
		if(mp.count(k)==0){
			mp[k] = 1;
		}
	}

	int m = mp.size();
	if(f == 0){
		printf("%d %d\n", m, m);
	}
	else if(m == 0){
		printf("%d %d\n", 1, f);
	}
	else{
		printf("%d %d\n", m, m+f);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>


using namespace std;



int main() {

	int H, W;
	string* S, a;

	cin >> H >> W;

	S = new string[H + 2];

	for (int i = 0; i < W + 2; i++) {
		S[0] += "#";
		S[H + 1] += "#";
	}

	for (int i = 1; i < H + 1; i++) {
		S[i] += "#";
		cin >> a;
		S[i] += a;
		S[i] += "#";
	}


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

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
vector<string> v;

bool wow(string &a,string &b){
    if(a.size()!=b.size())return b.size()>a.size();
    return b>a;
}

void a(string s){
    v.emplace_back(s);
    if(s.length()>10)return ;
    int n=s.length();
    if(s[n-1]=='0'){
        string t=s+s[n-1],tt=s+char(s[n-1]+1);
        a(t);a(tt);
    }
    else if(s[n-1]=='9'){
        string t=s+s[n-1],tt=s+char(s[n-1]-1);
        a(t);a(tt);
    }
    else {
        string t=s+s[n-1],tt=s+char(s[n-1]-1),ttt=s+char(s[n-1]+1);
        a(t);a(tt);a(ttt);
    }
}

int main(){
    int k;cin>>k;
    for(int i=1;i<10;i++)a(to_string(i));
    sort(v.begin(),v.end(),wow);
    cout<<v[k-1];
}

Measured memory_bytes: 43624
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <iomanip>
#include <cstring>
#include <cmath>

using namespace std;

const int MOD = 1000000007;

long long power(long long a, long long b) {
    if (b==0)
        return 1;
    if (b%2==0){
        long long d=power(a,b/2);
        return d*d%MOD;
    }
    return a*power(a,b-1)%MOD;
}

long long comb(long long x, long long y){
  long long res = 1;
  for (long long i = x; i > x - y; i--)
    res = res*i%MOD;
  for (long long i = 1; i <= y; i++)
    res = (res*power(i, MOD-2))%MOD;
  return res;
}

int main() {
    int n, a, b;
    cin>>n>>a>>b;
    long long m=power(2,n)-1;
    long long ca=comb(n,a);
    long long cb=comb(n,b);
    cout<<(2*MOD+m-ca-cb)%MOD<<endl;
}

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

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

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

bool mem[150][150];
int T, N, d[150][150], dx[] = {0, 0, 1, -1, 1, -1}, dy[] = {1, -1, 1, -1, 0, 0};
int bfs(int sx, int sy)
{
  queue<int> q;
  d[sx][sy] = 1;
  q.push(sx);
  q.push(sy);
  while(!q.empty())
  {
    int x = q.front(); q.pop();
    int y = q.front(); q.pop();
    for(int i = 0; i < 6; i++)
    {
      int tx = x + dx[i];
      int ty = y + dy[i];
      if(!mem[tx][ty] && d[x][y] <= T && !d[tx][ty])
      {
        d[tx][ty] = d[x][y] + 1;
        q.push(tx);
        q.push(ty);
      }
    }
  }
  int ans = 0;
  for(int i = 0; i < 150; i++)
    for(int j = 0; j < 150; j++)
      ans += d[i][j] != 0;
  return ans;
}

int main()
{
loop:
  for(int i = 0; i < 150; i++)
    for(int j = 0; j < 150; j++)
      mem[i][j] = d[i][j] = 0;
  cin >> T >> N;
  if(!T)
    return 0;
  for(int i = 0; i < N; i++)
  {
    int a, b;
    cin >> a >> b;
    mem[a + 75][b + 75] = 1;
  }

  int sx, sy;
  cin >> sx >> sy;
  cout << bfs(sx + 75, sy + 75) << endl;
  goto loop;
}

Measured memory_bytes: 1328
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}

//OJ freopen Template
void OJF(const char* inp, const char* out) {
	if (strlen(inp) > 0) freopen(inp, "r", stdin);
	if (strlen(out) > 0) freopen(out, "w", stdout);
}

const int mod = 1e9 + 7, maxn = 100005;

ll binpow(ll a, ll b) {
	int ans = 1, exp = a;
	while(b){
		if(b & 1){
			ans = 1LL * ans * exp % mod;
		}
		exp = 1LL * exp * exp % mod;
		b /= 2;
	}
	return ans;
}

int main(){
    ll n, k;
	cin >> n >> k;
	vector<bool> check(maxn);
	vector<ll> m(maxn), h(maxn);
	for(int i = 1; i <= k; i++){
		m[i] = 1;
		check[i] = true;
	}
	for(int i = 2; i <= k; i++){
		if(check[i]){
			for(int j = i; j <= k; j += i){
				check[j] = false;
				if((j / i) % i == 0){
					m[j] = 0;
				}else{
					m[j] *= -1;
				}
			}
		}
	}
	for(int i = 1; i <= k; i++){
		h[i] = binpow(k / i, n);
	}
	ll ans = 0;
	for(int j = 1; j <= k; j++){
		int f = 0;
		for(int i = j; i <= k; i += j){
			f = (f + 1ll * h[i] * m[i / j]) % mod;
		}
		ans = (ans + 1ll * j * f) % mod;
	}
	cout << (ans + mod) % mod;
	return 0;
}


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

struct info {
	int max{};
	bool done{};
};

int build_dp(info[1000][1000], int, int);
std::string str_x, str_y;

int main()
{
	int q;

	std::cin >> q;
	for (int i = 0; i < q; ++i)
	{
		info dp[1000][1000] {};
		std::cin >> str_x >> str_y;
		std::cout << build_dp(dp, str_x.size() - 1, str_y.size() - 1) << std::endl;
	}
	return 0;
}

int build_dp(info dp[1000][1000], int x_i, int y_i)
{
	if (x_i < 0 || y_i < 0) return 0;
	if (dp[x_i][y_i].done == true) return dp[x_i][y_i].max;

	if (str_x[x_i] == str_y[y_i])
	{
		dp[x_i][y_i].max = build_dp(dp, x_i - 1, y_i - 1) + 1;
		dp[x_i][y_i].done = true;
	}
	else
	{
		dp[x_i][y_i].max = std::max(build_dp(dp, x_i - 1, y_i), build_dp(dp, x_i, y_i - 1));
		dp[x_i][y_i].done = true;
	}
	return dp[x_i][y_i].max;
}


Measured memory_bytes: 11008
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<=n;i++)
	{cin>>a[i];}
	int dp[n];
	memset(dp,0,sizeof(dp));
	dp[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++)
	{
		int m=INT_MAX;
		for(int j=1;j<=k;j++)
		{
		    if(i-j<0)
		    {
		        break;
		    }
			m=min(dp[i-j]+abs(a[i-j]-a[i]),m);
		}
		dp[i]=m;
		//dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
		//cout<<dp[i]<<endl;
		
	}
	cout<<dp[n-1]<<endl;

	return 0;
}

Measured memory_bytes: 4388
// AOJ 0594
#include <iostream>
#include <algorithm>

using namespace std;

typedef pair <int, int> P;

int main()
{
	int w, h, n;
	cin >> w >> h >> n;

	P data[1280];
	// data[0].first = data[0].second = 0;
	for (int i = 0; i < n; i++){
		cin >> data[i].first >> data[i].second;
	}
	long long ret = 0;
	for (int i = 1; i < n; i++){
		P now = data[i - 1], nxt = data[i];
		if (now.first < nxt.first && now.second < nxt.second){
			ret += max(nxt.first - now.first, nxt.second - now.second);
		}
		else if (now.first > nxt.first && now.second > nxt.second){
			ret += max(now.first - nxt.first, now.second - nxt.second);
		}
		else {
			ret += (abs(now.first - nxt.first) + abs(now.second - nxt.second));
		}
		// cout << ret << endl;
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define ll long long 

using namespace std;

bool solve(int arr[],int n)
{
	for(int i=0;i<n;i++)
	{
		if(arr[i]%2==0)
		{
			if(arr[i]%3!=0)
			{
			   if(arr[i]%5!=0)
			     return false;
			   
			}
		}
	}
	return true;
}


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    
    if(solve(arr,n))
    {
    	cout<<"APPROVED"<<endl;
	}
	else 
	{
		cout<<"DENIED"<<endl;
    }
	return 0;

}



Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]

sm = sum(a)
acc = [0]
for i in range(n):
  acc.append(acc[-1] + a[i])

ans = 10000000000
for i in range(1,n):
  ans = min(ans,abs(sm - acc[i] * 2))
print(ans)


Measured memory_bytes: 100884
import java.util.*;
public class Main {
	public static void main(String[] args){
		// get numbers
		Scanner sc = new Scanner(System.in);        
		String a = sc.next();
        String b[] = new String[a.length()];
        int cal = 0;
        int ans = 0;

        for (int i = 0; i < a.length(); i++) {
            b[i] = a.substring(i, i+1);
        }

        for (String val : b) {
            if (val.equals("A") || 
                val.equals("C") || 
                val.equals("G") || 
                val.equals("T")) {
                cal++;
                if (cal > ans) {
                    ans = cal;
                }
            } else {
                cal = 0;
            }
        }
		// output
        System.out.println(ans);
        sc.close();
	}
}

Measured memory_bytes: 22868
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li		int32_t
#define lli		long long
#define ulli unsigned long long
 
#define pn			 printf("\n")
#define nl			 cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)
 
#define sl          cout<<' '
#define ps          printf(" ")
 
#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))
 
#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define lb		lower_bound
#define ub		upper_bound
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second
#define Dup     erase(unique(V.begin(),V.end()),V.end())
 
#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound
 
#define MX1     100000
#define MX2     1000000
#define MX3     10000
#define Inf     1000000000000000
#define mod		1000000007
using namespace std;

vlli V;
lli N,A,B;

bool f(lli x)
{
    lli i;
    lli Sum=0;
    
    rep(i,0,N)
    {
        if(V[i]>x*B)
        {
            lli y=(V[i]-x*B);
            
            lli z=ceil((y*1.0)/(A-B));
            Sum+=z;
        }
    }
    
    if(Sum<=x)
    return 1;
    
    return 0;
}

lli Power(lli a,lli b)
{
    lli result=1;
 
    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }
 
        b=b>>1;
        a=(a*a)%mod;
    }
 
 return result;
}
 
int main()
{
    opt;
 
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
    
    lli i;
    cin>>N>>A>>B;
    
    rep(i,0,N)
    {
        lli x;
        cin>>x;
        
        V.pb(x);
    }
    
    lli low=1,high=mod,Store;
    
    while(low<=high)
    {
        lli mid=(low+high)/2;
        
        if(f(mid))
        {
            Store=mid;
            high=mid-1;
        }
        else
        {
            low=mid+1;
        }
    }
    
    cout<<Store;
    
    
    
 
 return 0;
}

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

using namespace std;
using ll = long long;

const int N = 200005;

int n, k, a[N];
int p[N];

int main() {

	scanf("%d %d", &n, &k);

	for(int i = 1; i <= n; i++) scanf("%d", a + i);

	map<int, int> cnt;

	int s = 0;

	cnt[s]++;

	ll ans = 0;
	for(int i = 1; i <= n; i++) {
		if(i >= k) {
			cnt[p[i - k] - (i - k)]--;
		}
		s = (s + a[i]) % k;
		p[i] = s;
		ans += cnt[s - i];
		ans += cnt[s - i + k];
		cnt[s - i]++;
	}

	printf("%lld\n", ans);
}


Measured memory_bytes: 20608
import Control.Applicative
import Control.Monad
import Data.List
import Data.Array
import Data.Char

main = do
  n <- (read::String -> Int) <$> getLine
  print $ length $ filter is_valid [1,3..n]


is_valid::Int -> Bool
is_valid n = let numDiv = length $ filter (\i -> n `mod` i == 0) [1..n]
              in numDiv == 8


Measured memory_bytes: 508
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int main()
{
	int q; cin>>q;
	while(q--) 
	{
		int n; cin>>n;
		//set<int> used;
		bool used[1000001];
		fill(used,used+1000001,0);
		int ans=0;
		//while(used.find(n)==used.end()&&9<n)
		while(!used[n]&&9<n)
		{
			int next=0,r=0;
			//used.insert(n);
			used[n]=true;
			int mul=1;
			while(1)
			{
				r+=n%10*mul;
				n/=10;
				mul*=10;
				if(n==0) break;
				next=max(next,r*n);
			}
			n=next;
			ans++;
		}
		if(n<=9) cout<<ans<<endl;
		else cout<<-1<<endl;
	}
  return 0;
}

Measured memory_bytes: 2136
#include<bits/stdc++.h>
#define MAXN 100005
#define MAXM 200005
int N,A,B,Ans[MAXN];
bool mark[MAXN];
int tot,en[MAXM],nex[MAXM],las[MAXN];
void ADD(int x,int y)
{
    en[++tot]=y;
    nex[tot]=las[x];
    las[x]=tot;
}

int path[MAXN],Cnt[MAXN];
bool flag;
void Find_Path(int p,int f)
{
    if(flag)return;
    int i,y;
    if(p==N){flag=true;return;}
    for(i=las[p];i;i=nex[i])
    {
        y=en[i];
        if(y==f)continue;
        path[y]=p;
        Find_Path(y,p);
    }
}

void DFS1(int p,int f)
{
    int i,y;
    Cnt[p]=1;
    for(i=las[p];i;i=nex[i])
    {
        y=en[i];
        if(y==f||mark[y])continue;
        DFS1(y,p);
        Cnt[p]+=Cnt[y];
    }
}

void DFS2(int p,int f)
{
    int i,y;
    for(i=las[p];i;i=nex[i])
    {
        y=en[i];
        if(y==f||mark[y])continue;
        A++;
        DFS2(y,p);
    }
}
int main()
{
    int i,x,y,cnt=0;

    scanf("%d",&N);
    for(i=1;i<N;i++)scanf("%d%d",&x,&y),ADD(x,y),ADD(y,x);

    Find_Path(1,-1);
    for(i=N;i!=1;i=path[i])mark[path[i]]=true;
    mark[1]=mark[N]=true;
    for(i=N;path[i]!=1;i=path[i])DFS1(path[i],-1); 
    for(i=N;path[i]!=1;i=path[i])cnt++,Ans[cnt]=Ans[cnt-1]+Cnt[path[i]];
    
    DFS2(1,-1);
    B=A;A=0;
    DFS2(N,-1);
    
    if(B+Ans[cnt]-Ans[cnt/2]>A+Ans[cnt/2])printf("Fennec");
    else printf("Snuke");
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

struct Data {
    int seq;
    string name;
    int rep;

    Data(int s, string n, int r)
    {
        seq = s;
        name = n;
        rep = r;
    }
};

bool cmp(const Data& a, const Data& b)
{
    if (a.name == b.name) {
        return a.rep > b.rep;
    } else {
        return a.name < b.name;
    }
}

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

    vector<Data> arr;
    for (int i = 0; i < N; i++) {
        string S;
        int P;
        cin >> S >> P;
        Data d(i, S, P);
        arr.push_back(d);
    }

    std::sort(arr.begin(), arr.end(),cmp);
    for (int i = 0; i < N; i++) {
        cout << arr[i].seq+1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n, k;
	int p[10000] = {0};
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> p[i];
	}
	for(int i = 0; i < n - 1; i++){
		for(int j = 0; j < n - 1 - i; j++){
			if(p[j] > p[j + 1]){
				int buf = p[j];
				p[j] = p[j + 1];
				p[j + 1] = buf;
			}
		}
	}
	int c = 0;
	for(int i = 0; i < k; i++){
		c += p[i];
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class CExceptionHandling
    {
        static void Main(string[] args)
        {            
            var n = int.Parse(Console.ReadLine());
            var aList = new List<int>();
            int max = 0;
            int max2 = 0;
            int maxIndex = 0;
            for (int i = 0; i < n; i++)
            {
                int a = int.Parse(Console.ReadLine());
                aList.Add(a);

                if (max < a)
                {
                    max = a;
                    maxIndex = i;
                    continue;
                }
                if (max2 < a)
                {
                    max2 = a;
                    continue;
                }
            }

            var sb = new StringBuilder();
            for (int i = 0; i < n; i++)
            {
                sb.AppendLine(i == maxIndex ? max2.ToString() : max.ToString());
            }

            Console.WriteLine(sb.ToString());
            Console.ReadLine();
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LSOne(i) ((i) & -(i))

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

    ll a,b;
    cin >> a >> b;
    if ((a+b)&1) {
        cout << "IMPOSSIBLE\n";
    } else {
        cout << (a+b)/2 << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>//sort??¢??°????????¨?????????????????????
using namespace std;

int main(){
	int A[3];
	cin >> A[0] >> A[1] >> A[2];
	
	sort(A,A+3);
	
	
	cout << A[0]  << " "<< A[1] << " " << A[2] << "\n";

	return 0;
}

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

int main()
{
  int N;
  bool YFlag = false;
  cin >> N;

  for(int i = 1; i <= N; i++)
  {
    string color;
    cin >> color;

    if(color == "Y"){
      cout << "Four" << endl;
      YFlag = true;
      break;
    }
  }
  if(!YFlag){
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
N=int(input())
LL=[]
for i in range(N):
    a,b=list(map(int,input().strip().split(' ')))
    LL+=[(a,b)]
LL=sorted(LL,key=lambda x:sum(x),reverse=True)
ans=0
for i in range(len(LL)):
    if i%2==0:
        ans+=LL[i][0]
    else:
        ans-=LL[i][1]
print(ans)            

Measured memory_bytes: 22128
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define inf 1000000009
#define N 1000005
 
using namespace std;
 
int a,b;

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    
    cin >> a >> b;
    if(500 * a >= b) cout << "Yes";
    else cout << "No";

    return 0;
}

Measured memory_bytes: 256
G = []
cnt = 0

def insertionSort(A, n, g):
  for i in range(g, n):
    v = A[i]
    j = i - g
    while j >= 0 and A[j] > v:
      global cnt
      cnt += 1
      A[j+g] = A[j]
      j -= g
    A[j+g] = v

def shellSort(n, A):
  m = 1
  while m <= n / 9:
    m = m * 3 + 1
  while 0 < m:
    global G
    G.append(m)
    insertionSort(A, n, m)
    m = int(m / 3)

A = []
n = int(input())

for i in range(n):
  A.append(int(input()))

shellSort(n, A)

print(len(G))
print(*G)
print(cnt)

for i in range(n):
  print(A[i])


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

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String op;
      String[] words;
      Tree tree = new Tree();

      for(int i=0,k=0; i<n; i++,k=0){
        words = br.readLine().split(" ");
        op  = words[k++];
        if ( op.equals("insert") ) { 
          tree.insert(Integer.parseInt(words[k++]));
        }
        else {
          tree.dispRoundPath();
        }
      }

    }
    catch(IOException e) {
      System.out.println("IOException!");
    }
  }
}

class Tree {

  static final BTreeNode NIL = new BTreeNode(-1);
  BTreeNode root;
  StringBuilder buf;

  public Tree() {
    root = NIL;
    buf = new StringBuilder();
  }

  public void insert(int val) {
    BTreeNode y = NIL;
    BTreeNode x = root;
    BTreeNode z = new BTreeNode(val);

    while( !x.equals(NIL) ) {
      y = x;
      if( z.key < x.key )
        x = x.left;
      else
        x = x.right;
    }
    z.parent = y;

    if( y.equals(NIL) ){
      root = z;
    }
    else if( z.key < y.key )
      y.left = z;
    else
      y.right = z;
  } 
  void preParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      buf.append(" ").append(u.key);
      preParse(u.left);
      preParse(u.right);
    }
  }
  void inParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      inParse(u.left);
      buf.append(" ").append(u.key);
      inParse(u.right);
    }
  }

  void dispRoundPath() {

    inParse(root);
    buf.append("\n");
    preParse(root);
    buf.append("\n");

    System.out.print(buf);
    buf.setLength(0);
  }
}

class BTreeNode {
  int key;
  BTreeNode parent,left,right;

  public BTreeNode(int key) {
    this.key = key;
    this.parent =
    this.left =
    this.right = Tree.NIL;
  }

  @Override
  public boolean equals(Object o) {
    if(o == this) return true;
    if(o == null) return false;
    if(!(o instanceof BTreeNode)) return false;

    BTreeNode node = (BTreeNode)o;
    if(!(this.key == node.key)) return false;

    return true;
  }
}


Measured memory_bytes: 125784
import collections

m = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = collections.Counter(prime_factorize(m))
# index = list(c.keys())
number = list(c.values())
ans = 0
for i in number:
    step = 1
    key = 1
    while key <= i:
        ans += 1
        step += 1
        key += step

print(ans)

Measured memory_bytes: 9468
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,tot=0;
    for(int i=1;i<=3;i++)
    {
        scanf("%d",&x);
        tot=tot*10+x;
    }
    tot%4==0?printf("YES\n"):printf("NO\n");
    return 0;
}

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

int main()
{
	int n,i,sum=0;
	cin>>n;
	int a[n+1];
	for(i=1;i<=n;i++)
		cin>>a[i];
	bool b[101];
	for(i=1;i<=100;i++)
		b[i]=false;
	for(i=1;i<=n;i++)
		b[a[i]]=true;
	for(i=1;i<=100;i++)
		if(b[i]==true)
			sum++;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var S = ReadText();
            var x = 0L;
            var max = x;
            foreach (var s in S)
            {
                if (s == 'I')
                {
                    x++;
                }
                else
                {
                    x--;
                }

                max = Math.Max(max, x);
            }
            return max;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 27556
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ld long double
#define mem(a,b) memset(a,b,sizeof(a) )
#define M 2005
#define md 1000000007

ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}
//inline ll add(ll a,ll b){return (a+b)%md;}
//inline ll mul(ll a,ll b){return (a*b)%md;}
//ll f[M],iv[M];
//ll C(ll n,ll r){return mul(f[n],mul(iv[r],iv[n-r]));}
//void prep_fac(){
//    f[0]=1;
//    rep(i,1,M)f[i]=mul(i,f[i-1]);
//    iv[M-1]=power(f[M-1],md-2,md);
//    for(ll i=M-2;i>=0;--i)iv[i]=mul(i+1,iv[i+1]);
//}



int main()
{
	IOS;
	int n;
	cin>>n;
	vll v1,v2;
	rep(i,0,n){
		ll x,y;cin>>x>>y;
		ll p=(x-y);
		ll q=(x+y);
		v1.pb(p);
		v2.pb(q);
	}
	srt(v1),srt(v2);
	ll ans=max(v1[n-1]-v1[0],v2[n-1]-v2[0]);
	cout<<ans;
}



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

int main(){
	int m, d;
  	cin >> m >> d;
  	int c = 0;
    for(int j = 22; j <= d; j++){
        int temp = j;
        int d1 = temp%10;
        int d10 = temp/10;
        if(d1 <= 1 || d10 <= 1)continue;
        int num = d1*d10;
        if(num > m)continue;
        // cout << num << " " << d10 << " " << d1 << "\n";
        c++;
    }
  	cout << c;
}

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

const int MOD = 1000000007;

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

    int N;
    scanf("%d", &N);
    int A;
    int R = 0, B = 0, G = 0;
    int64_t ret = 1;
    for (int i = 0; i < N; i++) {
        scanf("%d", &A);
        int t = 1;
        if (R == A) {
            R++;
            if (B == A) t++;
            if (G == A) t++;
        } else if (B == A) {
            B++;
            if (G == A) t++;
        } else if (G == A) {
            G++;
        } else {
            cout << 0 << endl;
            return 0;
        }
        ret = ret * t % MOD;
    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
//TemplateMatching.cpp (B)
#include <iostream>
#include <string>
using namespace std;

int main(){
  int M,N;
  cin >> N >> M;
  string A[N],B[M];
  for(int i = 0; i < N; i++) cin >> A[i];
  for(int i = 0; i < M; i++) cin >> B[i];

  bool flag = false;
  int chk;
  for(int i = 0; i < N - M + 1; i++){
    for(int j = 0; j < N - M + 1; j++){
      chk = 0;
      for(int k = 0; k < M; k++){
        if(B[k] == A[i+k].substr(j,M)) ++chk;
      }
      if(chk == M){
        flag = true;
        break;
      }
    }
    if(flag) break;
  }

  if(flag) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <climits>
#include <cmath>
#include <algorithm>
#include <cassert>

#define TEST_ASSERT(msg, cond) do { if (cond) { cout << msg << " => pass" << endl;} else { cout << msg << " => failed" << endl;} } while(0)

using namespace std;

int main() {

  vector<char> ss(3);
  int cnt = 0;
  for (int i = 0; i < 3; i++) {
    cin >> ss[i];
    if (ss[i] == '1') {
      cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



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

    int ans = p.size();
    string s = p.substr(0, 1);
    string pr;
    for (int i = 1; i < p.size(); i++) {
        pr = s;
        string a = p.substr(i, 1);
        if (s != a) {
            s= a;
        }
        else {
            if (i < p.size() - 1) {
                s = p.substr(i, 2);
                i++; ans--;
            }
        }
      //  cout << s << endl;
    }
    if (pr == s)ans--;
    cout << ans<<endl;


    
    return 0;

}


Measured memory_bytes: 640