akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

string a, b;
int i = 0;


int main(){
    cin >> a;
    cin >> b;
    if(a.size() > b.size()){
        cout << "GREATER" << endl;
    }else if(a.size() < b.size()){
        cout << "LESS" << endl;
    }else{
        while( i < a.size()){
            if( stoi(a.substr(i,1)) > stoi(b.substr(i,1)) ){
                cout << "GREATER" << endl;
                break;
            }else if( stoi(a.substr(i,1)) < stoi(b.substr(i,1)) ){
                cout << "LESS" << endl;
                break;
            }else{
                i++;
                if(i == a.size()) cout << "EQUAL" << endl;
            }
        }
    }
}


Measured memory_bytes: 256
import numpy as np
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
i8 = np.int64
i4 = np.int32


def main():
    stdin = open('/dev/stdin')
    pin = np.fromstring(stdin.read(), i8, sep=' ')
    N = pin[0]
    M = pin[1]
    L = pin[2]
    ABC = pin[3: M * 3 + 3].reshape((-1, 3))
    A = ABC[:, 0] - 1
    B = ABC[:, 1] - 1
    C = ABC[:, 2]
    Q = pin[M * 3 + 3]
    st = (pin[M * 3 + 4: 2 * Q + M * 3 + 4] - 1).reshape((-1, 2))

    graph = csr_matrix((C, (A, B)), shape=(N, N))
    dist = np.array(floyd_warshall(graph, directed=False))
    dist[dist > L + 0.5] = 0
    dist[dist > 0] = 1
    min_dist = np.array(floyd_warshall(dist))
    min_dist[min_dist == np.inf] = 0
    for i in range(st.shape[0]):
        print(int(min_dist[st[i, 0], st[i, 1]] - 1.0))


if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }



typedef pair<ll, pair<ll, ll>> prr;
int main() {
    int n; cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];

    ll ans = 0;

    rep(i, n-1) for(int j=i+1; j < n; j++) ans += d[i] * d[j];

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
n,y = gets.split.map(&:to_i)
y /= 1000

# a + b + c = n
# 10a + 5b + c = y

(0..y/10).each do |i|
    (0..y/5).each do |j|
        
        c = y - (10 * i + 5 * j )
        # p( [i,j,c])
        break if c < 0
        if i + j + c == n
            puts [i,j,c] * " "
            exit
        end
    end
end

puts "-1 -1 -1"

Measured memory_bytes: 3836
var
  s1,s2:string;
  a,b:array['a'..'z']of longint;
  c:array[1..26]of boolean;
  f:boolean;
  i,j,k,p:longint;
begin
  readln(s1);
  read(s2);
  k:=length(s2);
  f:=true;
  if length(s1)<length(s2) then
     begin
       k:=length(s1);
       f:=false;
     end;
  for i:=1 to k-1 do
    begin
      inc(a[s1[i]]);
      inc(b[s2[i]]);
    end;
  if f then inc(b[s2[k]])
       else inc(a[s1[k]]);
  if f then p:=length(s1)
    else p:=length(s2);
  for i:=k to p do
  begin
  begin
     if f then inc(a[s1[i]])
	 else inc(b[s2[i]]);
  end;
  end;
  f:=true;
  for i:=1 to 26 do
  begin
     p:=a[chr(i+ord('a')-1)];
	 for j:=1 to 26 do
	 begin
	    if (c[j]=false)and(b[chr(j+ord('a')-1)]=p) then
		begin
		   c[j]:=true;
		   break;
		end;
	if j=26 then f:=false;
     end;
	 if f=false then begin write('No');
         exit; end;
  end;
  write('Yes');
end.

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

int main() {
  double a,b,c,d,e,f,g,h;
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &a,&b,&c,&d,&e,&f,&g,&h) == 8) {
    P aa(a,b), bb(c,d), cc(e,f), dd(g,h);
    if ( ccw(aa,bb,cc)==1&&ccw(bb,cc,dd)==1&&ccw(cc,dd,aa)==1&&ccw(dd,aa,bb)==1 || ccw(aa,bb,cc)==-1&&ccw(bb,cc,dd)==-1&&ccw(cc,dd,aa)==-1&&ccw(dd,aa,bb)==-1)
      cout << "YES";
    else
      cout << "NO";
    cout << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   cin>>n;
   int a,b;
   cin>>a>>b;
   int flag=0;
   for(int i=a;i<=b;i++)
   {
       if(i%n==0)
       {
           flag=1;
       }
   }
   if(flag)
   {
       cout<<"OK"<<endl;
   }
   else
    cout<<"NG"<<endl;
return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <string>

struct Trie {
    struct Node {
        int c;
        std::array<int, 26> nxt;  // 子のindex
        std::array<int, 26> cnt;  // 文字cを含むような子孫の数
        int sz;                   // 部分木のサイズ

        Node(int c) : c(c), sz(0) {
            nxt.fill(-1);
            cnt.fill(0);
        }
    };

    std::vector<Node> nodes;

    Trie() { nodes.emplace_back(-1); }

    void add(const std::string& s) {
        int pos = 0;
        for (char c : s) {
            int ci = c - 'a';

            int npos = nodes[pos].nxt[ci];
            if (npos == -1) {
                npos = nodes.size();
                nodes[pos].nxt[ci] = npos;
                nodes.emplace_back(ci);
            }
            pos = npos;
        }

        ++nodes[pos].sz;
    }

    int find(const std::string& s) const {
        int pos = 0;
        for (char c : s) {
            int ci = c - 'a';
            pos = nodes[pos].nxt[ci];
        }
        return pos;
    }

    // cntを埋める
    void fillcnt() {
        for (int pos = (int)nodes.size() - 1; pos >= 0; --pos) {
            auto& node = nodes[pos];

            for (int c = 0; c < 26; ++c) {
                int npos = node.nxt[c];
                if (npos == -1) continue;

                const auto& cnode = nodes[npos];
                node.sz += cnode.sz;
                for (int d = 0; d < 26; ++d) {
                    node.cnt[d] += cnode.cnt[d];
                }
            }

            // 全ての子孫はcを含む
            if (node.c != -1) node.cnt[node.c] = node.sz;
        }
    }
};

using lint = long long;

void solve() {
    int n;
    std::cin >> n;

    std::vector<std::string> ss(n);
    for (auto& s : ss) {
        std::cin >> s;
        std::reverse(s.begin(), s.end());
    }

    Trie trie;
    for (const auto& s : ss) trie.add(s);

    trie.fillcnt();

    lint ans = 0;

    for (auto s : ss) {
        // 末尾とそれ以外に分離
        int last = s.back() - 'a';
        s.pop_back();

        int pos = trie.find(s);

        // posの子でlastを含むものを数え上げ
        for (int ci = 0; ci < 26; ++ci) {
            int npos = trie.nodes[pos].nxt[ci];

            if (npos == -1) continue;
            ans += trie.nodes[npos].cnt[last];

            // 自分自身は除く
            if (ci == last) --ans;
        }
    }

    std::cout << ans << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 227984
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
#define f first
#define s second
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;
const double eps=1e-9;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<int> v(n),vC(n);
    for(int i=0;i<n&&cin>>v[i];i++)
        vC[i]=v[i];
    sort(vC.rbegin(),vC.rend());
    for(int i=0;i<n;i++)
        cout<<(v[i]!=vC[0]?vC[0]:vC[1])<<"\n";
    return 0;
}


Measured memory_bytes: 4768
xn, yn, e = map(int, input().split())
edges = [set() for _ in range(xn)]
matched = [-1] * yn

def dfs(v, visited):
    for u in edges[v]:
        if u in visited:
            continue
        visited.add(u)
        if matched[u] == -1 or dfs(matched[u], visited):
            matched[u] = v
            return True
    return False

for _ in range(e):
    x, y = map(int, input().split())
    edges[x].add(y)

print(sum(dfs(s, set()) for s in range(xn)))


Measured memory_bytes: 6480
while True:
        H, W = map(int, input().split())

        if H == 0 | W == 0:
                break

        countW, countH = 0, 0

        while True:
                if countH == H:
                        break
                while True:
                        if countW == W:
                                print('\n',end='')
                                countW = 0
                                break
                        print('#',end='')
                        countW += 1
                countH += 1
        print()

Measured memory_bytes: 9048
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll>a(n+1);
  rep(i,n){
    cin>>a[i+1];
  }
  rep(i,n){
    a[i+1]+=a[i];
  }
  ll res=1e18;
  rep(i,n+1){
    chmin(res,abs(a[i]*2-a[n]));
  }
  cout<<res<<endl;
  return 0;

}


Measured memory_bytes: 1792
import std.stdio;
import std.string;
import std.conv;

void main(){
  int qty = readInt();
  int[] value = readInts();
  int[] cost = readInts();
  
  int profit;
  foreach(i; 0 .. qty){
    if(value[i] > cost[i]){
      profit += value[i] - cost[i]; 
    }
  }
  
  writeln(profit);
}

int readInt(){
  return readln.chomp.to!int;
}

int[] readInts(){
  return readln.chomp.split.to!(int[]);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 4e5 + 5;
const ll maxm = 1e3 + 5;
inline void qread(){}
template<class T1, class ...T2>
inline void qread(T1 &IEE, T2&... ls){
    register T1 __ = 0, ___ = 1;
    register char ch;
    while(!isdigit(ch = getchar())) ___ = (ch == '-') ? -___ : ___;
    do{
        __ = (__ << 1) + (__ << 3) + (ch ^ 48);
    }while(isdigit(ch = getchar()));
    __ *= ___;
    IEE = __;
    qread(ls...);
    return ;
}
ll n, m, x, y, z, cur;
ll head[maxn], nex[maxn], to[maxn], dis[maxn], p[maxn];
void add(ll u, ll v){
    nex[++cur] = head[u];
    to[cur] = v;
    head[u] = cur;
    return ;
}
queue<ll> q;
int main(){
    qread(n, m);
    for(int i = 1;i <= m;i++){
        qread(x, y);
        add(x, y);
        add(y, x);
    }
    memset(dis, -1, sizeof(dis));
    dis[1] = 0;
    q.push(1);
    while(!q.empty()){
        ll fr = q.front();
        q.pop();
        for(int i = head[fr];i;i = nex[i]){
            ll t = to[i];
            if(dis[t] != -1) continue;
            dis[t] = dis[fr] + 1;
            p[t] = fr;
            q.push(t);
        }
    }
    for(int i = 2;i <= n;i++){
        if(dis[i] == -1){
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    for(int i = 2;i <= n;i++){
        cout << p[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 14872
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  string s[100];
  cin >> h >> w;
  for(int i=0;i<h;i++) cin >> s[i];
  for(int i=0;i<w+2;i++) cout << "#";
  cout << endl;
  for(int i=0;i<h;i++) cout << "#" << s[i] << "#" << endl;
  for(int i=0;i<w+2;i++) cout << "#";
  cout << endl;  
}

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

using namespace std;

using ll=long long;
using Point=pair<int, int>;
void solve() {
    int h,w,n;
    cin >> h >> w >> n;
    set<Point> st;
    for (int _ = 0; _ < n; _++) {
        int x,y;
        cin >> x >> y;
        st.insert({x,y});
    }
    set<Point> trk;
    vector<ll> cnt(10, 0);
    for (auto& p: st) {
        int x,y;
        tie(x,y) = p;
        for (int u = x-2; u <= x; u++) {
            for (int v = y-2; v <= y; v++) {
                if (u <= 0 || v <= 0) continue;
                if (u+2 > h || v+2 > w) continue;
                if (trk.find({u,v}) != trk.end()) continue;
                int sum = 0;
                for (int i = u; i < u+3; i++) {
                    for (int j = v; j < v+3; j++) {
                        if (st.find({i,j}) != st.end()) sum++;
                    }
                }
                cnt[sum]++;
                trk.insert({u,v});
            }
        }
    }
    ll sum = 0;
    for (int i = 1; i < 10; i++) {
        sum += cnt[i];
    }
    cnt[0] = 1ll*(h-2)*(w-2) - sum;
    for (auto& x: cnt) {
        cout << x << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

int main(){
    int H,W,i,j;

    while(1){
        cin >> H >> W;
        if(H==0 && W==0)break;

        for(int i=1 ; i<=H ; i++){
            for(int j=1 ; j<=W ; j++){
                cout << '#';
            } 
            cout << '\n';
            
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
N = int(input())
A =list(map(int,input().split()))
B =list(map(int,input().split()))
C =list(map(int,input().split()))
satis = B[A[0]-1]
for i in range(1,N):
    satis+=B[A[i]-1]
    if A[i-1]+1 == A[i]:
        satis += C[A[i-1]-1]
print(satis)

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    string A, B, C; cin >> A >> B >> C;
    int ans = 0;
    rep(i, N){
        if(A[i] != B[i] && B[i] != C[i] && C[i] != A[i]) ans += 2;
        else if(A[i] == B[i] && B[i] == C[i]) ans += 0;
        else ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

ll kaijo(int start, int end, ll &ans) {
    rep2(i, start, end+1) {
        ans *= i;
        ans %= 1000000007;
    }
    return ans;
}

int main() {
    int N, M;
    cin >> N >> M;
    if (N >= M+2 || M >= N+2) {
        cout << 0 << endl;
        return 0;
    }
    if (abs(N-M) == 1) {
         ll resn = 1;
         ll resm = 1;
         cout << (kaijo(1, N, resn))*(kaijo(1, M, resm))%1000000007 << endl;
         return 0;
    }
    if (N==M) {
        ll resn = 1;
        ll resm = 1;
        cout << (2*kaijo(1, N, resn))*(kaijo(1, M, resm))%1000000007 << endl;
        return 0;
    }
}


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

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	ll k, a, b;
	cin >> k >> a >> b;
	if(a + 2 >= b || k <= a - 1){
		cout << k + 1 << endl;
		return 0;
	}
	ll answer = a;
	k -= (a - 1);
	answer += (b - a) * (k / 2);
	if(k % 2 == 1){ ++answer; }
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

long long n,a[100005];

bool good(long long x){
    long long s=0;
    for(int i=1;i<=min(x,n);i++) s+=a[i];
    for(int i=x+1;i<=n;i++){
        if(2*s>=a[i]) s+=a[i];
        else return 0;
    }
    return 1;
}

int32_t main(){
    ios_base :: sync_with_stdio(0);
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    sort(a+1,a+n+1);
    int p=0;
    for(int i=(1<<17);i;i/=2){
        if(good(p+i)) continue;
        else p+=i;
    }
    if(good(p+1)) p++;
    cout << n-p+1;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <queue>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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


using namespace std;

bool is_integer( float x ){
    return floor(x)==x;
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

//yakusuu rekkyo
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // push its partner
            if (N/i != i) res.push_back(N/i);
        }
    }

    sort(res.begin(), res.end());
    return res;
}


vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // exponential

        // divide as much as you can
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // push the result
        res.push_back({a, ex});
    }

    // last num (if the lasting n is prime number and not 1)
    if (N != 1) res.push_back({N, 1});
    return res;
}



int main() {
    long long x; cin >> x;
    long long mem = -1;
    long long ans = 0;
    bool finish = false;
    vector<pair<long long, long long> > res;
    x ++;
    while(!finish) {
        x --;
        if(x == 1){
            ans = 1;
            break;
        }
        res = prime_factorize(x);
        rep(i, res.size()) {
            if(res.size() == 1 && res[i].second == 1) break;
            if (i == 0)mem = res[i].second;
            else {
                if (mem != res[i].second || mem == 1) {
                    break;
                }
            }
            if(i == res.size()-1){
                finish = true;
                ans = x;
            }
        }
    }

    cout << ans;

    return 0;
}











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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto& e : a) cin >> e;

    sort(begin(a), end(a));
    int select = 1e9;
    int mother = a.back();
    int target = (mother + 1) / 2;
    a.erase(end(a) - 1);
    a.shrink_to_fit();
    for (int i = 0; i < n; i++) {
        select = abs(select - target) < abs(a[i] - target) ? select : a[i];
    }

    cout << mother << " " << select << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

int N;
bool ok(vector<string>& s){
  REP(i, N) REP(j, N){
    if(s[i][j] != s[j][i]) return false;
  }
  return true;
}

signed main() {
  cin >> N;

  vector<string> s(N), t(N);
  REP(i, N) cin >> s[i], t[i] = s[i];

  int ans = 0;
  REP(k, N){
    REP(i, N) REP(j, N) t[i][j] = s[i][(j+k)%N];
    if(ok(t)) ans += N;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a; i ++)
bool maze[9][9];
void tate(vector<string> s){
  /*
  cout<<"tate"<<endl;
  rep(i,9){
    rep(j,9)
      cout<<s[j][i]<<" ";
    cout<<endl;
  }
  //*/
  rep(i,9){
    //cout<<i<<endl;
    int used[9] = {0};
    rep(j,9){
      used[s[j][i]-'1']++;
    }
    rep(j,9){
      if(used[j] > 1){
	rep(k,9){
	  if(s[k][i] == j + '1')maze[k][i] = false;
	}
      }
    }
  }  
}

void yoko(vector<string> s){
  rep(i,9){
    int used[9] = {0};
    rep(j,9){
      used[s[i][j]-'1']++;
    }
    rep(j,9){
      if(used[j] > 1){
	rep(k,9){
	  if(s[i][k] == j + '1')maze[i][k] = false;
	}
      }
    }
  }    
}

void masu(vector<string> s){
  rep(i,3){
    rep(j,3){
      int used[9] = {0};
      rep(k,3){
	rep(l,3){
	  int x = i * 3 + k, y =  j * 3 + l;
	  //cout<<x<<" "<<y<<" ";
	  used[s[x][y] - '1'] ++;
	}
	//cout<<endl;
      }
      //cout<<endl<<endl;;
      
      //rep(k,9)cout<<used[k]<<" ";cout<<endl;
      rep(k,3){
	rep(l,3){
	  
	  int x = i * 3 + k, y =  j * 3 + l;
	  //cout<<s[x][y]<<" "<<used[s[x][y]-'1']<< " ";
	  if(used[s[x][y] -'1'] >1)
	    maze[x][y] = false;
	    //if(s[x][y] ==  + '1')maze[x][y] = false;
	}
	//	cout<<endl;
      }
      //    cout<<endl;
      
    }
  }
}

int main(void){
  int n;
  cin>>n;
  rep(z,n){
    vector<string> s;
    rep(i,9){
      string str;
      rep(j,9){
	maze[i][j] = true;
	string ss;
	cin>>ss;
	str += ss;
      }
      s.push_back(str);
    }
    if(z)cout<<endl;
    
    tate(s);
    yoko(s);
    masu(s);
    rep(i,9){
      rep(j,9){
	if(maze[i][j])cout<<" ";
	else cout<<"*";
	cout<<s[i][j];
      }
      cout<<endl;
    }
  }
}

Measured memory_bytes: 1208
#include <iostream>
using namespace std;
#define ll long long
ll n,i,a,b,c,d;
string s;
int main ()
{
   cin>>n;
   for (i=1;i<=n;++i)
   {
       cin>>s;
       if (s=="AC") a++;
       else if (s=="WA") b++;
       else if (s=="TLE") c++;
       else if (s=="RE") d++;
   }
   cout<<"AC x "<<a<<"\n";
   cout<<"WA x "<<b<<"\n";
   cout<<"TLE x "<<c<<"\n";
   cout<<"RE x "<<d<<"\n";
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  vl x(n);
  rep(i, n) cin >> x[i];

  ll ans = 0;
  rep(i, n-1) {
    ans += min(b, a * (x[i+1] - x[i]));
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef pair<double,string> P;
int main(){
  int n;
  while(cin>>n,n){
    P pr[55];
    for(int i=0;i<n;i++){
      string l;
      cin>>l;
      int p,a,b,c,d,e,f,s,m;
      cin>>p>>a>>b>>c>>d>>e>>f>>s>>m;
      double sumi=f*s*m-p;
      double sumt=a+b+c+(d+e)*m;
      pr[i]=P(-(sumi/sumt),l);
    }
    sort(pr,pr+n);
    for(int i=0;i<n;i++)cout<<pr[i].second<<endl;
    cout<<"#"<<endl;
  }
  return 0;
}



Measured memory_bytes: 3064
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
ll bit[500005];
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(15)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}
ll gcd(ll number1,ll number2){
	if(number1 > number2){
		swap(number1,number2);
	}
	if(number1 == 0 || number1 == number2){
		return number2;
	}else{
		return gcd(number2 % number1,number1);
	}
}

ll i,j,k,ii,jj,r,l;
ll n,m,num,sum,ans;
ll a,b,c,d,e,g,h,w;
ll x[500005],y[500005],z[500005];
bool dp[10000];
char s[500005];

ll bitsum(ll i){
	ll s = 0;
	while(i>0){
		//p("hoi");
		s += bit[i];
		i -= i & -i;
	}
	return s;
}
void bitadd(ll b,ll x){
	while(b <= n){
		//p("hoi");
		bit[b] += x;
		b += b & -b;
	}
}

int main(){
	cin >> n;
	for(i=0;i<n;i++){
		cin >> x[i];
	}
	sort(x,x+n);
	reverse(x,x+n);	
	bool flag = false;
	x[n] = 0;
	num = 1;
	for(i=0;i<n;i++){
		if(x[i] == x[i+1]){
			num++;
		}else{
			if(num >= 4 && !flag){
				ans = x[i] * x[i];
				break;
			}else if(num >= 2 && a == 0){
				a = x[i];
				flag = true;
			}else if(num >= 2){
				b = x[i];
				break;
			}
			num = 1;
		}
	}
	if(ans == 0)ans = a * b;

	p(ans);


	return 0;
}

Measured memory_bytes: 29696
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; ++i)  cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    for(int i = 0; i < k; ++i)  ans += p[i];
    cout << ans << endl;
}

Measured memory_bytes: 3672
L, R = map(int, input().split())

if R - L >= 2019:
    print(0)
    exit()

flag = True
ans = 2020
for i in range(L, R+1):
    for j in range(i+1, R+1):
        ans = min(((i % 2019) * (j % 2019)) % 2019, ans)
print(ans)


Measured memory_bytes: 3060
h,w,k = map(int,input().split())


#dp[h][k]
bits = []
for i in range(2**(w-1)):
    bit = [0] * (w-1)
    for j in range(w-1):
        if ((i >> j) & 1):
            bit[j] = 1
    for j in range(w-2):
        if bit[j] == 1 and bit[j+1] == 1:
            break
    else:
        bits.append(bit)

path = [[0 for i in range(w)] for i in range(w)]

for bit in bits:
    for ww in range(w):
        flag = True
        if ww != w-1:
            if bit[ww] == 1:
                flag = False
                path[ww][ww+1] += 1
        if ww != 0:
            if bit[ww-1] == 1:
                flag = False
                path[ww][ww-1] += 1
        if flag:
            path[ww][ww] += 1

            
dp = [[0 for ww in range(w)] for hh in range(h+1)]

dp[0][0] = 1

for hh in range(h):
    for ww in range(w):
        for ww2 in range(w):
            dp[hh+1][ww2] += dp[hh][ww] * path[ww][ww2] 
            dp[hh+1][ww2] %= 1000000007
            
print(dp[-1][k-1])

Measured memory_bytes: 3188
s=input()
len_s=len(s)
mod=10**9+7
dp=[[0]*13 for i in range(len_s)]

if s[-1]!='?':
    dp[0][int(s[-1])%13]=1
else:
    for i in range(10):
        dp[0][i]=1

a=1
for i in range(1,len_s):
    a=10*a%13
    if s[-(i+1)]!='?':
        temp_S=int(s[-(i+1)])
        amari=(temp_S*a)%13
        for j in range(13):
            dp[i][(amari+j)%13]+=dp[i-1][j]%mod

    else:
        for k in range(10):
            amari=(k*a)%13
            for l in range(13):
                dp[i][(amari+l)%13]+=dp[i-1][l]%mod
#print(*dp,sep='\n')
print(dp[-1][5]%mod)


Measured memory_bytes: 61916
k, n = map(int, input().split())
a = list(map(int, input().split()))

dist = [0]*n

for i in range(n-1):
    dist[i] = a[i+1] - a[i]

dist[n-1] = k-a[n-1] + a[0]

ans = sum(dist) - max(dist)

print(ans)

Measured memory_bytes: 26444
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  set<string> s;
  while(n--)
  {
    string c;
    cin>>c;
    s.insert(c);
  }
  cout<<s.size()<<endl;
  return 0;
    
}

Measured memory_bytes: 19220
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    N = int(input())
    H = list(map(int, input().split()))
    
    count = 0
    highest = 0
    for index in range(N):
        if highest <= H[index]:
            highest = H[index]
            count += 1
            

    print(count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define g 9.80
#define eps 1e-8
int top;

int n;
double v,xx,yy;
struct rectangle
{
       double l,r,b,t;
}rec[101];

bool judge(double a,double len )
{
     int i;
     double hh = a*xx*(xx-len);
     double hi = -a*len*len/4.0;//抛物&#32447;最高点的y坐&#26631; 
     if ( yy-hh>eps || yy-hi>eps ) return false;//抛物&#32447;&#39134;&#36807;pig下方 
     for ( i=1;i<=n;i++ )
     {
         if ( rec[i].l>xx ) break;//障碍物的左&#36793;界大于pig的x坐&#26631; 
         double h1 = a*rec[i].l*(rec[i].l-len );//左&#36793;界&#23545;&#24212;的高度 
         double h2 = a*rec[i].r*(rec[i].r-len );//右&#36793;界&#23545;&#24212;的高度 
         if ( h1>=rec[i].b && h1<=rec[i].t ) return false;
         if ( h2>=rec[i].b && h2<=rec[i].t ) return false;//撞上&#36793;界 
         if ( h1<rec[i].b && h2<rec[i].b ) //抛物&#32447;从矩形下方&#39134;&#36807; 
              if (  len/2-rec[i].l>eps && rec[i].r-len/2>eps && hi-rec[i].b>eps  ) 
                 return false;//抛物&#32447;最高点在矩形中或者高于矩形 
         if ( rec[i].l<=xx && rec[i].r>=xx  && rec[i].b>yy ) //pig 在一个矩形的下面 
             if ( hh>rec[i].t ) return false;
     }
     return true;
}


void solve()
{
     int i;
     double h,t,vx,vy,len;
     for ( i=1;i<=500000;i++ )
     {
           vy=double(i)/500000*v;
           vx=sqrt(v*v-vy*vy);
           t=vy/g;
           h = g*t*t/2;
           len = vx*2*t;
           if ( xx-len>eps ) continue;
           else
           {
               double a = (-2*vy*vy)/(g*len*len);
               if ( judge(a,len) )
               {
                    printf("Yes\n");
                    return ;
               }
           }
     }
     printf("No\n");
}

bool cmp(rectangle a,rectangle b)
{
     return a.l<b.l;
}

int main()
{
    int i;
    while ( scanf("%d %lf %lf %lf",&n,&v,&xx,&yy)!=EOF )
    {
          for ( i=1;i<=n;i++ )
          {
              scanf("%lf %lf %lf %lf",&rec[i].l,&rec[i].b,&rec[i].r,&rec[i].t);
              rec[i].r = min(xx,rec[i].r);
          }
          sort(rec+1,rec+n+1,cmp);
          solve();
    }
    return 0;
}
          
          
          
          

Measured memory_bytes: 888
import numpy as np

N, M = map(int, input().split())
X = list(map(int, input().split()))
X_sort = np.array(sorted(X))[::-1]
X_diff = X_sort[:M-1] - X_sort[1:]

X_diff_sort = sorted(X_diff)[::-1]

print(max(sum(X_diff_sort[N-1:]), 0))

Measured memory_bytes: 23000
/*
 * e.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_H = 500;
const int MAX_W = 500;

const int dxs[] = {1, 0, -1, -1}, dys[] = {-1, -1, -1, 0};

/* typedef */

/* global variables */

int flds[MAX_H][MAX_W], ens[MAX_H][MAX_W];

/* subroutines */

/* main */

int main() {
  int h, w;
  cin >> h >> w;

  for (int y = 0; y < h; y++)
    for (int x = 0; x < w; x++) cin >> flds[y][x];

  memset(ens, -1, sizeof(ens));
  
  for (int y = 1; y < h - 1; y++)
    for (int x = 1; x < w - 1; x++) {
      int k = flds[y - 1][x - 1];
      if (k > 1) {
	printf("%d %d %d %d\n", y, x, y, x);
	return 0;
      }
      if (k == 1) {
	for (int y0 = y - 1; y0 <= y + 1; y0++)
	  for (int x0 = x - 1; x0 <= x + 1; x0++)
	    flds[y0][x0]--;

	ens[y][x] = 0;
	for (int di = 0; di < 4; di++) {
	  int x0 = x + dxs[di], y0 = y + dys[di];
	  if (ens[y0][x0] >= 0)
	    ens[y0][x0]++, ens[y][x]++;
	}
      }
    }

  int sx, sy, tx = -1, ty = -1;
  for (int y = 1; y < h - 1; y++)
    for (int x = 1; x < w - 1; x++)
      if (ens[y][x] == 1) {
	if (tx < 0) tx = x, ty = y;
	else sx = x, sy = y;
      }
  printf("%d %d %d %d\n", sy, sx, ty, tx);
  return 0;
}

Measured memory_bytes: 3108
#include<bits/stdc++.h>
#include<cstdlib>
#include<cmath>
using namespace std;
int main(){
  int r; int d; int z; cin>>r>>d>>z;
  for(int i=0; i<10; i++){
    cout<<r*z-d<<endl;
    z=r*z-d;
  }
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

using ll = long long;
const ll mod = LLONG_MAX;


int main(){
  int x;
  cin>>x;
  x>=1200 ? cout<<"ARC"<<endl : cout<<"ABC"<<endl;
}


Measured memory_bytes: 256
x, n = map(int, input().split())
l = list(map(int, input().split()))
vis = [0] * 103
for i in l: vis[i] = 1
mn = 9999
ans = -1
for i in range(103):
    if vis[i] == 0:
        if abs(x - i) < mn:
            mn = x - i
            ans = i
print(ans)

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

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

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

int main() {
    int A,B;
    cin >> A >> B;
    int sum = 0;
    if(A<B) swap(A,B);
    
    if(sum < A + A - 1) sum = A + A - 1;
    sum = max(sum, A + A -1);
    sum = max(sum, A + B);
    sum = max(sum, B + B - 1);
    
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
const double PI=acos(-1);

int main(){
    double a,b,x;cin>>a>>b>>x;
    double theta;
    if(2*x>=a*a*b) theta=atan2(2*(a*a*b-x),a*a*a);
    else theta=atan2(a*b*b,2*x);
    printf("%.16f",theta*180.0/PI);
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) begin(n),end(n)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	cout << ((n + 1) * n) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
N, K = gets.split(' ').map(&:to_i)
h = []
min = 10 ** 9

N.times do |i|
  h[i] = gets.to_i
end

h = h.sort

(N - K + 1).times do |i|
  diff = h[i + K - 1] - h[i]
  min = diff if diff < min
end

p min

Measured memory_bytes: 4676
#include<iostream>

using namespace std;

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

	int m = 0;
	int min, max;
	int minm, maxm;

	if(x > y){
		min = y;
		max = x;
		minm = b;
		maxm = a;
	}else{
		minm = a;
		maxm = b;
		min = x;
		max = y;
	}

	if((a+b)>(2*c)){
		m += min * c * 2;
		if(2*c > maxm)
			m += (max - min) * maxm;
		else
			m += (max - min) * 2 * c;
	}else{
		m = a*x + b*y;
	}
	cout << m;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a, b, c, d, e, f;
	int x = 0, y = 0;
	int ans_a = 0, ans_b = 0, ans_c = 0, ans_d = 0;
	double m, n, max = 0;
	scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);

	m = 1.0 * e / 100;
	for (int i = 0; i <= 30; i++)
	{
		int ii = a * 100 * i;
		if (f < ii) break;
		for (int j = 0; j <= 30; j++)
		{
			int jj = b * 100 * j;
			if (f < jj + ii) break;
			for (int k = 0; k < 5000; k++)
			{
				int kk = c * k;
				if (f < ii + jj + kk) break;
				for (int l = 0; l < 5000; l++)
				{
					int ll = d * l;
					if (f < ii + jj + kk + ll) break;
					x = a*i * 100 + b*j * 100;
					y = c*k + d*l;
					if (f >= x + y && x != 0)
					{
						n = 1.0 * y / x;
						if (m >= n)
						{
							if (max <= n)
							{
								max = n;
								ans_a = i;
								ans_b = j;
								ans_c = k;
								ans_d = l;
							}
						}
					}
				}
			}
		}
	}
	printf("%d %d", ((a*ans_a * 100) + (b*ans_b * 100) + (c*ans_c) + (d*ans_d)), ((c*ans_c) + (d*ans_d)));

	return 0;
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		List<Integer> list = new ArrayList<Integer>();

		while (sc.hasNext()) {
			int i = sc.nextInt();
			if (i == 0) {
				System.out.println(list.get(0));
				list.remove(0);
			} else {
				list.add(0, i);
			}
		}

	}
}

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

int main() {
  //int n, a,b,c;
  string s;
cin>>s;
  int arr[26];
  int cc=0;
  memset(arr,0,sizeof(arr));
  //cin>>s;
  for(int i=0;i<3;i++)
  {
   if(s[i]==s[i+1])
      cc=1;
  }
  
  if(cc)
  {
    cout<<"Bad"<<endl;
  }
  else
  {
    cout<<"Good"<<endl;
  }
}

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

using namespace std;
using ll = long long;
using vi = vector<int>;

#define scan(x) cin >>x;
#define print(x) cout << x << endl;
#define Endl endl
#define inf 99999999
#define llinf 1LL << 32

int main() {

	string s, t;

	scan(s); scan(t);

	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<char>());

	if (s < t) {
		print("Yes");
	}
	else {
		print("No");
	}

	return 0;
}

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

//#define int long long
#define reps(i,s,n) for(ll (i)=(s);(i)<(ll)(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,n+1)
#define repst(i,s,n) reps(i,s,n+1)
#define reprt(i,n,t) for(ll (i)=(n);(i)>=t;--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb emplace_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) for(int (i)=0;i<n;++i){cout<<x[i]<<(i==n-1?'\n':' ');}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// 値が確定してる頂点を値の小さい順に見ていき、その隣接点に+1した値を書き込む

int n, a, b, k, d[100100];
vi e[100100];
priority_queue<pii> q;

signed main() {
	cin >> n;
	rep(i,n-1) {
		cin >> a >> b;
		a--, b--;
		e[a].pb(b), e[b].pb(a);
	}
	cin >> k;
	memset(d, -1, sizeof(d));
	rep(i,k) {
		cin >> a >> b;
		a--;
		d[a] = b;
		q.push({-b,a});
	}
	while (!q.empty()) {
		int v = q.top().se; q.pop();
		each(i,e[v]) {
			if (d[i]==-1) {
				d[i] = d[v] + 1;
				q.push({-d[i], i});
			} else if (abs(d[i]-d[v])!=1) {
				cout << "No" << ln;
				return 0;
			}
		}
	}
	cout << "Yes" << ln;
	rep(i,n) cout << d[i] << ln;
}

Measured memory_bytes: 7924
N=int(input())
ls=[0,0,0,0,0]#MARCH
for i in range(N):
  x=input()
  if x[0]=='M':
    ls[0]+=1
  elif x[0]=='A':
    ls[1]+=1
  elif x[0]=='R':
    ls[2]+=1
  elif x[0]=='C':
    ls[3]+=1
  elif x[0]=='H':
    ls[4]+=1
ans=0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      ans+=ls[i]*ls[j]*ls[k]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
#define ll long long
ll mod=1e9+7;
int main()
{
	ll w,a,b;
	cin>>w>>a>>b;
	if(b>(a+w))
	{
		cout<<b-a-w;
	}
	else if(b<=(a+w)&&b>=a)
	{
		cout<<0;
	}
	else if(b<a)
	{
		cout<<a-(b+w);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;


void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
template<typename T>
T argument(const pair<T, T> &a, const pair<T, T> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

/* 注意 

    1LL<<60 * N とかのオーバーフローに気を付けろ
    制約がヒントになる、ちゃんと全ての制約を見ろ

*/

int const MAX = 2000000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

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

    COMinit();
    int n, k; std::cin >> n >> k;
    std::vector<std::vector<ll>> s(1010, std::vector<ll>(1010, 0));
    s[0][0] = 1;
    repr(i, 1, 1010) repr(j, 1, 1010) {
        s[i][j] = s[i-1][j-1] + j*s[i-1][j];
        chmod(s[i][j]);
    }
    ll ans = 0;
    repr(j, 1, k+1) { ans += s[n][j]; chmod(ans); }
    std::cout << ans << std::endl;
    
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
    }
    for(int i = 0; i < n; i++){
        cin >> b.at(i);
    }
    for(int i = 0; i < n; i++){
        cin >> c.at(i);
    }
    
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    long long int res = 0;
    long long int min = 0;
    long long int max = 0;
    for(int i = 0; i < n; i++){
        //min = lower_bound(a.begin(), a.end(), b[i]);
        min = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        //max = n - upper_bound(c.begin(), c.end(), b[i]);
        max = c.end() - upper_bound(c.begin(), c.end(), b[i]);
        res += min * max;
    }
    cout << res << endl;
}


Measured memory_bytes: 4504