akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define Rep(i, s, n) for (ll i = (ll)s; i < (ll)n; i++)
typedef long long ll;

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

    int n;
    string s;
    cin >> n >> s;
    int res = 1;
    Rep (i, 1, n) {
        if (s[i] != s[i-1]) res++;
    }
    cout << res << endl;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

void print_line(vector<int> &line) {
    for (int i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;

int insertion_sort(vector<int> &a, int n, int g) {
    int count = 0;
    for (int i = g; i < n; i++) {
        int v = a[i];
        int j = i - g;
        while (j >= 0 && a[j] > v) {
            a[j + g] = a[j];
            j = j - g;
            count++;
        }
        a[j + g] = v;
    }
    return count;
}

int main() {

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int count = 0;
    vector<int> g;
    for (int j = 1; j <= n; j = j * 3 + 1) g.push_back(j);
    reverse(g.begin(), g.end());
    rep(i, g.size()) count += insertion_sort(a, n, g[i]);

//    insertion_sort(a, n, 1);

    cout << g.size() << endl;
    print_line(g);
    cout << count << endl;
    rep(i, n) cout << a[i] << endl;

}



Measured memory_bytes: 6792
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

int p;

ll modpow(ll a, ll b) {
	ll ans = 1;
	a %= p;
	while (b) {
		if (b & 1) ans = ans * a%p;
		a = a * a%p;
		b >>= 1;
	}
	return ans;
}

vector<ll> fac(4005);
vector<ll> inv(4005);
vector<ll> facinv(4005);

void modcalc() {
	fac[0] = fac[1] = 1; inv[1] = 1;
	facinv[0] = facinv[1] = 1;
	for (int i = 2; i < 4005; i++) {
		fac[i] = fac[i - 1] * i % p;
		inv[i] = p - inv[p%i] * (p / i) % p;
		facinv[i] = facinv[i - 1] * inv[i] % p;
	}
}

ll modcomb(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return fac[n] * facinv[k] % p * facinv[n - k] % p;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	cin >> p;
	modcalc();

	vector<vector<int>> modpow_(p + 1, vector<int>(p));
	rep(i, p) {
		rep(j, p) {
			if (j == 0) modpow_[i][j] = 1;
			else {
				modpow_[i][j] = modpow_[i][j - 1] * i%p;
			}
		}
	}

	vector<int> a(p);
	int cnt = 0;
	vector<int> ans(p);
	rep(i, p) {
		cin >> a[i];
		if (a[i]) {
			cnt++;
			rep(j, p) {
				//cout << p - i << ' ' << p - 1 - j << endl;
				if (i != 0) ans[j] += p - modpow_[p - i][p - 1 - j] * modcomb(p - 1, j) % p;
			}
			if (i == 0) {
				ans[p - 1] += p - 1;
				ans[p - 1] %= p;
			}
		}
	}
	ans[0] += cnt;
	rep(i, p) cout << ans[i] % p << ' ';
	cout << endl;
}


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

int main() {
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  int dis = 0;
  for(int i = 0; i < n - 1; i++){
    int l = a.at(i + 1) - a.at(i);
    dis = max(dis, l);
  }
  
  int l = k + a.at(0) - a.at(n - 1);
  dis = max(dis, l);
  
  cout << k - dis << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    string o, e, ans;
    cin >> o >> e;
    int ol = o.size(), el = e.size();
    int l = min(ol, el);
    rep(i, l) {
        ans += o[i];
        ans += e[i];
    }
    if(ol > el) ans += o[ol - 1];
    else if(ol < el) ans += e[el - 1];

    cout << ans << endl;

    return 0;
}

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

struct UnionFind{
    vector<int> par,rank;

    UnionFind(int n){
        par.resize(n);
        rank.resize(n);
        for(int i=0; i<n; i++){
            par[i]=i;
            rank[i]=0;
        }
    }

    void unite(int x,int y)
    {
        x = root(x);y = root(y);
        if(x == y) return;

        if( rank[x] < rank[y] )
        {
            par[x] = y;
        }
        else
        {
            par[y] = x;
            if(rank[x] == rank[y])
            {
                rank[x]++;
            }
        }
    }

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

    int root(int x)
    {
        if (x == par[x]) return x;

        return root(par[x]);
    }
};


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

    UnionFind u(N);

    for(int i=0; i<Q; i++) {
        int p,a,b;
        cin >> p >> a >> b;

        if(p) {
            cout << (u.same(a,b) ? 1 : 0) << endl;
        }else{
            u.unite(a,b);
        }
    }
}

Measured memory_bytes: 1280
#!/usr/bin/env python
import sys
import re
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor
sys.setrecursionlimit(1000000)


def main():
    input = sys.stdin.readline
    #N, M = map(int, input().split())
    #N, K = map(int, input().split())
    #ps = list(map(int, input().split()))

    N = int(input())
    Hs = list(map(int, input().split()))

    cnt = 0
    max_cnt = 0
    for i in range(N-1):
        if Hs[i] >= Hs[i+1]:
            cnt += 1
            max_cnt = max([max_cnt, cnt])
        else:
            cnt = 0
    print(max_cnt)


if __name__ == '__main__':
    main()


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	char c;cin>>c;
	printf("%c\n",c+1);
}

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

int main(void){
    string s;
    int price = 700;
    cin >> s;

    if(s[0] == 'o')
        price += 100;
    if(s[1] == 'o')
        price += 100;
    if(s[2] == 'o')
        price += 100;

    cout << price << endl;

    return 0;
}

Measured memory_bytes: 3576
N = int(input())
A = [list(map(int, input().split())) for _ in range(2)]
if N == 1:
    print(A[0][0] + A[1][0])
else:
    s = sum(A[1]) + A[0][0]
    ans = s
    for i in range(1, N):
        s += A[0][i] - A[1][i - 1]
        ans = max(ans, s)
    print(ans)


Measured memory_bytes: 3060
n=int(input())
s=list(input().split())
t=int(s[0])
a=int(s[1])
h=list(input().split())
temp=[]
for i in range(n):
  temp.append(abs(a-(t-int(h[i])*0.006)))
print(temp.index(min(temp))+1)

Measured memory_bytes: 38256
N = gets.chomp.to_i
S = gets.chomp
A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
s = Array.new(S.size)

for i in 0...S.size do
    j = 0
    while S[i] != A[j]
        j += 1
    end
    s[i] = A[(j+N)%26]
end

for i in 0...S.size do
    print s[i]
end
puts

Measured memory_bytes: 2684
#include<iostream>
#include<fstream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<typeinfo>
using namespace std;

typedef unsigned long long ull;

ull factorial(ull n){
    if(n == 1) return 1;
    return (n*factorial(n-1))%(1000000000+7);
}

int main(){
    ull N;
    cin >> N;
    cout << factorial(N) << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N, K;
string S;

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

  vi b, e;
  if(S[0] == '0') {
    b.pb(0);
    e.pb(0);
  }

  bool seq = false;
  REP(i, N) {
    if(seq && S[i] == '0') {
      e.pb(i - 1);
      seq = false;
    }
    if(!seq && S[i] == '1') {
      b.pb(i);
        seq = true;
    }
  }
  e.pb(N - 1);

  if(b.size() <= K) {
    cout << N << endl;
    return 0;
  }

  int ans = 0;
  REP(i, b.size() - K + 1) {
    ans = max(ans, e[i + K] - b[i] + 1);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1020
#include <map>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

map <string, int> m;
int main() {
	int n;
	cin >> n;
	string s;
	for (int i = 1; i <= n; i++) {
		cin >> s;
		m[s]++;
	}
	cout << "AC x " << m["AC"] << endl;
	cout << "WA x " << m["WA"] << endl;
	cout << "TLE  x " << m["TLE"] << endl;
	cout << "RE x " << m["RE"] << endl;
	return 0;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

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

	set<char> ns, ew;
	for(auto x : s)
		if(x == 'N' || x == 'S')
			ns.insert(x);
		else
			ew.insert(x);

	if(ns.size()%2 == 0 && ew.size()%2 == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define ll long long
int main(){
  ll n,m,sum=0;
  cin>>n>>m;
  ll a[m];
  for(ll i=0;i<m;i++){
    cin>>a[i];
    sum+=a[i];
  }
  if(sum>n)
    cout<<"-1";
  else
    cout<<n-sum;
  return 0;
}

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

using namespace std;

#define ll long long
#define endl '\n'

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    if (n < 500) cout << (n / 5) * 5;
    else cout << (n / 500) * 1000 + ((n - (n / 500) * 500) / 5) * 5;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

int main()
{
  ll N,A,B;
  cin >> N >> A >> B;
  if(A < B && N >= 2)
    cout << (N-2)*(B-A) + 1 << endl;
  else if(A == B)
    cout << 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
Data = [0]
Push = [0] * (N+1)
for _ in range(N):
    Data.append(int(input()))

nowp = 1
Push[nowp] = 1

ans = 0
for i in range(N):
    nowp = Data[nowp] 
    ans += 1
    if nowp == 2:
        break
    elif Push[nowp] == 1:
        ans = -1
        break
    else:
        Push[nowp] = 1
print(ans)


Measured memory_bytes: 7880
N,M=map(int,input().split())
A=[int(i) for i in input().split()]
B=[0 for i in range(M)]
C=[0 for i in range(M)]
X=[]
for i in range(M):
    B[i],C[i]=map(int,input().split())
    X.append((B[i],C[i]))
A.sort()
X.sort(key=lambda x:x[1],reverse=True)
index=0
flag=1
for i in range(M):
    tmp=0
    for j in range(index,index+X[i][0]):
        if not(0<=j<N):
            break
        if A[j]<X[i][1]:
            A[j]=X[i][1]
            tmp+=1
        else:
            flag=0
            break
    if flag==0:
        break
    index+=tmp
print(sum(A))


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

const long double PI = acos(-1);
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

 bool IsPrime(ll 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;
}

int main(){
    ll x;
    cin >> x;

    for(ll i = x; ; i++){
        if (IsPrime(i)){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);



signed main(){
    int n,ans=0;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i < n;i++)
    {
        cin>>v.at(i);
    }

    for(int i=0;i < n-2;i++)
    {
        if(max({v[i],v[i+1],v[i+2]})!=v[i+1] && min({v[i],v[i+1],v[i+2]})!=v[i+1]){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int get_int() {
    int n = 0;
    int c = getchar_unlocked();
    if(c == 45) {
        c = getchar_unlocked();
        while(47 < c && c < 58) n = 10 * n + (c & 0xf), c = getchar_unlocked();
        return -n;
    } else if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) n = 10 * n + (c & 0xf), c = getchar_unlocked();
    return n;
}
void put_uint(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}

typedef struct UnionFind {
    int parent[100];
    int rank[100];
    int size[100];
} UnionFind;
void uf_init(UnionFind *UF) {
    const int N = 100;
    for(int i = 0; i < N; ++i) {
        UF->parent[i] = i;
        UF->rank[i] = 0;
        UF->size[i] = 1;
    }
}
#define uf_same(UF, x, y) (uf_find((UF), (x)) == uf_find((UF), (y)))
int uf_find(UnionFind *UF, int x) {
    if(x == UF->parent[x]) return x;
    else return UF->parent[x] = uf_find(UF, UF->parent[x]);
}
void uf_unite(UnionFind *UF, int x, int y) {
    x = uf_find(UF, x), y = uf_find(UF, y);
    if(x == y) return;
    if(UF->rank[x] < UF->rank[y]) UF->parent[x] = y;
    else {
        UF->parent[y] = x;
        if(UF->rank[x] == UF->rank[y]) UF->rank[x]++;
        int tmp = x, x = y, y = tmp;
    }
    UF->size[y] += UF->size[x];
    UF->size[x] = 0;
}

typedef struct Edge {
    int s, t, w;
} Edge;

void *partition(Edge *first, Edge *last) {
    Edge pivot = *(last - 1);
    Edge *p = first - 1;
    for(Edge *it = first; it != last - 1; ++it) {
        if(it->w <= pivot.w) {
            p++;
            Edge tmp = *p;
            *p = *it;
            *it = tmp;
        }
    }
    Edge tmp = *++p;
    *p = pivot;
    *(last - 1) = tmp;
    return p;
}
void quicksort(void *first, void *last, size_t N) {
    if(last - first <= N) return;
    void *mid = partition(first, last);
    quicksort(first, mid, N);
    quicksort(mid, last, N);
}

int kruskal(Edge *G, const int N) {
    quicksort(G, G + N, sizeof(Edge));
    UnionFind UF;
    uf_init(&UF);
    int cost = 0;
    for(int i = 0; i < N; ++i) {
        Edge e = G[i];
        if(!uf_same(&UF, e.s, e.t)) {
            cost += e.w;
            uf_unite(&UF, e.s, e.t);
        }
    }
    return cost;
}

int main(int argc, char **argv) {
    int n = get_int();
    int size = 0;
    Edge G[10000];
    for(int i = 0; i < n; ++i) {
        get_int();
        for(int j = 0; j < n; ++j) {
            int a = get_int();
            if(a != -1) G[size].s = i, G[size].t = j, G[size++].w = a;
        }
    }
    put_uint(kruskal(G, size));
    putchar_unlocked('\n');
    return 0;
}



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

bool f(int n){
    int reverse=0;
    int temp=n;
    while(temp!=0){
        reverse=reverse*10+temp%10;
        temp/=10;
    }
    if(reverse==n) return true;
    else return false;
}

int main(){
    int a,b;
    cin>>a>>b;
    int cnt=0;
    for(int i=a;i<=b;i++) if(f(i)) cnt++;
    cout<<cnt<<"\n";
    return 0;
}

Measured memory_bytes: 3564
#include <iostream>
using namespace std;
int main(){
  int64_t a,b,k;
  cin>>a>>b>>k;
  if(a>k) a-=k;
  else if(k-a<b) b-=k-a,a=0;
  else a=0 ,b=0;
  cout<<a<<' '<<b;
}
  

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

using namespace std;

#define ZERO_IQ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

vector<vector<int>> v;
vector<int> dp;
int c, maxx2;

void dfs(int node) {
    if(dp[node])return;
    for (auto i:v[node]) {
        //dp[i] = dp[node] + 1;
        dfs(i);
        dp[node] = max(dp[i] + 1,dp[node]);
    }
}

int main() {
    ZERO_IQ
    int n, m;
    cin >> n >> m;
    v.resize(n + 1);
    dp.resize(n + 1, 0);
    for (int i = 0; i < m; ++i) {
        int q, qq;
        cin >> q >> qq;
        v[q].push_back(qq);
    }
    for (int j = 1; j <= n; ++j) {
        if (!dp[j]) {
            dfs(j);
        }
    }
    int maxx = 0;
    for (int k = 1; k <= n; ++k) {
        maxx = max(maxx, dp[k]);
    }
    cout << maxx;
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,j;
	cin>>n;
	int a[n],b[n],sum=0; 
	
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		b[i]=-1;
	}
	sort(a,a+n);                                     
	b[0]=a[0];
	j=0;
	for(int i=1;i<n;i++)
		if(a[i]!=b[j])
		{
			j++;
			b[j]=a[i];
		}		
	for(int i=0;i<n;i++)
		if(b[i]!=-1)
			sum++;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
import sys
sys.setrecursionlimit(1000000)
c_list = {}
# 辞書の初期化
for node in range(n):
    c_list[node] = []

for _ in range(m):
    a, b = map(int, input().split())
    c_list[a].append(b)
    c_list[b].append(a)

colors = {}


# 色を割り当てていく
def dfs(node, c):
    if node not in colors:
        colors[node] = c
        for next in c_list[node]:
            dfs(next, c)


# stackでも書きたい
# 色の割当が間違っている
def assignColor():
    c = 0
    for node in c_list:
        if node not in colors:
            dfs(node, c)
            c += 1


def checkColor(u, v):
    if colors[u] == colors[v]:
        print('yes')
    else:
        print('no')


assignColor()
k = int(input())
for _ in range(k):
    u, v = map(int, input().split())
    checkColor(u, v)



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

int main() {

    int n;int i;int abbccount=0;
    string s;
    cin>>n;
      if(n<3)
        {
            cout<<0<<endl;
            exit(0);
        }
    cin>>s;

    for(i=0;i<n;i++)
    {
        if (s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
        {
            abbccount=abbccount+1;
        }
        else
        {
            continue;
        }

    }
    cout<<abbccount<<endl;


}


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

fn main() {
    remainder_reminder();
}

fn remainder_reminder() {
    let nk: Vec<i64> = read_spc();
    let n = nk[0];
    let k = nk[1];
    let mut m: i64 = 0;
    for b in 1..(n + 1) {
        let q = n / b;
        let r = n % b;
        m += q * max_i64(0, b - k) + max_i64(0, r - k + 1);
    }
    if k == 0 {
        m -= n;
    }
    println!("{}", m);
}

fn max_i64(n: i64, m: i64) -> i64 {
    let diff = n - m;
    match diff {
        diff if diff < 0 => m,
        _                => n
    }
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int n, a, b;

long POW(long x, long n){
  if (n == 0) return 1;
  long y = POW(x, n / 2);
  y = y * y % MOD;
  if (n % 2) return x * y % MOD;
  else return y;
}

int main()
{
  fastio;
  cin >> n >> a >> b;
  long res = POW(2, n) - 1;
  auto C = [&](int k, int n){
    long res = 1;
    for (int i = n - k + 1; i <= n; i++) res = res * i % MOD;
    for (int i = 1; i <= k; i++) res = res * POW(i, MOD - 2) % MOD;
    return res;        
  };
  res = (res - C(a, n) - C(b, n)) % MOD; res += MOD; res %= MOD;
  cout << res;
  return 0;
}

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

int gcd(int a, int b) {
  return b != 0 ? gcd(b, a % b) : a;
}

int near(int p, int n)
{
	int base=(int)(sqrt(p)*n)-1;
	for(int i=0; i<=2; i++)
	{
		if(1.0*(base+i)/n > sqrt(p)) return base+i-1;
	}
	
	return base+2;
}

int main()
{
	int p,n;
	while(scanf("%d%d", &p,&n), (p||n))
	{
		int sn=0,sd=1,ln=9999,ld=1;
		
		for(int i=1; i<=n; i++)
		{
			int nume=near(p,i);
			if(nume>n) nume=n;
			if(1.0*sn/sd < 1.0*nume/i)
			{
				sn=nume;
				sd=i;
			}
			
			if(nume>=n) nume--;
			if(1.0*(nume+1)/i < sqrt(p)) continue;
			if(1.0*ln/ld > 1.0*(nume+1)/i)
			{
				ln=nume+1;
				ld=i;
			}
		}
		
		int com=gcd(ln,ld);
		ln/=com; ld/=com;
		
		com=gcd(sn,sd);
		sn/=com; sd/=com;
		
		printf("%d/%d %d/%d\n", ln,ld,sn,sd);
	}
}

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

int main() {
  int n, q, t;
  string name;
  // 標準ライブラリから queue を使用
  queue<pair<string, int> > Q;  // プロセスのキュー

  cin >> n >> q;

  // 全てのプロセスをキューに順番に追加する
  for ( int i = 0; i < n; i++ ) {
    cin >> name >> t;
    Q.push(make_pair(name, t));
  }

  pair<string, int> u;    // ここで、pairは値の組を保持するための構造体テンプレートで、
  int elaps = 0, a;       // < >の中に2つの型を指定して宣言します。make_pairによって
                          // 組を生成し、1つ目の要素はfirst、2つ目の要素はsecondで
  // シミュレーション        // アクセスすることができます
  while ( !Q.empty() ) {
    u = Q.front(); Q.pop();
    a = min(u.second, q);  // q または必要な時間 u.second だけ処理を行う
    u.second -= a;  // 残りの必要時間を計算
    elaps += a;  // 経過時間を加算
    if ( u.second > 0 )
      Q.push(u);  // 処理が完了していなければキューに追加
    else
      cout << u.first << " " << elaps << endl;
  }

  return 0;
}


Measured memory_bytes: 6208
D,G=map(int,input().split())
li=[list(map(int,input().split())) for i in range(D)]
min_n=float('inf')
for i in range(2**D):
    s=0
    n=0
    for b in range(D):
        if (i >> b) & 0b1 == 1:
            s += li[b][0] * (b+1) * 100 + li[b][1]
            n += li[b][0]
    if s < G:
        for b in range(D):
            if ~(i >> (D-b-1)) & 0b1 == 1:
                if (D-b)*100 * li[D-b-1][0] < G-s:
                    n = float('inf')
                    break
                else:
                    n += -(-(G-s) // ((D-b)*100))
                    break
    min_n = min(min_n,n)
print(min_n)


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

int main() {
	long long int N,M;
	cin >> N >> M;
	long long int ans;
	if (N>=2 && M>=2)
	{
		ans = (N-2)*(M-2);
	}
	if (N>=2 && M==1)
	{
		ans = N-2;
	}
	if (N==1 && M>=2)
	{
		ans = M-2;
	}
	if (N==1 && M==1) {
		ans=1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    from bisect import bisect_left

    s = input()
    t = input()
    n = len(s)
    m = len(t)
    alpha = [[] for _ in range(26)]

    # See:
    # https://www.youtube.com/watch?v=lWETOlGiuaI
    # KeyInsight
    # 部分列判定：場所i以降で文字Cが最初に現れる位置を高速に求める
    # アルファベットの出現位置をリストで記録

    # sで各文字が出現する位置を2周分記録
    for index, si in enumerate(s):
        alpha[(ord(si) - ord('a'))].append(index)

    for index, si in enumerate(s):
        alpha[(ord(si) - ord('a'))].append(index + n)

    ans = 0
    p = 0  # after p

    for ti in t:
        c = ord(ti) - ord('a')

        if len(alpha[c]) == 0:
            print('-1')
            exit()

        # 二分探索でWAを量産
        # See:
        # https://atcoder.jp/contests/abc138/submissions/6999265
        # p以上の最小の値
        p = alpha[c][bisect_left(alpha[c], p)] + 1

        # インデックスが，sの長さ以上のとき
        if p >= n:
            p -= n
            ans += n

    ans += p

    print(ans)


if __name__ == '__main__':
    main()


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

#define MOD 1000000007

int main()
{
    long long N, K;
    cin >> N >> K;

    map<long long, long long> count;
    for (long long i = 1; i * i <= N; i++)
    {
        count[i] = 0;
        count[N / i] = 0;
    }

    long long pre = 0;
    long long idx = 0;
    map<long long, long long> dict;
    for (auto itr = count.begin(); itr != count.end(); itr++, idx++)
    {
        count[itr->first] = itr->first - pre;
        pre = itr->first;

        dict[idx] = itr->first;
    }

    vector<vector<long long>> dp(K, vector<long long>(count.size(), 0));
    // initialize
    for (long long i = 0; i < count.size(); i++)
    {
        dp[0][i] = count[dict[i]];
    }

    for (long long i = 1; i < K; i++)
    {
        long long sum = 0;
        for (long long j = count.size() - 1; j >= 0; j--)
        {
            sum += dp[i - 1][count.size() - j - 1];
            sum %= MOD;
            dp[i][j] = sum * count[dict[j]];
            dp[i][j] %= MOD;
        }
    }

    // for (auto row : dp)
    // {
    //     for (long long v : row)
    //     {
    //         cout << v << " ";
    //     }
    //     cout << endl;
    // }

    long long ans = 0;
    for (long long v : dp.back())
    {
        ans += v;
        ans %= MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 58240
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

#define ll long long
#define pb push_back

int N, M;
vector<pair<int, int>> V;
bool flag[10];
ll ans = 0;

void flagInit(){
	for(int i = 1; i <= N; i ++)flag[i] = false;
}
bool checkAllFlagTrue(){
	for(int i = 1; i <= N; i ++)if(!flag[i])return false;
	return true;
}
void search(int node){
	flag[node] = true;
	if(checkAllFlagTrue()){
		ans ++;
		return;
	}
	for(int i = 1; i <= M; i ++){
		if(V[i].first == node && !flag[V[i].second]){
			search(V[i].second);
			flag[V[i].second] = false;
		}
		if(V[i].second == node && !flag[V[i].first]){
			search(V[i].first);
			flag[V[i].first] = false;
		}
	}
}

int main(){

	cin >> N >> M;
	V.pb(make_pair(0, 0));
	for(int i = 1; i <= M; i ++){
		int a, b;
		cin >> a >> b;
		V.pb(make_pair(a, b));
	}
	flagInit();
	search(1);
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
require 'prime'

def _divisors(primes, k)
  Enumerator.new do |y|
    if primes.size == k
      y << 1
    else
      p, e = primes[k]
      _divisors(primes, k + 1).each {|d|
        (e + 1).times {|e1|
          y << p ** e1 * d
        }
      }
    end
  end
end

def divisors(n)
  _divisors(Prime.prime_division(n), 0).to_a.sort
end


n,k=gets.split.map(&:to_i)
array=gets.split.map(&:to_i)
sum=array.inject(:+)
answer=1
yakusuu=divisors(sum).reverse
ll=yakusuu.length

j=0
ll.times{
    
  
       array2=array.map{|i| i%yakusuu[j]}.sort
       array3=array2.map{|i| yakusuu[j]-i}
       
       score1=0
       score2=array3.inject(:+)
       
           (n+1).times{|index|
                if score1>k && score2>k
                    break
                end
                
               if score1==score2
                   puts yakusuu[j]
                   exit
               elsif array2[index]
                   score1+=array2[index]
                   score2-=array3[index]
               end
               
           }
   
   j+=1
}


Measured memory_bytes: 15864
mod=10**9+7
n,k=map(int,input().split())
A=list(map(int,input().split()))
K=k

B,C=[],[]
for i in A:
    if i>=0:B.append(i)
    else:C.append(i)

B.sort()
C.sort(key=lambda x:abs(x))

ans,flag=1,1
while k!=0:
    if k>=2:
        point=0
        if len(B)>=2 and len(C)>=2:
            if B[-1]*B[-2]>C[-1]*C[-2]:
                ans *=B.pop()
                point=1
            else:ans *=C.pop()*C.pop()
        elif len(B)>=2:ans *=B.pop()*B.pop()
        elif len(C)>=2:ans *=C.pop()*C.pop()
        else:flag=0
        k -=2-point
    else:
        if len(B)>=1:ans *=B.pop()
        else:flag=0
        k -=1
    ans %=mod

if flag:print(ans)
else:
    ans=1
    A=sorted(A,key=lambda x:abs(x))
    for i in range(K):
        ans *=A[i]
        ans %=mod
    print(ans)

Measured memory_bytes: 112392
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<iterator>
#include<iostream>
#include<cctype>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<list>
#include<stack>
#include<functional>
#include<utility>
#include<numeric>
#include<bitset>
#include<iterator>
#define INF (int)1e9
#define MOD 1000000007
#define tr(c, it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz size
#define ll long long
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MEM(a, b) memset(a, (b), sizeof(a))
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define PRE(i, m, n, in) for(int (i)=(m);(i)<(n);i+=in)
#define RFOR(i, n) for(int i=n ; i>=0 ; i--)
#define RPRE(i, j, k, in) for(int i=j ; i>=k ; i-=in)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
using namespace std;
typedef pair<int, int> II;
typedef vector <int> VI;
typedef vector<string> VS;
typedef vector <II> VII;
typedef vector <VI> VVI;
typedef vector <VII> VVII;
typedef map<int,int> MPII;
typedef set<int> SETI;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt","r",stdin);
    string s; cin >> s; int price = 700;
    if(s[0] == 'o') price += 100;
    if(s[1] == 'o') price += 100;
    if(s[2] == 'o') price += 100;
    cout << price << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
//#include <utility>

int main(void){
 
  int x,y,z;
  scanf("%d %d %d\n",&x,&y,&z);
  
  using std::swap;
  swap(x, y);
  swap(x, z);
  
  printf("%d %d %d\n",x,y,z);
  
  return 0;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        int i=n+m;
        int d=0;
        while(i>0)
        {
            i/=10;
            d++;
        }
        cout<<d<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
int main(){
	double n;
	double k; cin >> n >> k;

	double ans = 0;
	for(int i = 1; i < n+1; i++){
		int score = i;
		double p = 1;
		while(score < k){
			score = score*2;
			p *= 0.5;
		}
		ans += (1/(n*1.0))*p;

	}
	//cout << ans << endl;
	printf("%.12f\n",ans);
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =1e5+7;
const int mod = 1e14 ;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
typedef long long ll;
int main()
{
	int n;
	scanf("%d",&n);
	if(n%1000==0) printf("0\n");
	else printf("%d\n",(n/1000+1)*1000-n);
	return 0;
 } 

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

const int INF = 1001001001;

int main() {
    int n, m;
    cin >> n >> m;
    int N = 1 << n;
    vector<int> dp(N, INF), A(m), B(m, 0);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        A[i] = a;
        rep(j, b) {
            int c;
            cin >> c;
            c--;
            int d = 1 << c;
            B[i] |= d;
        }
    }
    dp[0] = 0;
    rep(i, N) {
        rep(j, m) {
            int ni = i | B[j];
            dp[ni] = min(dp[ni], dp[i]+A[j]);
        }
    }
    if (dp[N-1]==INF) {
        cout << -1 << endl;
        return 0;
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (a >= b)
		cout << "delicious" << "\n";
	else if (b - a <= x)
		cout << "safe" << "\n";
	else
		cout << "dangerous" << "\n";
}

Measured memory_bytes: 3596
#include<stdio.h>

int main(){
    int r,c,sum,total=0;
    scanf("%d %d",&r,&c);
    int table[r+1][c+1]={0};
    
    for(int i=0; i<r; i++){
        sum=0;
        for(int j=0; j<c; j++){
            scanf("%d ",&table[i][j]);
            sum+=table[i][j];
            table[r][j]+=table[i][j];
        }
        table[i][c]=sum;
        total+=sum;
    }
    table[r][c]=total;
    
    for(int i=0; i<r+1; i++){
        for(int j=0; j<c; j++){
            printf("%d ",table[i][j]);
        }
        printf("%d\n",table[i][c]);
    }
}



Measured memory_bytes: 2752
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const ll INF=1LL<<55;
const int maxn=(5e5)+10;
int n,m;
struct node { int l,r,z; } d[maxn];
ll tr[maxn],lazy[maxn];
bool cmp(node a,node b) { return a.l<b.l; }
void pushdown(int root) {
	if (lazy[root]==INF) return;
	tr[root*2]=min(tr[root*2],lazy[root]);
	tr[root*2+1]=min(tr[root*2+1],lazy[root]);
	lazy[root*2]=min(lazy[root*2],lazy[root]);
	lazy[root*2+1]=min(lazy[root*2+1],lazy[root]);
	lazy[root]=INF;
}
void add(int L,int R,int l,int r,int root,ll delta) {
	if (L>R) return;
	if (L<=l&&r<=R) {
		tr[root]=min(tr[root],delta);
		lazy[root]=min(lazy[root],delta);
		return;
	}
	pushdown(root);
	int mid=(l+r)/2;
	if (L<=mid) add(L,R,l,mid,root*2,delta);
	if (mid<R) add(L,R,mid+1,r,root*2+1,delta);
	tr[root]=min(tr[root*2],tr[root*2+1]);
}
ll query(int x,int l,int r,int root) {
	if (l==r) return tr[root];
	pushdown(root);
	int mid=(l+r)/2;
	if (x<=mid) return query(x,l,mid,root*2);
	return query(x,mid+1,r,root*2+1);
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(m);
	for (int i=1;i<=n*4;i++) lazy[i]=tr[i]=INF;
	for (int i=1;i<=m;i++) read(d[i].l),read(d[i].r),read(d[i].z);
	sort(d+1,d+m+1,cmp);
	add(1,1,1,n,1,0);
	for (int i=1;i<=m;i++) {
		ll tmp=query(d[i].l,1,n,1);
		add(d[i].l,d[i].r,1,n,1,tmp+d[i].z);
	}
	ll ans=query(n,1,n,1);
	if (ans==INF) ans=-1;
	printf("%lld\n",ans);
	return 0;
}
/*
  REMEMBER:
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Array size? Integer overflow? Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 10624
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <string.h>
#include <queue>
#include <functional>
#include <utility>
using namespace std;
signed main() {
	int n, l;
	cin >> n >> l;
	int a[100003];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}int judge = 0;
	for (int i = 0; i < n-1; i++) {
		if (a[i + 1] + a[i] >= l) { judge = i+1; }
	}
	if (judge) { cout << "Possible"<<endl; 
	for (int i = 0; i < judge - 1; i++) {
		cout << i+1 << endl;
	}
	for (int i = n - 1; i >= judge; i--)cout << i << endl;
	}
	else cout<< "Impossible";
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define INF LLONG_MAX
#define ll long long
#define rep(i,n) for(ll i=0; i<n; ++i)
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  vector<ll> X(N);
  rep(i,N) cin >> X[i];

  ll ans = 0;
  rep(i, N-1) ans += min(B, (X[i+1]-X[i])*A);
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
map<int,int>cnt;
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    int y[x];
    for (int i=0;i<x;i++){
        cin>>y[i];
        cnt[y[i]]++;
    }
    int ans=0;
    for (int i=0;i<x;i++){
        if (cnt[y[i]]>1)
            continue;
        vector<int>d;
        for (int j=1;j<=sqrtl(y[i]);j++){
            if (y[i]%j==0)
            {
                d.push_back(j);
                if (j*j!=y[i])
                    d.push_back(y[i]/j);
            }
        }
        bool valid=1;
        for (int j=0;j<d.size();j++){
            if (d[j]==y[i])
                continue;
            if (cnt[d[j]]){
                valid=0;
                break;
            }
        }
        if (valid)
            ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 33324
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math

mod = 10**9+7

A = int(input())
B = int(input())

if A > B:
    print("GREATER")
elif A < B:
    print("LESS")
else:
    print("EQUAL") 


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

int main()
{
    int a, b;
    cin >> a >> b;
    
    if(a % 3 == 0)
    {
        cout << "Possible" << endl;
        return 0;
    }
    else if(b % 3 == 0)
    {
        cout << "Possible" << endl;
        return 0;
    }
    else if((a+b) % 3 == 0)
    {
        cout << "Possible" << endl;
        return 0;
    }
    else
    {
        cout << "Impossible" << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <regex>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

const int MAX = 1000;
const int INF = 1 << 30;

int N, M;
int G[MAX][MAX];
bool dp[MAX] = { false };
int check[MAX] = { 0 };
vector<pair<int, int>> nums;


bool dfs(int v,int color,pair<int,int>& num) {
	if (check[v] != 0)return false;
	check[v] = color;

	if (color == 1)num.first++;
	else num.second++;

	for (int i = 0; i < N; i++) {
		if (i == v || G[v][i])continue;
		if (check[i] == color)return true;
		if (dfs(i, -color, num))return true;
	}
	return false;
}


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

	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a][b] = true;
		G[b][a] = true;
	}

	for (int i = 0; i < N; i++) {
		if (check[i] != 0)continue;

		pair<int, int> p;

		if (dfs(i, 1, p)) {
			cout << -1 << endl;
			return 0;
		}

		nums.push_back(p);
	}

	dp[0] = true;
	for (int i = 0; i < nums.size(); i++) {
		for (int j = N; j >= 0; j--) {
			if (!dp[j])continue;
			dp[j] = false;
			if (j + nums[i].first <= N)dp[j + nums[i].first] = true;
			if (j + nums[i].second <= N)dp[j + nums[i].second] = true;
		}
	}

	int a = 0, b = 0;
	int m = INF;

	for (int i = 0; i < N; i++) {
		if (!dp[i])continue;
		if (abs(N / 2 - i) < m) {
			m = abs(N / 2 - i);
			a = i;
		}
	}

	b = N - a;
	cout << a * (a - 1) / 2 + b * (b - 1) / 2 << endl;

	return 0;
}


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

int main()
{
  int N;

  vector<int> vec(4);

  cin >> N;

  string s;

  for(int i=0; i<N; ++i){
    cin >> s;

    if(s == "AC"){
      ++vec[0];
    }
    else if(s == "WA"){
      ++vec[1];
    }
    else if(s == "TLE"){
      ++vec[2];
    }
    else{
      ++vec[3];
    }
  }

  cout << "AC x " << vec[0] << endl;
  cout << "WA x " << vec[1] << endl;
  cout << "TLE x " << vec[2] << endl;
  cout << "RE x " << vec[3] << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int main()
{
    int N;
    cin >> N;
    map<int, int> m;
    int A;
    REP(i, N)
    {
        cin >> A;
        ++m[A];
    }
    priority_queue<int> q;
    for (auto kv : m)
    {
        q.push(kv.second);
    }
    while (!q.empty())
    {
        int a = q.top();
        if (a == 1) break;
        q.pop();
        if (q.empty())
        {
            --a;
            --a;
            if (a > 0) q.push(a);
        }
        else
        {
            int b = q.top();
            q.pop();
            --a;
            --b;
            if (a > 0) q.push(a);
            if (b > 0) q.push(b);
        }
    }
    cout << q.size() << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;

int main() {
    string s;
    cin>>s;
    int b=0;
    int ss=s.size();
    rep(i,ss-2){
        if (s[i]==s[i+1]){
            //string ans={s[i],s[i+1]};
            cout<<i+1<<" "<<i+2<<endl;
            b=1;
            break;
        }
        else if (s[i]==s[i+2]){
            //string ans={s[i],s[i+1],s[i+2]};
            //cout<<1<<endl;
            cout<<i+1<<" "<<i+3<<endl;
            b=1;
          break;
        }
    }
    if (b==0){
        if (s[ss-2]==s[ss-1]){
            //string ans={s[ss-2],s[ss-1]};
            
            cout<<ss-1<<" "<<ss<<endl;
        }
        else{
            cout<<-1<<" "<<-1<<endl;
        }
    
    }

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <stack>

using namespace std;

int main()
{
    stack<int> iStack;
    string s;
    int a, b;

    while(cin >> s){
        if( s == "+" ){
            a = iStack.top();
            iStack.pop();
            b = iStack.top();
            iStack.pop();
            iStack.push(a+b);
        } else if ( s == "*" ) {
            a = iStack.top();
            iStack.pop();
            b = iStack.top();
            iStack.pop();
            iStack.push(a*b);
        } else if ( s == "-" ) {
            a = iStack.top();
            iStack.pop();
            b = iStack.top();
            iStack.pop();
            iStack.push(b-a);
        } else {
            iStack.push(stoi(s));
        }
    }

    cout << iStack.top() << endl;
}

Measured memory_bytes: 3212