akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<utility>
#include<functional>
#include<algorithm>
#include<queue>
#include<map>
#include<string>
#include<numeric>


#define FOR(i, a, b) for(int i=a; i<b; i++)
#define COUT(a) cout << a << endl;

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


int main(){
    Int N;
    string s;


    cin >> N;
    cin >> s;

    vector<Int> es(N);
    vector<Int> ws(N);


 
    for(int i=1; i<N-1; i++){
        if (s[i-1] == 'W') {
            ws[i] = ws[i-1]+1;
        }else{
            ws[i] = ws[i-1];
        }
        if (s[N-i] == 'E'){
            es[N-1-i] = es[N-i]+1;
        }else{
            es[N-1-i] = es[N-i];
        }
    }

    if (s[N-2] == 'W'){
        ws[N-1] = ws[N-2] + 1;
    }else{
        ws[N-1] = ws[N-2];
    }
    if (s[1] == 'E'){
        es[0] = es[1] + 1;
    }else{
        es[0] = es[1];
    }

    Int ans = N;
    FOR(i, 0, N){
        Int tmp = 0;
        tmp = ws[i] + es[i];
        ans = min(ans, tmp);
    }

    COUT(ans);

}



Measured memory_bytes: 5380
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<int>A(M);
  for(int i=0;i<M;i++){
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  vector<long long>F(N,0);
  vector<int>T(N,0);
  bool flag=true;
  for(int i=0;i<M;i++){
    T.at(A.at(i)-1)=1;
  }
  for(int i=1;i<M;i++){
    if(A.at(i-1)+1==A.at(i)){
      flag=false;
    }
  }
  for(int i=0;i<N;i++){
    if(T.at(i)==0){
      if(i==0){
        F.at(i)=1;
      }
      else if(i==1){
        F.at(i)=1+F.at(0);
      }
      else{
        F.at(i)=F.at(i-1)%1000000007+F.at(i-2)%1000000007;
      }
    }
    else{
      F.at(i)=0;
    }
  }
  long long K=F.at(N-1);
  if(flag==false){
    cout<<0<<endl;
  }
  else{
    cout<<K%1000000007<<endl;
  }
}

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

#define SIZE(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n); ++i)
#define print(x) cout<<x<<endl;
#define vi vector<int>
#define v2(var,n,m) vector<vector<int>> var(n,vector<int>(m));
typedef long long ll;
typedef unsigned long long ull;

int gcd(int a, int b) { return min(a,b) ? gcd(min(a,b), max(a,b)%min(a,b)) : max(a,b); }
int dxy4[5] = { 0,1,0,-1,0 };
int dxy8[9] = { 0,1,1,0,-1,1,-1,-1,0 };
ll inf = 1LL <<61;
ll mod7 = 1000000007;
ll mod9 = 1000000009;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> a(n,vector<int>(3));
    vector<vector<int>> dp(n,vector<int>(3));
    rep(i,n)cin>>a[i][0]>>a[i][1]>>a[i][2];
    vi sl(n,0);
    rep(i,n){
        if(i==0){
            rep(j,3)dp[i][j] = a[i][j];           
        }else{
            rep(j,3)dp[i][j] = max(dp[i-1][(j+1)%3]+a[i][j],dp[i-1][(j+2)%3]+a[i][j]);
        }
    }
    int ans = *max_element(dp[n-1].begin(),dp[n-1].end());
    cout << ans <<endl;
  return 0;
}

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

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)

typedef long long ll;

ll n,m,k;
ll a,b;
ll arr[100001];

int main() {
    fast;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        arr[b + 1]--;
        arr[a]++;
    }

    for (int i = 1; i <= 100000; i++) {
        arr[i] += arr[i - 1];
    }

    for (int i = 1; i <= 100000; i++) {
        if (arr[i] > 0) m++;
    }
    cout << m << endl;
    return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a;cin >> a;
    unsigned long long sum = 0;
    for (int i = 1;i <=a;++i){
        if (i % 3 != 0 && i % 5 != 0){
            sum += i;
        }
    }
    cout << sum << endl;
    return 0;
}

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

#define loop(i,n) for(int i=1;i<=n;i++)
typedef pair<int,int> P;
int n,l;
int a[100002];
int t[100002];

int dfs(int i){
  if(i<1||n<i)return 0;
  if(a[i]==0)return 0;
  if(a[i]>a[i-1]&&a[i]>a[i+1]){
    t[i]=l-a[i]+max(t[i-1],t[i+1]);
    a[i]=0;
    dfs(i-1);
    dfs(i+1);
  }
  return 0;
}

int main(){
  cin>>n>>l;
  loop(i,n){
    cin>>a[i];
  }
  loop(i,n){
    dfs(i);
  }
  int m=0;
  loop(i,n)m=max(m,t[i]);
  cout<<m<<endl;
  return 0;
}

Measured memory_bytes: 5028
#include<bits/stdc++.h>
#define ll long long 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define PI 3.1415926535897932384626433832795
#define F first
#define S second
#define V vector<ll>
#define ALL(sss) sss.begin(),sss.end()
#define arall(rr,n) rr+0,rr+n 
#define mod 1000000007
#define M 100
#define MAXN 1000000000

 
int dp[262145][2];
int ans=INT_MAX;
ll n;
using namespace std;


void fileio(){
    #ifndef ONLINE_JUDGE
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
    #endif
}




int main(){


     fileio();
    
   
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  

    ll T=1,q;
    //cin>>T;
    while(T--){

        ll n;cin>>n;
        ll a[n];
        for (int i = 0; i < n; ++i)
        {
            /* code */cin>>a[i];
        }

        ll dp[n];

        dp[0]=0;dp[1]=abs(a[1]-a[0]);
        for (int i = 2; i <= n; ++i)
        {
            dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
        }

        cout<<dp[n-1];

        // cout<<"Case #"<<q<<": "<<ans<<endl;
    }
    
//prllf("%.9f\n", x);//precision: 9 decimal places.

/*
    GP SUM:(
    (bk)-a)/k-1;//k is ratio and b is final term, a is initial term;

    Comparing two decimal numbers

    if (abs(a-b) < 1e-9) {
        // a and b are equal
    }
*/
    return 0;
}


Measured memory_bytes: 5132
#include <vector>
#include <string>
#include <set>
#include <iterator>
#include <unordered_map>
#include <iomanip>
#include <cmath>
#include <limits>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <unordered_set>
#include <fstream>

#define Fill(a, b) memset(a, b, sizeof(a))
typedef long long LL;
const LL inf = 1LL << 61;
const LL mod = 1000000007;

#ifndef DEBUG
#define DEBUG
#endif

#ifdef DEBUG
#define Debug(x) cout << #x << "=" << (x) << endl;
#else
#define Debug(x) ;
#endif

using namespace std;


int main() {
    
    std::ios::sync_with_stdio(false);
    
    string s;
    while(cin >> s) {
        if (s.length() < 4 || s.substr(0, 4) != "YAKI") {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }
        
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;


int main()
{
	int A, B, T;
	cin >> A >> B >> T;
	cout << B * (T / A) << endl;
}

Measured memory_bytes: 3592
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    S, W = map(int, input().split())
    if S <= W:
        print("unsafe")
    else:
        print("safe")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();

			for (int k = 0; k <= 10001; k++) {
				if (a * k % b == c) {
					out.println("YES");
					return;
				}
			}
			out.println("NO");

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 21716
N, X, M = map(int, input().split())

count = [0 for _ in range(M)]
cumsum = [0]
now = X%M
nowcount = 1
while count[now] == 0:
  count[now] = nowcount
  cumsum.append(now + cumsum[-1])
  now = pow(now, 2, M)
  #print(now)
  nowcount += 1
#print(cumsum)
#print(nowcount)
#print(nowcount,count[now])
#print(len(cumsum), cumsum)
loop = cumsum[nowcount-1]-cumsum[count[now]-1]
#print(loop)
if N < nowcount:
  print(cumsum[N])
else:
  ans = cumsum[nowcount-1]
 # print("preans 1", ans)
  N -= (nowcount-1)
  f = nowcount - count[now]
  r = N%f
  q = N//f
 # print("preans 1",N, f, r, q)
  ans += q*loop + cumsum[count[now]-1+r] - cumsum[count[now]-1]
  print(ans)

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

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(void){
  //infinity //様々な流儀
  const long long INF = 1LL << 62; //long long 1を62bit左にシフト
  //dp table
  long long dp[100010]; //10^5などに合わせて
  //initialize
  for(int i=0;i<100010;i++) dp[i] = INF;
  //initial condition
  dp[0] = 0;

  int N;
  int h[100010];
  int K;

  cin >> N >> K;
  for(int i=0;i<N;i++) cin >> h[i];

  for(int i=0;i<N;i++){
    for(int j=1;j<N-i;j++){
      if(j>K) break;
      chmin(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
    }
  }

  cout << dp[N-1] << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>

using namespace std;

struct P{
  double x,y,r;
};

P A[100000];
double mr;
int N;

double closest_pair(P *a,int n){
  if(n<=1)return 1e9;
  int m=n/2;
  double x=a[m].x;
  double d=min(closest_pair(a,m),closest_pair(a+m,n-m));
  inplace_merge(a,a+m,a+n,[](const P &a,const P &b){
      return a.y<b.y;
    });
  vector<P> b;
  for(int i=0;i<n;i++){
    if(fabs(a[i].x-x)>=d+2*mr)continue;
    for(int j=0;j<b.size();j++){
      auto bj=b[b.size()-j-1];
      double dx=a[i].x-bj.x;
      double dy=a[i].y-bj.y;
      if(dy>=d+2*mr)break;
      d=min(d,sqrt(dx*dx+dy*dy)-a[i].r-bj.r);
    }
    b.push_back(a[i]);
  }
  return d;
}

int main(){
  while(cin>>N,N){
    mr=0;
    for(int i=0;i<N;i++){
      cin>>A[i].r>>A[i].x>>A[i].y;
      mr=max(mr,A[i].r);
    }
    sort(A,A+N,[](const P &a,const P &b){
	return a.x<b.x;
      });
    cout<<fixed<<closest_pair(A,N)<<endl;
  }
}

Measured memory_bytes: 9452
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}

int main(int argc, char *argv[]){
    int a, b; char op; cin >> a >> op >> b;
    if(op == '+') cout << a+b << endl;
    else cout << a-b << endl;
    return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
const long long MOD = 1e9+7, INF = 1e18;
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a=b;return true;}return false;}
//auto f = [&](int n)->int{return n;};
//auto a = [&](auto&&b){b(b)};



signed main(){
	int N;
	cin>>N;
	vector<int>a(N+1);
	vector<int>cnt(N+1,0);
	FOR(i,1,N+1)cin>>a[i];
	RFOR(i,1,N+1){
		int sum = 0;
		for(int j = i*2;j<=N;j+=i){
			if(cnt[j])sum++;
		}
		if(a[i]!=sum%2){
			cnt[i]++;
		}
	}
	vector<int>ans;
	FOR(i,1,N+1)if(cnt[i])ans.push_back(i);
	cout<<ans.size()<<endl;
	REP(i,ans.size()){
		cout<<ans[i]<<endl;
	}
}

Measured memory_bytes: 4980
import fractions
a,b,c,d = map(int,input().split())
num = b-a+1
ac = int((a-1)//c)
ad = int((a-1)//d)
bc = int(b//c)
bd = int(b//d)
e = c*d//(fractions.gcd(c,d))
a = int((a-1)//e)
b = int(b//e)
c = bc-ac
d = bd-ad
e = b-a
print(num-(c+d-e))

Measured memory_bytes: 5048
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    int n;cin>>n;
    string s[n];
    ll t[n];
    rep(i,n){
        cin>>s[i]>>t[i];
    }
    string x;cin>>x;
    ll ans=0;bool f=false;
    rep(i,n){
        if(f) ans+=t[i];
        if((!f) and s[i]==x){
            f=true;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define M 500000
#define NIL -2000000001

struct nodef{
  int p,k,l,r;
};
typedef struct nodef node;

node T[M];


void heap(int u,int p){
  if(T[u].l==NIL)return;

  if(u%2==0){
  if(T[u].l>T[u].k && T[u].l>=T[u].r){T[u/2].l=T[u].k=T[u].l;T[u].l=T[u*2].k=p;heap(u*2,p);}
  else if(T[u].r>T[u].k && T[u].r>T[u].l){T[u/2].l=T[u].k=T[u].r;T[u].r=T[u*2+1].k=p;heap(u*2+1,p);}
  }
  else {
    if(T[u].l>T[u].k && T[u].l>=T[u].r){T[u/2].r=T[u].k=T[u].l;T[u].l=T[u*2].k=p;heap(u*2,p);}
  else if(T[u].r>T[u].k && T[u].r>T[u].l){T[u/2].r=T[u].k=T[u].r;T[u].r=T[u*2+1].k=p;heap(u*2+1,p);}
  }
  
}

int main(){
  int a,i;
  scanf("%d",&a);

  for(i=0;i<=a;i++)T[i].p=T[i].l=T[i].r=NIL;
  
  for(i=1;i<=a;i++){
    scanf("%d",&T[i].k);
    if(i!=1){
    if(i%2==0){T[i/2].l=T[i].k;T[i].p=T[i/2].k;}
    else {T[i/2].r=T[i].k;T[i].p=T[i/2].k;}
    }
  }
  
  for(i=a;i>0;i--)heap(i,T[i].k);
  //heap(2,T[2].k);
  
  for(i=1;i<=a;i++){
    printf(" %d",T[i].k);
    //printf("node %d: key = %d, ",i,T[i].k);
    //if(T[i].p!=NIL)printf("parent key = %d, ",T[i].p);
    //if(T[i].l!=NIL)printf("left key = %d, ",T[i].l);
    //if(T[i].r!=NIL)printf("right key = %d, ",T[i].r);
    //printf("\n");
    }

  //heap(1,T[1].k);
  //for(i=1;i<=a;i++)printf(" %d",T[i].k);
  printf("\n");
}



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

typedef long long LL;

const int MAXN = 1e5 + 5;

int n, m, w[MAXN];

std::multiset<int> st[MAXN];
std::set<std::pair<int, int> > spec;

int fa[MAXN], part;

int Find(int x) {
    return fa[x] == x ? x : fa[x] = Find(fa[x]);
}

void merge(int u, int v) {
    if (Find(u) == Find(v)) return;
    if (st[fa[u]].size() > st[fa[v]].size()) std::swap(u, v);
    --part;
    for (int i: st[fa[u]]) {
        st[fa[v]].insert(i);
    }
    st[fa[u]].clear();
    if (!st[fa[v]].empty()) spec.insert(std::make_pair(st[fa[v]].size(), fa[v]));
    fa[fa[u]] = fa[v];
}

int main() {
    scanf("%d%d", &n, &m); part = n;
    for (int i = 0; i < n; ++i) {
        fa[i] = i;
        scanf("%d", w + i);
        st[i].insert(w[i]);
        spec.insert(std::make_pair(1, i));
    }
    
    for (int i = 1; i <= m; ++i) {
        static int u, v;
        
        scanf("%d%d", &u, &v);
        spec.erase(spec.find(std::make_pair(st[Find(u)].size(), Find(u))));
        spec.erase(spec.find(std::make_pair(st[Find(v)].size(), Find(v))));
        merge(u, v);
    }
    
    LL ans = 0;
    
    while (part > 1) {
        if (spec.size() < 2) {
            puts("Impossible");
            return 0;
        }
        auto x = *--spec.end();
        spec.erase(--spec.end());
        
        auto y = *--spec.end();
        spec.erase(--spec.end());
        
        int u = x.second, v = y.second;
        ans += *st[Find(u)].begin() + *st[Find(v)].begin();
        
        st[Find(u)].erase(st[Find(u)].begin());
        st[Find(v)].erase(st[Find(v)].begin());
        
        merge(u, v);
    }
    
    printf("%lld\n", ans);
    
    return 0;
}

Measured memory_bytes: 15104
def maximumx(N, S) : 
  x = 0
  max = 0
  
  for i in range(N) : 
    if S[i] == 'I' : 
      x += 1
      if max < x :
        max = x
    else : 
      x -= 1 
      
  return max


N = int(input())
S = input()

print(maximumx(N, S))

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// head

typedef double db;
db eps=1e-9;
struct point {
	db x,y;
	point() {}
	point(db x,db y):x(x),y(y) {}
	void input() { scanf("%lf%lf",&x,&y); }
	void output() { printf("%.10f %.10f\n",x,y); }
	db len() { return sqrt(x*x+y*y); }
	db len2() { return x*x+y*y; }
};
point operator + (const point &a,const point &b) { return point(a.x+b.x,a.y+b.y);}
point operator - (const point &a,const point &b) { return point(a.x-b.x,a.y-b.y);}
point operator * (const point &a,const db &b) { return point(a.x*b,a.y*b);}
point operator / (const point &a,const db &b) { return point(a.x/b,a.y/b);}
db dot(const point &a,const point &b) { return a.x*b.x+a.y*b.y; }
db det(const point &a,const point &b) { return a.x*b.y-a.y*b.x; }
struct line {
	point a,b;
	line() {}
	line(point a,point b):a(a),b(b) {}
};
point proj(const line &a,const point &b) {
	return a.a+(a.b-a.a)*dot(a.b-a.a,b-a.a)/(a.b-a.a).len2();
}
point reflect(const line &a,const point &b) {
	return proj(a,b)*2-b;
}
int dblcmp(db x) {
	return fabs(x)<eps?0:(x>0?1:-1);
}
int relation(const line &a,const point &b) {
	int x=dblcmp(det(a.b-a.a,b-a.a));
	if (x==1) return 0; // COUNTER_CLOCKWISE ?????¶???
	else if (x==-1) return 1; // CLOCKWISE ?????¶???
	else {
		x=dblcmp(dot(b-a.a,a.b-a.a));
		if (x<-eps) return 2; // ONLINE_BACK
		else {
			x=dblcmp(dot(b-a.b,a.b-a.a));
			if (x>eps) return 3; // ONLINE_FRONT
			else return 4; // ON_SEGMENT
		}
	}
}
bool parallel(line &a,line &b) { return dblcmp(det(a.a-a.b,b.a-b.b))==0;}
int segcrossseg(const line &a, const line &b) {
	int d1=dblcmp(det(a.b-a.a,b.a-a.a));
	int d2=dblcmp(det(a.b-a.a,b.b-a.a));
	int d3=dblcmp(det(b.b-b.a,a.a-b.a));
	int d4=dblcmp(det(b.b-b.a,a.b-b.a));
	if ((d1^d2)==-2&&(d3^d4)==-2) return 2; // ?§??????????
	return ((d1==0&&dblcmp(dot(b.a-a.a,b.a-a.b))<=0)||
			(d2==0&&dblcmp(dot(b.b-a.a,b.b-a.b))<=0)||
			(d3==0&&dblcmp(dot(a.a-b.a,a.a-b.b))<=0)||
			(d4==0&&dblcmp(dot(a.b-b.a,a.b-b.b))<=0)); // ????§????/?????????
}

int q;
int main() {
	scanf("%d",&q);
	rep(i,0,q) {
		point p1,p2,q1,q2;
		p1.input(); p2.input(); q1.input(); q2.input();
		puts(segcrossseg(line(p1,p2),line(q1,q2))>=1?"1":"0");
	}
}

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

int main() {
  string S;
  cin >> S;
  int size = S.size() - 1;
  long long sum = 0;

  for (int b = 0; b < (1 << size); ++b) {
    vector<int> points;
    for (int i = 0; i < size; ++i) {
      if (b & (1 << i)) {
        points.push_back(i);
      }
    }
    
    int p = 0;
    vector<long long> sums;
    for (int i = 0; i < (int)points.size(); i++) {
      int p0 = points.at(i) + 1;
      sums.push_back(stoi(S.substr(p, p0 - p)));
      p = p0;
    }

    sums.push_back(stoll(S.substr(p)));
	
    for (int i = 0; i < (int)sums.size(); i++) {
      sum += sums.at(i);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void calc_primes(int n, vector<int>& primes){
	vector<bool> tb(n+1,true);
	tb[0]=false;
	tb[1]=false;
	for(int i=2;i<=n;i++){
		if(tb[i]){
			int j=i;
			while(1ll*j*i <= 1ll*n){
				tb[i*j]=false;
				j++;
			}
			primes.pb(i);
		}
	}
}

void solve(){
	int n=2*int(1e5);
	vector<int> primes;
	calc_primes(n,primes);
	int x;
	cin>>x;
	for(int i=0;i<primes.size();i++)
		if(x<=primes[i]){
			cout<<primes[i]<<"\n";
			break;
		}
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

int color[10010];
int N;

int solve(int x, int cc){
  if(color[x] == cc) return N;
  int cnt = 1;
  int back, forward;
  
  for(back = x-1 ; back >= 0 ; back--){
    if(cc == color[back]) cnt++;
    else break;
  }
  for(forward = x+1 ; forward < N ; forward++){
    if(cc == color[forward]) cnt++;
    else break;
  }
  
  int res = N-cnt;
  
  if(cnt < 4) return N;
  else if(back < 0 || N <= forward) return res; // ツ端ツづーツ湘?つオツつスツ湘ェツ債?
  else if(color[back] != color[forward]) return res; // ツ禿アツ連ツ債スツづ可づつづ按つェツづァツづ按つ「ツ湘ェツ債?
  
  while(1){
    int tmp = 0;
    cc = color[back];
    for( ; back >= 0 ; back--){
      if(cc == color[back]) tmp++;
      else break;
    }
    for( ; forward < N ; forward++){
      if(cc == color[forward]) tmp++;
      else break;
    }
    if(tmp < 4) return res;
    else if(back < 0 || N <= forward) return res-tmp;
    else if(color[back] != color[forward]) return res-tmp;
    
    res -= tmp;
  }
  return res;
}

int main(){
  while(cin >> N, N){
    for(int i = 0 ; i < N ; i++) cin >> color[i];
    int ans = 10010;
    for(int i = 0 ; i < N ; i++){
      for(int c  = 1 ; c <= 3 ; c++){
	ans = min(ans, solve(i, c));   
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long long;
 
constexpr ll MOD = 1000000007;
 
#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : " << x.second << ")" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "["; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "(" << obj.first << ", " << obj.second << ")"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print_sim_py(void) {cout << endl;}
template <class Head> void print_sim_py(Head&& head) {cout << head;print_sim_py();}
template <class Head, class... Tail> void print_sim_py(Head&& head, Tail&&... tail) {cout << head << " ";print_sim_py(forward<Tail>(tail)...);}
 
#define print(...) print_sim_py(__VA_ARGS__);
#else
#define print(...);
#endif

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

	string ans;
	ll n;

	cin >> n;
	//vector<ll> a(n);
	unordered_map<ll,ll> cnt;
	bool pair_coprime = true;

	for (ll i = 0; i < n; i++){
		ll a;
		cin >> a;

		if(a==1)
			continue;
		

		for (ll j = 2; j * j <= a; j++){
			if(a%j==0){
				if(cnt.find(j)==cnt.end()){
					cnt[j]=1;
				}else{
					pair_coprime = false;
					cnt[j]++;
				}
				while(a%j==0){
					a/=j;
				}
			}
		}

		if(a!=1){
			if(cnt.find(a)==cnt.end()){
				cnt[a]=1;
			}else{
				pair_coprime = false;
				cnt[a]++;
			}
		}
	}

	bool set_coprime = true;
	for(auto&& c : cnt){
		if(c.second==n){
			set_coprime=false;
		}
    }

	if(pair_coprime){
		ans = "pairwise coprime";
	}else if(set_coprime){
		ans = "setwise coprime";
	}else{
		ans = "not coprime";
	}
    
    cout << ans << endl;
 
    return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

void solve() {
  int x;
  cin >> x;
  if (x < 1200) {
    cout << "ABC" << endl;
  } else {
    cout << "ARC" << endl;
  }
}

signed main() {
  solve();

  return 0;
}

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

using namespace std;

int main(){
    string s;
    cin >> s;
    int idx[3]={0,0,0};
    for(int i=0;i<s.length();i++){
        if(s[i]=='a'){
            idx[0]++;
        }else if(s[i]=='b'){
            idx[1]++;
        }else if(s[i]=='c'){
            idx[2]++;
        }
    }
    
    if(abs(idx[0]-idx[1])<=1&&abs(idx[1]-idx[2])<=1&&abs(idx[0]-idx[2])<=1){
        cout << "YES" << endl;
        //cout << idx[0] << " " << idx[1] << " " << idx[2] << endl;
    }else{
        cout << "NO" << endl;
        //cout << idx[0] << " " << idx[1] << " " << idx[2] << endl;
    }
    return 0;
}

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

#define mx 1005
#define md 1000000007

using namespace std;

int n, m, dp[mx][mx] = {1};
char s[mx];

int main(){
  scanf("%d%d", &n, &m);
  for(int i = 0; i < n; i++){
    scanf("%s", s);
    for(int j = 0; j < m; j++){
      if(s[j] == '.'){
        dp[i][j+1] = (dp[i][j+1] + dp[i][j]) % md;
        dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % md;
      }
    }
  }
  printf("%d\n", dp[n-1][m-1]);
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K; cin >> K;
  int A[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << A[K-1] << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
const double PI = acos(-1);
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> b(m);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> a.at(i).at(j);
        }
    }
    for (int i = 0; i < m; i++)
    {
        cin >> b.at(i);
        /* code */
    }
    vector<int> ans(n);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            ans.at(i) += a.at(i).at(j) * b.at(j);
        }
    }
    for (int i = 0; i < n; i++)
    {
        cout << ans.at(i) << endl;
        /* code */
    }
    
    

}
    


Measured memory_bytes: 3192
import sys
from itertools import accumulate, combinations

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


H, W, K = MI()
S = [[int(x) for x in list(input())] for _ in range(H)]


def fn(bits):
    slice = 0
    n = bin(bits).count("1")
    block_cnts = [0] * n
    for j in range(W):
        sec = 0
        col_cnts = [0] * n
        for i in range(H):
            col_cnts[sec] += S[i][j]
            if col_cnts[sec] > K:
                return -1
            if (bits >> i) & 1:
                sec += 1
        if all(block_cnts[sec] + col_cnts[sec] <= K for sec in range(n)):
            for sec in range(n):
                block_cnts[sec] += col_cnts[sec]
        else:
            slice += 1
            block_cnts = col_cnts
    return slice


ans = INF
for bits in range(1 << (H - 1)):
    hslice = bin(bits).count("1")
    wslice = fn(bits + (1 << (H - 1)))
    if wslice > -1:
        ans = min(ans, hslice + wslice)
print(ans)


Measured memory_bytes: 49756
// C - Otoshidama
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N,Y; cin>>N>>Y;
	Y /= 1000;
	rpz(x, min(N+1, (Y+10-1)/10+1)){
		rpz(y, min(N-x+1, (Y+5-1)/5+1)){
			int z = N - x - y;
			if(x*10 + y*5 + z != Y) continue;
			printf("%d %d %d\n", x, y, z);
			return 0;
		}
	}
	puts("-1 -1 -1");
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int L, R;

signed main()
{
	cin >> L >> R;

	int min = INT_MAX;
	for (int i = 0; i <= 2019; i++)
	{
		for (int j = i + 1; j <= 2019 * 2; j++)
		{
			int l = L + i;
			int r = L + j;

			if (l > R) continue;
			if (r > R) continue;

			int m = (l * r) % 2019;
			if (min > m)
			{
				min = m;
			}
		}
	}
	cout << min << endl;
}











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


#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int N = 2e5 + 10;


using namespace std;

int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    IOS;

    ll n;
    cin >> n;

    string ans = "";




    while (n > 0)
    {

        ll rem = n % 26;

        if (rem == 0)
        {
            ans += 'z';

            n = n / 26 - 1;
        }

        else
        {
            ans += ((rem - 1) + 'a');

            n = n / 26;
        }

        
    }

     reverse(all(ans));

   cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

vector<pair<int, int>> max_freq(map<int, int> freq) {
    vector<pair<int, int>> pair_freq;

    for (auto it : freq)
        pair_freq.emplace_back(it.second, it.first);

    sort(pair_freq.rbegin(), pair_freq.rend());
    return pair_freq;
}

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

    int N;
    cin >> N;
    vector<int> V(N);

    for (int &v : V)
        cin >> v;

    map<int, int> freq[2];

    for (int i = 0; i < N; i++)
        freq[i % 2][V[i]]++;

    vector<pair<int, int>> pair_freq[2] = {max_freq(freq[0]), max_freq(freq[1])};
    pair_freq[0].emplace_back(0, -1);
    pair_freq[1].emplace_back(0, -1);

    int keep = pair_freq[0].front().first + pair_freq[1].front().first;

    if (pair_freq[0].front().second == pair_freq[1].front().second)
        keep = max(pair_freq[0].front().first + pair_freq[1][1].first, pair_freq[0][1].first + pair_freq[1].front().first);

    cout << N - keep << '\n';
}


Measured memory_bytes: 8828
d = int(input())
c = list(map(int,input().split()))
up = []
for _ in range(d):
  up.append(list(map(int,input().split())))
ans = [[-1] for _ in range(26)]
for i in range(d):
  ans[i%26].append(i)
#ans[0].append(0)
#ans[16].append(1)
#ans[12].append(2)
#ans[13].append(3)
#ans[12].append(4)

for al in range(26):
  ans[al].append(d)
#print(ans)
import bisect
from random import random
from random import randrange
import math
scr = 0
for al in range(26):
  now = ans[al]
  l = len(now)
  for j in range(1,l):
    scr -= c[al] * (now[j]-now[j-1]-1) * (now[j]-now[j-1]) // 2
    #print(c[al] * (now[j]-now[j-1]-1) * (now[j]-now[j-1]) // 2)
  for j in range(1,l-1):
    scr += up[now[j]][al]
    #print(up[now[j]][al])
  #print('$')
#print(scr)
task = [i%26 for i in range(d)]
#print(task)
est = 20000
for _ in range(200):
  for _ in range(500):
    day = randrange(d)
    pre = task[day]
    pst = randrange(26)
    if pre == pst:
      continue
    bpre = bisect.bisect_left(ans[pre],day)
    bpst = bisect.bisect_left(ans[pst],day)
    bpre1 = ans[pre][bpre-1]
    bpre2 = ans[pre][bpre+1]
    bpst1 = ans[pst][bpst-1]
    bpst2 = ans[pst][bpst]
    #print(day,ans[pre][bpre],ans[pst][bpst])
    #print(day)
    #print(bpre1,day,bpre2,'#',pre)
    #print(bpst1,day,bpst2,'#',pst)
    tmp = 0
    tmp -= c[pre] * (day-bpre1) * (bpre2-day)
    #print(c[pre] * (day-bpre1) * (bpre2-day))
    tmp += c[pst] * (day-bpst1) * (bpst2-day)
    #print(c[pst] * (day-bpst1) * (bpst2-day))
    tmp -= up[day][pre]
    #print(up[day][pre])
    tmp += up[day][pst]
    #print(up[day][pst])
    #print(tmp)
    r = random()
    exp = math.exp(tmp/est)
    if exp > r:
      #print(ans[pre])
      #print(ans[pst])
      ans[pre].remove(day)
      bisect.insort(ans[pst],day)
      #print(ans[pre])
      #print(ans[pst])
      task[day] = pst
      scr += tmp
      #print(scr)
    #print('%')
  est -= 100
#for x in ans:
  #print(x)
for x in task:
  print(x+1)

Measured memory_bytes: 90328
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  int a;
  cin>>a;
  vector<string> b(a);
  fo(i,a)
    cin>>b[i];
  fo(i,a)
    Sort(b[i]);
  Sort(b);
  string c;
  int d;
  vector<int> e;
  for(int i=0;i<a;i=i){
    c=b[i];
    d=0;
    while(i<a){
      if(c!=b[i])
        break;
      else
        d++;
      i++;
    }
    e.push_back(d);
  }
  int f=e.size();
  int g=0,h;
  fo(i,f){
    h=e[i]*(e[i]-1);
    g+=h/2;
  }
  cout<<g<<endl;
}

Measured memory_bytes: 8444
($n,$k)=glob<>;
@a=sort{$a-$b}glob<>;
$s=1e9;
for$i($k-1..$n-1){
	$l=$-=-$a[$i-$k+1];
	$r=$-=$a[$i];
	$s-=$-=$s-$l-$r-${$l<$r?l:r};
}
print$s

Measured memory_bytes: 30204
#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 ll INF=1001001001001001001;

vector<ll> dist1(100005,INF);
vector<ll> distn(100005,INF);
vector<vector<int>> g(100005);


int dfs1(int t,int p, ll d){
  for(int to: g[t]){
    if (to==p)continue;
    dist1[to]=d+1;
    dfs1(to,t,d+1);
  }
}
int dfsn(int t,int p, ll d){
  for(int to: g[t]){
    if (to==p)continue;
    distn[to]=d+1;
    dfsn(to,t,d+1);
  }
}

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



  rep(i,n-1){
    int a1,b1;
    cin>>a1>>b1;
    a1--;b1--;
    g[a1].push_back(b1);
    g[b1].push_back(a1);

  }
  dist1[0]=0;
  distn[n-1]=0;
  dfs1(0,-1,0);
  dfsn(n-1,-1,0);


  ll S=0;
  ll F=0;
  rep(i,n){
  //  cout<<dist1[i]<<'i'<<distn[i]<<endl;
    if (dist1[i]<=distn[i])F++;
    else S++;
  }
  //cout<<S<<'S'<<F<<endl;
  if (F>S)cout<<"Fennec";
  else cout<<"Snuke";
  return 0;

}


Measured memory_bytes: 11904
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
s = LS()
print(s[0][0].upper()+s[1][0].upper()+s[2][0].upper())
"""
#B
a,b = IR(2)
if a < b:
    print("LESS")
elif a == b:
    print("EQUAL")
else:
    print("GREATER")
#C
"""
n = I()
a = LI()
b = [a[i] for i in range(n)]
ans = 0
k = a[0]
if a[0] == 0:
    a[0] = 1
    ans = 1
    k = 1
for i in range(1,n):
    if k*(k+a[i]) >= 0:
        if k < 0:
            ans += abs(1-k-a[i])
            a[i] = 1-k
            k = 1
        else:
            ans += abs(-1-k-a[i])
            a[i] = -1-k
            k = -1
    else:
        k += a[i]
if b[0] >= 0:
    ans2 = b[0]+1
    k = -1
    b[0] = -1
else:
    ans2 = 1-b[0]
    k = 1
    b[0] = 1
for i in range(1,n):
    if k*(k+b[i]) >= 0:
        if k < 0:
            ans2 += abs(1-k-b[i])
            b[i] = 1-k
            k = 1
        else:
            ans2 += abs(-1-k-b[i])
            b[i] = -1-k
            k = -1
    else:
        k += b[i]
print(min(ans,ans2))
"""
#D
"""
x,y = LI()
if abs(x-y) <= 1:
    print("Brown")
else:
    print("Alice")
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 38512
#map(int, input().split())
N=int(input())
a=list(map(int, input().split()))
A={a[i] : i+1 for i in range(N)}
A=sorted(A.items(), key=lambda x:x[0])
s=''
for i, j in A:
    s+=str(j)+' '
print(s[0:-1])

Measured memory_bytes: 24796
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,ans=0,num=0;
    cin>>n;
    for(int i=1;i<=n;i+=2){
        for(int j=1;j<=i;j++){
            if(i%j==0){
                num++;
            }
        }
        if(num==8){
            ans++;
        }
        num=0;
    }
    cout <<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF = 1001001001;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main() {
string s,t;
cin >> s >> t;
int mini = 10000;
rep(i,s.size()) {
    int cnt = 0;
    if (i+t.size() > s.size()) break;
    rep(j,t.size()) {
        if (t[j] != s[i+j]) cnt++;
    }
    mini = min(mini,cnt);
}

cout << mini << endl;
    
return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set> 
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>
using namespace std;
#define assem99 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define ld long double
#define ii pair<int, int>
#define f(i,a,b) for(int i=a; i<b; i++)
#define F first
#define S second
#define sz(a) (int)(a).size()
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
int x[] = { 0, -1, 0, 1, -1, 1, -1, 1 };
int y[] = { -1, 0, 1, 0, 1, -1, -1, -1 };
const int MOD = 1e9 + 7, N = 2e6 + 5;
const double pi = acos(-1);

ll arr[N], brr[N];
vector<ll> vec;

ll fp(ll b, ll p)
{
	if (p == 0)
		return 1;
	ll ans = fp(b, p / 2);
	ans = (ans * ans) % MOD;

	if (p % 2 != 0) ans = (ans *(b % MOD)) % MOD;
	return ans;
}

void getPrimes(ll n)
{
	map<ll, ll > curr;
	while (n % 2 == 0)
	{
		curr[2]++;
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		while (n % i == 0)
		{
			curr[i]++;
			n /= i;
		}
	}
	if (n > 2) curr[n]++;
	map<ll, ll>::iterator it;
	for (it = curr.begin(); it != curr.end(); it++) arr[it->F] = max(arr[it->F], it->S);
}

int main()
{
	assem99;

	ll n; cin >> n;
	f(i, 0, n)
	{
		cin >> brr[i];
		getPrimes(brr[i]);
	}
	ll ans = 1;
	f(i, 0, N) ans *= fp(i, arr[i]), ans %= MOD;
	ll sum = 0;
	f(i, 0, n) sum += ans * fp(brr[i], MOD - 2), sum %= MOD;
	cout<<sum;

	return 0;
}

Measured memory_bytes: 10624
#include<bits/stdc++.h>
using namespace std;
#define int long long int
signed main()
{
	int n;
  	cin>>n;
  	vector <int> v(n);
  	int dp[n+3];
	for (auto &it:v)
      cin>>it;
  	dp[0]=0;
  	dp[1]=abs(v[0]-v[1]);
  	for (int i=2;i<n;++i)
    {
    	dp[i]=min(dp[i-2]+abs(v[i-2]-v[i]),dp[i-1]+abs(v[i-1]-v[i]));
    }
  	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
    int i, n, min,max = -999999999;
    int R[200000];

    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &R[i]);
    }

    min =R[0];
    for(int j = 1; j < n; j++){
        if(max < R[j] - min){ max = R[j] - min;}
        if(min > R[j]){ min = R[j];}
    }

    printf("%d\n", max);

    return 0;
}


Measured memory_bytes: 2644
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<map>
#include<list>

using namespace std;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define MOD 1000000007

#define IMIN INT_MIN;
#define IMAX INT_MAX;


int main(){
    string S;
    int N;
    cin >> N >> S;
    vector<int> vr(N, 0), vg(N, 0), vb(N, 0);
    int rcnt = 0;
    int gcnt = 0;
    int bcnt = 0;
    rep(i, N) {
        if (S[i] == 'R') {
            rcnt++;
        }
        if (S[i] == 'G') {
            gcnt++;
        }
        if (S[i] == 'B') {
            bcnt++;
        }
        vr[i] = rcnt;
        vg[i] = gcnt;
        vb[i] = bcnt;
    }
    int tgt;
    ll ans = 0;
    rep(i, N-1) {
        rept(j, i+1, N) {
            if ((S[i] == 'G' && S[j] == 'B') || (S[i] == 'B' && S[j] == 'G')) {
                ans += vr[j-1] - vr[i];
                if ((i+j) % 2 == 0) {
                    tgt = (i+j) / 2;
                    if (S[tgt] == 'R') ans--;
                }
            }
            if ((S[i] == 'R' && S[j] == 'B') || (S[i] == 'B' && S[j] == 'R')) {
                ans += vg[j-1] - vg[i];
                if ((i+j) % 2 == 0) {
                    tgt = (i+j) / 2;
                    if (S[tgt] == 'G') ans--;
                }
            }
            if ((S[i] == 'R' && S[j] == 'G') || (S[i] == 'G' && S[j] == 'R')) {
                ans += vb[j-1] - vb[i];
                if ((i+j) % 2 == 0) {
                    tgt = (i+j) / 2;
                    if (S[tgt] == 'B') ans--;
                }
            }
        }
    }
    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

#define MOD_BY 1000000007

int add(int a, int b) {
	return a + b - MOD_BY * (a + b >= MOD_BY);
}

int N, M;
int a[114514];

char dame[114514];

int memo[114514];

int kitaeri(int cur) {
	if (cur == N) return 1;
	if (cur > N) return 0;
	if (dame[cur]) return 0;
	if (memo[cur]) return ~memo[cur];
	return ~(memo[cur] = ~add(kitaeri(cur + 1), kitaeri(cur + 2)));
}

int main(void) {
	int i;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < M; i++) {
		if (scanf("%d", &a[i]) != 1) return 1;
		dame[a[i]] = 1;
	}
	printf("%d\n", kitaeri(0));
	return 0;
}


Measured memory_bytes: 3328