akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n;
   string ans = "YES";
   cin >> n;
   int a[n] = {};
   FOR(i, 0, n)
      cin >> a[i];
   sort(a,a+n);
   FOR(i,1,n)
      if(a[i-1]==a[i])
         ans = "NO";
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {

        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int D = int.Parse(input[1]);

        int[][] vs = new int[N][];
             
        for (int i = 0; i < N; i++)
        {
            input = Console.ReadLine().Split(' ');
            vs[i] = new int[D];
            for (int j = 0; j < D; j++)
            {
                vs[i][j] = int.Parse(input[j]);
            }
        }

        int count = 0;

        for (int i = 0; i < N-1; i++)
        {
            for (int j = i+1; j < N; j++)
            {
                int sum = 0;
                for (int l = 0; l < D; l++)
                {
                    int sp = vs[i][l] - vs[j][l];
                    sum += sp * sp; 
                }

                double sq = Math.Sqrt(sum);
                if (sq == (int)sq) count++;
            }
        }

        Console.WriteLine(count);
    }

}

Measured memory_bytes: 13268
#include<stdio.h>

void trace(int A[], int N){
    int i;
    for (i = 0; i < N; i++){
        if (i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}

void insertionSort(int A[], int N){
    int i, j, v;
    for ( i = 1; i < N; i++){
        v = A[i]; // 注目しているカード
        j = i - 1;
        while (j >= 0 && A[j] > v){
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        trace(A, N);
    }
}

int main(){
    int N, i, j;
    int A[100];
    
    scanf("%d", &N);
    for (i = 0; i < N; i++) scanf("%d", &A[i]);
    trace(A, N);
    insertionSort(A, N);
    
    return 0;
}


Measured memory_bytes: 2700
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define forn(i,n) for(int i=0;i<(n);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define fordec(i,a,b) for(int i=(a);i>=(b);i--)
#define vi vector<int>
#define vl vector<ll>
#define vd vector<double>
#define vs vector<string>
#define pb push_back
#define vpi vector<pair<int, int>
#define vpl vector<pair<ll, ll>>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a); }
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////

int main()
{
    ios::sync_with_stdio(0);
	cin.tie(0);
    int times; cin >> times;
    vl size(times);
    forn(i, times) cin >> size[i];
    vl diff(times - 1);
    forn(i, times - 1) {
        diff[i] = size[i] - size[i+1];
    }
    int count = 0;
    int maxx = -1;
    forn(i, diff.size()) {
        if (diff[i] >= 0) count++;
        else {
            maxx = max(maxx, count);
            count = 0;
        }
    }
    maxx = max(count, maxx);
    cout << maxx;
    return 0;
}

Measured memory_bytes: 1792
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	string s;
	cin >> s;
	ll k;
	cin >> k;
	ll n = s.size();

	Vec2<ll> dp0(n+1, Vec(k+1)), dp1(n+1, Vec(k+1));

	ll m = s[0]-'0';
	dp0[0][0] = 1;
	dp0[0][1] = m-1;
	dp1[0][1] = 1;

	repn(i, n-1){
		rep(j, k+1){
			if(s[i] == '0'){
				dp0[i][j] = dp0[i-1][j];
				dp1[i][j] = dp1[i-1][j];
				if(j) dp0[i][j] += 9*dp0[i-1][j-1];
			}else{
				m = s[i]-'0';
				dp0[i][j] = dp0[i-1][j];
				dp0[i][j] += dp1[i-1][j];
				if(j){
					dp0[i][j] += 9*dp0[i-1][j-1];
					dp0[i][j] += (m-1)*dp1[i-1][j-1];
					dp1[i][j] = dp1[i-1][j-1];
				}
			}
		}
	}
	co(dp0[n-1][k]+dp1[n-1][k]);

	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define all(v) v.begin(),v.end()
#define itr(r,v) for(auto r=v.begin();r!=v.end();r++)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfr(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define ctime auto sttart = high_resolution_clock::now()
#define etime auto sttop = high_resolution_clock::now()
#define go_t ll testcases; cin>>testcases; for(ll caseno= 1 ;caseno <= testcases; caseno++)
#define ptime auto z1z = duration_cast<microseconds>(sttop-sttart); cout<<"\nTime taken : "<<z1z.count()<<" microseconds\n"
#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';

using namespace std;
using namespace std::chrono;

const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
const ll maxN = 3e3 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

ll powerM(ll x, ll y, ll M = MOD) { // default argument
	ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}

ll power(ll x, ll y) {
	ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	FIO
	ll n; cin >> n;
	double ph[n];
	FOR(i, n) cin >> ph[i];
	double dp[n + 1] = {};
	// linear dp by errichto
	// dp[i] -> probability that we have i heads so far
	dp[0] = 1.00;
	for (int coins = 0; coins < n; ++coins) {
		double p_heads = ph[coins];
		for (int i = coins + 1; i >= 0; --i) {
			dp[i] = (i == 0 ? 0 : dp[i - 1] * p_heads) + dp[i] * (1.00 - p_heads);
		}
	}
	double ans = 0.0;
	for (ll i = (n + 1) / 2; i <= n; i++) {
		ans += dp[i];
	}
	cout << fixed << setprecision(10) << ans;
	return 0;
}


Measured memory_bytes: 3796
#include <cstdio>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

typedef long long LL;
int n,d[310][310];
LL ans;

int main()
{
    scanf("%d",&n);
    repu(i,1,n)
        repu(j,1,n)
            scanf("%d",&d[i][j]);
    repu(i,1,n)
        repu(j,i+1,n)
        {
            bool flag=0;
            repu(k,1,n)
                if (i!=k && j!=k)
                {
                    flag|=d[i][j]==d[i][k]+d[j][k];
                    if (d[i][k]+d[j][k]<d[i][j])
                    {
                        puts("-1");
                        return 0;
                    }
                }
            if (!flag)
                ans+=d[i][j];
        }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 512
N = 1001

def init_fib
  fib = Array.new(1002)
  fib[0] = 1
  fib[1] = 2
  2.upto(N) do |i|
    fib[i] = (fib[i-1] + fib[i-2]) % N
  end
  fib
end

def root(tree, i)
  if tree[i] == i
    i
  else
    root(tree, tree[i])
  end
end

if __FILE__ == $0
  fib = init_fib
  STDIN.each_line do |input|
    count = 0
    v, d = input.split.map(&:to_i)
    tree = Array.new(v+1)

    # treeの初期化
    # tree[i] == i の場合、rootである
    0.upto(v) do |i|
      tree[i] = i
    end

    # 条件を満たすleafの統合
    # 常にrootに新しいleafをつける
    1.upto(v) do |i|
      (i+1).upto(v) do |j|
        tree[root(tree, j)] = root(tree, i) if (fib[j] - fib[i]).abs < d
      end
    end

    # rootの数を数える
    1.upto(v) do |i|
      count += 1 if root(tree, i) == i
    end

    # p tree
    puts count.to_s
  end
end

Measured memory_bytes: 6212
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second


using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
// const int INF=4e18+10;
const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}


void solve()
{
    int h1, m1, h2, m2, k;
    cin>>h1>>m1>>h2>>m2>>k;
    int min=0;
    while((h1<h2) || (h1==h2 && m1<m2))
    {
        min++;
        m1++;
        if(m1%60==0)
        {
            h1++;
            m1=0;
        }
    }
    cout<<max((int)0, min-k)<<endl;

}

signed main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    auto clk=clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

    int t=1;
    // cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;

    }

    // -------------------------------------Code ends here------------------------------------------------------------------


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
long long int gcd(long long int a,long long int b)
{
    long long int n1,c,i,n2;
    n1=a;
    n2=b;
    for(i=1;;i++)
    {
        c=n1%n2;
        n1=n2;
        n2=c;
        if(n2==0)break;
    }
    return n1;
}
int main()
{
    long long int n,a,i,j,k,s=0;
    cin>>n;
    if(n==0)
        cout<<"0"<<endl;
    else if(n==1)
        cout<<"1"<<endl;
    else if(n==2)
        cout<<"9"<<endl;
    else
    {
    for(i=1;i<=n;i++)
    {
       for(j=1;j<=n;j++)
       {
           for(k=1;k<=n;k++)
           {
               s+=gcd(k,gcd(i,j));
           }
       }
    }
    cout<<s<<endl;
    }

    return 0;
}


Measured memory_bytes: 3636
#include <cmath>
#include <cstdlib>
#include <cstdio>

#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

int main() {
  long n;
  long ans;

  std::cin >> n;

  ans = 100000;
  for(int i = 0; i < n; ++i) {
    ans = ans * 105 / 100;
    ans += 999;
    ans /= 1000;
    ans *= 1000;
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 1160
from itertools import product

N = int(input())
A = [None] * N
lst = [[] for _ in range(N)]
for i in range(N):
    A[i] = int(input())
    lst[i] = [list(map(int, input().split())) for _ in range(A[i])]

bit_lst = list(product(range(2), repeat=N)) #N桁のビット

ans = 0
for bit in bit_lst:
    f = True #このbitの証言が無意味になったらFalse
    for a in range(N):
        #1人ずつ順番に聞く : a人目の証言
        if f:
            for b in range(A[a]):
                #b個目の証言
                if bit[a] == 1:
                    #この人が正直者なとき
                    if lst[a][b][1] != bit[lst[a][b][0]-1]:
                        #正直者の証言と現実が食い違う
                        f = False
                        break
                else:
                    #正直者ではないとき
                    break
    if f:
        ans = max(ans, sum(bit))
print(ans)

Measured memory_bytes: 14512
#include<bits/stdc++.h>
using namespace std;
long long int n,w;
pair<long long int,long long int> arr[105];
//  weigh val

long long int dp[105][100005];

long long int max(long long int a,long long int b){
	if(a>b){
		return a;
	}
	return b;
}

long long int solve(long long int ind,long long int weigh){
	if(weigh>w){
		return INT_MIN;
	}
	if(ind>=n){
		return 0;
	}
	if(dp[ind][weigh]!=-1){
		return dp[ind][weigh];
	}
	dp[ind][weigh]=max(solve(ind+1,weigh),solve(ind+1,weigh+arr[ind].first)+arr[ind].second);
	return dp[ind][weigh];
}

int main(){
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	cin>>n>>w;
	for(long long int i=0;i<n;i++){
		cin>>arr[i].first;
		cin>>arr[i].second;
	}
	for(long long int i=0;i<n;i++){
		for(long long int j=0;j<w;j++){
			dp[i][j]=-1;
		}
	}
	cout<<solve(0,0);
	return 0;
}

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

using namespace std;


int main(){
 int n;
 int cont = 0;
 
 
cin>>n;
int* a = new int[n];

for(int i = 0; i < n; i++){
	cin>>a[i];
}
for(int i = 1; i < n-1; i++){
	if((a[i] > a[i-1] && a[i] < a[i+1]) || (a[i] < a[i-1] && a[i] > a[i+1]) ){
		cont++;
	}
}

cout << cont;
return 0;
}

Measured memory_bytes: 256
n,k = map(int, input().split())

cnt_l = [0]*(k+1)
MOD = 10**9+7

for i in range(k,0,-1):
    multi_cnt = k//i
    cnt = pow(multi_cnt,n,MOD)
    
    i_multi = i+i
    while i_multi <= k:
        cnt -= cnt_l[i_multi]
        i_multi+=i

    cnt_l[i] = cnt%MOD

ans = 0
for i, cnt in enumerate(cnt_l):
    ans += i*cnt
    ans %= MOD

# print(cnt_l)
print(ans)

Measured memory_bytes: 69128
import java.util.*;

public class Main {

    static int MOD = 1000000007;
    public static void main(String[] args) {

        int ans=0;
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int[][] c = new int[10][10];
        for(int i=0;i<10;i++)for(int j=0;j<10;j++)c[i][j]=0;

        for(int i=1;i<=n;i++){
            String tempA = String.valueOf(i);
            int al=Integer.parseInt(tempA.substring(0,1));
            int ar=Integer.parseInt(tempA.substring(tempA.length()-1,tempA.length()));
            //System.out.println(al+" "+ar);

            for(int l=0;l<10;l++){
                for(int r=0;r<10;r++){

                    if(al==l&&ar==r){
                        c[l][r]++;
                    }
                }
            }
        }

        for(int i=0;i<10;i++)for(int j=0;j<10;j++){
            ans += c[i][j]*c[j][i];
        }

        System.out.println(ans);
    }

}


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

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

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

ll slova[26];
string s;

int main(){
    cin >> s;
    REP(i, s.size()){
        ++slova[s[i] - 'a'];
    }
    ll sol = s.size() * (s.size() + 1) / 2 + 1;
    REP(i, 26){
        sol -= slova[i] * (slova[i] + 1) / 2;
    }
    cout << sol;
return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
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> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll k, x;
    cin >> k >> x;

    if(k*500 >= x) cout << "Yes" << endl;
    else cout << "No" << endl;    

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

int main(){
    int a, b, c;
    int count_five = 0;
    int count_seven = 0;
    std::cin >> a >> b >> c;

    if (a == 5) count_five++;
    if (a == 7) count_seven++;
    if (b == 5) count_five++;
    if (b == 7) count_seven++;
    if (c == 5) count_five++;
    if (c == 7) count_seven++;

    if(count_five == 2 && count_seven == 1){
      std::cout << "YES" << std::endl;
    } else {
      std::cout << "NO" << std::endl;
    }

}

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

#define pb push_back
#define pop_b pop_back
#define pf push_front
#define pop_f pop_front

typedef long long int ll;
typedef pair<int, int> ii; // are aligned to the right like this
typedef vector<ii> vii;  //vector pair
typedef vector<int> vi;   //vector integer
typedef vector<string> vs; //vector string


int divisorSum(int n) 
{ 
    int sum = 0; 
    for (int i = 1; i <= n; ++i) 
        sum += (n / i) ; 
    return sum; 
} 
int main() 
{
    int n;
    cin>>n;
    int sum=divisorSum(n-1);
    cout<<sum;
   
}
 

/*
0
0
2
2
3
*/

Measured memory_bytes: 3636
n = gets.chomp.to_i
arr = gets.chomp.split(" ").map(&:to_i)

result = 0
(1..n-1).each do |i|
  if arr[i-1] > arr[i]
    result += arr[i-1] - arr[i]
    arr[i] = arr[i-1]
  end
end
puts result

Measured memory_bytes: 30184
#include	<iostream>

using namespace std;

void
Main();

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

void
Main() {

	int		N;			cin >> N;

	long	A[ N ];		for ( auto i = 0; i < N; i++ ) cin >> A[ i ];

	long	v = 0;
	long	w = 0;
	int		j = 0;

	for ( auto i = 0; i < N; i++ ) {
		while ( j < N && ( w ^ A[ j ] ) == ( w + A[ j ] ) ) {
			w += A[ j ];
			j++;
		}
		v += j - i;
		w -= A[ i ];
	}

	cout << v << endl;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> h(n), cost(n, -1);
    for(auto&& i : h){
        cin >> i;
    }
    cost[0] = 0;
    for(int i = 1; i < n; i++){
        cost[i] = cost[i - 1] + abs(h[i - 1] - h[i]);
        if(2 <= i){
            cost[i] = min(cost[i], cost[i - 2] + abs(h[i - 2] - h[i]));
        }
    }
    cout << cost[n - 1] << "\n";
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String firstLine[] = scanner.nextLine().split(" ", 2);
        int n = Integer.parseInt(firstLine[0]);
        int t = Integer.parseInt(firstLine[1]);

        int cs[] = new int[n];
        int ts[] = new int[n];
        for (int i = 0; i < n; i++) {
            String line[] = scanner.nextLine().split(" ", 2);
            cs[i] = Integer.parseInt(line[0]);
            ts[i] = Integer.parseInt(line[1]);
        }

        int cost = new Main().minCost(n, t, cs, ts);
        if (cost == 1001) {
            System.out.println("TLE");
        } else {
            System.out.println(cost);
        }
    }

    public int minCost(int n, int t, int costs[], int times[]) {
        int min = 1001;
        for (int i = 0; i < n; i++) {
            if (times[i] <= t && costs[i] < min) {
                min = costs[i];
            }
        }
        return min;
    }
}


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

using ld = long double;
const ld eps = 1e-8, pi = acos(-1.0);

bool eq(ld a, ld b) {
	return abs(a - b) < eps;
}

using Point = complex<ld>;

class Line {
public:
	Point a, b;
};

ld dot(Point a, Point b) {
	return real(conj(a) * b);
}

ld cross(Point a, Point b) {
	return imag(conj(a) * b);
}

int ccw(Point a, Point b, Point c) {
	b -= a, c -= a;
	if (cross(b, c) > eps) return 1;
	if (cross(b, c) < -eps) return -1;
	if (dot(b, c) < 0) return 2;
	if (norm(b) < norm(c)) return -2;
	return 0;
}

bool isis_ll(Line l, Line m) {
	return abs(cross(l.b - l.a, m.b - m.a)) > eps;
}

int main()
{
	int q;
	ld x1, x2, x3, x4, y1, y2, y3, y4;
	cin >> q;
	while (q--) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
		Line l1 = { (Point) { x1, y1 }, (Point) { x2, y2 } };
		Line l2 = { (Point) { x3, y3 }, (Point) { x4, y4 } };
		cout << (!isis_ll(l1, l2) ? 2 : eq(abs(cross(l1.b - l1.a, l2.b - l2.a)), abs(l1.b - l1.a) * abs(l2.b - l2.a)) ? 1 : 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 3272
from collections import deque

H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]

block_count = 0
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            block_count += 1

d = [[0] * W for _ in range(H)]

dxdy = [(1, 0), (-1, 0), (0, 1), (0, -1)]

que = deque([])
que.append((0, 0))
d[0][0] = 1
while que:
    x, y = que.popleft()
    
    for dx, dy in dxdy:
        nx = x + dx
        ny = y + dy
        if 0 <= nx < W and 0 <= ny < H and d[ny][nx] == 0 and s[ny][nx] == '.':
            que.append((nx, ny))
            d[ny][nx] = d[y][x] + 1

if d[H-1][W-1]:
    print(H * W - d[H-1][W-1] - block_count)
else:
    print(-1)


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

const int INF = 1e9;
const int MAX = 5e2;

int main()
{
	int n;
	while (cin >> n, n) {
		vector<int> p(n);
		vector<vector<int>> dp(MAX + 1, vector<int>(101, -1));
		dp[0][0] = 0;
		for (int i = 0; i < n; i++) {
			cin >> p[i];
			for (int j = MAX; j >= 0; j--) {
				for (int k = 100; k >= 0; k--) if (dp[j][k] != -1) {
					int val = (p[i] + 999) / 1000;
					if (p[i] % 1000 == 0 || p[i] % 1000 > 500) {
						dp[j + val][k] = max(dp[j + val][k], dp[j][k] + val * 1000 - p[i]);
						if (dp[j][k] >= (val * 1000 - p[i] - 500)) {
							dp[j + val][k + 1] = max(dp[j + val][k + 1], dp[j][k] + val * 1000 - p[i] - 500);
						}
					}
					else {
						dp[j + val][k + 1] = max(dp[j + val][k + 1], dp[j][k] + val * 1000 - p[i] - 500);
					}
				}
			}
		}
		int cnt = 0, res = 0;
		for (int i = 0; i <= MAX; i++) {
			for (int j = 0; j <= 100; j++) {
				if (dp[i][j] != -1) {
					if (cnt < j) {
						cnt = j;
						res = i * 1000 - 500 * j - dp[i][j];
					}
					else if (cnt == j) {
						res = min(res, i * 1000 - 500 * j - dp[i][j]);
					}
				}
			}
		}
		cout << cnt << ' ' << res << endl;
	}
	return 0;
}



Measured memory_bytes: 3240
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> vp1, vp2;
    int c = 0;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        int left = 0, right = 0, max_diff1 = 0, max_diff2 = 0;
        for (auto ss : s) {
            if (ss == '(') {
                left++;
            } else {
                right++;
            }
            max_diff1 = max(max_diff1, right - left);
        }
        left = 0, right = 0;
        for (int j = s.size() - 1; j >= 0; j--) {
            if (s[j] == '(') {
                left++;
            } else {
                right++;
            }
            max_diff2 = max(max_diff2, left - right);
        }
        c += left - right;
        if (left > right) {
            vp1.push_back(make_pair(max_diff1, left - right));
        } else  {
            vp2.push_back(make_pair(max_diff2, right - left));
        }
    }
    if (c != 0) {
        cout << "No" << endl;
        return 0;
    }
    sort(vp1.begin(), vp1.end());
    sort(vp2.begin(), vp2.end());
    c = 0;
    for (auto p : vp1) {
        
        if (c >= p.first) {
            c += p.second;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    c = 0;
    for (auto p : vp2) {
        if (c >= p.first) {
            c += p.second;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 11248
N, M = map(int, input().split())
a = set([int(input()) for _ in range(M)])
INF = 1000000007

dp = [0] * (N + 1)
dp[0] = 1
if 1 not in a:
  dp[1]=1
else:
  dp[1]=0
for i in range(2,N+1):
  if i not in a:
    dp[i]=dp[i-1]+dp[i-2]
  else:
    dp[i]=0
    
print(dp[-1]%INF)

Measured memory_bytes: 460020
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <random>
#include <iomanip>
#include <functional>
#include <list>
#include <unordered_map>
using namespace std;

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

    for (int k = m / n; k >= 1; k--)
    {
        int s = k * n;
        int r = m - s;
        if (r % k == 0)
        {
            cout << k;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int n;cin>>n &&n;){
		vvi a(n,vi(n));
		rep(i,n) rep(j,n) cin>>a[i][j];
		vvi s(n+1,vi(n+1));
		
		rep(i,n) rep(j,n) s[i+1][j+1]=s[i+1][j]+a[i][j];
		rep(i,n) rep(j,n) s[i+1][j+1]+=s[i][j+1];
		
		int res=-INFTY;
		rep(i,n) rep(j,n) repi(k,i,n) repi(l,j,n){
			int tmp=s[k+1][l+1]-s[k+1][j]-s[i][l+1]+s[i][j];
			res=max(res,tmp);
		}
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1300
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<stack>
#include<set>
#include<queue>
#include<algorithm>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    
    if(a==b)
        cout<<c<<endl;
    else if(a==c)
        cout<<b<<endl;
    else if(b==c)
        cout<<a<<endl;

	return 0;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j); i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define ALL(x) x.begin(),x.end()
typedef long long LL;
int get_int(){int x;scanf("%d",&x);return x;}
int get_ll(){LL x;scanf("%lld",&x);return x;}

void tests(){
    ;
}

int main()
{
    string s;
    cin >> s;
    int sz = s.size();
    int res1 = 0,res2 = 0;
    _for(i,0,sz){
        if(i%2){
            if(s[i] == '0') res1++;
        }
        else{
            if(s[i] == '1') res1++;
        }
    }

    _for(i,0,sz){
        if(i%2){
            if(s[i] == '1') res2++;
        }
        else{
            if(s[i] == '0') res2++;
        }
    }

    cout << min(res1,res2) << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << (a * b) - a - b + 1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main(){
  int m,d,ans;
  ans=0;
  cin>>m>>d;
  for(int i=1;i<m+1;i++){
    for(int j=22;j<d+1;j++){
      if(i==(j/10)*(j%10)&&j%10>=2){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;

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

  int n;
  cin >> n;
  vector<int> high(n), low(n);
  for (int i = 0; i < n; ++i) {
    cin >> high[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> low[i];
  }
  for (int i = 1; i < n; ++i) {
    high[i] += high[i - 1];
  }
  for (int i = n - 1; 0 < i; --i) {
    low[i - 1] += low[i];
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    ans = max(ans, high[i] + low[i]);
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int fi[512][512];

int main(void)
{
  int n, m;
  cin >> n >> m;
  vector<int> dp(32768,-1);
  int bc[10] = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  int bits=0;
  REP(i, m) {
    int x;
    cin >> x;
    bits = (bits | (1 << x));
  }
  dp[0] = 0;
  REP(i, 10) {
    if(bits & (1 << i))
      REP(j, 16384) {
        if(dp[j] != -1) dp[j+bc[i]] = max(dp[j+bc[i]], dp[j] + 1);
      }
  }
  for(int i = 9; i >= 1 ; --i) {
    if(bits & (1 << i))
      for(;;) {
        if(n >= bc[i] && dp[n] == dp[n - bc[i]] + 1) {
          cout << i;
          n-=bc[i];
        } else break;
      }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 384
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn fac_recursive(n: i64) -> i64 {
    let MOD = 1000000007;
    if n <= 1 {
        1
    } else {
        n * fac_recursive(n - 1) % MOD
    }
}

fn main() {
    let MOD = 1000000007;
    let n: i64 = read().unwrap();
    let m: i64 = read().unwrap();

    if (n - m).abs() > 1 {
        println!("{}", 0);
        return;
    }
    if (n - m).abs() == 1 {
        println!("{}", fac_recursive(n) * fac_recursive(m) % MOD);
        return;
    }
    println!("{}", fac_recursive(n) * fac_recursive(m) * 2 % MOD);
}


Measured memory_bytes: 5884
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double N = sc.nextDouble();
		double X = sc.nextDouble();
		int T = sc.nextInt();
		sc.close();
		double ans = N / X;
		System.out.println((int)(Math.ceil(ans)*T));
	}
}



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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,K;
  cin>>N>>K;
  if(K>N*(N-1)/2-(N-1)){
    cout<<-1<<endl;
  }
  else{
    vector<pii>ans;
    for(int i=2;i<=N;i++){
      ans.push_back({1,i});
    }
    int c=0;
    for(int i=2;i<=N;i++){
      for(int j=i+1;j<=N;j++){
        if(c>=N*(N-1)/2-(N-1)-K)break;
        ans.push_back({i,j});
        c++;
      }
      if(c>=N*(N-1)/2-(N-1)-K)break;
    }
    cout<<ans.size()<<endl;
    for(auto it:ans){
      cout<<it.first<<" "<<it.second<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    std::string s;std::cin>>s;
    lint n=s.length();
    std::vector<lint>a(n);
    for(lint l=0,c=0,r=0;l<n;l=r){
        for(c=l;c<n&&s.at(c)=='R';c++);
        for(r=c;r<n&&s.at(r)=='L';r++);
        a.at(c-1)=((r-l)+(c-l)%2)/2;
        a.at(c)=r-l-a.at(c-1);
    }
    for(lint i=0;i<n;i++){
        std::cout<<(i?" ":"")<<a.at(i);
    }
    std::cout<<'\n';
}


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

int main() {
  int H, W;
  while (true) {
    cin >> H >> W;
    if (H == 0 && W == 0) break;
    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
        if (i == 0 || i == H - 1 || j == 0 || j == W - 1) cout << "#";
        else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3104
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    println(Math.max(0, c - a + b))
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 31008
// 2020-08-29 14:36:26
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
void answer() {
  ll n;
  cin >> n;
  vector<int> ans;
  rep(i, 40) {
    if (n % (1ll << (i + 1))) {
      ans.push_back(1);
      if (i % 2)
        n += (1ll << i);
      else
        n -= (1ll << i);
    } else {
      ans.push_back(0);
    }
    if (n == 0) break;
  }
  reverse(ALL(ans));
  for (auto i : ans) cout << i;
  cout << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
#define P(a,b) make_pair(a,b);
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
  string S;
  cin >> S;
  ll cnt = 0;
  rep(i,S.size()) if(S[i] == 'o') cnt++;
  if(cnt + 15 - S.size()>= 8) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
// ABC059_B
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    string A, B;
    cin >> A >> B;
    
    // calculation
    // 辞書順では 1 < 9
    if (A == B) {
        cout << "EQUAL" << "\n";
    } else {
        if (A.length() == B.length()) {
            // 長さが同じ
            // 1 < 9
            if (A < B) {
                cout << "LESS" << "\n";
            } else {
                cout << "GREATER" << "\n";
            }
        } else if (A.length() < B.length()){
            // A の方が文字数が少ない
            // A < B より
            cout << "LESS" << "\n";
        } else {
            // B の方が文字数が少ない
            // A > B
            cout << "GREATER" << "\n";
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/



////////////////////////////////////////

void no(){
    cout<<"NO"<<endl;
}
void yes(){
    cout<<"YES"<<endl;
}

int main(){
    string s;cin>>s;int pos=s.size()-1;
    char a[10]="maerd",b[10]="esare",c[10]="remaerd",d[10]="resare";
    while(pos>=6){
        if(s[pos]=='m'){pos--;
            for(int i=1;i<=4;i++){
                if(s[pos--]!=a[i]){
                    no();return 0;
                }
            }
        }else if(s[pos]=='e'){pos--;
            for(int i=1;i<=4;i++){
                if(s[pos--]!=b[i]){
                    no();return 0;
                }
            }
        }else if(s[pos]=='r'&&s[pos-1]=='e'){
            pos-=2;
            if(s[pos]=='m'){pos--;
                for(int i=3;i<=6;i++){
                    if(s[pos--]!=c[i]){
                        no();return 0;
                    }
                }
            }else if(s[pos]=='s'){pos--;
                for(int i=3;i<=5;i++){
                    if(s[pos--]!=d[i]){
                        no();return 0;
                    }
                }
            }else{
                no();return 0;
            }
        }else{
            no();
            return 0;
        }
    }
    if(pos==5){
        for(int i=0;i<=5;i++){
            if(s[pos--]!=d[i]){
                no();return 0;
            }
        }
    }
    if(pos==4){
        if(s[pos]=='m'){pos--;
            for(int i=1;i<=4;i++){
                if(s[pos--]!=a[i]){
                    no();return 0;
                }
            }
        }else if(s[pos]=='e'){pos--;
            for(int i=1;i<=4;i++){
                if(s[pos--]!=b[i]){
                    no();return 0;
                }
            }
        }
    }
    if(pos<0){
        yes();return 0;
    }else{
        no();return 0;
    }
    
    return 0;
}


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
  int a, b, c, d, e, f;
  int ans = 0;
  cin >> a >> b >> c >> d >> e >> f;

  int sum = a + b * 5 + c * 10 + d * 50 + e * 100 + f * 500;

  if(sum >= 1000){
    ans = 1;
    }
    cout << ans << endl;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int count = 0;
  for(int i = 0; i <= a; i++) {
    for(int j = 0; j <= b; j++) {
      for(int k = 0; k <= c; k++) {
        if(x == 500 * i + 100 * j + 50 * k && i + j +k >= 1) {
          count++;
        }
      }
    }
  }
  cout << count << endl;
}
    

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

int N;
int K;
int ans;
int field[4141][4141];

int main() {
  scanf("%d%d", &N, &K);
  for (int g=0; g<N; g++) {
    char c;
    int x, y;
    scanf("%d%d %c", &x, &y, &c);
    x %= 2*K;
    y %= 2*K;
    for (int s=-6; s<=6; s++) {
      for (int t=-6; t<=6; t++) {
        if ((c == 'B') ^ ((s+t)%2 == 0)) continue;
        
        int cnt = 0;
        for (int i=0; i<2; i++) {
          for (int j=0; j<2; j++) {
            int p = x+1+s*K-K*i;
            int q = y+1+t*K-K*j;
            if (p < 0 || 4*K <= p) continue;
            if (q < 0 || 4*K <= q) continue;
            cnt++;
          }
        }
        if (cnt < 4) continue;

        for (int i=0; i<2; i++) {
          for (int j=0; j<2; j++) {
            int p = x+1+s*K-K*i;
            int q = y+1+t*K-K*j;
            if (i ^ j) field[p][q] += -1;
            else field[p][q] += 1;
          }
        }
      }
    }
  }
  for (int i=0; i<=4*K; i++) {
    for (int j=1; j<=4*K; j++) {
      field[i][j] += field[i][j-1];
    }
  }

  for (int i=1; i<=4*K; i++) {
    for (int j=0; j<=4*K; j++) {
      field[i][j] += field[i-1][j];
    }
  }

  for (int i=0; i<=4*K; i++) {
    for (int j=0; j<=4*K; j++) {
      ans = max(ans, field[i][j]);
    }
  }
  printf("%d\n", ans);
}



Measured memory_bytes: 65920
local num = tonumber(io.read())
local input = {}

for i = 1, num do
  local v = table.pack(string.byte(io.read(), 1, 10))
  table.sort(v)
  v = string.char(table.unpack(v))
  if input[v] ~= nil then
    input[v] = input[v] + 1
  else
    input[v] = 1
  end
end

local t = 0
for k, v in pairs(input) do
  t = t + v * (v - 1) // 2
end
print(t)

Measured memory_bytes: 23268
PROGRAM WalkOnMultiplicationTable
      IMPLICIT NONE
      integer(16) :: n,sqrtN,i,j
      
      read*,n
      
      sqrtN = ceiling(sqrt(real(N)))
      !print*,sqrtN
      
      !find i
      i = sqrtN
      do while( .true. )
        if( mod(n,i)==0 ) exit
        i = i - 1
      end do
      j = n / i
      
      print*,(j-1) + (i-1)
      
      
      
      END PROGRAM

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
c = gets.split.map(&:to_i)
sum = 0
pre = -1
for i in a
    sum += b[i-1]
    if i == pre+1
       sum += c[pre-1]
    end
    pre = i
end

puts sum


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

int main(){
string s;
cin>>s;
int N=s.size()+1;
vector<int> a(N);
//for(int i=0;i<N;i++) a[i]=-1234567890;
long ans=0;


if(s[0]=='<') {
  a[0]=0;
  int idx=0;
  while(s[idx]=='<' && idx<N){
    a[idx+1]=max(a[idx]+1,a[idx+1]);
    idx++;
  }
}

if(s[s.size()-1]=='>'){
   a[N-1]=0;
   int idx = N-1;
   while(s[idx-1]=='>' && idx>0){
     a[idx-1]=max(a[idx]+1,a[idx-1]);
     idx--;
   }
 }


for(int i=1;i<s.size();i++){
  if(s.substr(i,2)=="><"){
    a[i+1]=0;
    int idx=i+1;
    while(s[idx-1]=='>' && idx>0){
      a[idx-1]=max(a[idx]+1,a[idx-1]);
      idx--;
    }
    idx=i+1;
    while(s[idx]=='<' && idx<N){
      a[idx+1]=max(a[idx]+1,a[idx+1]);
      idx++;
    }
  }
}
/*
for(int i=0;i<N;i++){
  cout<<a[i]<<" ";
}
cout<<endl;
*/
for(int i=0;i<N;i++) ans+=a[i];
cout<<ans<<endl;

}


Measured memory_bytes: 2820
#include <iostream>
using namespace std;
int main(){

  int n,s1=1145141919,s2,result=-1145141919;

  cin>>n>>s2;
  for(int i=1;i<n;i++){
    s1=min(s1,s2);
    cin>>s2;
    result=max(result,s2-s1);
  }
   
  cout<<result<<endl;

  return 0; 

}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
void solve(){
  
  
}
int main()
{
 
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(!a)
        cout<<1<<endl;
    else if(!b)
        cout<<2<<endl;
    else if(!c)
        cout<<3<<endl;
    else if(!d)
        cout<<4<<endl;
    else
        cout<<5<<endl;  
  return 0;
}

Measured memory_bytes: 3596