akhauriyash/Code-Regression huggingface dataset:
#エラトネスの篩
def Eratosthene(n):
    prime = [1]*(n+1)
    prime[0] = 0
    prime[1] = 0

    for i in range(2, int(n**0.5)+1, 1):
        if prime[i]==0:
            continue
        for j in range(i+1, n+1, 1):
            if prime[j]==0:
                continue
            if j%i==0:
                prime[j] = 0
    return prime

prime = Eratosthene(10**3)
P = []
for i in range(10**3+1):
    if prime[i]==1:
        P.append(i)

N = int(input())

ANS = 1
for p in P:
    a = p
    ans = 0
    while 1:
        if N/p>0:
            ans = ans + int(N/p)
        else:
            break
        p = p*a
    ANS = ANS * (ans+1)
print(ANS%(10**9+7))

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

double memo[150010][2];
int edge[150010][2];
int edc[150010];
vector<int> lis[150010];
double dfs(int j, int d)
{
    if (memo[j][d] > -0.5) return memo[j][d];

    int nod = edge[j][d];
    if (edc[nod] == 1)
    {
        return memo[j][d] = 1;
    }
    double ret = 0;
    for (int item : lis[nod])
    {
        if (item == j) continue;

        ret += dfs(item, edge[item][0] == nod ? 1 : 0) + 1;
    }
    return memo[j][d] = ret / (edc[nod] - 1);
}

int main() {
    int n;
    cin >> n;
    if (n == 1)
    {
        cout << "0\n";
        return 0;
    }
    for (int i = 0; i < n - 1; i++)
    {
        memo[i][0] = memo[i][1] = -1;
        scanf("%d %d", &edge[i][0], &edge[i][1]);
        --edge[i][0];
        --edge[i][1];
        ++edc[edge[i][0]];
        ++edc[edge[i][1]];
        lis[edge[i][0]].emplace_back(i);
        lis[edge[i][1]].emplace_back(i);
    }
    double ans[150010];
    for (int i = 0; i < n; i++)
    {
        ans[i] = 0;
        if (edc[i] == 1 && edge[lis[i][0]][0] + edge[lis[i][0]][1] - i < i)
        {
            int j = edge[lis[i][0]][0] + edge[lis[i][0]][1] - i;
            printf("%.9f\n", ans[i] = (ans[j] * edc[j] - 1) / (edc[j] - 1) + 1);
            continue;
        }
        for (int item : lis[i])
        {
            ans[i] += dfs(item, edge[item][0] == i ? 1 : 0);
        }
        ans[i] /= edc[i];
        printf("%.9f\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 21376
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
int main() {
  IOS;
  int n, x, t;
  cin >> n >> x >> t;
  cout << t * (n / x) + (n % x != 0) * t << endl;
}


Measured memory_bytes: 3660
/* THEORY

(1) x1 + x2 + x3 = x, 1 <= x1 <= n, 1 <= x2 <= n, 1 <= x3 <= n, x1 < x2 < x3.

For x1 < x2,
(2) x2 < x - x1 - x2 <= n.

For x1,
(3) x2 > x1, x2 < (x - x1) / 2, x2 >= x - x1 - n.

Therefore,
(4) max(x1 + 1, x - x1 - n) <= x2 < ceil( (x - x1) / 2 ).

*/

function linear_solve(n, x) {
	var res = 0, x1, bottom, top;
	for (x1 = 1; x1 <= n; x1++) {
		bottom = Math.max(x1 + 1, x - x1 - n);
		top = Math.ceil( (x - x1) / 2 );
		res += (top > bottom) ? (top - bottom) : 0;
	}
	return res;
}

/*
const assert = require('assert');
assert(linear_solve(5, 9) === 2);
assert(linear_solve(1, 6) === 0);
assert(linear_solve(2, 6) === 0);
assert(linear_solve(3, 6) === 1);
assert(linear_solve(4, 6) === 1);
assert(linear_solve(4, 7) === 1);
assert(linear_solve(4, 8) === 1);
assert(linear_solve(5, 8) === 2);
*/

line = require('fs').readFileSync('/dev/stdin', 'ascii').split(/\r?\n/);
for (i in line) {
	if (line[i] === '0 0') break;
	nx = line[i].split(' ');
	console.log(linear_solve(nx[0], nx[1]));
}

Measured memory_bytes: 16140
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
bool diff(long long a, long long b) {
  if (a < 0 && b > 0) return true;
  if (a > 0 && b < 0) return true;
  return false;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  long long ans = (a[0] == 0 ? 1 : 0), sum = (a[0] == 0 ? 1 : a[0]);
  FOR(i, 1, n) {
    if (diff(sum + a[i], sum)) {
      sum += a[i];
    } else {
      long long need = (sum > 0 ? -1 : 1);
      long long now = need - sum;
      ans += abs(now - a[i]);
      sum = need;
    }
  }
  long long tmp = abs(a[0]) + 1;
  sum = (a[0] >= 0 ? -1 : 1);
  FOR(i, 1, n) {
    if (diff(sum + a[i], sum)) {
      sum += a[i];
    } else {
      long long need = (sum > 0 ? -1 : 1);
      long long now = need - sum;
      tmp += abs(now - a[i]);
      sum = need;
    }
  }
  cout << min(ans, tmp) << '\n';
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

int n, r;

void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> n >> r;
    int ans = 0;
    if (n >= 10)
        ans = r;
    else
        ans = r + 100 * (10 - n);
    cout << ans << endl;
    solve();
    return 0;
}


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

int main(){
  while(true){
  int n,h,total=0;
  cin>>n;
  if(n==0){
    break;
  }
  for(int i=0;i<n/4;i++){
    cin>>h;
    total=total+h;
  }
  cout<<total<<endl;
  }

    return 0;
}

Measured memory_bytes: 1160
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define free  freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define Fast  ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second

bool vowel(char che)
{
    if (che == 'A' || che == 'E' || che == 'I' || che == 'O' || che == 'U' || che == 'Y')
        return true;
    else
        return false;
}

const int N = 1e6+5;
const int mod = 1e9+7;
ll a[N], b[N], c[N], d, dp[N], dis;
//pair <ll, ll> p[N], p1[N];
char o;
bool mark[N], h;
string s, s1;
//stack <int> st;
//set <ll> st1, st2;
//deque <int> dq;
//vector <ll> vm, vp, vt[N];
//int a1[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main()
{
    Fast
    ll t, n, m, k = 0, f = 0, sum = 0, ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    b[n-1] = 0;
    for (int i = n-2; i >= 0; i--){
        b[i] += a[i+1]+b[i+1];
        b[i] %= mod;
    }
    for (int i = 0; i < n-1; i++){
        ans += 1ll*a[i]*b[i];
        ans %= mod;
    }
    cout << ans%mod << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];
#define int long long

signed main(){
    int N,M;
    cin >> N >> M;
    vector<int> dislike(M,N);
    rep(i,N){
        int K; cin >> K;
        rep(k,K){
            int A; cin >> A;
            dislike[--A]--;
        }
    }
    int everyone_like = M;
    rep(i,M){
        if(dislike[i]) everyone_like--;
    }
    cout << everyone_like << endl;
}

Measured memory_bytes: 256
import fractions
from functools import reduce

n=int(input())
a1=[int(i) for i in input().split()]
a2=[]
a3=[]
nul2 = a1[0]
nul3 = a1[-1]
a2.append(nul2)
a3.append(nul3)
#nが2以上?
for i in range(1,n-1):
    nul2=fractions.gcd(nul2,a1[i])
    nul3=fractions.gcd(nul3,a1[-i-1])
    a2.append(nul2)
    a3.append(nul3)
#print(a2)
#print(a3)
c=max([a2[-1],a3[-1]])
for i in range(n-2):
    d=fractions.gcd(a2[i],a3[-i-2])
    if d>c:
        c=d
print(c)


Measured memory_bytes: 16148
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int n, m;
char s[55][55];
int main() {
	scanf("%d%d", &n, &m);
	for(int i = 0; i < n; i++)scanf("%s", s[i]);
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			if(s[i][j] != '#') {
				int cnt = 0;
				for(int x = -1; x <= 1; x++)
					for(int y = -1; y <= 1; y++) {
						int dx = i + x;
						int dy = j + y;
						if(dx >= 0 && dx < n && dy >= 0 && dy < m) {
							if(s[dx][dy] == '#')cnt++;
						}
					}
				printf("%d", cnt);
			}
			else printf("%c", s[i][j]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include <stack>
using namespace std;
int gcd(int a,int b);
bool bigprime(int a);

int main(){

  int n;
  while(  cin >> n && n!=0){



    
    int data[25][24];
    for(int i=0;i<25;i++){
      for(int j=0;j<24;j++){
	data[i][j]=0;
      }
    }
    int day,now,inp;
    for(int i=0;i<n;i++){
      cin >> day >> now;
      
      for(int j=0;j<day;j++){
	cin >> inp;
	  data[day][(j+day-now)%day]+=inp;
      }
      
    }

    int ans=0,max=0,temp=0;
  
    for(int i=0;i<55440;i++){

      for(int j=1;j<25;j++){
	if(!bigprime(j)){
	  temp+=data[j][i%j];
	}
      }
      if(temp>ans)ans=temp;
      temp=0;
    }
    
    for(int i=13;i<24;i++){
      if(bigprime(i)){
	for(int j=0;j<i;j++){
	  if(max<data[i][j])max=data[i][j];
	}
	ans+=max;
	max=0;
      }
    }
    cout << ans << endl;
  }
}

int gcd(int a,int b){
  if(a<b){
    int t=a;
    a=b;
    b=t;
  }

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

bool bigprime(int a){
  if(a==13||a==19||a==17||a==23){
    return true;
  }else{
    return false;
  }
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
#define INF 1000000

int n;

void matrixChainOrder(int* p){
  int i,j,l,k,q;
  int m[100][100];
 
  for(i=1;i<=n;i++){
    m[i][i] = 0;
  }
 
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j = i+l-1;
      m[i][j] = INF;
      for(k=i;k<j;k++){
    q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
    m[i][j] = min(m[i][j],q);
      }
    }
  }
  printf("%d\n",m[1][n]);
}
 
int min(int x,int y){
  if(x<y)return x;
  else return y;
}

int main(){
  int *p,i;
   
  scanf("%d",&n);
   
  p = (int *)malloc(sizeof(int)*(n+2));
 
  for(i=0;i<n;i++){
    scanf("%d %d",&p[i],&p[i+1]);
  }
 
  matrixChainOrder(p);
 
  return 0;
}

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

using namespace std;

int64_t n, a, b, c, d;

int main()
{
  cin >> n >> a >> b >> c >> d;

  for (int i = 0; i <= n-1; i++) {
    int64_t x1 = -i*d, y1 = -i*c, x2 = (n-1-i)*c, y2 = (n-1-i)*d;
    if (x1+x2 <= b - a && b - a <= y1+y2) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;

  return 0;
}


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

int main() {
  int n, counter = 0;
  cin >> n;
  vector<int> vec(n);
  for(int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }

  bool stop = false;
  for(int i = 0; true; i++) {
    for(int j = 0; j < n; j++) {
      if(vec.at(j) % 2 == 0) {
        vec.at(j) /= 2;
      } else {
        stop = true;
        break;
      }
    }
    if(stop) break;
    counter++;
  }

  cout << counter << endl;
}


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).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; }

int dy[]={0, 0, 1, -1, 1, -1, -1, 1};
int dx[]={1, -1, 0, 0, 1, 1, -1, -1};

struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};


int main() {
    cout<<fixed<<setprecision(10);

    ll n,m; cin>>n>>m;
    vint a(n); rep(i,n) cin>>a[i];
    UnionFind uf = UnionFind(n);

    rep(i,m){
        int x,y; cin>>x>>y;
        uf.unite(x, y);
    }

    map<ll,priority_queue<ll, vint, greater<ll>>> forest;
    rep(i,n) forest[uf.find(i)].push(a[i]);

    ll nf = forest.size();


    if(( nf-1 )*2 > n) puts("Impossible");
    else if(nf == 1) puts("0");
    else{
        ll ans = 0;
        for(auto &p:forest){
            ans += p.second.top();
            p.second.pop();
        }

        priority_queue<ll, vint , greater<ll>> pq;
        for(auto &p:forest){
            while(!p.second.empty()){
                pq.push(p.second.top());
                p.second.pop();
            }
        }
        rep(i,nf-2){
            ans += pq.top();
            pq.pop();
        }
        cout<<ans<<endl;
    }



    return 0;

}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    long long a[3 * N];
    for (int i = 0; i < 3 * N; i++)
    {
        cin >> a[i];
    }
    sort(a, a + 3 * N);
    long long ans = 0;
    for (int i = 0; i < N; i++)
    {
        ans += a[3 * N - 2 * (i + 1)];
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()

typedef long long int ll;

ll num[50];
ll num2[50];
ll num3[50];
//ll num[ten52];
//stack<char> stk;
//set<ll> sll;
//map<string,ll> mp,mp1;
//map<string,ll>::iterator iter;
//map<ll,ll> mp;
//deque<char> deq;
priority_queue<double> pq;


int main(void)
{
    double ans=0.0,d,d1,d2,sumd=0.0;
    //float f,g,h;
    long long int m,n,i,j,k=1;
    long long int a,a1,a2,a3,sum;
    string s,s1,s2;
    char c,c1;
    sum=a=a1=a2=a3=0;
    cin>>n;
    for(i=0;i<n;i++) cin>>num[i];
    for(i=0;i<n;i++) cin>>num2[i];
    for(i=0;i<n;i++) num3[i]=i+1;
    /*for(i=0;i<n;i++) cout<<num[i];cout<<endl;
    for(i=0;i<n;i++) cout<<num2[i];cout<<endl;
    for(i=1;i<=n;i++) cout<<num3[i];cout<<endl;*/
    do
    {
        a++;
        for(i=0;i<n;i++)
        {
            k=1;
            if(num[i]!=num3[i])
            {
                k=0;
                break;
            }
        }
        if(k==1) a1=a;
        for(i=0;i<n;i++)
        {
            k=1;
            if(num2[i]!=num3[i])
            {
                k=0;
                break;
            }
        }
        if(k==1) a2=a;
        if(a1*a2!=0) break;
    }while(next_permutation(num3,num3+n));
    cout<<abs(a1-a2);
    return 0;
}

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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int m = max(max(a, b), c);
  int ans = a + b+ c - m;
  ans += m*pow(2, k);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	ll a,n;
	cin>>a;
	n=a;
	map<ll,int> s;
	while(n!=1){
roopstart:
		int hoge=sqrt(n);
		for(int i=2;i<=hoge;++i){
			if(n%i==0){
				auto itr=s.find(i);
				if(itr!=s.end()){
					++s[i];
				}else{
					s[i]=1;
				}
				n/=i;
				goto roopstart;
			}
		}
		if(1!=n){
			auto itr=s.find(n);
			if(itr!=s.end()){
				++s[n];
			}else{
				s[n]=1;
			}
		}
		break;
	}
	ll c=0;
	for(auto itr=s.begin();itr!=s.end();++itr){
		int i=0;
		for(;i<itr->second;++i,itr->second-=i);
		c+=i;
	}
	cout<<c;
}

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

int main(){
  int n,W;
  cin>>n>>W;
  int w[n],v[n];
  int DP[n+1][W+1];
  for(int i=0;i<n;i++){
    cin>>v[i]>>w[i];
  }
  for(int j=0;j<=W;j++){
    DP[0][j]=0;
  }
  for(int i=1;i<=n;i++){
    for(int j=0;j<=W;j++){
      if(j<w[i-1]){
        DP[i][j]=DP[i-1][j];
      }else{
        if(DP[i-1][j]>DP[i-1][j-w[i-1]]+v[i-1]){
          DP[i][j]=DP[i-1][j];
        }else{
          DP[i][j]=DP[i-1][j-w[i-1]]+v[i-1];
        }
      }
    }
  }
  cout<<DP[n][W]<<endl;
  return 0;
}



Measured memory_bytes: 7072
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9,MOD = 1e9+7,ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=0,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>n;
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    if(n%2==1){
    cmp=a[n/2];
    cnt=abs(cmp-a[0]);
    ll cntt=1;
    rep(i,n/2){
        if(cntt==n-1)break;
        cnt+=abs(a[i]-a[n-i-1]);
        cntt++;
        if(cntt==n-1)break;
        cnt+=abs(a[n-i-1]-a[i+1]);
        cntt++;
        if(cntt==n-1)break;
    }
    //Cout(cnt);
    ans=cnt;

    cnt=abs(cmp-a[n-1]);
    cntt=1;
    rep(i,n/2){
        if(cntt==n-1)break;
        cnt+=abs(a[i]-a[n-i-1]);
        cntt++;
        if(cntt==n-1)break;
        cnt+=abs(a[i]-a[n-i-2]);
        cntt++;
        if(cntt==n-1)break;
    }
    //Cout(cnt);
    ans=max(ans,cnt);
    }
    else{
        cmp=a[n/2-1];
        cnt=abs(cmp-a[0]);
        ll cntt=1;
        rep(i,n/2){
            if(cntt==n-1)break;
            cnt+=abs(a[i]-a[n-i-1]);
            cntt++;
            if(cntt==n-1)break;
            cnt+=abs(a[n-i-1]-a[i+1]);
            cntt++;
            if(cntt==n-1)break;
        }
        ans=max(ans,cnt);
        
        cmp=a[n/2-1];
        cnt=abs(cmp-a[n-1]);
        cntt=1;
        rep(i,n/2){
            if(cntt==n-1)break;
            cnt+=abs(a[i]-a[n-i-1]);
            cntt++;
            if(cntt==n-1)break;
            cnt+=abs(a[n-i-2]-a[i]);
            cntt++;
            if(cntt==n-1)break;
        }
        ans=max(ans,cnt);

        cmp=a[n/2];
        cnt=abs(cmp-a[n-1]);
        cntt=1;
        rep(i,n/2){
            if(cntt==n-1)break;
            cnt+=abs(a[i]-a[n-i-1]);
            cntt++;
            if(cntt==n-1)break;
            cnt+=abs(a[n-i-2]-a[i]);
            cntt++;
            if(cntt==n-1)break;
        }
        ans=max(ans,cnt);

        cmp=a[n/2];
        cnt=abs(cmp-a[0]);
        cntt=1;
        rep(i,n/2){
            if(cntt==n-1)break;
            cnt+=abs(a[i]-a[n-i-1]);
            cntt++;
            if(cntt==n-1)break;
            cnt+=abs(a[n-i-1]-a[i+1]);
            cntt++;
            if(cntt==n-1)break;
        }

        ans=max(ans,cnt);
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>

using namespace std;

long long cnt = 0;

void insertionSort(long long n,long long a[],long long interval){
  for(long long outer = interval;outer<n;outer++){
    long long value = a[outer];
    long long inner = outer - interval;
    while(inner>=0 && a[inner]>value){
      a[inner+interval] = a[inner];
      inner = inner - interval;
      cnt++;
    }
    a[inner+interval] = value;
  }
}



void shellsort(long long n, long long a[]){
  long long interval = 1;
  long long index = 0;
  long long inter[200] = {
    0
  };        
  if(n==1)inter[index++] = 1;
  while(interval<n){
   inter[index++] = interval; 
   interval = interval*3 + 1;
  }
   
    
  
  
  for(long long i = index-1;i>=0;i--){
    insertionSort(n,a,inter[i]);
    interval/=3;
  }
  
  cout << index << '\n';
  for(long long i=index-1;i>=0;i--){
    if(i==0)printf("%lli\n",inter[i]);
    else printf("%lli ",inter[i]);
  }
  printf("%lli\n",cnt);
  for(long long i=0;i<n;i++)printf("%lli\n",a[i]);
    
}

long long a[10000000] = {
  0
};


int main(){
  
long long n; cin >> n;
for(long long i=0;i<n;i++){
  cin >> a[i];
}

shellsort(n,a);


  
  
  return 0;
}


Measured memory_bytes: 10960
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  string s,t;
  cin>>s>>t;
  string ans="";
  rep(i,n){
    ans+=s[i];
    ans+=t[i];
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int H = sc.nextInt();

		int W = sc.nextInt();

		char[][] sky = new char[H][W];

		int[][] ans = new int[H][W];

		String str;

		for(int i=0;i<H;i++) {

			str = sc.next();

			for(int j=0;j<W;j++) {

				sky[i][j] = str.charAt(j);
			}
		}

		boolean flag;

		int r = 0;

		for(int i=0;i<H;i++) {

			flag = false;

			for(int j=0;j<W;j++) {

				if(sky[i][j]=='c') {

					ans[i][j] = 0;

					flag = true;

					r = j;

				}else if(flag == false){

					ans[i][j] = -1;

				}else if(flag == true){

					ans[i][j] = j-r;
				}
			}
		}

		for(int i=0;i<H;i++) {

			for(int j=0;j<W;j++) {

				System.out.print(ans[i][j]);

				if(j!=W-1) System.out.print(" ");
			}

			System.out.println();
		}
	}

}



Measured memory_bytes: 34764
#include <stdio.h>
#include <stdbool.h>

bool solve1(int *a, int *b, int *c);
bool solve2(int *a, int *b, int *c);

int main() {
	int a = 0;
	int b = 0;
	int c = 0;
	bool ans = false;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);

	ans = solve1(&a, &b, &c);
	ans = solve2(&a, &b, &c);

	if (ans == true) {
		printf("Yes");
	}
	else {
		printf("No");
	}
}

bool solve1(int *a, int *b, int *c) {
	if ((*a + *b + *c) % 2 == 0) {
		return true;
	}
	else{
		return false;
	}
}

bool solve2(int *a, int *b, int *c) {
	if ((*a + *b) == *c) {
		return true;
	}
	else if ((*a + *c) == *b) {
		return true;
	}
	else if ((*b + *c) == *a) {
		return true;
	}
	else {
		return false;
	}
}

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

int main(){
int w,h,x,y,r;
cin>>w>>h>>x>>y>>r;
if(x-r>=0 && x+r<=w && y-r>=0 && y+r<=h){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
}



Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

string a, b, c;

int main()
{
	cin >> a >> b >> c;
	cout << "A" << b[0] << "C" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(998244353)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  ll n;cin>>n;
  ll count[100004];
  vector<ll> D;
  rep(i,100002){
    count[i] = 0;
  }
  rep(i,n){
    ll d;cin>>d;
    D.push_back(d);
    count[d]++;
  }
  if(D[0] != 0){
    cout<<0<<endl;
    return 0;
  }

  ll memo = 0;
  ll ans = 1;
  rep(i,n){
    if(count[i] == 0) break;
    if(i == 0 && count[i] != 1){
      cout<<0<<endl;
      return 0;
    }
    if(i==0){
      memo++;
      continue;
    }
    ans *= mpow(count[i-1], count[i]);
    ans %= MOD;
    memo += count[i];
  }
  if(memo != n){
    cout<<0<<endl;
    return 0;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2168
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<cmath>
#include<vector>
#include<cstring>
#include<queue>
using namespace std;

int main(){
    int n,d;
    int ret;
    while(cin>>n>>d){
        d = 2*d+1;
        ret = n/d;
        if(n%d) ret++;
        cout<<ret<<endl;
    }

    return 0;
}

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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second

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

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

bool check(const vi& v) {
    REP(i, 1, v.size()) if (v[i - 1] > v[i]) return false;
    return true;
}

int main() {
#ifdef LOCAL_TEST
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    bool isPos = true, isNeg = true;
    rep(i, n) {
        if (a[i] < 0) isPos = false;
        if (a[i] > 0) isNeg = false;
    }
    if (check(a)) {
        cout << 0 << endl;
    }
    else if (isPos) {
        int mi = 0;
        rep(i, n) {
            if (a[mi] < a[i]) mi = i;
        }
        cout << n << endl;
        cout << mi + 1 << " " << 1 << endl;
        REP(i, 1, n) {
            cout << i << " " << i + 1 << endl;
        }
    } else if (isNeg) {
        int mi = 0;
        rep(i, n) {
            if (a[mi] > a[i]) mi = i;
        }
        cout << n << endl;
        cout << mi + 1 << " " << n << endl;
        for (int i = n - 1; i > 0; --i) {
            cout << i + 1 << " " << i << endl;
        }
    } else {
        int mi = 0;
        rep(i, n) {
            if (abs(a[mi]) < abs(a[i])) mi = i;
        }
        cout << 2 * n << endl;
        rep(i, n) cout << mi + 1 << " " << i + 1 << endl;
        if (a[mi] > 0) {
            cout << mi + 1 << " " << 1 << endl;
            REP(i, 1, n) {
                cout << i << " " << i + 1 << endl;
            }
        } else {
            cout << mi + 1 << " " << n << endl;
            for (int i = n - 1; i > 0; --i) {
                cout << i + 1 << " " << i << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
'use strict'
function Main(input) {
  input = input.split(" ");
  const r = input[0];
  const D = input[1];
  const xi = input[2];
  let result = xi;
  
  for(let i =0; i < 10; i++){
    result = result * r - D;
    console.log(result);
  }
  
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21320
use std::io::*;
use std::str::FromStr;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let x: i32 = sc.read();
    println!("{}", x*x*x);
}



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

int main() {
  int D;
  int N;
  int C;
  cin >> D >> N >> C;
    if ((D== N)&(N ==C)){
    cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
  int N;
  ll A, B;
  cin >> N >> A >> B;
  vector<ll> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }
  ll L = 0, R = 1e9 + 10;
  while (R - L > 1) {
    ll K = (L + R) / 2;
    ll need = 0;
    for (ll x: h) {
      need += (max(0ll, x - K * B) + (A - B) - 1) / (A - B);  
    }
    if (need <= K) {
      R = K;
    } else {
      L = K;
    }
  }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <math.h>

using namespace std;


bool isPrimeNumber(int Specimen){
	double DividedSqrt = sqrt(Specimen);
	for (int i = 2; i <= DividedSqrt; ++i){
		if (Specimen % i == 0 && Specimen != 2){
			return false;
		}
	}

	return true;

}

int main(){
	
	int NumberOfInput;
	int InputArray;
	int PrimeNumbersCount = 0;

	cin >> NumberOfInput;

	for (int i = 0; i < NumberOfInput; ++i){		
		cin >> InputArray;
		PrimeNumbersCount += (int)isPrimeNumber(InputArray);
	}

	cout << PrimeNumbersCount<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin >> s;
    if(s == "AKIHABARA" ||
       s == "AKIHABAR" ||
       s == "AKIHABRA" ||
       s == "AKIHBARA" ||
       s == "KIHABARA" ||
       s == "AKIHABR" ||
       s == "AKIHBAR" ||
       s == "KIHABAR" ||
       s == "AKIHBRA" ||
       s == "KIHABRA" ||
       s == "KIHBARA" ||
       s == "AKIHBR" ||
       s == "KIHABR" ||
       s == "KIHBAR" ||
       s == "KIHBRA" ||
       s == "KIHBR" ){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
}

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

#define int long long
#define pii pair<int, int>
#define pb push_back
#define lc (i<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)

int const N = 2e5 + 10;
int tree[4*N][2], lazy[4*N][2], row[N], col[N], n, Q;
int merge(int x, int y) { return min(x, y); }
int cnt(int l, int r){ return 1; } // 1 for RMQ

void build(int i,int l,int r, bool b){
    if(l == r){
        tree[i][b] = n;
        lazy[i][b] = n;
        return;
    }
    build(lc,l,mid,b);build(rc,mid+1,r,b);
    tree[i][b] = merge(tree[lc][b],tree[rc][b]);
    lazy[i][b] = n;
}
void propogate(int i, int l, int r, bool b) {
  if(l != r){lazy[lc][b] = min(lazy[lc][b], lazy[i][b]); lazy[rc][b] = min(lazy[rc][b], lazy[i][b]);}
  tree[i][b] = min(tree[i][b], lazy[i][b]); lazy[i][b] = min(lazy[i][b], n);
}

void update(int i, int l, int r, int ql, int qr, int val, bool b) {
  propogate(i, l, r, b);
  if(r < ql || l > qr) return;
  if(ql <= l && r <= qr)
  { lazy[i][b] = val; propogate(i, l, r, b); return; }
  update(lc, l, mid, ql, qr, val, b);
  update(rc, mid+1, r, ql, qr, val, b);
  tree[i][b] = merge(tree[lc][b], tree[rc][b]);
}

int query(int i, int l, int r, int ql, int qr, bool b) {
  propogate(i, l, r, b);
  if(r < ql || l > qr) return n; // -inf for RMQ
  if(ql <= l && r <= qr) return tree[i][b];
  int q1 = query(lc, l, mid, ql, qr, b);
  int q2 = query(rc, mid+1, r, ql, qr, b);
  return merge(q1, q2);
}


signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> Q;
    int ans = (n-2)*(n-2);
    build(1, 1, n, 0); build(1, 1, n, 1);
    while (Q--) {
        int t, x;
        cin >> t >> x;
        if (t == 1) {
            int min_col = query(1, 1, n, x, x, 1);
            ans -= max(0LL, (min_col - 2));
            update(1, 1, n, 1, min_col, x, 0);
        } else {
            int min_row = query(1, 1, n, x, x, 0);
            ans -= max(0LL, (min_row - 2));
            update(1, 1, n, 1, min_row, x, 1);
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 19972
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()

int main(){
  ll n, m;
  cin >> n >> m;
  ll ans = n * (n - 1) / 2 + m*(m - 1) / 2;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

void print_class(int a, int b, int c) {
  if (a == 100 || b == 100 || c == 100)
    printf("A\n");
  else if ((a + b) / 2 >= 90 || (a + b + c) / 3 >= 80)
    printf("A\n");
  else if ((a + b + c) / 3 >= 70)
    printf("B\n");
  else if ((a + b + c) / 3 >= 50 && (a >= 80 || b >= 80))
    printf("B\n");
  else
    printf("C\n");
}

int main(void) {
  int pm[10000], pe[10000], pj[10000], n, i;
  
  while (scanf("%d", &n) != EOF) {
    if (n == 0) break;
    
    for (i = 0; i < n; i++)
      scanf("%d %d %d", &pm[i], &pe[i], &pj[i]);
    
    for (i = 0; i < n; i++)
      print_class(pm[i], pe[i], pj[i]);
  }
  
  return 0;
}

Measured memory_bytes: 600
N = int(input())
mod = 10**9+7

answer_10 = 1
answer_9 = 1
answer_8 = 1

for _ in range(N):
  answer_10 = (answer_10*10)%mod
  answer_9 = (answer_9*9)%mod
  answer_8 = (answer_8*8)%mod

answer = (answer_10 - 2*answer_9 + answer_8)%mod

print(answer)

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

using namespace std;

int main()
{
    int l,p;
    cin>>l>>p;
    char arr[l];
    for(int i=1;i<=l;i++){
        cin>>arr[i];
    }
    arr[p]=arr[p]+32;
    for(int i=1;i<=l;i++){
        cout<<arr[i];
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<string> s(n + 1, "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz");
	vector<pair<int, string>> b(n);
	rep(i, n) { cin >> s[i]; }
	sort(s.begin(), s.end());
	int cnt = 1;
	int j = 0;
	rep(i, n) {
		if (s[i] != s[i + 1]) {
			b[j] = make_pair(-cnt, s[i]);
			cnt = 1;
			++j;
		}
		else ++cnt;
	}
	vector<pair<int, string>> e(j);
	rep(i, j) {
		e[i] = b[i];
	}
	sort(e.begin(), e.end());
	cout << e[0].second << endl;
	rep2(i, 1, j) {
		if (e[i - 1].first == e[i].first) cout << e[i].second << endl;
		else return 0;
	}

}



Measured memory_bytes: 19200
#include <iostream>

using namespace std;

int main(){
  int n;
  char m[1000][1001];
  while(cin>>n&&n){
    int a=0;
    for(int i=0;i<n;++i) cin>>m[i];
    for(int i=0;i<n-a;++i){
      for(int j=0;j<n-a;++j){
	if(m[i][j]=='.'){
	  bool f=true;
	  for(int k=1;f;++k){
	    for(int l=0;l<=k;++l){
	      if(m[i+l][j+k]!='.'){
		a=max(a,k);j+=k;f=false;break;
	      }
	      if(m[i+k][j+l]!='.'){
		a=max(a,k);j+=l;f=false;break;
	      }
	    }
	  }
	}
      }
    }
    cout<<a<<endl;
  }
  return 0;
}

Measured memory_bytes: 2140
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll a,b;
	cin>>a>>b;
	ll sub=abs(a-b)/2;
	if(sub*2==abs(a-b))
	cout<<sub+min(a,b);
	else
	cout<<"IMPOSSIBLE";
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		new Sol().Solve();
	}
}

class Sol{
	public void Solve(){
		
		while(true){
			var d=ria();
			N=d[0];M=d[1];P=d[2];
			if(N==0&&M==0&&P==0)return;
			int Inf=(int)1e9;
			int[][] WF=new int[N][];
			for(int i=0;i<N;i++){
				WF[i]=new int[N];
				for(int j=0;j<N;j++){
					WF[i][j]=(i==j)?0:Inf;
				}
			}
			
			E=new List<Pair>[N];
			for(int i=0;i<N;i++)E[i]=new List<Pair>();
			
			for(int i=0;i<M;i++){
				d=ria();
				E[d[0]].Add(new Pair(d[1],d[2]));
				E[d[1]].Add(new Pair(d[0],d[2]));
				WF[d[0]][d[1]]=WF[d[1]][d[0]]=d[2];
			}
			
			for(int k=0;k<N;k++){
				for(int i=0;i<N;i++){
					for(int j=0;j<N;j++){
						WF[i][j]=Math.Min(WF[i][j],WF[i][k]+WF[k][j]);
					}
				}
			}
			
			//0->N-1???????????????????????????????????§??????????????????
			//???????????????
			Pair[] tmp=new Pair[N];
			for(int i=0;i<N;i++){
				tmp[i]=new Pair(i,WF[i][N-1]);//???->N-1??????????????¢
			}
			Array.Sort(tmp,(x,y)=>x.Cost>y.Cost?-1:x.Cost<y.Cost?1:0);
			
			double[] dp=new double[N];//dp[i]:0??????i???????????????????????°
			dp[0]=1;
			for(int i=0;i<N;i++){
				int now=tmp[i].Pos;
				foreach(var next in E[now]){
					if(WF[now][N-1]==next.Cost+WF[next.Pos][N-1] && WF[now][0]+next.Cost==WF[next.Pos][0]){
						dp[next.Pos]+=dp[now];
					}
				}
			}
//for(int i=0;i<N;i++)Console.WriteLine("{0}-{1}",tmp[i].Pos,tmp[i].Cost);			
			for(;P>0;P--){
				int c=ri();
				double[] dp2=new double[N];//dp2[i]:c??????i???????????????????????°
				dp2[c]=1;
				for(int i=0;i<N;i++){
					int now=tmp[i].Pos;
					foreach(var next in E[now]){
//Console.WriteLine("now={0},0->now:{1} +now->next;{2} +next->N-1:{3},next={4},C:{5}",now,WF[0][now],next.Cost,WF[next.Pos][N-1],next.Pos,WF[0][N-1]);
						if(WF[now][N-1]==next.Cost+WF[next.Pos][N-1] && WF[now][0]+next.Cost==WF[next.Pos][0]){
							dp2[next.Pos]+=dp2[now];
						}
					}
				}
//Console.WriteLine("0->{0}:{1},->N-1:{2},tot={3}",c,dp[c],dp2[N-1],dp[N-1]);
				Console.WriteLine("{0:F12}",((double)dp[c]/(double)dp[N-1])*(double)dp2[N-1]);
			}
			Console.WriteLine();
		
		}
	}
	
	int N,M,P;
	List<Pair>[] E;
	
	class Pair{
		public int Pos,Cost;
		public Pair(int p,int c){
			Pos=p;Cost=c;
		}
	}
	
	
	

	public Sol(){
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}

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

int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int res = 0;
	for (int a = 0; a <= A; ++a) {
		for (int b = 0; b <= B; ++b) {
			for (int c = 0; c <= C; ++c) {
				int total = 500 * a + 100 * b + 50 * c;
				if (total == X) ++res;
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
ll n,a[101]; bool dp[100005];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout<<setprecision(12)<<fixed;
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,l,m,k;
    	cin>>n>>k;
    	rep(i,0,n)
    	cin>>a[i];
    	repi(i,0,k)
    	{
    		dp[i]=false;
		}
		repi(i,0,k)
		{
			rep(j,0,n)
			{
				if(i>=a[j] && !dp[i-a[j]])
				dp[i]=true;
			}
		}
    	if(dp[k]==true)
    	cout<<"First";
    	else
    	cout<<"Second";
    } 
	return 0;
}

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

using ll = long long;
#define REP(i, n) for(int (i)=0; (i)< (n); ++i)
#define REPR(i, n) for(int (i)=(n); (i)>=0; --i)
#define FOR(i, n, m) for(int (i)=(n); (i)<(m); ++i)
#define INF 1e9
int main(){
  int N, X, Y;
  cin >> N >> X >> Y;
  X--, Y--;
  vector<vector<int>> g(N);
  REP(i, N-1){
    g[i].push_back(i+1);
    g[i+1].push_back(i);
  }
  g[X].push_back(Y);
  g[Y].push_back(X);
  vector<int> ans(N, 0);
  REP(i, N){
    vector<int> dist(N, INF);
    queue<int> que;
    que.push(i);
    dist[i] = 0;
    while(!que.empty()){
      int v = que.front(); que.pop();
      for(auto nv : g[v]){
        if(dist[nv] != INF) continue;
        dist[nv] = dist[v] + 1;
        que.push(nv);
      }
    }
    FOR(j, i+1, N){
      ans[dist[j]]++;
    }
  }
  FOR(i, 1, N){
    cout << ans[i] << endl;
  }

  
  return 0;
}


Measured memory_bytes: 384
N,L = map(int, input().split())

lst = list()
for i in range(0, N):
    lst.append(L + i)

base = sum(lst)
div = abs(lst[0])
res = base - lst[0]
for i in range(1, len(lst)):
    if abs(lst[i]) < div:
        div = abs(lst[i])
        res = base - lst[i]

print(res)

Measured memory_bytes: 3316
import math
import functools

TARGET = 75

def main():
    l = [0]
    for j in range(1, 101):
        f = math.factorial(j)
        primes = prime_factorization(f)
        primes = [x for _, x in primes.items()]
        counts = []
        for i, _ in enumerate(primes):
            counts.append(0)
        l.append(count_divisor(primes, counts, 0, 0))
        print(j)
        print(l, flush=True)
    print(l)

def answer():
    buf = input()
    N = int(buf)
    table = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 8, 8, 11, 11, 11, 11, 14, 14, 32, 32, 35, 35, 35, 35, 42, 42, 42, 42, 49, 49, 49, 49, 49, 49, 75, 75, 86, 86, 86, 86, 86, 86, 123, 123, 131, 131, 131, 131, 148, 148, 153, 153, 170, 170, 170, 170, 170, 170, 227, 227, 227, 227, 227, 227, 250, 250, 323, 323, 324, 324, 324, 324, 354, 354, 354, 354, 384, 384, 384, 384, 384, 391, 491, 491, 529, 529, 529, 529, 529, 529, 543]
    print(table[N])

def prime_factorization(number):
    n = number
    i = 2
    factor = {}
    while i * i <= n:
        while n % i == 0:
            if i in factor:
                factor[i] += 1
            else:
                factor.update({i : 1})
            n //= i
        i += 1
    if n > 1 or not factor:
        if n in factor:
            factor[n] += 1
        else:
            factor.update({n : 1})
    return factor

def count_divisor(primes, counts, current, count):
    divisors = functools.reduce(lambda x, y: x*(y+1), counts, 1)
    if divisors >= TARGET:
        if divisors == TARGET:
            return count + 1
        else:
            return count
    new_counts = list(counts)
    for i in range(current, len(counts)):
        if counts[i] >= primes[i]:
            continue
        new_counts[i] += 1
        count = count_divisor(primes, new_counts, i, count)
        new_counts[i] -= 1
    return count

if __name__ == '__main__':
    #main()
    answer()


Measured memory_bytes: 3820