akhauriyash/Code-Regression huggingface dataset:
//#include "pch.h"
//#include "stdafx.h"
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
-------------------------------------------------------------------------------*/
#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define INF			2e9
#define MOD			1e9+7
#define MIN(a, b)		((a) < (b) ? a : b)
#define MAX(a, b)		((a) > (b) ? a : b)
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)		/* 奇数 */
#define IsEven(x)		(!IsOdd((x)))					/* 偶数 */
#define ArrayLength(x)	(sizeof(x) / sizeof(x[0]))

typedef short SWORD;
typedef unsigned short WORD;
typedef long SDWORD;
typedef unsigned long DWORD;
typedef long long int QWORD;

/*-----------------------------------------------------------------------------
　処理
-------------------------------------------------------------------------------*/
int main()
{
	string s, t;
	cin >> s >> t;
	
	// dp[i+1][j+1] = dp[i][j] + 1					(s[i] == t[i])
	// dp[i+1][j+1] = MAX(dp[i+1][j], dp[i][j+1])	(s[i] != t[i])
	int i, j;
	int sLegnth = s.length();
	int tLegnth = t.length();
	static int dp[3000 + 1][3000 + 1];
	for (i = 0; i < sLegnth; i++) {
		for (j = 0; j < tLegnth; j++) {
			if (s[i] == t[j]) {
				dp[i + 1][j + 1] = dp[i][j] + 1;
			} else {
				dp[i + 1][j + 1] = MAX(dp[i + 1][j], dp[i][j + 1]);
			}
		}
	}

	// カウントが変わったら対象とした文字列として採用し、1段おりる
	// 採用しない場合は大きいほうに降りる
	string ret = "";
	i = sLegnth;
	j = tLegnth;
	while ((0 < i) && (0 < j)) {
		if ((dp[i][j] != dp[i - 1][j - 1]) &&
			(dp[i][j] != dp[i][j - 1]) &&
			(dp[i][j] != dp[i - 1][j])) {
			ret += t[j - 1];
			i--;
			j--;
		} else if (dp[i][j - 1] < dp[i - 1][j]) {
			i--;
		} else {
			j--;
		}
	}

	// 逆順に出力
	reverse(ret.begin(), ret.end());
	cout << ret << endl;

	return 0;
}



Measured memory_bytes: 35456
def sieve(n): # エラトステネスの篩
    num = [1]*n
    num[0]=num[1]= 0
    for i in range(int(n**0.5)+1):
        if num[i]:
            for j in range(i**2,n,i):
                num[j] = 0
    return num # list ### 1なら素数0なら合成数

primes = sieve(55555)

N = int(input())
ans = []
for i in range(55555//10):
    if len(ans) == N:
        break
    if primes[3+10*i] == 1:
        ans.append(3+10*i)
    else:
        pass
print(' '.join(map(str,ans)))


Measured memory_bytes: 38896
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF 1<<28

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int N, T; cin >> N >> T;
	vector<P> ct(N);
	rep (i, N){
		cin >> ct[i].first >> ct[i].second;
	} // end rep

	sort(ALL(ct));

	int res = INF;
	rep (i, N){
		int c = ct[i].first;
		int t = ct[i].second;
		if (t <= T){
			res = min(res, c);
		} // end if
	} // end rep

	if (res == INF){
		cout << "TLE" << endl;
	}else{
		cout << res << endl;
	} // end if

	return 0;
}

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

template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

const int INF=1e9;

int d[250][250];

signed main(){
  int N;cin>>N;
  vector<string> s(N);
  for(int i=0;i<N;i++)cin>>s[i];
  vector<int> v(N,-1);
  queue<int> que;
  que.push(0);v[0]=0;
  while(que.size()){
    int p=que.front();que.pop();
    for(int i=0;i<N;i++){
      if(s[p][i]=='0')continue;
      if(v[i]==-1){
        v[i]=v[p]^1;
        que.push(i);
        continue;
      }
      if(v[i]==(v[p]^1))continue;
      fin(-1);
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(i==j)d[i][j]=0;
      else{
        if(s[i][j]=='1')d[i][j]=1;
        else d[i][j]=INF;
      }
    }
  }
  for(int k=0;k<N;k++){
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  int ans=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      ans=max(ans,d[i][j]);
    }
  }

  cout<<ans+1<<endl;
}


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

int main() {
	int n;
	cin >> n;
	int dp[n];
	int val[n];
	for(int i = 0;i < n;i++)
	cin >> val[i];
	dp[0] = 0;
	dp[1] = abs(val[0] - val[1]);
	for(int i = 2;i < n;i++)
	dp[i] = min(dp[i-1] + abs(val[i] - val[i-1]),dp[i-2] + abs(val[i] - val[i-2]));
	cout << dp[n-1] << "\n";
	return 0;
}

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

void solve(){
    
}

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

    int n;
    cin>>n;

    if(n%1000==0){
        cout<<0<<"\n";
    }else{
        cout<< 1000 - n%1000;
    }
      
    return 0;
}

Measured memory_bytes: 3600
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		char a = sc.next().charAt(0), b = sc.next().charAt(0);
		System.out.println(!(a=='H' ^ b=='H') ? 'H' : 'D');
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}

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

using namespace std;

typedef long long ll;

int main() {
    ll n;   cin >> n;
    vector<ll> x(n), y(n);
    for (int i = 0; i < n; i++)
        cin >> x[i] >> y[i];

    vector<ll> p, q, r, s;
    for (int i = 0; i < n; i++) {
        p.push_back(x[i] + y[i]);
        q.push_back(x[i] - y[i]);
        r.push_back(-x[i] + y[i]);
        s.push_back(-x[i] - y[i]);
    }
    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    sort(r.begin(), r.end(), greater<ll>());
    sort(s.begin(), s.end(), greater<ll>());
   

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll a = x[i], b = y[i];
        ll c = p[0] - a - b;
        ll d = q[0] - a + b;
        ll e = r[0] + a - b;
        ll f = s[0] + a + b;
        ans = max(ans, max(max(c, d), max(e, f)));
    }

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

Measured memory_bytes: 12884
//Code by 27.
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath> 
#include<memory.h> 
#include<sstream>
#include<time.h>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const long long MOD=19260817;
int main()
{
	int n;
	cin>>n;
	cout<<48-n;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;

signed main() {
  ll N;
  cin >> N;
  ll ans = 0;
  rep(i, N) {
    ll num = i + 1;
    if (num % 3 == 0 && num % 5 == 0) {
      continue;
    } else if (num % 3 == 0) {
      continue;
    } else if (num % 5 == 0) {
      continue;
    }
    // debug(num);
    ans += num;
  }

  COUT(ans);
  return 0;
}

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

using namespace std;

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

    int n,m;cin>>n>>m;
    vector<double> l(n),a(n),b(n);
    double res=0;
    for(int i=0;i<n;i++) cin>>l[i]>>a[i]>>b[i];
    for(int i=0;i<(1<<n);i++){
        int cnt=0,tmp=i;
        vector<int> use;
        for(int j=0;j<n;j++){
            if(tmp%2){
                cnt++;
                use.push_back(j);
            }
            tmp/=2;
        }
        if(cnt!=m) continue;
        double d=0;
        for(int j=0;j<m;j++){
            for(int k=j+1;k<m;k++){
                d+=(l[use[k]]-l[use[j]])*(l[use[k]]-l[use[j]])+(a[use[k]]-a[use[j]])*(a[use[k]]-a[use[j]])+(b[use[k]]-b[use[j]])*(b[use[k]]-b[use[j]]);
            }
        }
        res=max(res,d);
    }
    cout<<fixed<<setprecision(10)<<res<<endl;
}

Measured memory_bytes: 3304
def sum(lista: list):
    soma = 0
    for l in lista:
        soma = soma + l
    return soma


n = int(input())
x = []
line = input()
for _ in range(n):
    x = [int(t) for t in line.split()]
sum1 = []
sum2 = []
diff = []

for i in range(1, n):
    sum1 = sum(x[0:i])
    sum2 = sum(x[i:])
    diff.append(abs(sum1-sum2))
diff.sort()
print(diff[0])

Measured memory_bytes: 3064
code = '9876543210000000000'
def judge(n):
    n = str(n)
    for i in range(len(n)-1):
        ni = int(n[i])
        if abs((ni) - int(n[i+1])) > 1:
            if ni==9:

                return int(n[:i]+code[:len(n)-i])
            else:
                idx = 8 - ni
                return int(n[:i]+code[idx:idx+len(n)-i])
    return -1


i = 1
cnt = 0
k = int(input())
while(1):
    j = judge(i)
    if j==-1:
        cnt += 1

        i+=1
    else:
        i = j
    if cnt == k:
        print(i-1)
        exit()

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0


int main() {

    int N;
    vl A;
    vl B;
    deque<int> isum;

    Scd(N);
    ll ans = 0;

    A.resize(3*N);
    B.resize(3*N);

    Rep(i,N){
        Scd(A[i]);
        A[i+N] = A[i];
        A[i+2*N] = A[i];
    }
    Rep(i,N){
        Scd(B[i]);
        B[i+N] = B[i];
        B[i+2*N] = B[i];
        if( B[i] < A[i] ) ans = -1;
    }

    if( ans < 0 ){ 
        printf ("%lld\n", ans );
        return 0;
    }

    Repe(i,N*2,N){
        if( B[i] > B[i-1] + B[i+1] ){
            isum.push_back(i);
        }
    }

    ans = 0;

    while( isum.size() ){
        int from = isum.front();
        isum.pop_front();


        ll cnt = ( B[from] - A[from] ) / ( B[from-1] + B[from+1] );
        ans += cnt;
        B[from] -= ( B[from-1] + B[from+1] ) * cnt;
        B[from+N] = B[from]; B[from-N] = B[from];

        if( B[from-1] > B[from-2] + B[from] ) isum.push_back((from-1+N)%N+N);
        if( B[from+1] > B[from] + B[from+2] ) isum.push_back((from+1+N)%N+N);

    }

    Rep(i,N){
        if( B[i] != A[i] ) ans = -1;
    }
    printf ("%lld\n", ans );


    return 0;
}



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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int a,b,c;
	cin >>a >>b >>c;
	
	cout << max(0, c-(a-b)) << endl; 
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ll<<62)-1)
#define cINFINT ((1<<30)-1)

ll knapsackNonLimit( const vector<ll>& v, const vector<ll>& w, ll maxW )
{
	ll n = min( v.size(), w.size() );
	vector<ll> dp( maxW+1, 0 );
	REP( i, n ) REP( j, maxW+1 ) if( j >= w[i] )
		dp[j] = max( dp[j], dp[j - w[i]] + v[i] );
	return dp[maxW];
}

int main()
{
	ull n = 0;
	cin >> n;
	vector<ll> a( 3, 0 ), b( 3, 0 );
	cin>>a[0]>>a[1]>>a[2]>>b[0]>>b[1]>>b[2];
	
	auto v0 = b; v0.push_back(1);
	auto w0 = a; w0.push_back(1);
	auto v1 = a; v1.push_back(1);
	auto w1 = b; w1.push_back(1);

	ll n1 =knapsackNonLimit( v0, w0, n );
	ll n2 =knapsackNonLimit( v1, w1, n1 );
	
	cout << n2 << endl;
	return 0;
}

Measured memory_bytes: 195584
while True:
    (a, op, b) = [int(i) if i.isdigit() else i for i in input().split()]
 
    if op == '?':
        break
    elif op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)

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

int main(){
    long N;
    cin >> N;
    vector<long> A(N);
    for (long i = 0; i < N; i++){
        cin >> A[i];
    }
    for (long i = 0; i < N; i++){
        long v, j;
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v){
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        for (long k = 0; k < N - 1; k++){
            cout << A[k] << " ";
        }
        cout << A[N - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    std::string s, _;
    std::cin >> _  >> s >> _;
    std::cout << "A" << s.front() << "C" << '\n';
}


Measured memory_bytes: 256
N, C, K = map(int, input().split())
c = C
T = 0
ans = 0
t = []
for i in range(N):
	t.append(int(input()))
t.sort()
for i in t:
	if i <= T  and c > 0:
		c -= 1
	else:
		T = i + K
		c = C - 1
		ans += 1
print(ans)

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

int main() {
	string s;
	int k;
	map<string, int> m;

	cin >> s >> k;

	for (int i = 0; i < s.size(); ++i) {
		for (int k = 1; k <= 5; ++k) {
			m[s.substr(i, k)] = 1;
		}
	}

	auto itr = m.begin();
	for (int i = 0; i < k; ++i, ++itr);
	
	--itr;
	cout << (*itr).first << endl;

	return 0;
}



Measured memory_bytes: 1920
use std::io;


fn main() {
    let n = read_one::<usize>();
    let mut ans = 0;
    for i in 1..(n + 1) {
        if i % 2 == 0 { continue; }
        let mut cnt = 0;
        for j in 1..(i + 1) {
            if i % j == 0 { cnt += 1; }
        }
        if cnt == 8 { ans += 1; }
    }
    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define all(x) (x).begin(), (x).end()
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007ll

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  //cout << fixed << setprecision(15)
  ll n;
  cin >> n;
  ll ans = 1, temp1 = 2, temp2 = 1;
  for (int i = 0; i < n; i++) {
    ans *= 10;
    ans %= MOD;
    temp1 *= 9;
    temp1 %= MOD;
    temp2 *= 8;
    temp2 %= MOD;
  }
  cout << (ans + MOD + temp2 - temp1) % MOD << endl;
}



Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int A, B;
  std::cin >> A >> B;
  std::cout << max({A+B, A-B, A*B}) << '\n';
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
const int64_t MAX = 2000005;
const int64_t MOD = 1000000007;
int64_t POW25[MAX], POW26[MAX];

int64_t fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

int64_t nCk(int64_t n, int64_t k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void init()
{
  POW25[0] = POW26[0] = 1;
  for (int i = 1; i < MAX; i++)
  {
    POW25[i] = (POW25[i - 1] * 25) % MOD;
    POW26[i] = (POW26[i - 1] * 26) % MOD;
  }
  COMinit();
}

int main()
{
  int64_t K, ans = 0;
  string S;
  cin >> K >> S;
  int64_t N = S.size();
  init();
  for (int i = 0; i <= K; i++)
  {
    int64_t tmp = POW26[K - i];
    (tmp *= POW25[i]) %= MOD;
    (tmp *= nCk(N + i - 1, N - 1)) %= MOD;
    (ans += tmp) %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 82452
#include <map>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, m, p[109], dp[109]; string str; map<string, int> x; vector<int> G[109];
int solve(int pos) {
	if (dp[pos] != -1) return dp[pos];
	int ret = p[pos], sum = 0;
	for (int i : G[pos]) sum += solve(i);
	if (G[pos].size()) ret = min(ret, sum);
	return dp[pos] = ret;
}
int main() {
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			cin >> str >> p[i];
			x[str] = i;
		}
		cin >> m;
		fill(G, G + n, vector<int>());
		for (int i = 0; i < m; i++) {
			cin >> str; int z = x[str];
			int e; cin >> e;
			for (int j = 0; j < e; j++) {
				cin >> str;
				G[z].push_back(x[str]);
			}
		}
		cin >> str;
		fill(dp, dp + n, -1);
		cout << solve(x[str]) << endl;
	}
	return 0;
}

Measured memory_bytes: 3188
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,maxi=0,f=0,mini=INF,sum=0,q;
	string str,g;
    cin>>a>>b;
    if(a==2||b==2){
        No;return 0;
    }else{
        if(a==4||a==6||a==9||a==11){
            if(b==4||b==6||b==9||b==11){
Yes;
return 0;
            }else{
            }
            No;
            return 0;
        }
        if(b==4||b==6||b==9||b==11){
No;
return 0;
            }
    }
    Yes;
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;
  pair<int,int> cor[n];
  rep(i,n){
    int x,l;
    cin >> x >> l;
    cor[i]=mp(x+l,x-l);
  }
  sort(cor,cor+n);
  //  int dp[n];
  //  dp[0]=0;
  int most_left = cor[0].first;
  ll ans=0;
  rep1(i,n-1){
    if(cor[i].second < most_left){
      ans++;
    }
    else most_left = cor[i].first;
  }

  cout << n-ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 1024
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define mod 1000000007
#pragma GCC optimize ("O3")
#define endl '\n'
using namespace std;
typedef long long int ll ;
#define MAX 1005
vector<pair<ll,ll>> v;
set<pair<ll,ll>> st;
int main()
{
    ll n;
    cin>>n;
    ll val=log2(n);
    val++;
    val=pow(2,val);
    val--;
    cout<<val<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld DINF = 1e12;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

bool is_kaibun(string s)
{
  int n = s.length();
  rep(i, n)
  {
    if (s[i] != s[n - 1 - i])
      return false;
  }
  return true;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  string s;
  cin >> s;
  int n = s.length();
  string t = s.substr(0, (n - 1) / 2), u = s.substr((n + 1) / 2);
  dbg(t);
  dbg(u);
  Yes(is_kaibun(s) && is_kaibun(t) && is_kaibun(u));
  return 0;
}

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

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

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcd(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

class UnionFind {
    private:
      std::vector<int> par;
      std::vector<int> sizes;
      std::vector<int> rank;
      int group;

    public:
      UnionFind(int n) : par(n), sizes(n, 1), rank(n, 0), group(n) {
        for(int i = 0; i < n; ++i) par[i] = i;
      }

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

      void unite(int x, int y) {
        x = find(x);
        y = find(y);

        if(x == y) return;

        if(rank[x] < rank[y]) std::swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
        if(rank[x] == rank[y]) rank[x]++;
        group--;
      }

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

      int size(int x) {
        return sizes[find(x)];
      }

      int groupSize() {
        return group;
      }
  };

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

  int n, q;
  cin >> n >> q;
  UnionFind uf(n);
  rep(i, 0, q) {
    int c, x, y;
    cin >> c >> x >> y;
    if(c == 0) uf.unite(x, y);
    else {
      if(uf.same(x, y)) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }
}


Measured memory_bytes: 3352
#include <iostream>
#include <vector>
#include <queue>
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define pb push_back
using namespace std;

const int INF=10000000;
int V;
struct edge {
    int to,money,time;
};
struct state {
    int from, d;
    bool operator<(const state& a)const{
        return d>a.d;
    }
};
vector<vector<edge> > G;

int d[111];
int ds(int s,int g, int r){
    FOR(i,0,111)d[i]=INF;
    d[s]=0;
    priority_queue<state> q;
    q.push({s,0});
    while(q.size()){
        state sta=q.top();
        q.pop();
        int from=sta.from;
        if(d[from]<sta.d) continue;
        FOR(i,0,G[from].size()){
            const edge& e=G[from][i];
            int to=e.to;
            int cost=r?e.time:e.money;
            if(d[to]>d[from]+cost){
                d[to]=d[from]+cost;
                q.push({to,d[to]});
            }
        }
    }
    return d[g];
}

int main(){
    int n;
    while(1){
        cin>>n>>V;
        if(!(n||V)) break;
        G=vector<vector<edge> >(n+1);
        FOR(i,0,n){
            int a,b,m,t;cin>>a>>b>>m>>t;
            G[a].pb({b,m,t});
            G[b].pb({a,m,t});
        }
        int k;cin>>k;
        FOR(i,0,k){
            int p,q,r;cin>>p>>q>>r;
            cout<<ds(p,q,r)<<endl;
        }
    }
}

Measured memory_bytes: 1512
#include<iostream>

int main(){
        int a,b;
        while(std::cin >> a >> b){
                int ta,tb,r,gcd,lcm;
                if(a<b){
                        r = a;
                        a = b;
                        b = r;
                }
                ta = a; tb = b;

                r = ta % tb;
                while(r != 0){
                        ta = tb;
                        tb = r;
                        r = ta % tb;
                }
                gcd = tb;
                ta = a; tb = b;
                ta = (int)(ta / gcd);
                tb = (int)(tb / gcd);
                lcm = ta * tb * gcd;
                std::cout << gcd << " " << lcm << std::endl;
        }
        return 0;
}

Measured memory_bytes: 3016
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;

void main()
{
	auto n = readln.chomp.to!int;
	long sum;
	foreach (i; 0..n) {
		sum += readln.chomp.to!long;
	}
	writeln(sum / n);
}

Measured memory_bytes: 1036
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string S;cin >> S;

    if (S[0]!='A'){
        cout << "WA" << endl;
        return 0;
    }

    int cCount = 0;
    for (int i=2;i<S.size()-1;i++){
        if (S[i] == 'C') {
            cCount++;
        }
    }

    if (cCount != 1){
        cout << "WA" << endl;
        return 0;
    }

    for (int i=0;i<S.size();i++){
        if (S[i] == 'A' || S[i] == 'C'){
            continue;
        }

        if (isupper(S[i])) {
            cout << "WA" << endl;
            return 0;
        }
    }
    cout << "AC" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
mod = 10**9+7

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

comb = Combination(2 * 100000)

def main():
    N, M, K = map(int, input().split())

    """
    xについてだけ考えればいいのはOK
    この後だが、xi, xjを固定したときに\Sum_{置き方} |xi - xj|を求めればよい。
    （シグマの順番を入れ替えた。つまりxiとxjに駒が置かれるような配置が何通りあるかを求めたい。）
    （iとjに騙されないこと！xi, xjと書くんじゃなくてx, x'と書いた方が分かりやすいかもしれない。）

    これは単純にcomb(NM-2, K-2)なので一応これで解けた。すなわち
        ans = \Sum_{xi, xj} |xi - xj| * comb(NM-2, K-2)

    しかしi, jに関してそれぞれforループを回しているのでこれだと間に合わない。
    まずcomb(NM-2, K-2)はi, jに依存しないので二重forループの外に出せる。
    そして\Sum_{i<=j}|xi-xj|だが、|xi-xj|=dとなる(i, j)の組は(N-d)*M^2個になる。（解説放送参照）
    """

    ans_x = 0
    for d in range(1, N):
        ans_x += d * (N - d) * M ** 2
        ans_x %= mod
    ans_y = 0
    for d in range(1, M):
        ans_y += d * (M - d) * N ** 2
        ans_y %= mod
    ans = (ans_x + ans_y) * comb(N * M - 2, K - 2)
    print(ans % mod)




if __name__ == "__main__":
    main()


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a != b && a == c) cout << "Yes" << endl;
    else if(a == b && a != c)  cout << "Yes" << endl;
    else if(a != b && b == c)  cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <bitset>
#include <string>
#include <set>
#include <stack>
#include <sstream>
#include <list>
//#include <array>
#include <vector>
#include <queue>
#include <map>
#include <memory>
#include <iterator>
#include <climits>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define FAST_IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef unsigned int UINT;
typedef unsigned long long ull;
typedef pair<int, int> pdi;
typedef pair<ll, int> pli;

int const maxn = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
inline int lc(int x)  {return x << 1;}
inline int rc(int x)  {return x << 1 | 1;}

int mp[maxn];
int v[maxn];
ll a[maxn];

int main(void) {
    FAST_IO;
    
    int n;
    cin >> n;
    int x = 0;
    for (int i = 1; i <= n; i++) {
        cin >> v[i];
        x = max(x, v[i]);
        a[v[i]] = -1;
        mp[v[i]]++;
    }
    ll cnt = 0;
    for (int j = 1; j <= x; j++) {
        if (mp[j] == 0) continue;
        cnt += 1LL * (mp[j] - 1) * (mp[j]) / 2;
    }
    for (int i = 1; i <= n; i++) {
        if (a[v[i]] == -1) {
            a[v[i]] = cnt - 1LL * (mp[v[i]] - 1) * (mp[v[i]]) / 2 +  1LL * (mp[v[i]] - 1) * (mp[v[i]] - 2) / 2;
        }
        cout << a[v[i]] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4736
#include <stdio.h>

int bunkai(int* data, int num) {
	int count = 0;
	int i;
	for (i = 2; i * i <= num; i++) {
		while (num % i == 0) {
			data[count++] = i;
			num /= i;
		}
	}
	if (num > 1) data[count++] = num;
	return count;
}

int main(void) {
	int p, q;
	int i, j;
	int pcount, pdata[32], qcount, qdata[32];
	int answer, prev;
	if (scanf("%d%d", &p, &q) != 2) return 1;
	pcount = bunkai(pdata, p);
	qcount = bunkai(qdata, q);

	answer = 1;
	for (i = 0; i < pcount; i++) {
		for (j = 0; j < qcount; j++) {
			if (qdata[j] == pdata[i]) {
				qdata[j] = 0;
				break;
			}
		}
	}
	prev = -1;
	for (i = 0; i < qcount; i++) {
		if (qdata[i] == 0) continue;
		if (qdata[i] != prev) answer *= qdata[i];
		prev = qdata[i];
	}
	printf("%d\n", answer);
	return 0;
}

Measured memory_bytes: 596
N, M = map(int, input().split())
grp = []
for i in range(0, N):
	grp.append([])
for i in range(0, M):
	A, B = map(lambda v: int(v)-1, input().split())
	grp[A].append(B)
	grp[B].append(A)
memo = []
for i in range(0, N):
	memo.append(True)
memo[0] = False
cnt = 0
stack = [[0, memo]]
while stack != []:
	now = stack.pop(-1)
	if True not in now[1]:
		cnt += 1
	else:
		for i in range(0, len(grp[now[0]])):
			next = grp[now[0]][i]
			if now[1][next]:
				nextmemo = now[1][:next] + [False]
				if next != N-1:
					nextmemo = nextmemo + now[1][next+1:]
				stack.append([next, nextmemo])
print(cnt)

Measured memory_bytes: 42224
[a,b,k] = [int(i) for i in input().split()]

if k > (b-a+1):
    for i in range(a,b+1):
        print(i)
else:
    for i in range(a,a+k):
        print(i)
    for i in range(max(a+k,b-k+1),b+1):
        print(i)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Go_ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int> >,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll  MAX=1e18+500;
const int sz=1e6+100;

int le[sz];

void init()
{
    for(int i=1;i<sz;i++){
        int sq=sqrt(i);
        int ct=0;
        for(int j=1;j<=sq;j++){
            if(i % j==0){
                ++ct;
                if(j*j != i) ++ct;
            }
        }

       le[i]=ct;
    }
}

int main()
{
    Go_
    int a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;

   init();

   cin>>n;

   ll ans=0;
   
   for(int i=1;i<n;i++){
       ll p=(ll) le[i];
       ans+=p;
   }

   cout<<ans<<'\n';

}

Measured memory_bytes: 7576
s = input()
t = input()

ls = len(s)
lt = len(t)
dp = [[0 for _ in range(lt+1)] for _ in range(ls+1)]
for i in range(ls):
    for j in range(lt):
        dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])
        if s[i] == t[j]:
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + 1)

ans = []
x = ls
y = lt
while x + y > 0:
    if dp[x][y] == dp[x-1][y] and x != 0:
        x -= 1
    elif dp[x][y] == dp[x][y-1] and y != 0:
        y -= 1
    else:
        ans.append(s[x-1])
        x -= 1
        y -= 1

print(''.join(reversed(ans)))


Measured memory_bytes: 120412
# たぶん最小の値は最小公倍数になりそう
# 内包表記 -> TLE
# [0]*l -> RE

n, m = map(int, input().split())
s, t = input(), input()


def gcd(a, b):
    if b > a:
        return gcd(b, a)
    while a > 0:
        a, b = b % a, a
    return b


def lcm(a, b):
    return (a * b) // gcd(a, b)


l = lcm(n, m)
arr = {}

for i in range(n):
    x = i * (l // n)
    arr[x] = s[i]

for i in range(m):
    x = i * (l // m)
    if x in arr and arr[x] != t[i]:
        print(-1)
        exit()
print(l)

Measured memory_bytes: 15396
#include<cstdio>
#include<vector>
#include<cstdlib>
#define SZ(v)((int)v.size())
#define pb push_back
using namespace std;
typedef vector<int>VI;
const int N=200005;
VI li[N],id;
char s[N];
int n,m,L,ec,sum,mark[N];

void markit(){
	for(int i=0;i<<2<id.size();++i){
		for(int j:{0,1}){
			for(int k:{0,1}){
				mark[id[i<<2|j<<1|k]]=ec+k+1;
			}
		}
		ec+=2;
	}
}

void output(){
	puts("Yes");
	for(int i=0;i<L;++i){
		if(!mark[i])
		mark[i]=ec<0?-ec:++ec,ec=-ec;
		printf("%d ",mark[i]);
	}
	exit(0);
}

int main(){
	scanf("%d",&n);
	scanf("%s",s+1);
	s[0]='1';L=n<<1;
	for(int i=0,j;i<L;++i){
		if(s[i]=='0'&&s[(i+1)%L]=='1'){
			li[m].pb(i),j=(i+1)%L;
			for(;s[j]=='1';j=(j+1)%L)
			li[m].pb(j);
			++m;
		}
	} 
	if(!m){
		if(~n&1){
			for(int i=0;i<L;++i)id.pb(i);
			markit();output();
		}else puts("No"),exit(0);
	}
	for(int i=0;i<m;++i)sum+=SZ(li[i])-2;
	if(sum&1)puts("No"),exit(0);
	if(sum&2){
		for(int i=0;i<m;++i)
		if(SZ(li[i])>2)li[m-1].swap(li[i]);
		for(int i=0;i<m-1;++i){
			if(SZ(li[i])>2){
				VI&a=li[i],&b=li[m-1];
				int la=SZ(a)-1,lb=SZ(b)-1;
				int ea=a[la],eb=b[lb];
				mark[a[la-1]]=++ec;
				mark[b[lb-1]]=ec;
				a.pop_back();b.pop_back();
				a.pop_back();b.pop_back();
				a.pb(eb);b.pb(ea);
				sum-=2;
				break;
			}
		}
		if(sum&2)puts("No"),exit(0);
	}
	for(int i=0;i<m;++i){
		mark[li[i][0]]=ec+1+i;
		mark[li[i][SZ(li[i])-1]]=ec+1+(i+1)%m;
		for(int j=1;j<SZ(li[i])-1;++j)
		id.pb(li[i][j]);
	}
	ec+=m;
	markit();
	output();
	return 0;
}

Measured memory_bytes: 9084
#include <iostream>

using namespace std;

int main()
{

   char s[4];
   cin>>s;
   if(s[0]=='7'||s[1]=='7'||s[2]=='7'||s[3]=='7'){
    cout<<"Yes";
   }
   else{
    cout<<"No";
   }

    return 0;
}


Measured memory_bytes: 3592
a=input()
b=input()
ans="EQUAL"
if len(a)!=len(b):
  if(len(a)>len(b)):
    ans="GREATER"
  else:
    ans="LESS"
else:
  for i in range(len(a)):
    if int(a[i])>int(b[i]):
      ans="GREATER"
      break
    if int(a[i])<int(b[i]):
      ans="LESS"
      break
print(ans)
      

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n)
{
	vector<pair<ll, ll>> p;
	for (ll i = 2; i * i <= n; i++)
	{
		if ((n % i) != 0)
			continue;
		pair<ll, ll> a = make_pair(i, 0);
		while ((n % i) == 0)
		{
			n /= i;
			a.second += 1;
		}
		p.push_back(a);
	}

	if (n != 1)
		p.push_back(make_pair(n, 1));
	return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a)
{
	ll b = MOD, u = 1, v = 0;
	while (b)
	{
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0)
	{
		u += MOD;
	}
	return u;
}
// 順列
ll permutation(const ll n, const ll m)
{
	ll result = 1;
	for (ll i = n; i > n - m; i--)
	{
		result = (result * i) % MOD;
	}
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x)
{
	if (x == 0)
		return 1;
	ll res = repeat_square(n, x / 2);
	res = res * res % MOD;
	if ((x % 2) == 1)
		res = res * n % MOD;
	return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m)
{
	ll p = permutation(n, m);
	ll div = 1;
	for (ll i = 2; i <= m; i++)
	{
		div = (div * i) % MOD;
	}
	return (p * modinv(div)) % MOD;
}

int main() {
	string S;
	ll K;
	cin >> S >> K;

	ll result = 0;
	vector<int> n;
	string prev = S.substr(0, 1);
	n.push_back(1);
	int idx = 0;
	rep(i, 1, S.length()) {
		string s = S.substr(i, 1);
		if (prev == s) {
			n[idx] += 1;
		} else {
			idx++;
			prev = s;
			n.push_back(1);
		}
	}

	if (n.size() == 1) {
		result += (n[0]*K / 2);
		cout << result << endl;
		return 0;
	}
	rep(i, n.size()) result += (n[i] / 2);
	result *= K;

	if (S.substr(0, 1) == S.substr(S.length()-1, 1)) {
		int a = n[0];
		int b = n[n.size()-1];
		result -= ((a/2 + b/2 - (a+b)/2) * (K-1));
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()

bad_list = ['RGB', 'RBG', 'GRB', 'GBR', 'BRG', 'BGR']
res = S.count("R") * S.count("G") * S.count("B")
for (i, s) in enumerate(S):
  
  for j in range(((i+1)//2)+1)[1:]:
    if S[i::-j][:3] in bad_list:
      res -= 1


print(res)

Measured memory_bytes: 68400
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
const ll  big =2e5+5;
pair <int,int> p[1005];
ll a[1005],b[1005];

int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
char c;
cin>>c;
if(isupper(c))cout<<"A";
else cout<<"a";
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h> // imports every library in c++
using namespace std; // ; is essential | says that you are USING the libraries

int P, Q, R;

int main() {
    cin >> P;
    cin >> Q;
    cin >> R;
    int a = P + Q;
    int b = P + R;
    int c = Q + R;
    if (b >= a and c >= a) {
        cout << a;
    }  else if  (a >= b and c >= b) {
        cout << b;
    } else if (a >= c and b >= c) {
        cout << c;
    }
    return 0;
}

Measured memory_bytes: 256
from collections import*
h,w,m=map(int,input().split())
d=defaultdict(int)
a=[0]*h
b=[0]*w
for _ in range(m):
  x,y=map(int,input().split())
  x-=1
  y-=1
  a[x]+=1
  b[y]+=1
  d[(x,y)]+=1

ma=max(a)
mb=max(b)

ind_x=[i for i,j in enumerate(a) if j==ma]
ind_y=[i for i,j in enumerate(b) if j==mb]


for x in ind_x:
  for y in ind_y:
    if d[(x,y)]==0:
      print(ma+mb)
      exit()
print(ma+mb-1)


Measured memory_bytes: 85748
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }

    static Scanner cin;

    void calc()
    {
        int A = cin.nextInt();
        int B = cin.nextInt();

        int K = (A + B) / 2;

        if (Math.Abs(A - K) == Math.Abs(B - K)) Console.WriteLine(K);
        else Console.WriteLine("IMPOSSIBLE");
    }


    //swap
    void swap<T>(ref T a, ref T b)
    {
        T c = a;
        a = b;
        b = c;
    } 


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> s(h, vector<char>(w));
    rep(i, h)rep(j, w){
        char tmp;
        cin >> tmp;
        s[i][j] = tmp;
    }
    int num = 1;
    vector<vector<int>> ans(h, vector<int>(w));
    rep(j, w){
        stack<P> a;
        bool flag = false;
        rep(i, h){
            a.push(make_pair(i, j));
            if(s[i][j]=='#'){
                flag = true;
                while(!a.empty()){
                    int x = a.top().first;
                    int y = a.top().second;
                    a.pop();
                    ans[x][y] = num;
                }
                num++;
                continue;
            }
            if(i == h-1){
                if(flag){
                    while(!a.empty()){
                        int x = a.top().first;
                        int y = a.top().second;
                        a.pop();
                        ans[x][y] = num-1;
                    }
                }else{
                    while(!a.empty()){
                        int x = a.top().first;
                        int y = a.top().second;
                        a.pop();
                        ans[x][y] = -1;
                    }
                }
            }
        }
    }

    rep(i, h){
        stack<int> a;
        int nn;
        rep(j, w){
            a.push(j);
            if(ans[i][j] == -1){
                continue;
            }else{
                nn = ans[i][j];
                while(!a.empty()){
                    int kk = a.top();
                    a.pop();
                    ans[i][kk] = nn;
                }
            }
        }
    }

    rep(i, h){
        stack<int> a;
        int nn;
        for(int j=w-1; j>=0; j--){
            a.push(j);
            if(ans[i][j] == -1){
                continue;
            }else{
                nn = ans[i][j];
                while(!a.empty()){
                    int kk = a.top();
                    a.pop();
                    ans[i][kk] = nn;
                }
            }
        }
    }

    rep(i, h)rep(j, w){
        cout << ans[i][j] << ' ';
        if(j==w-1){
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1280
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main(int argc, char *argv[]) {
	string s = "ATCG";
	string b;
	cin >> b;
	for (int i = 0; i < 4; ++i) {
		if (s[i] == b[0]) {
			cout << s[i ^ 1] << endl;
		}
	}
	return 0;
}


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

int main(){
  int X,N; cin >> X >> N;
  vector<int> f(102,0);
  
  for(int i=0; i<N; i++){
    int d;
    cin >> d;
    f[d]=1;
  }
  int dmin=100000;
  int c=0;
  for(int i=0; i<=101; i++){
    int da=(X>i?X-i:i-X);
    if(dmin>da&&f[i]==0){
      dmin=da;
      c=i;
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 3600