akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b,s[11000];
  cin >> n >> a >> b;

  for(int i=1; i<n+1; i++){
    s[i]=0;
    int l=i;
    while(true){
      if(l>=10||l%10!=0){
        s[i]=s[i]+l%10;
        l=l/10;
      }
      else break;
    }
  }
  
  vector<int> v;
  for(int i=1; i<n+1; i++){
    if(a<=s[i]&&s[i]<=b){
      v.push_back(i);
    }
  }
  
  int res=0;
  for(int i=0; i<v.size(); i++){
    res = res+v[i];
  }
  
  cout << res << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const int M=10;
int n,m,a[M],b[M]={0,2,5,5,4,5,6,3,7,6};

int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x;
		cin>>x;
		a[x]++;
	}
	vi dp(n+1,-1);
	dp[0]=0;
	for(int i=0;i<n;i++) for(int j=1;j<M;j++) if(a[j]&&i+b[j]<=n) dp[i+b[j]]=max(dp[i+b[j]],dp[i]+1);
	int N=dp[n],I=n;
	for(int i=0;i<N;i++) for(int j=M-1;j>0;j--) if(a[j]&&I-b[j]>=0&&dp[I]==dp[I-b[j]]+1){
		I-=b[j];
		cout<<j;
		break;
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ld long int
#define ll long long int
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define INF (ll)1e9+5
#define pp pair<ll,ll> 
#define vv vector< pair<ll ,ll> > 
#define vi vector<ll> 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;




int main() {
    int n,i,k,sm,c,x;
    vector<int> a;
    set<int> m;
    set<int>:: iterator it;
    
    cin>>n;
    sm=c=0;
    
    for(i=0;i<n;i++)
    {
        cin>>x;
        a.pb(x);
        if((x%10)==0)
         c++;
        else
        {
            m.insert(x);
        }
        sm+=x;
    }
    //cout<<sm;
    if((sm%10)!=0)
    {
        cout<<sm;
        return 0;
    }
    
    if(c==n)
    {
        cout<<0;
        return 0;
    }
    
    it=m.begin();
    x=(*it);
    cout<<sm-x;
	// your code goes here
	return 0;
}

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

using namespace std;

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

int main(){
	string n; cin >> n;
	if(n[0] == n[2]) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=q
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)

n = readInt()
a = readInts()

d = defaultdict(int)

ans = 0

for i in a:
	d[i]+=1

maxv = 0
for i in d:
	maxv+=comb(d[i],2)

for k in range(0,n):
	b = d[a[k]]
	delta = comb(b,2)-comb(b-1,2)
	ans = maxv-delta
	print(ans)

Measured memory_bytes: 26600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin >> a;
  int c=1;
    int d=1;
    int e=1;
    int f=1;
  while(a > 0){
    string b;
    cin >> b;
    if(b == "P")
      c = 0;
    else if(b == "Y")
      d = 0;
    else if(b == "W")
      e = 0;
    else if(b == "G")
      f = 0;
    a--;
  }
  if(d == 0)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}
  


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

sum = 0
for a in A:
    sum += a
x = A[0]
y = sum - A[0]
min_num = abs(x-y)

for i in range(1, len(A)-1):
    x = x + A[i]
    y = y - A[i]
    n = abs(x-y)
    if n < min_num:
        min_num = n
print(min_num)


Measured memory_bytes: 24832
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func search(in [9]byte) int {
	for i := 0; i < 9; i++ {
		if in[i] == byte(0) {
			return i
		}
	}
	panic("not found 0")
}

func up(in [9]byte) (bool, [9]byte) {
	pos := search(in)
	if pos > 2 {
		in[pos], in[pos-3] = in[pos-3], in[pos]

	} else {
		return false, in
	}
	return true, in

}

func down(in [9]byte) (bool, [9]byte) {
	pos := search(in)
	if pos < 6 {
		in[pos], in[pos+3] = in[pos+3], in[pos]
	} else {
		return false, in

	}
	return true, in

}

func left(in [9]byte) (bool, [9]byte) {
	pos := search(in)
	// mod(pos, 3) == 0
	if pos != 0 && pos != 3 && pos != 6 {
		in[pos], in[pos-1] = in[pos-1], in[pos]
	} else {
		return false, in
	}
	return true, in

}
func right(in [9]byte) (bool, [9]byte) {
	pos := search(in)
	// mod(pos, 3) == 2
	if pos != 2 && pos != 5 && pos != 8 {
		in[pos], in[pos+1] = in[pos+1], in[pos]
	} else {
		return false, in

	}
	return true, in

}

func next() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i

}

var goal = [9]byte{1, 2, 3, 4, 5, 6, 7, 8, 0}

func pp(s [9]byte) {

	for i := 0; i < 3; i++ {
		fmt.Printf("%d %d %d\n", s[0+3*i], s[1+3*i], s[2+3*i])
	}
	fmt.Println("----------------------")

}

type item struct {
	d *[9]byte
	c int
}

var queue = []item{}
var closed = map[[9]byte]bool{}

func bfs(cost int) int {
	for {

		top := queue[0]
		queue = queue[1:]

		if *top.d == goal {
			return top.c
		}
		closed[*top.d] = true

		ok, ur := up(*top.d)
		ok2, _ := closed[ur]
		if ok && !ok2 {
			queue = append(queue, item{&ur, top.c + 1})
		}
		ok, dr := down(*top.d)
		ok2, _ = closed[dr]
		if ok && !ok2 {
			queue = append(queue, item{&dr, top.c + 1})
		}
		ok, lr := left(*top.d)
		ok2, _ = closed[lr]
		if ok && !ok2 {
			queue = append(queue, item{&lr, top.c + 1})
		}
		ok, rr := right(*top.d)
		ok2, _ = closed[rr]
		if ok && !ok2 {
			queue = append(queue, item{&rr, top.c + 1})
		}
	}

}

func main() {
	sc.Split(bufio.ScanWords)
	var state [9]byte
	for i := 0; i < 9; i++ {
		state[i] = byte(next())
	}
	queue = append(queue, item{&state, 0})
	cost := bfs(0)
	fmt.Println(cost)
}



Measured memory_bytes: 20584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string arr;
const int q =  1e5+5;
ll dp[q][150][2];
int d;
ll getsum(int ind, int n, int sum, bool flag, int use){
    if(ind>=n) return use==d;
    // {if(d==0) return 1;return 0;} 
    int limit=9;
    if(!flag) limit= arr[ind]-'0';
    
    if(dp[ind][use][flag]!=-1) return dp[ind][use][flag];
    
    ll res=0;
    for(int i=0;i<=limit;i++){
        // if(i!=0)use++;
            res+= getsum(ind+1, n, 1, flag || i<limit,  use+(i!=0));
            
    }
    return dp[ind][use][flag]= res;
}

int main(){
    // int t;cin>>t;
    // while(t--){
        // ll x, y; cin >> x >> y;
        cin>>arr;
         cin>>d;
        for(int i=0;i<arr.size();i++)for(int j=0;j<150;j++)for(int k=0;k<2;k++) 
            dp[i][j][k]=-1;
        
        // for(int i=0;i<b.size();i++) arr[i]=b[i]-'0';
        ll right=getsum(0, arr.size(), 0, 0, 0);
        cout << right<< endl;
    // }
}

Measured memory_bytes: 3832
#include<cstdio>
#include<algorithm>
long long const INF = 1000000000000000000;
long long v[1001][3], dp[1001][1001];
int main() {
	int n, m, i, j;
	long long x, y, z;
	long long ans = -INF;
	scanf("%d%d", &n, &m);
	for (i = 1; i <= n; i++)for (j = 0; j < 3; j++)scanf("%lld", &v[i][j]);
	//最大値になりうるのは、+x+y+z,...,-x-y-zの最大値のどれか
	for (x = -1; x <= 1; x += 2) {
		for (y = -1; y <= 1; y += 2) {
			for (z = -1; z <= 1; z += 2) {
				//dp[i][j]=(1番からi番のケーキのうちj個選んだ時の評価の最大値)
				for (i = 0; i <= n; i++)dp[i][0] = 0;
				for (j = 1; j <= n; j++)dp[j - 1][j] = -INF;
				for (int i = 1; i <= n; i++) {
					for (int j = 1; j <= i; j++) {
						dp[i][j] = std::max(dp[i - 1][j - 1] + x*v[i][0] + y*v[i][1] + z*v[i][2], dp[i - 1][j]);
					}
				}
				ans = std::max(ans, dp[n][m]);
			}
		}
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int gcd(int a,int b){
  if(a < b) gcd(b, a);
  if(b==0) return 0;
  int r;
  while ((r=a%b)) {
	a = b;
	b = r;
  }
  return b;
}

int main(int argc, const char * argv[]) {
	int N;
	cin >> N;
	int GCD,A;
	cin >> GCD;
	FOR(i,1,N-1){
		cin >> A;
		GCD = gcd(A,GCD);
//		println(GCD);
	}

	println(GCD);
	return 0;
}


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

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

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()


int main()
{
    ll N;  cin>>N;
    ll M;  cin>>M;
    ll jma, a;
    VL ans(M,0);
    rep(i,0,N){
        cin>>jma;
        rep(j,0,jma){
            cin>>a;
            ans[a-1]++;
        }
    }

    ll sum=0;
    rep(i,0,M){
        if(ans[i]==N)sum++;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  int a, b, m;
  cin >> a >> b >> m;
  vector<int> refrigerators(a, 0);
  vector<int> microwaves(b, 0);
 
  for (int i = 0; i < a; i++) cin >> refrigerators[i];
  for (int i = 0; i < b; i++) cin >> microwaves[i];
  int min_cost = INT_MAX;
  for (int i = 0; i < m; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    min_cost = min(min_cost, (refrigerators[x - 1] + microwaves[y - 1] - c));
  }
  
  min_cost = min(min_cost, *min_element(refrigerators.begin(), refrigerators.end())
                 + *min_element(microwaves.begin(), microwaves.end()));
  cout << min_cost << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<numeric>
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
int main() {
	long long  a = 0, b = 1, c = 0, x = 0, max = 0, dig = 0, ans = 0;
	long long  n = 0, k = 0, nc = 0;
	long long left = 0, right = 0;
	string s, t, u,now;
	vector<double> z, zz,count,countc;
	vector<string>ss;
	vector<long long int>::iterator position;
	bool q = false;
	cin >> n;
	ans = n / 2;
	if (n % 2 == 1)ans++;
	cout << ans << endl;
	please AC;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

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

    double result;
    result = 2 * 3.14159 * R;
    cout << result;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}


Measured memory_bytes: 3688
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string str;
	int i,j;
	string ans = "yes";
	cin>>str;
	for(i=0;i<str.size();i++){ 
	for(j=i+1;j<str.size();j++){
	if(str[i]==str[j])
	{
		ans = "no";
		
		}
	}
	}
		cout << ans << endl;
			return 0;
			}

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

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

Measured memory_bytes: 256
#include<iostream>
#include<ios>
using namespace std;
template<int N>struct a{
	long ar[N+1];
	constexpr a():ar(){
		ar[0]=1;
		for(long i=1;i<=N;i++)ar[i]=ar[i-1]*i%1000000007;
	}
};
constexpr auto ans=a<100000>();
int n,c;
main(){
  for(;(c=getchar_unlocked())>10;)n=n*10+c-48;
	printf("%d",ans.ar[n]);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  cin >> str;
  int i;
  int m,b;
  while(str!="-"){
    cin >> m;
    for(i=0;i<m;i++){
      cin >> b;
      str=str.substr(b,str.size()-b)+str.substr(0,b);
    }
    cout << str << endl;
    cin >> str;
  }
  
}


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

int main() {
  
  string s, t;
  cin >> s >> t;
  
  int size = s.size();
  int size2 = t.size();
  
  int a = 0;
  for (int i = 0; i < size; i++){
    if(s.at(i) == t.at(i)){
      a = a + 1;
    }
  }
  
  if(a == size && size + 1 == size2){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
   
  
  
}



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

#define eb emplace_back
#define sz(s) (int)(s.size())
#define all(s) s.begin(), s.end()
#define ll long long

const int N = 1e6 + 9;
const int INF = 1e9 + 9;
const int NN = 2005;

int p[NN][NN], p2[NN][NN], p3[NN][NN];

char s[NN][NN];

void solve() {
	int n, m, q;
	cin >> n >> m >> q;
	for (int i = 1; i <= n; ++ i) {
		for (int j = 1; j <= m; ++ j) {
			cin >> s[i][j];
		}
	}
	for (int i = 1; i <= n; ++ i) {
		for (int j = 1; j <= m; ++ j) {
			p[i][j] = p[i-1][j] + p[i][j-1] - p[i-1][j-1] + (s[i][j] - '0') * ('1' - s[i-1][j] + '0' - s[i][j-1]);
			p2[i][j] = p2[i][j-1] + (s[i][j] - '0') * (s[i-1][j] - '0');
			p3[i][j] = p3[i-1][j] + (s[i][j] - '0') * (s[i][j-1] - '0');
		}
	}
	while(q--) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		cout << p[c][d] + p[a-1][b-1] - p[c][b-1] - p[a-1][d] + p2[a][d] - p2[a][b-1] + p3[c][b] - p3[a-1][b] << '\n';
	}
}

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


Measured memory_bytes: 52864
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 9999999

using namespace std;

typedef pair<int, int> P;

int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
unsigned long long c[100000];

int main() {
	long long a, b;
	cin >> a >> b;
	long long d = b - a;
	long long h = 0;
	for (int i = 1; i <= d; i++) {
		h += i;
	}
	cout << h - b << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
  string s;
  cin >> s;
  
  const size_t begin = s.find_first_of('A');
  const size_t end = s.find_last_of('Z');
  
  const size_t cnt = end - begin + 1;
  
  cout << cnt << endl;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        this.ItemMax = inpt[0];
        this.Total = inpt[1];

        long ans = 0;
        for (int i = 0; i <= ItemMax; i++)
        {
            if (Total - i > ItemMax * 2)
            {
                continue;
            }
            if (Total - i < 0)
            {
                continue;
            }
            int min = Math.Max(0, Total - i - ItemMax);
            int max = Math.Min(this.ItemMax, Total - i);
            ans += max - min + 1;
        }
        Console.WriteLine(ans);

    }


    private int ItemMax;
    private int Total;


    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"




2 2


";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 3032
#include <iostream>
using namespace std;
template <typename T>
T gcd(T a,T b){
  if(a%b==0)return b;
  else return gcd(b,a%b);
}
template <typename T>
T lcm(T a,T b){
  return a/gcd(a,b)*b;
}
int main(){
  int N;cin>>N;
  int A[N];
  for(int i = 0; N > i; i++){
    cin>>A[i];
  }
  int B[N];
  B[0] = A[0];
  for(int i = 1; N > i; i++){
    B[i] = gcd(B[i-1],A[i]);
  }
  int C[N];
  C[N-1] = A[N-1];
  for(int i = N-2; 0 <= i; i--){
    C[i] = gcd(C[i+1],A[i]);
  }
  int ans = 0;
  for(int i = 0; N > i; i++){
    if(i==0){
      ans = max(ans,C[i+1]);
    }else if(i+1 == N){
      ans =max(ans,B[i-1]);
    }else{
      ans = max(ans,gcd(B[i-1],C[i+1]));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll N=100005;
vector<ll> adj[N],indeg(N,0), dp(N,0);
inline ll mult(ll x,ll y){x%=hell;y%=hell;return (1LL*x*y)%hell;}
inline ll add(ll x,ll y){x+=y;return x%hell;}
inline ll powMod(ll base,ll expo){
	if(base==0)return 0;
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base); 
		expo>>=1;
	}
	return ans;
}
void solve(){
	stack<ll> st;
	ll n, m, x, y, ans=0;
	cin>>n>>m;
	rep(i,0,m){
		cin>>x>>y;
		adj[x].pb(y);
		indeg[y]++;
	}
	rep(i,1,n+1){
		if(indeg[i]==0)st.push(i);
	}
	while(!st.empty()){
		x=st.top();
		st.pop();
		ans=max(ans,dp[x]);
		for(auto u : adj[x]){
			dp[u]=max(dp[u],dp[x]+1);
			indeg[u]--;
			if(indeg[u]==0)st.push(u);
		}
	}
	cout<<ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))
// #define int long long

int d_sum(int n){
    string s = to_string(n);
    int ret = 0;
    for(char c: s){
        ret += c - '0';
    }
    return ret;
}

signed main(){
    int n, a, b;
    cin >> n >> a >> b;
    int ans = 0;
    reps(i,1,n){
        int d = d_sum(i);
        if(a <= d && d <= b) ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
<?php
list($s) = strs();
$ans = PHP_INT_MAX;
for ($i = 0; $i < 26; ++$i)
    $ans = min($ans, max(array_map('strlen', explode(chr(97 + $i), $s))));
echo $ans;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}


Measured memory_bytes: 16180
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

#define LEN 362880
int head = 0, tail = 0;
int que[LEN];

int start[9]; //初期状態	
int goal = 46233;	//最終状態
int search[362880] = { 0 };	//探索済み
int board[362880][9];	//盤面の状態
int d[362880];	//時間
int oya; //親のナンバー
int dummy[9];	//盤面コピー用
int p0[362880];	//0の位置を記憶

/*盤面の隣接リスト*/
int next[9][5] = { {2, 1, 3},
				   {3, 0, 2, 4},
                   {2, 1, 5},
				   {3, 0, 4, 6},
                   {4, 1, 3, 5, 7},
				   {3, 2, 4, 8},
                   {2, 3, 7},
                   {3, 4, 6, 8},
				   {2, 5, 7}
};

/*キューの実装*/
int isempty() {
	return head == tail;
}

void enqueue(int x) {
	que[tail] = x;
	if ((tail + 1) == LEN)
		tail = 0;
	else
		tail++;
}

int dequeue() {
	int x;
	x = que[head];
	if ((head + 1) == LEN)
		head = 0;
	else
		head++;
	return x;
}

/*0のマスを探索*/
int a_mas0(int a[]) {
	for (int i = 0; i < 9; i++)
		if (a[i] == 0)
			return i;
}

/*盤面をコピー*/
void board_copy(int a[], int b[]) {
	for (int i = 0; i < 9; i++)
		b[i] = a[i];
}

/*階乗を計算*/
int n_factorial(int n) {
	if (n == 1)
		return 1;
	return n * n_factorial(n - 1);
}

/*盤面記憶のために使用*/
void a_location(int a[], int s) {
	for (int i = s + 1; i < 9; i++)
		if (a[s] < a[i])
			a[i]--;
}

/*盤面の状態を数値に変換*/
int assign_number(int a[]) {
	int b[9];
	int num = 0;
	int pos = 8;
	board_copy(a, b);
	for (int i = 8; i > 0; i--) {
		num = num + b[8 - i] * n_factorial(i);
		a_location(b, 8 - i);
		if (a[8 - i] == 0)
			pos = 8 - i;
	}
	p0[num] = pos;
	return num;
}

/*マスの移動*/
void move(int *a, int *b) {
	int box;
	box = *a;
	*a = *b;
	*b = box;
}

/*盤面の表示*/
void puzzle_print(int a[]) {
	for (int i = 0; i < 9; i++)
		printf("%d ", a[i]);
	printf("\n");
}

/*0の位置を探索*/
int zero_position(int a[]) {
	for (int i = 0; i < 9; i++)
		if (a[i] == 0)
			return i;
}

/*幅優先探索*/
int bsf() {
	int num;
	int pos;
	while (isempty() != 1) {
		oya = dequeue();
		pos = p0[oya];
		for (int i = 1; i <= next[pos][0]; i++) {
			board_copy(board[oya], dummy);	//oyaの盤面をdummyにコピー
			move(&dummy[pos], &dummy[next[pos][i]]);	//dummyの盤面を移動
			num = assign_number(dummy);	//移動した盤面を数値に変換
			if (num == goal){	//最終状態を発見
				d[num] = d[oya] + 1;	
				search[num] = 1;
				return 1;
			}
			else if (search[num] != 1) {	//最終状態でない
				search[num] = 1;
				board_copy(dummy, board[num]);
				d[num] = d[oya] + 1;
				enqueue(num);
			}
		}
	}
	return 0;
}

int main(void) {
	int i = 0;
	int num;
	
	/*初期状態の設定*/
	for (i = 0; i < 9; i++)
		scanf("%d", &start[i]);
	num = assign_number(start);	//初期状態の数値
	board_copy(start, board[num]);	//初期状態の盤面を記憶
	search[num] = 1;	//初期状態の数値を記憶(1をたてる)
	d[num] = 0;	//初期状態の時間を0に設定
	enqueue(num); //初期状態の数値をキューに格納
	
	/*探索開始*/
	if (num == goal)
		printf("0\n");
	else if (bsf() == 1)
		printf("%d\n", d[goal]);
	else
		printf("なし\n"); 
	
	return 0;
}


Measured memory_bytes: 19456
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b;

    c=min(a,b);
    b=max(a,b);
    a=c;
    if(a==1){
      if(b==2){
	cout<<3<<'\n';
      }
      else{
	cout<<2<<'\n';
      }
    }
    else{
      cout<<1<<'\n';
    }  
    
    return 0;
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    vector<int> a(n);
    int odd = 0, mul2 = 0, mul4 = 0;
    for(int in=0;in<n;in++) {
        cin >> a.at(in);
        if(a.at(in)%2==1) odd++;
        if(a.at(in)%4==0) mul4++;
    }
    mul2 = n - odd - mul4;

    if(odd<=mul4) cout << "Yes" << endl;
    else if(odd<=mul4+1&&mul2==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 640
object Main extends App {
    def gcd(a: Long, b: Long): Long = {
        if(b == 0) a
        else gcd(b, (a % b))
    } 

    def lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

    val input = io.StdIn.readLine.split(' ').map(_.toLong)
    val a = input(0)
    val b = input(1)

    println(lcm(a,b))
}

Measured memory_bytes: 27212
// Problem : A - Kyu in AtCoder
// Contest : AtCoder - M-SOLUTIONS Programming Contest 2020
// URL : https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;

#define ll       long long int
#define ull      unsigned long long int
#define pb       push_back
#define vi       vector<int>
#define vb       vector<bool>
#define vll      vector<long long int>
#define pi       pair<int,int>
#define all(x)   (x).begin(), (x).end()

const int MOD = 1000000007;




int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int t=1;
	//cin>>t;
	
	while(t--)
	{
		int n;
		cin>>n;
	
		
		if(n>=400 && n<=599)cout<<8<<"\n";
		else if(n>=600 && n<=799)cout<<7<<"\n";
		else if(n>=800 && n<=999)cout<<6<<"\n";
		else if(n>=1000 && n<=1199)cout<<5<<"\n";
		else if(n>=1200 && n<=1399)cout<<4<<"\n";
		else if(n>=1400 && n<=1599)cout<<3<<"\n";
		else if(n>=1600 && n<=1799)cout<<2<<"\n";
		else if(n>=1800 && n<=1999)cout<<1<<"\n";
		
		
	}
	
   	return 0;
}



Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main(void){

  int n;
  while( cin >> n, n ){

    int ans = 0 ;
    for( int i = 1 ; i < n ; i++ ){
      int sum = 0;
      for( int j = i ; j < n ; j++ ){
	sum += j;
	if( sum == n ){
	  ans++;
	  break;
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    while( 1 ){
        if( min(a,b) == 0 ) break;
        int m = max(a,b)%min(a,b);
        a = min(a,b);
        b = m;
    }
    cout << a << endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
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() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    REP(i, s.size() - 1) {
        if (s[i] == s[i + 1]) {
            std::cout << "Bad" << '\n';
            return 0;
        }
    }

    std::cout << "Good" << '\n';

    return 0;
}

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

using namespace std;
int gcd(int a, int b) {return b == 0? a: gcd(b, a%b);}
int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n; scanf("%d", &n);
    int a[n];
    for (int i=0; i<n; ++i) scanf("%d", a+i);
    int ans=0;
    for (int i=0; i<n; ++i) ans = gcd(a[i], ans);
    printf("%d", ans);
    return 0;
}


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

int main(){
    unsigned long long N, M, ura;
    cin >> N >> M;
    if (N == 1 && M == 1) ura = 1;
    else if (N == 1 || M == 1){
        ura = N*M - 2;
    }
    else{
        ura = N*M - (2*N + 2*M - 4);
    }
    cout << ura << endl;
}

Measured memory_bytes: 256
n, k, d = map(int, input().split())
if k >= abs(n // d):
    d1 = n % d
    d2 = n % d - d
    if k % 2 == (n // d) % 2:
        print(abs(d1))
    else:
        print(abs(d2))
else:
    print(abs(n) - k * d) 

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

int main(){
  int n;
  while(cin >> n,n){
    int sum = 0;
    for(int i=0; i<n/4; ++i){
      int tmp;
      cin >> tmp;
      sum += tmp;
    }
    cout << sum << endl;
  }
  return 0;
}



Measured memory_bytes: 3016
#include<bits/stdc++.h>
using namespace std;
int main(){
  int count,N;
  long long int a,b,D;
  cin>>N>>D;
  count=0;
  for(int i=0; i<N; i++){
  cin>>a>>b;
    if(a*a+b*b<=D*D){
    count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3648
A,B,X = gets.split.map(&:to_f)
if A*A*B/2 <= X
  puts Math.atan2((B-X/(A*A))*2, A) * 180 / Math::PI
else
  puts Math.atan2(B, 2*X/(A*B)) * 180 / Math::PI
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
 
using namespace std;
#define int long long
const int MAX = 2001;
const int MOD = 1000000007;
 
 


 
signed main(){
    int k,x;
    cin>>k>>x;
    for(int i= -1*k+1;i<k;i++){
        cout<<i+x<<' ';
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
string S;
map<string,ll> strMap;
bool Check(ll len){
    if(N<len)return false;
    string tmp=S.substr(0,len);
    strMap[tmp]=len-1;
    //cout<<tmp<<endl;
    for(ll i=len;i<N;i++){
        tmp+=S[i];
        tmp=tmp.substr(1,tmp.length()-1);
        //cout<<tmp<<endl;
        if(strMap.find(tmp)!=strMap.end()){
            if(strMap[tmp] < i-len+1)return true;
        }else{
            strMap[tmp]=i;
        }
    }
    return false;
}
ll binarySearch(function<bool(ll)> check, ll ok, ll ng) {
  while ((ok - ng > 1) || (ng - ok > 1)) {
    ll mid = (ok + ng) / 2;
    if (check(mid)) ok = mid;
    else ng = mid;
  }
  return ok;
}
int main(){
    cin>>N>>S;
    cout<<binarySearch(Check,0,N)<<endl;
    return 0;
}

Measured memory_bytes: 76928
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb(x)           push_back(x)
#define mkp(x,y)        make_pair(x,y)
#define L               length()
#define int             long long
#define bs              binary_search
#define mod             1e9+7
#define IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define mem0(a)         memset(a,0,sizeof(a))
#define mem1(a)         memset(a,-1,sizeof(a))
#define F               first
#define S               second
#define pii             pair<int,int>
#define vi              vector<int>
#define vs              size()
#define endl            '\n'
#define atoi            stoi
#define elasped_time    1.0 * clock() / CLOCKS_PER_SEC
#define si              set <int>
#define vpii            vector < pair <int,int> >
#define memf(a)         memset(a,false,sizeof(a))
#define memt(a)         memset(a,true,sizeof(a))
#define xxx             998244353
#define pi              3.141592653589
#define ninf            INT_MIN
#define inf             INT_MAX
#define sz(v)           ((int)(v).size())
#define rep(i,a,b)      for(int i=a;i<=b;i++)
int max(int a,int b){if(a>b){return a;}else{return b;}}
int min(int a,int b){if(a<b){return a;}else{return b;}}
int power(int b,int e)
{
    if(e==0)
    return 1;
    if(e%2)
    return ((b*power((b)*(b),(e-1)/2)));
    else
    return power((b)*(b),e/2);
}
int modpower(int b,int e,int q)
{
    int MOD=q;
    if(e==0)
    return 1;
    if(e%2)
    return ((b%MOD)*modpower((b%MOD)*(b%MOD),(e-1)/2,q))%MOD;
    else
    return modpower((b%MOD)*(b%MOD),e/2,q)%MOD;
}
void dpv(vi v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
void dpv(vpii v)
{
    for(int i=0;i<v.vs;i++)
    {
        cout<<v[i].F<<" "<<v[i].S<<endl;
    }
}
void dpv(set <int> v)
{
    for(auto i:v)
    {
        cout<<i<<" ";
    }
    cout<<endl;
}
//////////////////////**TREE MOVES STARTS**//////////////////////////////
///// **TREE MOVES ENDS**////////////////////////////

////*SOLUTION TO THE QUESTION STARTS HERE*///////
// C++ program for the above approach 

// Function to find the gcd of a & b 
// by Euclid's method 

// x and y store solution of 
// equation ax + by = g 
void oblivious()
{
    string s;
    cin>>s;
    if(s[s.L-1]=='s')
    {
        cout<<s<<"es"<<endl;
    }
    else
    {
        cout<<s<<"s"<<endl;
    }
}
signed main()
{
    IOS;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    int t=1;
    //cin>>t;
    //int z=t;
    while(t--)
    {
        //cout<<"Case #"<<(z-t)<<": ";
        oblivious();
    }
    return 0;
}
//Editorial
/*

    */

Measured memory_bytes: 3652
#include<stdio.h>
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if((0<a)&&(0<b)&&(a<10)&&(b<10)){
        printf("%d\n",a*b);
    }
    else{
        printf("-1\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
	 int n;
	 while(scanf("%d",&n)!=EOF)
	 
{
	 	 if(n<1200)
	 printf("ABC\n");
	 else
	 if(n<2800)
	 printf("ARC\n");
	 else
	 printf("AGC\n");
}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
        int a, b, c;
        cin >> a >> b >> c;

        if (a == b && b != c || b == c && c != a || c == a && a != b) {
                cout << "Yes" << endl;
        } else {
                cout << "No" << endl;
        }

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
long long calc(long long c) {
    long long x = 0;
    for (long long i = 1; i < c; i++) {
        x += i;
    }
    return x;
}
int main() {
    int n;
    cin >> n;
    vector<long long> a(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] += (i == 0 ? 0 : a[i-1]);
    }
    sort(a.begin(), a.end());

    long long prev = a[0];
    long long c = prev == 0 ? 1 : 0;
    long long t = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] == 0) {
            c++;
        }
        if (a[i] == prev) {
            t++;
        } else {
            if (t > 0) {
                c += calc(t + 1);
            }
            t = 0;
        }

        prev = a[i];
    }

    if (t > 0) {
        c += calc(t + 1);
    }
    
    cout << c << endl;
}


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

int main() {
    int n;
    cin>>n;
    int a[n+1];
    double sum = 0.0;
    int gg = 0, lcm = 1;
    for(int i=0;i<n;i++) {
        cin>>a[i];
        double xx = 1.0/a[i];
        sum+=xx;
    }
    sum = 1.0/sum;
    cout<<fixed<<setprecision(10)<<sum<<endl;
}


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

int main (int argc, char *argv[])
{
    string A,B;
    cin >> A >> B;
    int i = 0;
    
    if(A.size() > B.size()){
        cout << "GREATER" << endl;
    } else if (A.size() < B.size()){
        cout << "LESS" << endl;
    } else{
        for(int i=0; i<A.size() ; i++){
            if(A[i] > B[i]){
                cout << "GREATER" << endl;
                break;
            } else if(A[i] < B[i]){
                cout << "LESS" << endl;
                break;
            } else if(i == A.size()-1){
                cout << "EQUAL" << endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
if n % 2 == 0:
  print(-1)
else:
  a = 7
  b = 0
  for i in range(1000000):
    if a % n == 0:
      print(i+1)
      b = 1
      break
    a = (a%n) * 10 + 7
  if b == 0:
    print(-1)


Measured memory_bytes: 63256
#include <stdio.h>

int main()
{
    int A,B,coin = 0;

    scanf ("%d %d", &A , &B);
    for (int i = 0;i < 2;i++){
        if (A > B){
            coin += A;
            A--;
        }else{
            coin += B;
            B--;
        }
    }
    printf("%d",coin);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <climits>
#include <set>
using namespace std;
#define repn(i,s,n) for (int i=int(s); i < int(n); i++)
#define rep(i,n) repn(i,0,n)
#define repd(i,n) for (int i=int(n)-1; i >= 0; i--)

typedef vector<int> VI;
typedef vector<VI> VVI;


struct UnionFind {
  vector<int> p; 
  UnionFind(int n) : p(n, -1) { };
  void unite(int u, int v) {
    if ((u = find(u)) == (v = find(v))) return;
    if (p[u] > p[v]) swap(u, v);
    p[u] += p[v]; p[v] = u;
  }
  bool same(int u, int v) { return find(u) == find(v); }
  int find(int u) { return p[u] < 0 ? u : p[u] = find(p[u]); }
  int size(int u) { return -p[find(u)]; }
};



int n, m;
VI h;
const int MAX_H = 1000010;

struct Edge
{
  int a, b, cost;

  int getSinkTime() const {
    return min(h[a], h[b]);
  }

  bool operator<(const Edge& o) const {
    int sinkTime = getSinkTime();
    int oSinkTime = o.getSinkTime();
    if (sinkTime != oSinkTime) return sinkTime > oSinkTime;  // 最後に沈むのを先に
    return cost < o.cost;
  }
};

void solve() {
  vector<Edge> es;
  h = VI(n);
  VI numSunk(MAX_H);
  rep(i, n) {
    cin >> h[i];
    numSunk[h[i]]++;
  }
  rep(i, MAX_H-1) numSunk[i+1] += numSunk[i];
  rep(i, m) {
    Edge e;
    cin >> e.a >> e.b >> e.cost;
    e.a--;
    e.b--;
    es.push_back(e);
  }

  // get count
  sort(es.begin(), es.end());
  UnionFind uf(n);
  int count = 1;
  int last_unconnected_h = MAX_H-1;
  for (int ei = 0; ei < m; ) {
    int sinkTime = es[ei].getSinkTime();
    int numV = n - numSunk[sinkTime];
    if (numV > count) last_unconnected_h = sinkTime;
    while (ei < m && es[ei].getSinkTime() == sinkTime) {
      Edge& e = es[ei++];
      if (!uf.same(e.a, e.b)) {
        count++;
        uf.unite(e.a, e.b);
      }
    }
  }
  if (count < n) {
    cout << 0 << endl;
    return;
  }
  // cout << last_unconnected_h << endl;

  // 非連結になる時間に全部同時に沈むようにする
  rep(i, n) {
    h[i] = min(h[i], last_unconnected_h);
  }

  sort(es.begin(), es.end());
  uf = UnionFind(n);
  int min_cost = 0;

  rep(ei, es.size()) {
    Edge& e = es[ei];
    if (!uf.same(e.a, e.b)) {
      min_cost += e.cost;
      uf.unite(e.a, e.b);
    }
  }

  cout << min_cost << endl;
}

int main() {
  while (cin >> n >> m, n||m) solve();
  return 0;
}

Measured memory_bytes: 5756
# 何故か2問だけWAになる
from itertools import combinations


N, K = map(int, input().split())

# 最短距離が2であるような頂点のペアの数の最大値は (N-1)(N-2)/2 で、これはスター型のトポロジをつくった時
# 最小値は 0 で、これは完全グラフを構築した時
max_pairs = int((N - 1) * (N - 2) / 2)
if K > max_pairs:
    print(-1)
    exit(0)

# スター型のトポロジを作ると辺の数は N - 1 本
# 周辺の頂点に1ペアを作るごとに辺を1本足す必要がある
M = N - 1 + max_pairs - K
print(M)

# スターの中心には頂点Nを配置することにする
for i in range(1, N):
    print(i, N)
if K == max_pairs:
    exit(0)

# Kペアになるまで周辺の頂点をつないでいく
pairs = max_pairs
for a, b in combinations(range(1, N), 2):
    print(a, b)
    pairs -= 1
    if pairs == K:
        exit(0)


Measured memory_bytes: 42864
from collections import defaultdict
n=int(input())
MAX=10001
RMAX=102
d = defaultdict(int)
for i in range(1,RMAX):
    wkx = i * i
    if wkx > MAX:
        break
    for j in range(1,RMAX):
        wky = wkx + j * j  + i * j
        if wky > MAX :
            break
        for k in range(1,RMAX):
            wkz = wky + k * k + i * k  + j * k
            if wkz > MAX :
                break
            d[wkz] += 1
            
for i in range(n):
    k = i + 1
    print(d[k])


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

int N;

int flog(int i, vector<int> &dp, vector<int> &h){
    if(i==0){
        return 0;
    }
    
    if(dp[i] !=1e9){
        return dp[i];
    }

    if(i==1){
        dp[i] = flog(i-1 , dp ,h) + abs(h[i]-h[i-1]);
    }else{
        dp[i] = min(abs(h[i]-h[i-2])+flog(i-2, dp ,h), abs(h[i]-h[i-1]) + flog(i-1, dp ,h));    
    }
    //cout << "dp[" << i <<"]" << dp[i] << endl;

    return dp[i];
}


int main(){
    cin >> N;
    vector<int> dp(N,1e9);
    vector<int> h(N);
    
    rep(i,N){
        int x; cin >> x;
        h[i] = x;
    }

    int ans = flog(N-1, dp ,h);
    cout << ans << endl;
}


Measured memory_bytes: 11816
N=int(input())
XL=[list(map(int,input().split())) for _ in range(N)]
s,e=0,0
L=[]
for xl in XL:
    x,l=xl[0],xl[1]
    s,e=x-l,x+l
    L.append([e,s])
L.sort()
end=L[0][0]
len_L=len(L)
ans=1
for i in range(1,len_L):
    if end<=L[i][-1]:
        ans+=1
        end=L[i][0]
print(ans)

Measured memory_bytes: 41440
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};

ll s(ll x) {
	ll ans = 0;
	while (x) {
		ans += x % 10;
		x /= 10;
	}
	return ans;
}

ld f(ll x) {
	return (ld)x / s(x);
}

signed main() {
	IOS();
	ll k;
	cin >> k;
	vector<pair<ll, ld>> tmp;
	vector<ll> ans;
	for (int i = 1; i <= 9; i++) {
		tmp.emplace_back(i, 1);
	}
	ll d10 = 10;
	ll n   = 19;
	while (n < 1e15) {
		//cout << n << " " << s(n) << endl;
		tmp.emplace_back(n, f(n));
		n += d10;
		if ((ld)n / (n + d10) > (ld)s(n) / (s(n) + 1)) {
			d10 *= 10;
			n = ((n + 1) / d10 + 1) * d10 - 1;
		}
	}
	ll m = tmp.size();
	//return 0;
	for (int i = 0; i < m; i++) {
		bool ok = true;
		for (int j = i; j < m; j++) {
			if (tmp[i].second > tmp[j].second) ok = false;
		}
		if (ok) ans.push_back(tmp[i].first);
	}
	//dump(ans.size());
	for (int i = 0; i < k; i++) {
		dump(ans[i]);
	}
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (int i = 1; ; i++) {
            int x = sc.nextInt();
            if (x == 0) {
                break;
            }
            System.out.printf("Case %d: %d\n", i, x);
        }
        sc.close();
    }
}


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

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

    for (size_t i = 0; i < 9; i++)
    {
        for (size_t j = 0; j < 9; j++)
        {
            if((i+1) * (j+1) == N){
                cout << "Yes" << endl;
                return 0;
            }
        }
        
    }

    cout << "No" << endl;
    
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  lli A, B;
  while (cin >> n >> A >> B) {
    int x[n];
    for (int i = 0; i < n; ++i) {
      cin >> x[i];
    }
    lli sum = 0;
    for (int i = 0; i + 1 < n; ++i) {
      // cout << ">> " << min((x[i + 1] - x[i]) * A, B) << endl;
      sum += min((x[i + 1] - x[i]) * A, B);
    }
    cout << sum << endl;
  }
  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define INF 1000000007
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2)*pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int jo(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= 2;
	}
	return ans;
}
signed main() {
	string a, b, c;
	cin >>a>> b >> c;
	cout << a[0] << b[0] << c[0] << endl;
}

Measured memory_bytes: 256