akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int N, S;
int main(){
  while (cin >> N && N > 0) {
    int sum = 0;
    int max = 0;
    int min = 1000000000;
    for(int i = 0 ; i < N ; i++){
      cin >> S;
      sum += S;
      if(S > max){
	max = S;
      }
      if(S < min){
	min = S;
      }
    }
    cout << (sum-max-min)/(N-2) << endl;
    //cout << "max:" << max << endl;
    //cout << "min:" << min << endl;
  }
}

Measured memory_bytes: 3092
// #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

    int n;
    cin >> n;
    vector<int> t(n), x(n), y(n);
    for (int i = 0; i < n; i++)
    {
        cin >> t[i] >> x[i] >> y[i];
    }

    int time = 0;
    int dx = 0, dy = 0;
    bool flag = true;

    for (int i = 0; i < n; i++)
    {
        time = t[i] - time;
        dx = abs(x[i] - dx);
        dy = abs(y[i] - dy);
        if (time < dx + dy || time % 2 != (dx + dy) % 2)
        {
            flag = false;
        }
    }

    cout << ((flag) ? "Yes" : "No") << '\n';
    return (0);
}


Measured memory_bytes: 4524
#include <iostream>

using namespace std;

int main() {
	int n;

	cin >> n;
	for (int i = 0; i < n; i++) {
		int Y, M , D;
		cin >> Y >> M >> D;
		int ans = -D + 1;
		if (M % 2 == 1 || Y % 3 == 0) {
			ans += 20;
		} else {
			ans += 19;
		}
		for (int y = Y; y < 1000; y++) {
			for (int m = (y==Y)?M+1:1; m <= 10; m++) {
				if (m % 2 == 1 || y % 3 == 0) {
					ans += 20;
				} else {
					ans += 19;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h + 1, vector<int>(w + 1, 0));
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> a[i][j];
        }
    }

    int count = 0;
    int y_prev[250000] = {}, x_prev[250000] = {}, y_next[250000] = {}, x_next[250000] = {};
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j < w; j++) {
            if (a[i][j] % 2 == 1) {
                a[i][j]--;
                y_prev[count] = i;
                x_prev[count] = j;
                a[i][j + 1]++;
                y_next[count] = i;
                x_next[count] = j + 1;
                count++;
            }
        }

        if (a[i][w] % 2 == 1 && i < h) {
            a[i][w]--;
            y_prev[count] = i;
            x_prev[count] = w;
            a[i + 1][w]++;
            y_next[count] = i + 1;
            x_next[count] = w;
            count++;
        }
    }

    cout << count << endl;
    for (int i = 0; i < count; i++) {
        cout << y_prev[i] << " " << x_prev[i] << " " << y_next[i] << " " << x_next[i] << endl;
    }
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> T(N);
    for (int i = 0; i < N; i++)
        cin >> T[i];
    int M;
    cin >> M;
    vector<pair<int, int>> m;
    for (int i = 0; i < M; i++)
    {
        int p, x;
        cin >> p >> x;
        p--;
        m.push_back(make_pair(p, x));
    }
    for (int i = 0; i < M; i++)
    {
        int ans = 0;
        int oldp = m[i].first;
        int oldx = m[i].second;
        int tmp = T[oldp];
        T[oldp] = oldx;
        for (int i = 0; i < N; i++)
        {
            ans += T[i];
        }
        cout << ans << endl;
        T[oldp] = tmp;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
vector<int> e[N];
void dfs(int u, int dist[])
{
	dist[u]=0;
  for(auto v:e[u])
  {
  	if(dist[v]==-1)
    {
     dfs(v, dist);
    	dist[u]=max(dist[u],1+dist[v]);
    }
    else dist[u]=max(dist[u], 1+dist[v]);
  }
}

int main()
{
	int n,m;
	cin>>n>>m;
	int dist[n];
  for(int i=0;i<m;i++)
  {
    int a,b;
    cin>>a>>b;
    a--, b--;
    e[a].push_back(b);
  }
  	memset(dist, -1, sizeof(dist));
    for(int i=0;i<n;i++)
    {
    	if(dist[i]==-1)
        {
        	dfs(i, dist);
        }
    }
  int maxx=0;
  for(int i=0;i<n;i++) maxx=max(dist[i], maxx);
  cout<<maxx;
}

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

ave_a = sum(a) / n
dist = 1000007
flamenum = 0

for i in range(n):
    if abs(a[i] - ave_a) < dist:
        dist = abs(a[i] - ave_a)
        flamenum = i
        #print(dist)

print(flamenum)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
s = input()
k = int(input())

ss = set()
for i in range(len(s)):
    for j in range(i+1,min(len(s)+1,i+k+1)):
        ss.add(s[i:j])
l = sorted(list(ss))
# print(ss)
# print(l)
print(l[k-1])


Measured memory_bytes: 4592
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    x = int(input())

    # %%
    #output
    if x >= 30:
        print("Yes")
    else:
        print("No")

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Measured memory_bytes: 9092
#include<bits/stdc++.h>
using namespace std;
#define Mod 1000000007
#define ll long long
#define tc getchar()
inline int read(void){
    int a=0;static char c;
    while((c=tc)<'0'||c>'9');
    while(c>='0'&&c<='9')a=a*10+c-'0',c=tc;
    return a;
}
ll fac[8005],inv[8005],n,f[4005][4005],x[200005],y[200005],ans,b[4005][4005];
inline ll C(ll n,ll m){
    return (fac[n]*inv[m]%Mod)*inv[n-m]%Mod;
}
int main(){
    int i,j;
    fac[0]=inv[0]=inv[1]=1;
    for(i=2;i<=8004;++i)    
        inv[i]=(Mod-Mod/i)*inv[Mod%i]%Mod;
    for(i=1;i<=8004;++i)
        fac[i]=fac[i-1]*i%Mod,inv[i]=inv[i-1]*inv[i]%Mod;
    n=read();
    for(i=1;i<=n;++i)
        x[i]=read(),y[i]=read(),++f[2001-x[i]][2001-y[i]],++b[2001+x[i]][2001+y[i]];
    for(i=1;i<=4004;++i)
        for(j=1;j<=4004;++j){
            f[i][j]=(f[i][j]+f[i-1][j]+f[i][j-1])%Mod;
            if(b[i][j])ans=(ans+b[i][j]*f[i][j]%Mod)%Mod;
        }
    for(i=1;i<=n;++i)
        ans=(((ans-C((x[i]+y[i])*2,x[i]*2)))%Mod+Mod)%Mod;
    printf("%d",ans*inv[2]%Mod);
    return 0;
}


Measured memory_bytes: 192640
#include<stdio.h>
#include <iostream>
#include <algorithm>

using namespace std; 

int zettai(int x);

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (zettai(a - c) <= d)
		cout << "Yes" << endl;
	else if (zettai(a - b) <= d&& zettai(c - b) <= d)
		cout << "Yes" << endl;
	else 
		cout << "No" << endl;
}

int zettai(int x)
{
	if (x < 0) x *= -1;
	return x;
}

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

int64_t X(int64_t x){
  int64_t xa = 1;
  if(x <= 1){
    return  0;
  }
  else{
  xa = x * (x-1) / 2;
  return xa;
  }
}

int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  vector<int64_t> S(N+1,0);
  for(int j=0; j<N; j++){
    S.at(j+1) += S.at(j) + vec.at(j);
  }
  sort(S.begin(),S.end());
  
  int64_t ans = 0;
  int64_t cnt = 0;
  for(int k=0; k<N; k++){
    if(S.at(k) == S.at(k+1)){
      cnt++;
    }
    if(S.at(k) != S.at(k+1) || k == N-1){
      ans += X(cnt+1);
      cnt = 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    if(c<=a+b)
    {
        cout<<"No\n";
    }
    else
    {
        c = c-a-b;
        c = c*c;
        if(4*a*b<c)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

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

    int n, m; cin >> n >> m;
    UnionFind uf(n);

    int res = n;
    rep(_, m){
        int a, b, c; cin >> a >> b >> c;
        a--, b--;
        
        if(not uf.findSet(a, b)){
            res--;
            uf.unionSet(a, b);
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 640
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define  all(v)            v.begin(), v.end()
#define  sz(x)             (int)x.size()
#define  debug(x)          cout << '>' << #x << ':' << x << endl;
#define  rep(i,n)          for(int i = 0; i <  n ; i++)
#define  reps(i,n)         for(int i = 1; i <= n ; i++)
#define  make_unique(v)    sort(all(v));v.erase(unique(all(v)), v.end());
#define  rot(v)            rotate(v.begin(), v.begin() + k, v.end());
#define  rmv(v,a)          v.erase(remove(v.begin(),v.end(), a), v.end());
#define  max(x,y)          ((x>y)?x:y)
#define  min(x,y)          ((x<y)?x:y)
#define  pb                push_back
#define  eb                emplace_back
#define  mp                make_pair
#define  endl              '\n'
#define  fi                first
#define  se                second
#define  ajs(a)            (a<0)?(-1*a):a
using namespace std;
typedef long long          ll;
// use count() instead of find() in sets.
const ll MOD = 1e9 + 7;
const double PI  = acos(-1.0);
const double EPS = (1e-10);
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = { -1, 0, 1, 0};
const int dx8[8] = { -1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = { -1, 0, 1, 1, 1, 0, -1, -1};
bool cmp(int X, int Y) {return X > Y;}
int dcp(double A, double B){return fabs(A-B)<=EPS ? 0 : A<B ? -1:1;}


ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll lcm(ll a, ll b) {return (a / gcd(a, b)) * b;}
ll modpow(ll a, ll b, ll m ){a %= m; ll res = 1; while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}




int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n,k;cin>>n>>k;
ll w[n+1],v[n+1];
reps(i,n){cin>>w[i]>>v[i];}

ll dp[n+1][k+1];
memset(dp,0,sizeof(dp));

for(ll i = 1 ; i<=n ; i++){
    for(ll j = 1; j<=k ; j++){
        dp[i][j] = dp[i-1][j];
        if(j - w[i] >=0){
        dp[i][j] = max(dp[i][j] , dp[i-1][j - w[i]] + v[i]);
        }
    }
}
cout<<dp[n][k];

}





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

int main() {
	int a,b,k;
	cin>>a>>b>>k;
	for(int i=0;i<k;i++){
	    if(i%2==0){
	        a=a/2;
	        b=b+a;
	    }
	    else{
	        b=b/2;
	        a=a+b;
	    }
	}
	cout<<a<<endl<<b;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>

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

int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i;
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

int main() {
    int a = iin(), b = iin(), h = iin();
    iout((a + b) * h / 2);
    return 0;
}


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

int n, m, p, y;
vector<pair<int, int>> v[200001];
pair<int, int> a[200001];
void f(int n) {
	if (n < 10) cout << "00000";
	else if (n < 100) cout << "0000";
	else if (n < 1000) cout << "000";
	else if (n < 10000) cout << "00";
	else if (n < 100000) cout << "0";
	cout << n;
}
int main() {
	cin >> n >> m;
	rep(i, m) {
		cin >> p >> y;
		v[p - 1].push_back(make_pair(y, i));
	}
	rep(i, n) sort(v[i].begin(), v[i].end());
	rep(i, n) {
		rep(j, v[i].size()) {
			a[v[i][j].second] = make_pair(i + 1, j + 1);
		}
	}
	rep(i, m) {
		f(a[i].first);
		f(a[i].second);
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, std::vector<double> v)
{
    SORT(v);
    double ans = 0;
    for (int i = 0; i < N - 1; i++)
    {
        ans = (v[i] + v[i + 1]) / 2;
        v[i + 1] = ans;
    }
    cout << setprecision(15) << v[N - 1] << endl;
}

int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<double> v(N);
    for (int i = 0; i < N; i++)
    {
        cin >> v[i];
    }
    solve(N, std::move(v));
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/


void Calc() {
  int n = in;
  auto a = in.Array(n);
  map<ll, ll> m;
  for (auto& i : a) {
    m[-i]++;
  }
  vector<ll> x;
  for (auto& i : m) {
    while (i.second >= 2) {
      i.second -= 2;
      x.push_back(i.first);
      if (x.size() == 2)break;
    }
  }
  if (x.size() < 2) {
    cout << (0) << endl;
  }
  else {
    cout << (x[0] * x[1]) << endl;
  }
}


Measured memory_bytes: 6912
import std.stdio;
import std.string;
import std.math;
import std.conv;
import std.algorithm;
import std.bigint;

void main(){

    int[10][10] map;
    while(true){
	auto s = split(chomp(readln()),',');
	if(stdin.eof()) break;
	int x,y,size;
	x = to!int(s[0]);
	y = to!int(s[1]);
	size = to!int(s[2]);

	if(size >0){
	    auto d = [1,0,-1,0 ,0];
	    auto d1 = [0,1,0,-1,0];
	    for(int i=0;i<5;i++){
		if(0 <= d[i] + x &&  d[i] + x < 10 && 0 <= d1[i] + y &&  d1[i] + y < 10){
		    map[d[i] + x][d1[i] + y]++;
		}
	    }
	}
	size--;
	if(size>0){
	    auto d = [ 1,-1];
	    for(int i=0;i<2;i++){
		for(int j=0;j<2;j++){
		    if(0 <= d[i] + x &&  d[i] + x < 10 && 0 <= d[j] + y &&  d[j] + y < 10){
			map[d[i] + x][d[j] + y]++;
		    }
		}
	    }
	}
	size--;
	if(size>0){
	    auto d = [2,0,-2,0,0];
	    auto d1 = [0,2,0,-2,0];
	    for(int i=0;i<5;i++){
		if(0 <= d[i] + x &&  d[i] + x < 10 && 0 <= d1[i] + y &&  d1[i] + y < 10){
		    map[d[i] + x][d1[i] + y]++;
		}
	    }
	}
    }
    int ans1 = 0,ans2=0;
    for(int i=0;i<10;i++){
	for(int j=0;j<10;j++){
	    if(map[i][j] == 0) ans1++;
	    ans2 = max(map[i][j] , ans2);
	}
    }
    writeln(ans1);
    writeln(ans2);
}

Measured memory_bytes: 2424
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>
#include<assert.h>

#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

int main()
{ios_base::sync_with_stdio(false);
int n;
cin>>n;
if(n==3)
{
	ol("2 5 63");
	return 0;
}
int s1=n-n/4,s2=n/4;
if(s2==0)s2=2,s1-=2;
if(s2%2==1)s2++,s1--;
vii v;
int x=0,su2=0;
rep(i,0,s1-1)
{
	x+=2;
	v.pb(x);
	su2+=x;
	su2%=6;
}

while(1)
{
	if(su2%6==0)break;
	v[v.size()-1]+=2;
	su2+=2;
	su2%=6;
}
x=3;
int su3=0;
rep(i,0,s2-1)
{
	
	v.pb(x);
	su3+=x;
	su3%=6;
	x+=6;
}
while(1)
{
	if(su3%6==0)break;
	v[v.size()-1]+=6;
	su3+=6;
	su3%=6;
}
rep(i,0,n-1)
{
	assert(v[i]<=30000);
}
assert(v.size()==n);
int gg=v[0];
rep(i,0,n-1)gg=__gcd(gg,v[i]);
//assert(gg==1);
rep(i,0,n-1)
{
	ol(v[i]);os;
}
return 0;
}



Measured memory_bytes: 640
import math
n = int(input())
c = [0] * (n-1)
s = [0] * (n-1)
f = [0] * (n-1)
for i in range(n-1):
    cc,ss,ff = map(int,input().split())
    c[i] = cc
    s[i] = ss
    f[i] = ff

ans = [0] * n

for i in range(n-1):
    t = s[i] + c[i]
    for j in range(i+1,n-1):
        if t <= s[j]:
            t = c[j] + s[j]
        else:
            tmp = t - s[j]
            if t % f[j] == 0:
                t +=  c[j]
            else:
                t += f[j] - (t % f[j]) + c[j]
    ans[i] = t
    print(t)
print(0)


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

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

		    long n = sc.nextLong();
		    long a = sc.nextLong();
		    long b = sc.nextLong();
		    long count = 0;
		    
		    
		    if(a > b) {
		    	count = 0;
		    }else {
		    	if(n ==1) {
		    		if(a == b) {
		    			count = 1;
		    		}else {
		    			count = 0;
		    		}
		    	}else {
		    		count = (b-a)*(n-2)+1;
		    	}
		    }
		    System.out.println(count);
		    
		    sc.close(); }
}

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

int main(){

 string s;
 cin>>s;

 int x=0;

 for(int i=0;i<3;i++){
     if(s[i]==s[i+1]){
         x=1;
     }
 }

 if(x==0)cout<<"Good"<<endl;
 else cout<<"Bad"<<endl;

return 0;
}

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

static const int INF=1e9;
static const int MOD=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int N; cin >> N;
    string s; cin >> s;
    set<string> ans;
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            for(int k=0;k<=9;k++){
                bool flag1=false,flag2=false,flag3=false;
                int tmp=i;
                for(int right=0;right<N;right++){
                    int res=s[right]-'0';
                    if(res==i&&!flag1){
                        flag1=true;
                        continue;
                    }
                    if(flag1&&res==j&&!flag2){
                        flag2=true;
                        continue;
                    }
                    if(flag1&&flag2&&res==k){
                        flag3=true;
                    }
                }
                if(flag1&&flag2&&flag3){
                    string tmp=to_string(i)+to_string(j)+to_string(k);
                    //cout << tmp << endl;
                    ans.insert(tmp);
                }
            }    
        }
    }
    cout << ans.size() << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std ;
#define LL long long
int a[200010] ;
int b[20][200010] , sum[20][200010] ;
int two[20] ;
int main(){
    int n ;
    cin >> n ;
    for( int i = 1 ; i <= n ; i++ )
        scanf( "%d" , &a[i] ) ;
    two[0] = 1 ;
    for( int i = 1 ; i < 20 ; i++ )
        two[i] = two[i - 1] * 2 ;
    for( int i = 1 ; i <= n ; i++ ){
        int r = a[i] ;
        for( int j = 19 ; j >= 0 ; j-- ){
            b[j][i] = r / two[j] ;
            r %= two[j] ;
        }
    }
    for( int i = 0 ; i < 20 ; i++ )
        for( int j = 1 ; j <= n ; j++ )
            sum[i][j] = sum[i][j - 1] + b[i][j] ;
    LL ans = 0 ;
    for( int i = 1 ; i <= n ; i++ ){
        int l = i ;
        int r = n + 1 ;
        while( l + 1 < r ){
              int mid = ( l + r ) >> 1 ;
              bool flag = true ;
              for( int j = 0 ; j < 20 ; j++ ){
                  int res = sum[j][mid] - sum[j][i - 1] ;
                  if ( res > 1 ) flag = false ;
              }
              if ( flag ) l = mid ;
              else r = mid ;
        }
        ans += l - i + 1 ;
    }
    cout << ans << endl ;
    return 0 ;
}


Measured memory_bytes: 32256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long

int main() {
 int n,m;
 cin>>n>>m;
 int num[n]={0};
 rep(i,m){
     int a,b;
     cin>>a>>b;
     a--;b--;
     num[a]++;
     num[b]++;
 }
 rep(i,n){
     cout<<num[i]<<endl;
 }

}

Measured memory_bytes: 256
from collections import OrderedDict

# トランプの生成
cards = OrderedDict()  # 順序付き辞書
for s in ['S', 'H', 'C', 'D']:
    for r in range(1, 13 + 1):
        key = "{} {}".format(s, r)
        cards[key] = False

count = int(input())

# 所持しているトランプの処理
for n in range(count):
    input_key = input()
    cards[input_key] = not(cards[input_key])  # 真理値を反転 (Trueへ)

# 不足しているトランプの表示
for k, v in cards.items():
    if not v:
        print(k)


Measured memory_bytes: 5992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N=3010,M=1000010;
int P;
const int inf=0x3f3f3f3f;
const int INF=0xcfcfcfcf;
const double eps=1e-6,pi=asin(1)*2;
inline ll read();
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
inline int ADD(int a,int b) { return a+b>=P?a+b-P:a+b; }
inline int MINUS(int a,int b) { return a-b<0?a-b+P:a-b; }
#define plus(a,b) a=ADD(a,b)
#define minus(a,b) a=MINUS(a,b)
#define mul(a,b) a=(a*(b))%P
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp(x,y) make_pair(x,y)

int n;
inline int quickmi(int x,int n,int p=P)
{
	int res=1;
	for(;n;n>>=1)
	{
		if(n&1) res=1ll*res*x%p;
		x=1ll*x*x%p;
	}
	return res;
}

int S[N][N];
int C[N][N];

inline void init(int n=3005)
{
	S[0][0]=1;
	for(int i=0;i<=n;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++)
			C[i][j]=ADD(C[i-1][j-1],C[i-1][j]),
			S[i][j]=ADD(S[i-1][j-1],1ll*S[i-1][j]*j%P);
	}
/*
	for(int i=0;i<=5;i++)
	{
		for(int j=0;j<=i;j++) cerr<<S[i][j]<<" ";
		cerr<<"\n";
	}
//*/
}

#ifdef FILE
char buf[1<<25],*p1=buf,*p2=buf;
#define getchar() p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<25,stdin),p1==p2)?EOF:*p1++
#endif
inline ll read()
{
	ll s=0;
	bool flag=false;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') flag=true;
	for(;'0'<=ch&&ch<='9';ch=getchar()) s=(s<<3)+(s<<1)+(ch^'0');
	if(flag) return -s;
	return s;
}

int main()
{
#ifdef FILE
	freopen(FILE ".in","r",stdin);
	freopen(FILE ".out","w",stdout);
#endif
	n=read(),P=read();
	init();
	int ans=0;
	for(int i=0;i<=n;i++)
	{
		int sum=0,mi1=quickmi(2,quickmi(2,n-i,P-1)),mi2=quickmi(2,n-i);
		for(int j=0,tmp=1;j<=i;j++,tmp=1ll*tmp*mi2%P)
			plus(sum,1ll*S[i+1][j+1]*tmp%P);
//		cerr<<i<<" "<<sum<<" "<<C[n][i]<<" "<<mi1<<"\n";
		sum=1ll*sum*C[n][i]%P*mi1%P;
		if(i&1) minus(ans,sum);
		else plus(ans,sum);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 69760
#include "bits/stdc++.h"
using namespace std;

int main(){

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

	ios::sync_with_stdio(false),cin.tie(0);

	int n; cin >> n;
	int m; cin >> m;
	int d; cin >> d;
	cout <<  m/d - (n-1)/d << endl;

	return 0;
}

Measured memory_bytes: 3604
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll x, y;
  cin >> x >> y;
  rep(i, 100){
    rep(j, 100){
      if(i+j==x && 2*i+4*j==y){
        Pr(1);
      }
    }
  }
  Pr(0);
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repin(a, n)  \
    vector<ll> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repins(a, n)     \
    vector<string> a(n); \
    rep(i, n) { cin >> a[i]; }
#define repind(a, n)     \
    vector<double> a(n); \
    rep(i, n) { cin >> a[i]; }
#define in(a) \
    ll a;     \
    cin >> a;
#define ins(a) \
    string a;  \
    cin >> a;
#define ind(a) \
    double a;  \
    cin >> a;
template <class T>
inline void out(T a) {
    cout << a << endl;
}
inline void out(double a) { printf("%.10f\n", a); }
#define all(x)        (x).begin(), (x).end()
#define rep2(i, a, b) for (ll i = (a); i < (b); ++i)
#define yes           out("Yes");
#define no            out("No");

int main() {
    in(n);
    in(k);
    repin(p, n);
    sort(all(p));

    ll ans = 0;

    rep(i, k) {
        ans += p[i];
    }
    out(ans);
}

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

int main() {
  
  	int A,B;
  	string op;
  	cin >> A >> op >> B;
  
  	if(op=="+"){
    	cout << A + B << endl;
    }
  	else{
    	cout << A - B << endl;
    }
}

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


already_city = [-1 for i in range(N)]
already_city[0] = 0
dep_city = 1

move_count  = 0
while move_count < K:
    move_count += 1
    dep_city = A[dep_city - 1]
    if already_city[dep_city - 1] == -1:
        already_city[dep_city - 1] = move_count
    else:
        loop_count = move_count - already_city[dep_city - 1]
        remain_ = K - move_count
        div_loop_count = remain_ % loop_count
        ans_list_num = div_loop_count + already_city[dep_city - 1]
        dep_city = already_city.index(ans_list_num) + 1
        break
        
        
print(dep_city)

Measured memory_bytes: 32380
#include<iostream>
using namespace std;
int main(){
  long long n,d,x,y;
  int count=0;
  cin >> n >> d;
  for(int i=0; i<n; i++){
    cin >> x >> y;
    if(x*x+y*y<=d*d)count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
	vector<char> letter;
	ll n;
	cin>>n;
	while(n>0)
	{
		n--;
//		cout<<"Make to: "<<n<<" and mod: "<<n%26<<"\n";
		letter.push_back((char)('a'+(n%26)));
		n/=26;
	}
	for(int i=letter.size()-1; i>-1; i--)
		cout<<letter[i];
}
int main()
{
//	ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3636
import math
a, b, h, m = map(int, input().split())

## 短針の角度取得
rShort = (h * (360 / 12)) + m * 1/2;

## 長針の角度取得
rLong = m * (360 / 60);

## 角度取得
ang = abs(rLong - rShort);

## 角度が小さいほうを表示
ang = min(ang, (360 - ang));

print(math.sqrt(a**2 + b**2 - 2*b*a*math.cos(math.radians(ang))))

Measured memory_bytes: 9516
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f,oo = inf;
#define IL inline
#define RG register
#define rep(i,a,b) for(RG int i=(a);i<int(b);++i)
#define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
#define Dep(i,a,b) for(RG int i=(a);i>=(b);--i)
#define pc putchar
#define gc getchar
IL ll read(){
    RG ll x=0;char f=0;RG char c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return f?-x:x;
}
IL void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);pc(x%10+'0');}
IL void writeln(ll x){write(x);puts("");}
#define mem(x,v) memset(x,v,sizeof(x))
const ll N=3000010;
ll cant[N],n,K,Q;
ll b[N],c[N],ans[N],answ;
pair<int,int> a[N];
int main(){
	answ = inf;
	n=read();
	K=read();
	Q=read();
	Rep(i,1,n)a[i]=make_pair(b[i]=read(),i);
	sort(a+1,a+n+1);cant[n+1]=1;
	Rep(i,1,n-K+1){
		ll pos=1;
		Rep(j,1,n)c[j]=b[j];
		for(;cant[pos];++pos);
		ans[0]=0;
		for(;pos<=n;)if (!cant[pos]){
			ll Pos=pos;
			for(;!cant[Pos+1];++Pos);
			sort(c+pos,c+Pos+1);
			Rep(k,pos,Pos-K+1)ans[++ans[0]]=c[k];
			pos=Pos+1;
		}else	pos++;
		sort(ans+1,ans+ans[0]+1);
		if (ans[0]>=Q)answ=min(answ,ans[Q]-ans[1]);
		cant[a[i].second]=1;
	}writeln(answ);
}

/*
给你一个n个点，m条边的无向图
一开始，你可以选择一个节点，并拥有w元钱
每次，你可以进行两种操作中的一种
1、走向相邻的一个节点(v)，要满足你当前拥有的前不少于A[v]
2、把这个节点(v)激活，花费B[v]的钱。
如果把所有节点都激活，任务胜利
问最小的w满足这个条件。 
*/

Measured memory_bytes: 8448
//Look at my code, my code is clean :3
//Khánh đẹp trai
#include <bits/stdc++.h>
#define FORUP(i, start, end) for (int i = start; i <= end; i++)
#define FORDOWN(i, end, start) for (int i = end; i >= start; i--)
#define mem(a, v) memset(a, v, sizeof a)
#define ll long long
#define ld long double
#define pir pair<int, int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

const ll MAX = 20, MOD = 1000000007, BASE = 311, inf  = 1e9;

int du[] = {1, 0}, dv[] = {0, 1};
struct node {
    ll v; ll d; ll e;
};

using namespace std;

string s;

int main()
{
    fast_io;
    cin >> s;
    if(s.back() == 's') cout << s << "es" << endl;
    else cout << s << "s" << endl;

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

int K;
cin >> K;
vi A = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
cout << A[K-1] << endl;

return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <utility>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

int main(){

    int n, q, processtime=0;
    cin >> n >> q;
    queue<pair<string, int>> p;

    string tmps;
    int tmpi;
    REP(i,n){
        cin >> tmps >> tmpi;
        p.push(make_pair(tmps,tmpi)); 
    }

    while(!(p.empty())){
        if(p.front().second<=q){
            processtime += p.front().second;
            cout << p.front().first <<" " << processtime << endl;
            p.pop();
     
        }else{
            p.front().second -= q;
            p.push(p.front());
            p.pop();
            processtime += q;
        }
    }


    return 0;
}


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

int main()
{
  double pi = 3.141592653589;
  double r,l,s;

  cin >> r;

  l = 2*r*pi;
  s = r*r*pi;

  cout << fixed << setprecision(6) << s <<" "
       << fixed << setprecision(6) << l << endl;
}



Measured memory_bytes: 3252
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;


const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll MAXN = 3e2 + 10;
const ll INF = 1e18;
char a[MAXN][MAXN];
ll n;

void Shift(){
	for (int i = 0; i < n; i ++){
		char c = a[i][n - 1];
		for (int j = n - 1; j > 0; j--){
			a[i][j] = a[i][j - 1];
		}
		a[i][0] = c;
	}
	
	
	
	
}

bool isval(){
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			if (a[i][j] != a[j][i]) return 0;
		}
	}
	return 1;
	
	
}
void Shift1(){
	for (int i = 0; i < n; i++){
		char c = a[n - 1][i];
		for (int j = n - 1; j > 0; j--){
			a[j][i] = a[j - 1][i];
		}
		a[0][i] = c;
	}
	
	
	
	
	
}



int main(){
	IOS;
	cin >> n;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			cin >> a[i][j];
		}
	}
	ll ans = 0;
	if (isval()) ans += n;
 	for (int i = 1; i < n; i++){
		Shift();
		if (isval()){
			ans += n - i;
			//cout << i << '\n';
		}
	}
	Shift();
	/*for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j ++) cout << a[i][j];
		cout << endl;
 	}*/
	for (int i = 1; i < n; i++){
		Shift1();
		if (isval()){
			//cout << i << ' ';
			ans += n - i;
		}
	}
	kill(ans);

	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <climits>
#include <queue>

using namespace std;

const int kSize = 100001;

vector<int> V;

struct Node {
    int to;
    int weight;

    Node(int _to, int _weight) {
        to = _to;
        weight = _weight;
    }
};

int n;
vector<Node> adj[kSize];
bool isMarked[kSize];
int tree[kSize];
int dis[kSize];

void Dijkstra(int s) {
    dis[s] = 0;
    priority_queue<pair<int, int>, vector<pair<int, int> >, greater<> > pq;

    pq.push(make_pair(s, 0));
    isMarked[s] = true;
    tree[s] = s;

    while (!pq.empty()) {
        pair<int, int> p = pq.top();
        pq.pop();
        int from = p.first;
        for (int i = 0; i < adj[from].size(); ++i) {
            int to = adj[from][i].to;
            if (!isMarked[to]) {
                if (dis[from] + adj[from][i].weight < dis[to]) {
                    dis[to] = dis[from] + adj[from][i].weight;
                    tree[to] = from;
                    pq.push(make_pair(to, dis[to]));
                }
            }
        }
    }
}

int main() {
    fill(isMarked, isMarked + kSize, false);
    fill(dis, dis + kSize, INT_MAX);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; ++j) {
            int v, c;
            cin >> v >> c;
            adj[u].emplace_back(v, c);
        }
    }

    Dijkstra(0);
    for (int i = 0; i < n; ++i) {
        cout << i << " " << dis[i] << endl;
    }
}


Measured memory_bytes: 5988
//package com.company;
import java.util.*;
import java.lang.*;
import java.io.*;
//****Use Integer Wrapper Class for Arrays.sort()****
public class Main {
    static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
    public static void main(String[] Args)throws Exception{
        FastReader scan=new FastReader(System.in);
        int t=1;
//        t=scan.nextInt();
        while(t-->0){
            int n=scan.nextInt();
            long mod=1000000007;
            long ans=power(10,n);
            ans=(ans-power(9,n)+mod)%mod;
            ans=(ans-power(9,n)+mod)%mod;
            ans=(ans+power(8,n))%mod;
            out.println(ans);
        }
        out.flush();
        out.close();
    }
    static long power(long x, long y){
        long res = 1;
        long mod=1000000007;
        while (y > 0)
        {
            if (y%2!=0)
                res = (res*x)%mod;
            y>>=1;
            x=(x*x)%mod;
        }
        return res;
    }
    static class FastReader {

        byte[] buf = new byte[2048];
        int index, total;
        InputStream in;

        FastReader(InputStream is) {
            in = is;
        }

        int scan() throws IOException {
            if (index >= total) {
                index = 0;
                total = in.read(buf);
                if (total <= 0) {
                    return -1;
                }
            }
            return buf[index++];
        }

        String next() throws IOException {
            int c;
            for (c = scan(); c <= 32; c = scan()) ;
            StringBuilder sb = new StringBuilder();
            for (; c > 32; c = scan()) {
                sb.append((char) c);
            }
            return sb.toString();
        }

        int nextInt() throws IOException {
            int c, val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
        long nextLong() throws IOException {
            int c;
            long val = 0;
            for (c = scan(); c <= 32; c = scan()) ;
            boolean neg = c == '-';
            if (c == '-' || c == '+') {
                c = scan();
            }
            for (; c >= '0' && c <= '9'; c = scan()) {
                val = (val << 3) + (val << 1) + (c & 15);
            }
            return neg ? -val : val;
        }
    }
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(-1.0);
const int limit = 100010;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    int ans = 0;
    while (a[1] != a[2]) {
        a[0]++;
        a[1]++;
        ans++;
    }

    if ((a[2] - a[0]) % 2 == 0) {
        ans += (a[2] - a[0]) / 2;
    } else {
        ans += (a[2] - a[0]) / 2 + 2;
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
  string s; cin>>s;
  int n=s.size(), win=0;
  for(int i=0; i<n; ++i){
    if(s[i]=='o')++win;
  }

  if(win+15-n>=8)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <numeric>
#include <queue>
#include <unordered_set>                // 0. include the library
#include <atomic>
#include <array>

using namespace std;

int main(){

    int cnt = 0;
    bool ret = false;
    int N = 0;
    cin >> N;
    
    for(int i=0; i<N; i++){
        int a, b;
        cin >> a >> b;
        if(a == b){
            cnt++;
            if(3 == cnt){
                ret = true;
                break;
            }
            else{
                /* nothing */
            }
        }
        else{
            cnt = 0;
        }
    }

    if(true == ret){
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    

    return (0);
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  string s;
  cin>>s;
  cout<<(s=="ABC" ? "ARC" : "ABC")<<'\n';
  return 0;
}


Measured memory_bytes: 3616