akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<cmath>
#include<queue>

using namespace std;


int main(){
  //エラトステネスの篩を実装する
  int n[100001]={0};//i番目が整数iに対応(1~100000)
  int n2[100001]={0};//i番目が整数iに対応(1~100000)
  vector<int> pr;
  //0になったところは素数
  for(int i=2;i<=1000;i++){
    if(n[i]==0){
      for(int j=1;j<=floor(100000/i);j++){
        if(j!=1){
          n[j*i]=1;
        }
      }
    }
  }
  int c=0;
  for(int i=3;i<100000;i++){
    if(i%2!=0 and n[i]==0 and n[int((i+1)/2)]==0){c+=1;}
    n2[i]=c;
  }
  //cout << n2[2017] << endl;
  /*
  for(int i=0;i<100;i++){
    cout << n[i] << " ";
  }
  for(int i=0;i<100;i++){
    cout << n2[i] << " ";
  }
  */
  int q;cin >> q;
  for(int i=0;i<q;i++){
    int l,r;cin >>l >>r;
    cout << n2[r]-n2[l-1] << endl;
  }
}


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

using namespace std;
int main()
{
  int n;
  cin>>n;
  unordered_map<string,int> freq;
  while(n--) {
    string str;
    cin>>str;
    freq[str]++;
  }
  cout<<"AC x "<<freq["AC"]<<"\nWA x "<<freq["WA"]<<"\nTLE x "<<freq["TLE"]<<"\nRE x "<<freq["RE"]<<'\n';
  return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M = 1e5+7;
list<int> adj[M];
bool visited[M] = {};
int dp[M];

void dfs(int v, int p) {
    visited[v] = true;
    dp[v] = 0;
    for(int u : adj[v]) {
        if(u != p) {
            if(!visited[u])
                dfs(u, v);
            dp[v] = max(dp[v], 1+dp[u]);
        }
    }
}

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; ++i) {
        int u,v;
        cin >> u >> v;
        adj[u].push_back(v);
    }
    for(int i = 1; i<= n; ++i) {
        if(!visited[i]) {
            dfs(i, i);
       }
    }
    cout << *max_element(dp+1, dp+n+1);
    return 0;
}



Measured memory_bytes: 8192
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

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

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  string s; cin >> s; ll n = s.size();
  ll afirst = 0; ll zlast = n-1;
  
  rep(i,n){
    if(s[i] == 'A'){
      afirst = i;
      break;
    }
  }
  
  for(ll i=n-1; i >= 0; i--){
    if(s[i] == 'Z'){
      zlast = i;
      break;
    }
  }
  
  cout << zlast - afirst + 1 << endl;
  
  
}

Measured memory_bytes: 3728
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    s=chomp(readline())
    cnt=[0 for i in 'a':'z']
    for i in s
        cnt[i-'a'+1]+=1
    end
    if sum(cnt)<26
        for i in 'a':'z'
            if cnt[i-'a'+1]==0
                println(s*string(i))
                break
            end
        end
    elseif s==join('z':-1:'a')
        println(-1)
    else
        for i in length(s)-1:-1:1
            tmp='z'+1
            for j in i+1:length(s)
                if s[j]>s[i]
                    tmp=min(s[j],tmp)
                end
            end
            if s[i]<tmp && tmp<'z'+1
                println(s[1:i-1]*string(tmp))
                break
            end
        end
    end
end
main()

Measured memory_bytes: 169864
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")

MOD = 998244353  # type: int


class Combination(object):

    def __init__(self, N, mod=MOD):
        fac, finv, inv = [0]*(N+1), [0]*(N+1), [0]*(N+1)
        fac[:2] = 1, 1
        finv[:2] = 1, 1
        inv[1] = 1
        for i in range(2, N+1):
            fac[i] = fac[i-1]*i % mod
            inv[i] = -inv[mod % i]*(mod//i) % mod
            finv[i] = finv[i-1]*inv[i] % mod
        self.N = N
        self.MOD = mod
        self.fac = fac
        self.finv = finv
        self.inv = inv

    def __call__(self, n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        fac = self.fac
        finv = self.finv
        mod = self.MOD
        return fac[n] * (finv[k]*finv[n-k] % mod) % mod


def div(a, b):
    return (a * pow(b, MOD-2, MOD)) % MOD


def solve(N: int, M: int, K: int):

    cmb = Combination(N)
    tot = 0
    for k in range(N-K, N+1):
        buf = cmb(N-1, k-1)
        buf *= (M*pow(M-1, k-1, MOD)) % MOD
        buf %= MOD
        # print(N, k, cmb(N, k), buf)
        tot += buf
        tot %= MOD
    print(tot)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, M, K)


if __name__ == '__main__':
    main()


Measured memory_bytes: 32628
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3fll
#define ll long long
#define db double
#define eps 1e-8
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define pi acos(-1.0)
#define lowbit(x) x &(-x)
const ll maxn = 1e5 + 10;
const ll mod = 1e9;

signed main()
{
	string s;
	cin >> s;
	map<char, int> c;
	for(auto i:s){
		c[i]++;
	}
	if(c['A'] && c['B']){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
}


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

using namespace std;

int A, B, X;

int solve(int total, int volume, bool flag) {
	int cnt;

	cnt = total / volume;
	if (flag && total % volume != 0) {
		++cnt;
	}
	
	return cnt;
}

int main() {
	int cntA, cntB;

	cin >> A >> B >> X;
	if (A < B) {
		cntA = solve(X, 1000, true);
		cout << A*cntA << endl;
		return 0;
	}
	if (A > 2*B) {
		cntB = solve(X, 500, true);
		cout << B*cntB << endl;
		return 0;
	}
	cntA = solve(X, 1000, false);
	X %= 1000;
	cntB = 0;
	if (X > 0 && X <= 500) {
		cntB = 1;
	}
	else if (X > 500) {
		++cntA;
	}
	//cout << "X=" << X << ends << cntA << ends << cntB << endl;
	cout << A*cntA + B*cntB << endl;

	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
typedef long long ll;


template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

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

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    UnionFind<int> uf(n);

    vector<int> p(n); 
    rep(i,n){
        int pin;
        cin >> pin; pin--; p[i] = pin;
    }

    rep(i,m){
        int a, b;
        cin >> a >> b; a--; b--;
        uf.merge(a,b,0);
    }

    int ans = 0;

    rep(i,n){
        if(uf.issame(i,p[i])) ans++;
    }

    dunk(ans);
}
    

Measured memory_bytes: 1792
package main

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

var sc *bufio.Scanner

func main() {
	ALDS1_1_D(os.Stdin, os.Stdout)
}

// nextLineInt 次の標準入力を数値型に変換して読み込む
func nextLineFloat64() int {
	sc.Scan()
	line := sc.Text()
	val, _ := strconv.Atoi(line)
	return val
}

func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func minInt(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// ALDS1_1_D の解答
func ALDS1_1_D(stdin io.Reader, stdout io.Writer) {
	sc = bufio.NewScanner(stdin)
	row := nextLineFloat64()
	maxPrice := math.MinInt32
	minPrice := math.MaxInt32

	for i := 0; i < row; i++ {
		price := nextLineFloat64()
		maxPrice = maxInt(maxPrice, price-minPrice)
		minPrice = minInt(minPrice, price)
	}
	fmt.Fprintln(stdout, maxPrice)
}



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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);
const int N = 1e5 + 5;

int fact[N], invfact[N];

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int modinv(int k)
{
	return pow(k, MOD-2, MOD);
}

void precompute()
{
	fact[0]=fact[1]=1;
	for(int i=2;i<N;i++)
	{
		fact[i]=fact[i-1]*i;
		fact[i]%=MOD;
	}
	invfact[N-1]=modinv(fact[N-1]);
	for(int i=N-2;i>=0;i--)
	{
		invfact[i]=invfact[i+1]*(i+1);
		invfact[i]%=MOD;
	}
}

int nCr(int x, int y)
{
	if(y>x)
		return 0;
	int num=fact[x];
	num*=invfact[y];
	num%=MOD;
	num*=invfact[x-y];
	num%=MOD;
	return num;
}
int32_t main(){
	fast;
	precompute();
	int n,k;
	cin >> n >> k;
	
	int a[n];
	for(int i=0 ; i<n ; i++)
	{
		cin >> a[i];
	}
	
	sort(a , a+n);
	
	int ans = 0;
	int ans1 = 0;
	for(int i=0 ; i<n ; i++)
	{
		int big = max(0LL , n - 1 - i);
		int small = max(0ll , i);
		
		ans =(ans + a[i]*nCr(big , k-1))%MOD;
		ans1 =(ans1 + a[i]*nCr(small , k-1))%MOD;
	}
	
	ans = (ans1 - ans + n*MOD)%MOD;
	cout << ans;
}



Measured memory_bytes: 2560
N = int(input())
T = list(map(int, input().split(" ")))

M = int(input())
X = []
for _ in range(M):
    x_list = list(map(int, input().split(" ")))
    X.append(x_list)

T_sum = sum(T)
for (i, x) in X:
    i -= 1
    diff = T[i] - x
    print(T_sum - diff)


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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

ll N, P;

int main(){

    cin >> N >> P;
    map<ll, int> m;
    for(ll i = 2; i *i <= P; i++){
        while(P % i == 0){
            m[i]++;
            P /= i;
        }
    }
    if(P != 1) m[P]++;

    ll ans = 1;
    for(pair<ll, int> p : m){
        for(ll i = 0; i < (p.second / N); i++){
            ans *= p.first;
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 100000000000000000000
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define out(s) cout<<s
#define outs(s,a) cout<<s<<a
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
void solve(){
	ll a,b,c;
	in3(a,b,c);
	set<ll>ss;
	ss.insert(a);
	ss.insert(b);
	ss.insert(c);
	if(ss.size()==2){
		cout<<"Yes\n";
	}else{
		cout<<"No\n";
	}
}	
int main(){
	clock_t t1=clock();
	gear_change;
	ll test=1;
	// in(test);
	while(test--){
		solve();
	}
	clock_t t2=clock();
	cerr<<"Time elapsed:- "<<(double)(t2-t1)/CLOCKS_PER_SEC<<'\n';
}	


Measured memory_bytes: 256
#include <cstdio>
#include <map>
#define maxn 100010
using namespace std;
int n,ans;
map<int, int> m;
int main() {
	scanf("%d",&n);
	for (int i=0;i<n;i++) {
		int ai;
		scanf("%d",&ai);
		m[ai]++;
	}
	ans = m.size();
	if (ans%2==0)
		ans--;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
inline bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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);
	vector<vector<int>> a(3,vector<int>(3));
	rep(i,3){
		rep(j,3) cin >> a[i][j];
	}
	vector<vector<bool>> c(3,vector<bool>(3));
	int n;cin >> n;
	rep(i,n){
		int b;cin >> b;
		rep(j,3){
			rep(k,3){
				if(a[j][k] == b) c[j][k] = true;
			}
		}
	}
	bool ok = false;
	rep(i,3){
		bool flg = true;
		rep(j,3){
			if(!c[i][j]) flg = false;
		}
		if(flg){
			ok = true;
			break;
		}
		flg = true;
		rep(j,3){
			if(!c[j][i]) flg = false;
		}
		if(flg){
			ok = true;
			break;
		}
	}
	if((c[0][0] && c[1][1] && c[2][2]) || (c[2][0] && c[1][1] && c[0][2])) ok = true;
	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;


int main(){
    int n,m;
    cin>>n>>m;
    int s[5]={};
    int c[5]={};
    rep(i,m){
        cin>>s[i]>>c[i];
    }
    if(n==1){
        rep(i,10){
            int cnt=0;
            rep(j,m){
                if(s[j]==1&&c[j]==i)cnt++;
            }
            if(cnt==m){
                cout<<i<<endl;
                return 0;
            }
        }
    }else if(n==2){
        for(int i=10;i<100;i++){
            int cnt=0;
            rep(j,m){
                if(s[j]==1&&c[j]==(i/10))cnt++;
                if(s[j]==2&&c[j]==(i%10))cnt++;
            }
            if(cnt==m){
                cout<<i<<endl;
                return 0;
            }
        }
    }else{
        for(int i=100;i<1000;i++){
            int cnt=0;
            rep(j,m){
                if(s[j]==1&&c[j]==(i/100))cnt++;
                if(s[j]==2&&c[j]==((i/10)%10))cnt++;
                if(s[j]==3&&c[j]==(i%10))cnt++;
            }
            if(cnt==m){
                cout<<i<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int r, d, x;
	cin >> r >> d >> x;
	vector<int> g(10);

	for (int i = 0; i < 10; i++){
		g.at(i) = r*x - d;
		x = r*x - d;
	}

	for (int i = 0; i < 10; i++){
		cout << g.at(i) << endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
n=int(input())
h=list(map(int,input().split()))
li=[0]*n
li[1]=abs(h[1]-h[0])
for i in range(2,n):
    li[i]=min(li[i-1]+abs(h[i]-h[i-1]),li[i-2]+abs(h[i]-h[i-2]))
##print(li)
print(li[n-1])


Measured memory_bytes: 13980
M = 10**9 + 7
a = [1] + [0] * 12
b = 1, 10, 9, 12, 3, 4
for k, c in enumerate(reversed(input())):
    p = b[k % 6]
    r = range(0, p * 10, p) if c == '?' else (p * int(c),)
    a = [sum(a[(i - j) % 13] for j in r) % M for i in range(13)]
print(a[5])


Measured memory_bytes: 46316
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define RFOR(i, begin, end) for(int i=(end)-1, i##_begin_=(begin);i>=i##_begin_;i--)
#define rep(i, N) FOR(i, 0, N)
#define rrep(i, N) RFOR(i, 0, N)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define mp make_pair
using namespace std;
using ll = long long int;
using V = vector<ll>;
using P = pair<ll, ll>;
using VP = vector<P>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
constexpr int inf = 1e9;
constexpr ll  lnf = 1LL << 60;
constexpr int mod = 1e9+7;
template<class T> inline bool chmax(T& a, const T& b) { if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if(a>b) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}

VP fact(ll n) {
    VP ret;
    for(ll i=2; i*i <= n; ++i) {
        if(n%i) continue;
        ret.eb(i, 0);
        while(n%i == 0) {
            n /= i;
            ret.back().second++;
        }
    }
    if(n != 1) ret.eb(n, 1);
    return ret;
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    auto f = fact(g);
    ll ret = f.size() + 1;
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
string a,b;
cin>>a>>b;
if(a.size()>b.size()){
    cout<<"GREATER";
    return 0;}
    else if(b.size()>a.size()){
        cout<<"LESS";return 0;
    }
for(int i=0;i<a.size();i++){
    if(a[i]>b[i]){
        cout<<"GREATER";
        return 0;
        }
    else if (a[i]<b[i]){
        cout<<"LESS";return 0;}
}
cout<<"EQUAL";
return 0;
}


Measured memory_bytes: 256
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     makep        make_pair
#define     maket        make_tuple
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n,m;
    cin>>n>>m;

    int v[n][3];
    for(int i=0;i<n;++i)
    {
        for(int j=0;j<3;++j)
            cin>>v[i][j];
    }

    vector<int> vec;
    int ans=0;
    for(int k=0;k<8;++k)
    {
        vec.clear();

        for(int i=0;i<n;++i)
        {
            int sum=0;
            for(int j=0;j<3;++j)
            {
                if(k&(1<<j))
                    sum+=v[i][j];
                else
                    sum-=v[i][j];
            }

            vec.pb(sum);
        }

        sort(all(vec));
        reverse(all(vec));

        //show(vec);

        ans=max(ans,accumulate(vec.begin(),vec.begin()+m,0ll));
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 256
my $N = <STDIN>;

my $sum =0;
my %del;
for(my $i=$N;$i>0;$i--){
 $count = 0;
 for(my $j=1;$j<=$N;$j++){
    if( ($j%$i == 0) ){ $count++;}
 }
 $del{$i} = ($count*$count*$count);
 #print "i$i count$count del$del{$i}  \n";
}
for(my $i=$N;$i>0;$i--){
 #print "i$i  del$del{$i} \n";
 for(my $j=1;$j<$i;$j++){
    if( ($i%$j == 0) ){ $del{$j}= $del{$j} - $del{$i};}
 }
 $sum = $sum + $i*$del{$i};
 #print "i$i del$del{$i} $sum\n";
}
print "$sum";
exit;

Measured memory_bytes: 4688
#include<bits/stdc++.h>
#define XX first
#define YY second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  int N;
  cin >> N;
  string s;
  map<string, int> mp;
  rep(i, N) {
    cin >> s;
    mp[s]++;
  }
  int mx = 0;
  for (auto &itr : mp) {
    MX(mx, itr.YY);
  }

  for (auto &itr : mp) {
    if (itr.YY == mx) cout << itr.XX << endl;
  }
}


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

int main() {
    string s;
    cin >> s;
    if(s == "SUN") cout << 7 << endl;
    if(s == "MON") cout << 6 << endl;
    if(s == "TUE") cout << 5 << endl;
    if(s == "WED") cout << 4 << endl;
    if(s == "THU") cout << 3 << endl;
    if(s == "FRI") cout << 2 << endl;
    if(s == "SAT") cout << 1 << endl;
}

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

const int MOD = (int)1e9+7;

int main(){
	int N;
	cin >> N;
	
	vector<vector<vector<vector<vector<int>>>>> ACGT(N+1,vector<vector<vector<vector<int>>>>(4,vector<vector<vector<int>>>(4,vector<vector<int>>(4,vector<int>(4,0)))));
	ACGT.at(0).at(3).at(3).at(3).at(3)=1;
	for(int i=0;i<N;i++){
		for(int c1=0;c1<4;c1++){
			for(int c2=0;c2<4;c2++){
				for(int c3=0;c3<4;c3++){
					for(int c4=0;c4<4;c4++){
						if(ACGT.at(i).at(c1).at(c2).at(c3).at(c4)==0)	continue;
						if(c2==0 && c3==2 && c4==1)	continue;
						if(c2==0 && c3==1 && c4==2)	continue;
						if(c2==2 && c3==0 && c4==1)	continue;
						if(c1==0 && c2==2 && c4==1)	continue;
						if(c1==0 && c3==2 && c4==1)	continue;
						
						for(int c5=0;c5<4;c5++){
							ACGT.at(i+1).at(c2).at(c3).at(c4).at(c5)+=ACGT.at(i).at(c1).at(c2).at(c3).at(c4);
							ACGT.at(i+1).at(c2).at(c3).at(c4).at(c5)%=MOD;
						}
					}
				}
			}
		}
	}
	
	long long ans=0;
	for(int c1=0;c1<4;c1++){
		for(int c2=0;c2<4;c2++){
			for(int c3=0;c3<4;c3++){
				for(int c4=0;c4<4;c4++){
					if(c2==0 && c3==2 && c4==1)	continue;
					if(c2==0 && c3==1 && c4==2)	continue;
					if(c2==2 && c3==0 && c4==1)	continue;
					if(c1==0 && c2==2 && c4==1)	continue;
					if(c1==0 && c3==2 && c4==1)	continue;
					ans+=ACGT.at(N).at(c1).at(c2).at(c3).at(c4);
					ans%=MOD;
				}
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
 
//Write From this Line

//const ll mod = 1e9+7;
//const ll mod = 998244353;
int main()
{
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n)cin>>a[i];

	bool sagaru = false;

	ll m = a[0];
	ll M = a[0];
	ll ans = 1000;
	ll kabu = 0;
	rep(i,n){
		chmin(m,a[i]);
		chmax(M,a[i]);
		if(a[i] > a[i+1]){
			sagaru = true;
			ll kau = ans / m;
			ans -= kau * m;
			ans += kau * M;
			if(i < n-1){
				m = a[i+1];
				M = a[i+1];
			} else {
				m = a[i];
				M = a[i];
			}
		}
	}
	ll kau = ans / m;
	ans -= kau * m;
	ans += kau * M;
	cout << ans << endl;
}


Measured memory_bytes: 3524
// solution is at the bottom

import kotlin.math.*
import kotlin.system.exitProcess

@JvmField val INPUT = System.`in`
@JvmField val OUTPUT = System.out

const val _BUFFER_SIZE = 1 shl 16
@JvmField val _buffer = ByteArray(_BUFFER_SIZE)
@JvmField var _bufferPt = 0
@JvmField var _bytesRead = 0

tailrec fun readChar(): Char {
    if(_bufferPt == _bytesRead) {
        _bufferPt = 0
        _bytesRead = INPUT.read(_buffer, 0, _BUFFER_SIZE)
    }
    return if(_bytesRead < 0) Char.MIN_VALUE
    else {
        val c = _buffer[_bufferPt++].toChar()
        if (c == '\r') readChar()
        else c
    }
}

fun readLine(): String? {
    var c = readChar()
    return if(c == Char.MIN_VALUE) null
    else buildString {
        while(true) {
            when(c) {
                '\n', Char.MIN_VALUE -> return@buildString
                else -> {
                    append(c)
                    c = readChar()
                }
            }
        }
    }
}
fun readLn() = readLine()!!

fun read() = buildString {
    var c = readChar()
    while(c <= ' ') {
        if(c == Char.MIN_VALUE) return@buildString
        c = readChar()
    }
    do {
        append(c)
        c = readChar()
    } while(c > ' ')
}
fun readInt() = read().toInt()
fun readDouble() = read().toDouble()
fun readLong() = read().toLong()
fun readStrings(n: Int) = List(n) { read() }
fun readLines(n: Int) = List(n) { readLn() }
fun readInts(n: Int) = List(n) { read().toInt() }
fun readIntArray(n: Int) = IntArray(n) { read().toInt() }
fun readDoubles(n: Int) = List(n) { read().toDouble() }
fun readDoubleArray(n: Int) = DoubleArray(n) { read().toDouble() }
fun readLongs(n: Int) = List(n) { read().toLong() }
fun readLongArray(n: Int) = LongArray(n) { read().toLong() }

fun main() {
    val (n, m) = readIntArray(2)
    val par = IntArray(n) {it}
    val size = IntArray(n) {1}

    fun get(x: Int): Int {
        if (x == par[x]) {
            return x
        }

        val p = get(par[x])
        par[x] = p
        return p
    }

    fun union(xx: Int, yy: Int) {
        var x = get(xx)
        var y = get(yy)

        if (x != y) {
            if (size[x] > size[y]) {
                x = y.also { y = x }
            }

            par[x] = y
            size[y] += size[x]
        }
    }


    for (i in 1..m) {
        var (a, b) = readIntArray(2)

        a--
        b--

        union(a, b)
    }

    println(size.max()!!)
}


Measured memory_bytes: 57172
#include <iostream>

using namespace std;
int A[100000];
int Partition(int A[],int p,int r){
    int x = A[r];
    int i=p-1;
    for(int j=p;j<r;j++){
        if(A[j]<=x){
            i++;
            int temp = A[i];
            A[i] = A[j];
            A[j] = temp;
        }
    }
    int temp = A[i+1];
    A[i+1] = x;
    A[r] = temp;
    return i+1;
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
    int i = Partition(A,0,n-1);
    for(int j=0;j<n;j++){
        if(j>0) cout<<" ";
        if(j==i) cout<<"[";
        cout<<A[j];
        if(j==i) cout<<"]";
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 3464
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF = 100000000;
ll i,j,k;
ll mod=1000000007;

int main(){
    ll n,a,b,c,d,e;cin>>n;
    
    vector<ll> can_take(5,0);//輸送可能な人数

    for(i=0;i<5;i++){cin>>can_take[i];}
    
    sort(can_take.begin(),can_take.end());
    ll min=can_take[0];//この人数は最短(5日)で行ける.残りの人は詰まる
    ll ans=5;//答え
    
    if(min<n && min!=1){ans+=(n/min);}//最短で行けないとき
    if(min==1){ans+=(n-1);}

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

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define ll long long
using namespace std;
const int N = 21, mod = 1e9 + 7;
bool a[N][N];
short n;
ll dp[1 << N];
pair < int, int > mask[1 << N];
int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < (1 << n); i++){
        mask[i].first = __builtin_popcount(i);
        mask[i].second = i;
    }
    sort(mask, mask + (1 << n));
    dp[0] = 1;
    for(int i = 0; i < (1 << n); i++){
        int cur_mask = mask[i].second;
        int man = mask[i].first;
        for(int woman = 0; woman < n; woman++){
            if(((cur_mask >> woman) & 1) || !a[man][woman])continue;
            int next_mask = cur_mask | (1 << woman);
            dp[next_mask] += dp[cur_mask]; 
            if(dp[next_mask] >= mod)dp[next_mask] -= mod; 
        }
    }
    cout << dp[(1 << n) - 1] << endl;
}    

Measured memory_bytes: 33024
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x/GCD(x,y)*y;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
ll r,D;
vector<ll> x(11);
cin>>r>>D>>x[0];
for(ll i=1;i<=10;++i){x[i]=r*x[i-1]-D;
cout<<x[i]<<endl;}
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

    int X;
    X = (int)(1.0 * N / 1.08);
    if ((int)(X * 1.08) == N ) {
        cout << X << "\n";
    } else if ((int)((X+1) * 1.08) == N) {
        cout << X + 1 << "\n";
    } else {
        cout << ":(" << "\n";
    }
}

Measured memory_bytes: 256
#include<iostream>



using namespace std;

int f(int x){
    return x*x;
}

int main(){

    int d;
    while (cin >> d)
    {
        int result = 0;
        for (int i = 0; i < 600; i = i + d){
            result += d* f(i);
        }
        cout << result << endl;
    }
    return 0;
}

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

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

  int digit_sum = 0;
  string str_num = to_string(n);
  for (char c : str_num) {
    digit_sum += c - '0';
  }
  cout << (n % digit_sum == 0 ? "Yes" : "No") << endl;
}


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
 
  if (N * A >= B) {
    cout << B << endl;
  }
  
  else if (N * A < B) {
    cout << N * A << endl;
  }
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a[n];
  int count=0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    if(i%2==0&&a[i]%2!=0)
    {
      count++;
    }
  }
  cout<<count;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;



int main() {
    int n;cin>>n;
    int a[n];
    bool f = true;
    rep(i,n)cin>>a[i];
    rep(i,n) {
        if(a[i]%2 == 0){
            if(a[i]%3 != 0 && a[i]%5 != 0) {
                f = false;
            }
        }
    }
    if(f)cout << "APPROVED";
    else cout << "DENIED";
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] road = new int[n];
		for (int i = 0; i < 2 * m; i++){
			int a = sc.nextInt();
			road[a-1] ++;
		}
		
		for (int i = 0; i < n; i++){
			System.out.println(road[i]);
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
#define dump(a) cout << (a) << endl;
typedef long long ll;

int main() {
    int N, C;
    cin >> N >> C;
    vector<int> s(N), t(N), c(N);
    vector<int> time(200001, 0), channel(200001, 0);
    for( int i = 0; i < N; i++ ) cin >> s[i] >> t[i] >> c[i];
    for( int i = 1; i <= 30; i++ ) {
        for( int j = 0; j <= 200000; j++ ) channel[j] = 0;
        for( int j = 0; j < N; j++ ) {
            if( c[j] == i ) {
                channel[s[j]*2-1]++;
                channel[t[j]*2]--;
            }
        }
        for( int j = 0; j < 200000; j++ ) channel[j+1] += channel[j];
        for( int j = 0; j <= 200000; j++ ) if( channel[j] > 0 ) time[j]++;
    }
    // for( int i = 0; i < 200000; i++ ) time[i+1] += time[i];
    int ma = -1;
    for( int i = 0; i <= 200000; i++ ) ma = max( ma, time[i] );
    dump( ma );
    return 0;  
}

Measured memory_bytes: 2944
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#include <string>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;

#define rep(i, n) for(int i = 0; i < n ; i++ )
#define For(i, a, b) for(int i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

int main(void){
    string b;

    cin >> b;

    if (b == "A"){
        cout << "T" << endl;
    }else if (b == "T"){
        cout << "A" << endl;
    }else if (b == "C"){
        cout << "G" << endl;
    }else if (b == "G"){
        cout << "C" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10


def main():
    X, t = map(int, input().split())
    print(max(0, X - t))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
const int M = 400005 ;
using namespace std ;
inline int read(){
    char c = getchar() ; int x = 0, w =1 ;
    while(c>'9'||c<'0'){ if(c=='-') w = -1; c = getchar() ;}
    while(c>='0'&&c<='9'){ x=x*10+c-'0'; c=getchar() ;}
    return x*w ;
}
int n;
int p[M],f[M];
int Ans ;
int main(){
	n = read();
	for(int i=1;i<=n;i++)
	  p[i] = read();
	for(int i=1;i<=n;i++)
		f[p[i]]=f[p[i]-1]+1;
	for(int i=1;i<=n;i++)
	  Ans = max(Ans,f[i]) ;
	printf("%d\n",n-Ans);
	return 0;
}

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

int main(){
  int n,m,x;
  cin >> n >> m >> x;
  int a[m]={};
  for(int i=0;i<m;i++){
      cin >> a[i];
  }
  int count = 0;
  for(int i=0;i<m;i++){
      if(a[i]<x) count++;
      else break;
  }
  cout << min(count,m-count) << endl;
}


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

int main() {
  int A,B;
  cin >> A >> B;
  if (A <= 5) {
    cout << 0 << endl;
  } else if (6 <= A && A <= 12) {
    cout << B/2 << endl;
  } else {
    cout << B << endl;
  }
}

Measured memory_bytes: 256
T = int(input())
for i in range(T):
    n = [int(i) for i in input().split()]
    c = [i for i in input().split()]
    value = [[],[],[]]
    for j in range(9):
        if c[j] == "R":
            value[0].append(n[j])
        elif c[j] == "G":
            value[1].append(n[j])
        else:
            value[2].append(n[j])
    ans = 1
    for i in range(3):
        l = len(value[i])
        if l%3 != 0:#RGBの長さが3の倍数でないと、正解になる可能性はない
            ans = 0
        else:
            value[i].sort()
            s = l//3
            j=0
            while ans>0 and s>0 and j<len(value[i])-2:
                if value[i][j] == value[i][j+1]:#隣り合う数字が一致している場合
                    if value[i][j+1] == value[i][j+2]:#3連続で同じ数字が並んでいる場合
                        for k in range(3):
                            value[i].pop(j)#値の削除
                        s-=1
                    elif value[i][j+1]+1==value[i][j+2]:#2つめの数字と3つ目の数字が連番　ex)112,223,334,
                        k=j+3
                        while k<len(value[i]) and value[i][k]==value[i][j+2]:#3つめと4つめの値が同じ
                            k+=1
                        if k>=len(value[i]) or value[i][k]!=value[i][j+2]+1:#4つ目と5つ目の数字が連番でない場合 ex)11225,22335　不正解
                            ans=0
                        else:
                            #値削除
                            value[i].pop(k)
                            value[i].pop(j+2)
                            value[i].pop(j)
                        s-=1
                    else:#3つ目の数字が全然違うやつ
                        ans=0

                elif value[i][j]+1==value[i][j+1]:#隣り合う数字が連番の場合
                    k=j+2
                    while k<len(value[i]) and value[i][k]==value[i][j+1]:
                        k+=1
                    if k>=len(value[i]) or value[i][k]!=value[i][j+1]+1:#3つめの数字が連番でない場合　不正解
                        ans=0
                    else:
                        #値削除
                        value[i].pop(k)
                        value[i].pop(j+1)
                        value[i].pop(j)
                        s-=1
                else:#隣り合う数字が連番でもなく、同値でもない場合　不正解
                    ans=0
        i+=1
    print(ans)


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

using namespace std;

#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define MP(x)	make_pair(x);

#define debug(x)        cerr << #x << '=' << x << endl;
#define debug2(x, y)    cerr << #x << '=' << x << ' ' << #y << '=' << y << endl;
#define debugn(_a)      cerr << #_a << ": "; for (const auto _x: _a) cerr << _x << ' '; cerr << endl;
#define debugm(a)       cerr << #a << ":\n"; \
                        for (auto v: a) { for(const auto x: v) cerr << x << ' '; cerr << "\n"; }
 
#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vii;
typedef vector<string> vs;
typedef unsigned long long ull;
 
const int INF  = LONG_LONG_MAX;
const int NINF = LONG_LONG_MIN;
const int mmod = 1000000007;

int32_t main()
{
	FAST_IO;
	
	string s, t;
	cin >> s >> t;
	cout << t << s << endl;
}
// g++ -Wall -Wextra -Wshadow -fsanitize=undefined 


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const int MOD = 1000000007;

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

  ll k;
  cin >> k;

  ll a = k/2, b = k-a;
  cout << a * b << endl;

  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
x_s=list(map(int,input().split()))
if n >= m:
    print(0)
    exit()
x_s.sort()
sa=[]

for i in range(m-1):
    sa.append(x_s[i+1]-x_s[i])
sa.sort()

print(sum(sa)-sum(sa[m-n:m]))


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


int main()
{


    int n, l;
    cin >> n >> l;
    int ans;
    ans = n * (l + l + n - 1) / 2;

    if(l*(l+n-1)<=0){
        ans = n * (l + l + n - 1) / 2;
    }
    else{
        ans = ans - min(abs(l), abs(l + n - 1)) * l / abs(l);
    }

    cout << ans <<"\n";

    return 0;
}

Measured memory_bytes: 256
import heapq
from itertools import product
def resolve():
    n, m = map(int, input().split())
    cakes = [list(map(int, input().split())) for _ in range(n)]

    ans = 0

    if m == 0:
        print(0)
        return 

    for i in product([1, -1], repeat=3):
        hq = []
        heapq.heapify(hq)
        for x, y, z in cakes:
            point = i[0] * x + i[1] * y + i[2] * z
            if len(hq) != m:
                heapq.heappush(hq, point)
            elif hq[0] < point:
                heapq.heapreplace(hq, point)

        ans = max(ans, sum(hq))

    print(ans)
    
resolve()

Measured memory_bytes: 3412
import java.io.PrintWriter
val pw = PrintWriter(System.out)
fun main(args: Array<String>) {
    func()
    pw.flush()
}
fun println(value: Any) { pw.println(value) }

fun func() {
    val (N, M) = listOfInt()
    var SW = Array<Int>(N, { 0 })
    for (m in 0 until M) {
        val mm = 1 shl m
        val K = listOfInt().drop(1)
        for (k in K) {
            val sw = k - 1;
            SW[sw] = SW[sw] or mm
        }
    }
    var p = 0
    val P = listOfInt()
    P.forEachIndexed { index, i -> p = p or (i shl index)}

    var ans = 0;
    for (k in 0 until (1 shl N)) {
        var t = 0
        for (n in 0 until N) {
            if (((k ushr n) and 1) != 0) t = t xor SW[n]
        }
        if (t == p) ans++
    }
    println(ans);
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) } //{ it.toInt() }


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

int main() {

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a+b+c == 2*max({a,b,c}))
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define endl '\n'
#define ll long long
#define int long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> ppi;
typedef vector<vector<int>> mat;
const ll mod = 1e9+7;
const ll cfmod = 998244353;
const ll LINF = 0x3f3f3f3f3f3f3f;
const int MAXN = 2e5+5;

int a, b, c, n, m, k, q;
string s, t, u;


int32_t main() {
	cin >> n >> m;
	priority_queue<int> fila;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		fila.push(x);
	}
	while(m) {
		int x = fila.top();
		fila.pop();
		fila.push(x/2);
		m--;
	}
	int ans = 0;
	while(!fila.empty()) {
		ans += fila.top();
		fila.pop();
	}
	cout << ans << endl;
}


Measured memory_bytes: 1400
n,m=map(int,input().split())
t=[list(map(int,input().split())) for _ in range(m)]
tmp=[1,n]
for i in range(m):
  l,r=t[i]
  if tmp[0]<l:
    tmp[0]=l
  if r<tmp[1]:
    tmp[1]=r
print(max(0,tmp[1]-tmp[0]+1))

Measured memory_bytes: 27336
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
int a[2000];
int n,m;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	ll sum=0;
	for(int i=0;i<m;i++)sum+=a[i];
	cout<<sum;
	return 0;
}



Measured memory_bytes: 3592