akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int k, s;
    cin >> k >> s;

    int cnt = 0;
    for (int x = 0; x <= k; x++) {
        for (int y = 0; y <= k; y++) {
            if (0 <= s - x - y && s - x - y <= k) cnt++;
        }
    }
    cout << cnt << endl;
}   

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <map>

#define rep(i, a, b) for ( long long  i = (a); i < (b); i++ )
#define per(i, a, b) for ( long long i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define pr_arr(name, a, b) \
  for (int i = (a); i < (b); i++) { \
    for (int j = (a); j < (b); j++) {\
      if (j > (a)) printf(" "); \
      printf("%lld", name[i][j]); \
    }\
    printf("\n");\
  }\

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

struct Sushi {
  ll t, d;
  
  bool operator< (const Sushi &s) const {
    return d < s.d;
  }
    bool operator> (const Sushi &s) const {
    return d > s.d;
  }
};

ll N, K, sum;
priority_queue<Sushi, vector<Sushi>, greater<Sushi> > S; //K個で同じ種類数のうち、最大の集合
priority_queue<Sushi> T;
map<ll, int> m;
vector<ll> ans;


int main(void) {
    scanf("%lld %lld", &N, &K);
    rep(i, 0, N) {
      Sushi s;
      scanf("%lld %lld", &s.t, &s.d);
      
      T.push(s);
    }
    
    ll num = 0; //S内のネタの種類数
    rep(i, 0, K) {
      Sushi t = T.top(); T.pop();
      if(m[t.t] == 0) {
        num++;
      }
      m[t.t]++;
      sum += t.d;
      S.push(t);
    }
    
    sum += num*num;
    ans.pb(sum);
    
    //S内の種類数がKになるか、TにSと同じ種類しか残されていないか、Tが空になるまで続ける
    while (num<K && !T.empty() && !S.empty()) {
      // TからSとネタが重複しないもののうち、最大おいしさのすしを選ぶ
      Sushi t = T.top(); T.pop();
      while(m[t.t] >= 1 && !T.empty()) {
        t = T.top(); T.pop();
      }
      if (m[t.t] >= 1) break;
      
      //Sから重複しているもののうち、最大おいしさの寿司を取り除く
      //空なら無視
      Sushi s = S.top(); S.pop();
      while (m[s.t] <= 1 && !S.empty()) {
        s = S.top(); S.pop();
      }
      if (m[s.t] <= 1) break;
      
      num += 1;
      if (m[s.t] >= 2) m[s.t]--;
      m[t.t]++;
      sum = sum - s.d + t.d + 2 * num - 1;
      ans.pb(sum);
      //printf("%lld\n", sum);
      
    }
    sort(ans.bg, ans.en, greater<ll>());
    
    
  
    printf("%lld\n", ans[0]);
    return 0;
}


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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

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

const ll mod=LLONG_MAX;

ll modPow(ll a,ll p){
	ll s=1;
	REP(i,30){
		if((p>>i)&1)
			s=s*a%mod;
		a=a*a%mod;
	}
	return s;
}

ll modInv(ll a){
	return modPow(a,mod-2);
}

int main(){
	string s;
	cin>>s;
	int n=s.size();
	ll ans=0;
	REP(i,n)
		ans+=ll(s[i]-'0')*modPow(10,n-1-i)*modPow(2,i);
	REP(i,n-1)
		ans+=ll(s[i]-'0')*modPow(2,n-2)*(modPow(5,n-1-i)-1)/4;
	cout<<ans<<endl;
}


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

int main()
{
    //偶数番目に出て来る文字のうち、最大のもの
    //奇数番目に出て来る文字のうち、最大のもの。それらが等しいときは、その次の数の比較。(それがないときはどんな文字でもいい的な感じ)
    ll n;
    cin >> n;
    map<ll, ll> o;
    map<ll, ll> e;
    for (int i = 0; i < n; i++)
    {
        ll j = 0;
        cin >> j;
        if (i % 2 == 0)
        {
            o[j] += 1;
        }
        if (i % 2 == 1)
        {
            e[j] += 1;
        }
    }
    priority_queue<ll> store1;
    priority_queue<ll> store2;
    for (auto x : o)
    {
        store1.push(x.second); //この最大値の値がどの数字なのかという情報がないと解けない(2つあればいける)。
    }
    for (auto y : e)
    {
        store2.push(y.second);
    }
    int max_o1, max_o2;
    int max_e1, max_e2;

    max_o1 = store1.top();
    // cout << max_o1 << endl;
    store1.pop();
    if (store1.empty())
    {
        max_o2 = 0;
    }
    else
    {
        max_o2 = store1.top();
    }
    max_e1 = store2.top();
    store2.pop();
    if (store2.empty())
    {
        max_e2 = 0;
    }
    else
    {
        max_e2 = store2.top();
    }
    int t;
    int u;
    int g;
    int h;
    for (auto x : o)
    {
        if (x.second == max_o1)
        {
            t = x.first;
        }
        if (x.second == max_o2)
        {
            u = x.first;
        }
    }
    for (auto y : e)
    {
        if (y.second == max_e1)
        {
            g = y.first;
        }
        if (y.second == max_e2)
        {
            h = y.first;
        }
    }

    //これでできたはず。
    if (t != g)
    {
        cout << n - max_e1 - max_o1;
    }
    else //等しい時には、後ろの値で決める。
    {
        //2番目の値が大きい方が2番目で変更して。小さい方が1番目で変更する。
        if (max_e2 < max_o2)
        { //奇数番目を2番目の方で置き換える。
            cout << n - max_o2 - max_e1;
        }
        else
        {
            //偶数番目を2番目の数で置き換える。
            cout << n - max_e2 - max_o1;
        }
    }
}

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

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

    ll k;
    cin >> k;

    while (k) {
        if (a >= b) {
            b = b*2;
            k--;
        }
        if (a < b) break;
    }

    while (k) {
        if (b >= c) {
            c = c*2;
            k--;
        }
        if (b < c) break;
    }

    if (a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 3632
N,M = map(int,input().split())
AC = (N+1)*[0]
WA = (N+1)*[0]
wa=0

for m in range(M):
  p,s = input().split()
  p = int(p)
  
  if AC[p]==0 and s=="AC":
  	AC[p]=1
  	wa+=WA[p]
    
  WA[p]+=1

print(sum(AC),wa) 

Measured memory_bytes: 4596
def main():
    import sys 
    input = sys.stdin.readline
    n,t = map(int,input().split())
    l = list(map(int,input().split()))
    ans = []
    check = l[0]
    for i in l:
        if i < check:
            check = i
        else:
            dis = i-check
            ans.append(dis)
    print(ans.count(max(ans)))

if __name__ == "__main__":
    main()

        


Measured memory_bytes: 14252
n = int(input())
a = [int(x) for x in input().split()]
a.sort()
ans = [0]*(n-1)

k1, k2 = a[0], a[-1]
for i in range(1, n-1):
  if a[i] >= 0:
    ans[i-1] = (k1, a[i])
    k1 -= a[i]
  else:
    ans[i-1] = (k2, a[i])
    k2 -= a[i]
ans[n-2] = (k2, k1)
print(k2-k1)
for value in ans:
  print(*value)

Measured memory_bytes: 19428
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int[] h = new int[1000];

    for(int i = 1; i <= 999; i++){
      h[i] = h[i-1] + i;
    }

    int ans = 0;
    for(int i = 1; i <= 999; i++){
      if(b - a == h[i] - h[i-1]){
        ans = h[i] - b;
        break;
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 23764
#include <iostream>
using namespace std;
int main(){
	int a,b,c,d;
	cin >> a >> b >>c;
	if(a>b){
	     d=a;
	     a=b;
	     b=d;
	}
	if(b>c){
		d=b;
		b=c;
		c=d;
	}
	if(a>b){
		d=a;
		a=b;
		b=d;
	}
	cout << a << " "<< b << " "<< c <<endl;

	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int N;
vector<int> a;

int main () {
  cin >> N;
  a.resize(N);
  rep(i,N)cin >> a[i];
  sort(all(a));

  int ans = 0;
  rep(i,N) {
    if(i&1) {
      ans -= a[N-1-i];
    } else {
      ans += a[N-1-i];
    }
  }

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


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

int main() {
    int k, n, ans = 1e9; cin >> k >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    a.push_back(k+a[0]);
    for (int i = 0; i < n; ++i) {
        ans = min(ans, k-(a[i+1]-a[i]));
    }
    cout << ans << endl;
    return 0;
}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    int a, b;
    cin >> a >> b;
    int c = a + b;

    if (a % 3 == 0 || b % 3 == 0 || c % 3 == 0) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    ll x;
    cin >> x;
    ll yokin = 100;
    ll ans = 0;
    while(yokin < x){
        ll rs  = yokin/100;
        yokin += rs;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
template<class T>using vv = vector<vector<T>>;

// #define rep(i,n) for(int i=0;i<(n);++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
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;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
#else
#define debug(...) 42
#endif


int main() {
  int K; cin >> K;
  int N; cin >> N;

  vi A(N);
  rep(i, N) cin >> A[i];

  int ans = (K - A.back()) + A[0];
  rep(i, N-1) {
    chmax(ans, A[i+1] - A[i]);
  }
  cout << K - ans << endl;

  return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<int(n);i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using Pint = pair<int,int>;
const ll mod = 1e9+7;

int main(){
  string s, t;
  cin>>s>>t;

  cout<<t<<s<<endl;

  return 0;
}

Measured memory_bytes: 3600
N,M = map(int,input().split())
H = [0]+list(map(int,input().split()))

l = [[] for i in range(N+1)]
for i in range(M):
    A,B = map(int,input().split())
    l[A].append(B)
    l[B].append(A)

ans = 0
for i in range(1,N+1):
    dp = []
    for j in l[i]:
        dp .append(H[j])
    maxi = max(dp) if dp else 0
        
    if H[i]>maxi:
        ans += 1
print(ans)

Measured memory_bytes: 97776
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
const ll mod = 1e9+7;
const ll INF = 1e18;
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;

class mint {
public:
    long long x;
    constexpr mint(long long x=0) : x((x%mod+mod)%mod) {}
    constexpr mint operator-() const { 
      return mint(-x);
    }
    constexpr mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    constexpr mint& operator*=(const mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    constexpr mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    constexpr mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    constexpr mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    constexpr mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    constexpr mint inv() const {
        return pow(mod-2);
    }
    constexpr mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    constexpr mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
};
ostream& operator<<(ostream& os, const mint& m){
    os << m.x;
    return os;
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll k;
  cin >> k;
  if (k%2 == 0) {
    cout << -1 << '\n';
    return 0;
  }
  ll s = 7;
  for (ll i = 1;i < k+100; ++i) {
    if (s%k == 0) {
      cout << i << '\n';
      return 0;
    }
    s += 7*modpow(10,i,k);
    s %= k;
  }
  cout << -1 << '\n';

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int A,B,C;
int X;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> A >> B >> C >> X;
}

int solve(){
    int ans=0;
    for (int i = 0; i <= A; i++)
    for (int j = 0; j <= B; j++)
    for (int k = 0; k <= C; k++)
        if((500*i+100*j+50*k)==X) ans++;
    cout << ans << endl;
    
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include <stdio.h>
#include <bits/stdc++.h>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

inline void setmin(int &x, int y) { if (y < x) x = y; }
inline void setmax(int &x, int y) { if (y > x) x = y; }
inline void setmin(ll &x, ll y) { if (y < x) x = y; }
inline void setmax(ll &x, ll y) { if (y > x) x = y; }

const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int A, B;
    cin >> A >> B;
    char a[100][100];
    rep(i, 0, 100)
        rep(j, 0, 100)
            if (i < 50)
                a[i][j] = '.';
            else
                a[i][j] = '#';
    A--; B--;
    for (int i = 48; i >= 0; i -= 2)
        for (int j = 0; j < 100; j += 2)
            if (B > 0)
            {
                a[i][j] = '#';
                B--;
            }
    for (int i = 51; i < 100; i += 2)
        for (int j = 0; j < 100; j += 2)
            if (A > 0)
            {
                a[i][j] = '.';
                A--;
            }
    cout << 100 << " " << 100 << "\n";
    rep(i, 0, 100)
    {
        rep(j, 0, 100)
            cout << a[i][j];
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int k, q;
  cin >> k >> q;
  vector<int> d(k);
  for (int i = 0; i < k; i++) 
    cin >> d[i];
  
  for (int i = 0; i < q; i++) {
    int n, x, m;
   	cin >> n >> x >> m;
    
    vector<int> a(k), b(k);
    int eq = d[0] % m == 0;
    b[0] = d[0] % m;
    for (int j = 1; j < k; j++) {
      b[j] = b[j - 1] + d[j] % m;
      a[j] = a[j - 1] + b[j] / m;
      b[j] = b[j] % m;
      if (d[j] % m == 0) eq++;
    }
    
    int rounds = (n - 1) / k;
    long long sa = 1LL * a.back() * rounds;
    long long sb = x % m + 1LL * b.back() * rounds;
    if ((n - 1) % k > 0) {
      sa += a[(n - 1) % k - 1];
      sb += b[(n - 1) % k - 1];
    }
    sa += sb / m;
 
    int ans = n - 1 - sa - eq * rounds;
    for (int j = 0; j < (n - 1) % k; j++)
      if (d[j] % m == 0) ans--;
    cout << ans << '\n';
  }
 
  return 0;
}

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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

#define int int64_t
int cnt[26]={0};
int32_t  main(){
	IOS;
  int n;
  cin>>n;
  string s;
  cin>>s;
  memset(cnt,0,sizeof(cnt));
  for(int i=0;i<n;++i)cnt[s[i]-'a']++;
  int ans=1;
  for(int i=0;i<26;++i)ans*=(cnt[i]+1),ans%=mod;
  ans-=1;
  if(ans<0)ans+=mod;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 512
function Main(input) {
  input = input.split("\n");
  n = parseInt(input[0]);
  tmp=input[1].split(" ");
  v=new Array(n);
  var countse = {};
  var countso = {};
  var maxe1 =0;
  var maxe2 =0;
  var maxenum=0;
  var maxo1 =0;
  var maxo2 =0;
  var maxonum=1;
  var ans =0;
  for(i=0;i<n;i++){
    v[i]=parseInt(tmp[i]);
    if(i%2==0){
      var num = v[i];
      countse[num]=countse[num] ? countse[num] +1 :1;
      if(maxe1!=0&&v[maxenum]!=v[i]&&countse[num]>maxe2){
        maxe2=countse[num];
      }
      if(countse[num]>maxe1){
        if(v[maxenum]!=v[i]){
          maxe2=maxe1;
        }
        maxe1=countse[num];
        maxenum=i;
      }
    }else{
      var num = v[i];
      countso[num]=countso[num] ? countso[num] +1: 1;
      if(maxo1!=0&&v[maxonum]!=v[i]&&countso[num]>maxo2){
        maxo2=countso[num];
      }
      if(countso[num]>maxo1){
        if(v[maxonum]!=v[i]){
          maxo2=maxo1;
        }
        maxo1=countso[num];
        maxonum=i
      }
    }
  }

  if(v[maxenum]!=v[maxonum]){
    ans=n-maxe1-maxo1;
  }else{
    ans=Math.min(n-maxe1-maxo2,n-maxe2-maxo1);
  }


  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 33876
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int INF = 19191919;

int n,m;
int c[10];

int ans = INF;
string x = "?";

string t;
void dfs(int d, int r){
    if(d == n){
        int v = atoi(t.c_str());
        if(v < ans){
            ans = v;
            x = t;
        }
        return;
    }

    rep(i,10)if(r-c[i]>=0){
        t[d] = '0'+i;
        dfs(d+1, r-c[i]);
        t[d] = '9';
    }
}

int main(){
    cin >>n >>m;
    rep(i,10) cin >>c[i];

    ans = INF;
    t = string(n,'9');
    dfs(0,m);

    if(ans == INF) cout << "NA" << endl;
    else cout << x << endl;
    return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#pragma optimize("-O3")
#define int long long int
#define f first
#define s second
#define pb push_back
#define endl '\n'

main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	int arr[n];
	for(int i=0; i<n; i++){
		cin>>arr[i];
	}
	int ans=0;
	int maxi=0;
	for(int i=0; i<n; i++){
		if(arr[i]<maxi){
			ans+=(maxi-arr[i]);
			continue;
		}
		else{
			maxi=arr[i];
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5204
#include <cstdio>
#include <iostream>

using namespace std;

string s;

int solve( int pos, int c ){
    string p = "";
    char l = s[pos];
    while( pos > 0 && l == s[pos] ){
        p+=s[pos];
        pos--;
    }
    //cout << p << ' ' << pos << '\n';
    
    if( pos == 0 && s[pos+1] != s[pos] ) return c + 1;
    
    if( pos == 0 ) return c;
    return solve(pos, c + 1);
}

int main() {
    
    cin >> s;
    if( (int)s.size() == 1 ) cout << 0 << '\n';
    else cout << solve( (int)s.size()-1, 0 ) << '\n';
    
    
}

Measured memory_bytes: 16000
#include <stdio.h>
 
int main(void)
{
	int s_1,s_2,s_3;
	int N;
	int u_1,u_2,u_3;
	scanf("%d",&N);
	
	s_1=N/100;
	s_2=(N-(100*s_1))/10;
	s_3=(N-(100*s_1)-(10*s_2));
	
	if(s_1==7){
		u_1=1;
	}else{
		u_1=0;
	}
	
	if(s_2==7){
		u_2=1;
	}else{
		u_2=0;
	}
 
if(s_3==7){
		u_3=1;
	}else{
		u_3=0;
	}
 
if(u_1+u_2+u_3>=1){
	printf("Yes");
    }else{
        printf("No");
    }

	
	return 0;
}
	

Measured memory_bytes: 1732
var a:array[0..200000]of longint;
    n,i:longint;
begin
  readln(n);
  for i:=1 to n do
    read(a[i]);
  i:=n;
  while i>0 do
  begin
    write(a[i],' ');
    dec(i,2);
  end;
  i:=(n and 1)+1;
  while i<=n do
  begin
    write(a[i],' ');
    inc(i,2);
  end;
end.

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

int main() {
        int H, W;
        cin >> H >> W;
        vector<vector<char>> A(H, vector<char>(W));
        vector<vector<int>> B(H, vector<int>(W, -1));

        rep(h, H) {
                rep(w, W) {
                        cin >> A.at(h).at(w);
                }
        }
        rep(w, W) {
                rep(h, H) {
                        rep(p, W-w) {
                                if (A.at(h).at(p) == 'c' && B.at(h).at(w + p) < 0) {
                                        B.at(h).at(w + p) = w;
                                }
                        }
                }
        }
        rep(h, H) {
                rep(w, W) {
                        cout << B.at(h).at(w);
                        if (w == W - 1) {
                                cout  << endl;
                        } else {
                                cout << " ";
                        }
                }
        }
        return 0;
}



Measured memory_bytes: 3184
# coding: utf-8
#ABC106B_105.rb
n = gets.to_i
count = 0
ans = 0

(1..n).each do |nn|
  next if nn%2 == 0
  count = 0
  (1..nn).each do |mm|
    if nn % mm == 0
      count += 1
    end
  end
  ans += 1 if count==8
end

puts ans



Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

ll dfs(const vector<vecint>& g, const vector<tuple<int,int>>& vt, int i, int v, int p = -1) {
  for(auto&& to:g[i]) {
    if (to == p) continue;
    if (to == v) {
      int s=i, t=to;
      if (s<t) swap(s,t);
      int index = boost::find(vt, make_tuple(s,t)) - begin(vt);
      return 1l << index;
    } else {
      ll tmp = dfs(g,vt,to,v,i);
      if (tmp > 0) {
        int s=i, t=to;
        if (s<t) swap(s,t);
        int index = boost::find(vt, make_tuple(s,t)) - begin(vt);
        return tmp + (1l << index);
      }
    }
  }
  return 0;
}

int main()
{
  ll n;
  cin>>n;
  vector<tuple<int,int>> vt;
  vector<vecint> g(n);
  for(auto&& i:irange(0l,n-1)) {
    int a,b;
    cin>>a>>b;
    --a;--b;
    g[a].push_back(b);
    g[b].push_back(a);
    if (a<b) swap(a,b);
    vt.emplace_back(a,b);
  }
  int m;
  cin>>m;
  vecll consts;
  for(auto&& i:irange(0,m)) {
    int u,v;
    cin>>u>>v;
    --u;--v;
    consts.push_back(dfs(g,vt,u,v));
  }
  vecll p2(50);
  p2[0] = 1;
  for(auto&& i:irange(0,49)) {
    p2[i+1] = p2[i] * 2;
  }
  ll ans = 0;
  for(auto&& i:irange(0,1<<m)) {
    ll mask = (1l << (n-1)) - 1;
    ll cnt = 0;
    for(auto&& j:irange(0,m)) {
      if ((i>>j)&1) {
        mask &= ~consts[j];
        ++cnt;
      }
    }
    ll p = p2[__builtin_popcountll(mask)];
    ans += (cnt % 2) ? -p : p;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int main() {
    int N, K;
    while (~scanf("%d %d", &N, &K)) {
          LL sum = 0;
          for (int i = 1; i <= N; i++) {
              LL minb = K - (i % K);
              if (minb == 0) minb = K;
              LL numb = (N - minb) / K + 1;
              LL minc = i % K;
              if (minc == 0) minc = K;
              LL numc = (N - minc) / K + 1;
              if (minb == minc) sum += numb * numc;
          }
          printf("%lld\n", sum);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <time.h>
#include <bits/stdc++.h>

#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
const ll INF=1e18+5;
int dp[3005][3005];
int  dp_track[3005][3005];
vector<int>rep_word2[27];
string world1,world2;
int size1;
int size2;
int solve (int index1 , int index2 ){
    if(index1>=size1||index2>=size2)return 0;
    if(dp[index1][index2]!=-1)return dp[index1][index2];
    int charc=world1[index1]-'a';
    int index_world2=lower_bound(rep_word2[charc].begin(),rep_word2[charc].end(),index2)-rep_word2[charc].begin();
    if(index_world2==rep_word2[charc].size()){
        dp[index1][index2]=solve(index1+1,index2);
        dp_track[index1][index2]=index2;
    } else{
        int num1 =solve(index1+1,index2);
        int num2=1+solve(index1+1,rep_word2[charc][index_world2]+1);
        if(num1>num2){
            dp_track[index1][index2]=index2;
        } else{
            dp_track[index1][index2]=rep_word2[charc][index_world2]+1;
        }
        dp[index1][index2]=max(num1,num2);
    }
    return dp[index1][index2];
}
void print_track(int index1 ,int index2){
    if(index1>=size1||index2>=size2)return;
    int next_index2=dp_track[index1][index2];
    if(next_index2!=index2){
        cout<<world1[index1];
    }
    print_track(index1+1,next_index2);
}
int main() {
#ifdef _DEBUG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    IO;
     cin>>world1>>world2;
     size1=world1.size();
     size2=world2.size();
    for(int i = 0; i<size2 ; i++ ){
        rep_word2[world2[i]-'a'].push_back(i);
    }
    memset(dp,-1, sizeof(dp));
    solve(0,0);
    print_track(0,0);
   // cout<<solve(0,0)<<endl;
    return 0;
}
//"ezupkr"
//"ubmrapg"

Measured memory_bytes: 70784
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String C[] = new String[N];
		char B[] = new char[N];
		int A[] = new int[N];
		char wc;
		int i, j, min, wi, flg=0;
		for(i=0; i<N; i++){
			C[i] = sc.next();
		}

		for(i=0; i<N; i++){
			B[i] = C[i].charAt(0);
			A[i] = Integer.parseInt("" + C[i].charAt(1));
		}
		for(i=0; i<N-1; i++){
			for(j=N-1; j>=i+1; j--){
				if(A[j]<A[j-1]){
					wc     = B[j];
					B[j]   = B[j-1];
					B[j-1] = wc;
					wi     = A[j];
					A[j]   = A[j-1];
					A[j-1] = wi;
				}
			}
		}
		for(i=0; i<N; i++){
			if(i!=0) System.out.print(" ");
			System.out.print(""+B[i]+A[i]);
		}
		System.out.println();
		System.out.println("Stable");

		for(i=0; i<N; i++){
			B[i] = C[i].charAt(0);
			A[i] = Integer.parseInt("" + C[i].charAt(1));
		}
		for(i=0; i<N-1; i++){
			min = i;
			for(j=i+1; j<N; j++){
				if(A[min]>A[j]) min = j;
			}
			if(min!=i){
				for(j=i+1; j<min; j++){
					if(A[i]==A[j]){
						flg = 1;
						break;
					}
				}
				wc     = B[i];
				B[i]   = B[min];
				B[min] = wc;
				wi     = A[i];
				A[i]   = A[min];
				A[min] = wi;
			}
		}
		for(i=0; i<N; i++){
			if(i!=0) System.out.print(" ");
			System.out.print(""+B[i]+A[i]);
		}
		System.out.println();
		if(flg==0) System.out.println("Stable");
		else       System.out.println("Not stable");
	}
}

Measured memory_bytes: 17384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct node{
  struct node *left, *right, *parent;
  int key;
}node;
node *T;
void Insert(int);
void Inorder(node*);
void Preorder(node*);
int Find(int);
void Delete(int);
node* Successor(node*);
node* Minimum(node*);
node* Maximum(node*);
void Free(node*);
int main(){
  int n, i, key;
  char func[6];
  T = (node *)malloc(sizeof(node) * 1);
  T->parent = T->left = T->right = NULL;
  T->key = -1;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%s",func);
    if(strcmp(func,"insert") == 0){
      scanf("%d",&key);
      Insert(key);
    }
    else if(strcmp(func,"print") == 0){
      Inorder(T);
      printf("\n");
      Preorder(T);
      printf("\n");
    }
    else if(strcmp(func,"find") == 0){
      scanf("%d",&key);
      Find(key) ? printf("yes\n") : printf("no\n");
    }
    else if(strcmp(func,"delete") == 0){
      scanf("%d",&key);
      Delete(key);
    }
  }
  Free(T);
  return 0;
}
void Inorder(node* x){
  if(x != NULL){
    Inorder(x->left);
    printf(" %d",x->key);
    Inorder(x->right);
  }
}
void Preorder(node* x){
  if(x != NULL){
    printf(" %d",x->key);
    Preorder(x->left);
    Preorder(x->right);
  }
}
void Free(node* x){
  if(x != NULL){
    Free(x->left);
    Free(x->right);
    free(x);
  }
}
void Insert(int key){
  node *x, *y, *R;
  if(T->key == -1){
    T->key = key;
    return;
  }
  R = (node *)malloc(sizeof(node) * 1);
  R->key = key;
  R->parent = R->left = R->right = NULL;
  x = T;
  while(x != NULL){
    y = x;
    if(key < x->key) x = x->left;
    else x = x->right;
  }
  R->parent = y;
  if(R->key < y->key) y->left = R;
  else y->right = R;
}
int Find(int key){
  node *x;
  for(x=T; x != NULL;){
    if(x->key > key) x = x->left;
    else if(x->key < key) x = x->right;
    else return 1;
  }
  return 0;
}
void Delete(int key){
  node *x, *y, *z;
  for(x=T; x != NULL;){
    if(x->key > key) x = x->left;
    else if(x->key < key) x = x->right;
    else break;
  }
  z = x;
  if(z->left == NULL || z->right == NULL) y = z;
  else y = Successor(z);
  if(y->left != NULL) x = y->left;
  else x = y->right;
  if(x != NULL) x->parent = y->parent;
  if(y->parent == NULL) T = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;
  if(y != z) z->key = y->key;
}
node* Successor(node* x){
  node *y;
  if(x->right != NULL) return Minimum(x->right);
  y = x->parent;
  while(y != NULL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}
node* Minimum(node* x){
  while(x->left != NULL) x = x->left;
  return x;
}
node* Maximum(node* x){
  while(x->right != NULL) x = x->right;
  return x;
}

Measured memory_bytes: 19364
#include <iostream>
#include <math.h>
using namespace std;

#define INF 1e4 + 3;
int dp[100005];
int nums[100005];



int solve(int n) {
    for(int i = 0; i <= n; i++) {
        dp[i] = 0;
    }
    dp[0] = 0;
    dp[1] = abs(nums[1] - nums[0]);

    for(int i = 2; i < n; i++) {
        dp[i] = min(dp[i - 1] + abs(nums[i] - nums[i - 1]), dp[i - 2] + abs(nums[i] - nums[i - 2]));        
    }
    
    return dp[n - 1];
}

int main()
{
    int n;
    cin >> n;
    
    for(int i = 0; i < n; i++)
        cin >> nums[i];
        
    cout << solve(n) << endl;

    return 0;
}


Measured memory_bytes: 1024
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Array.IO
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
applyBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
applyBin op f g x = op (f x) $ g x
applyUni :: (a -> b -> c) -> (a -> b) -> a -> c
applyUni op f x = op x $ f x
-- end of templete


main = sum . map read . wordsBy (not . isDigit) <$> getContents>>= print

Measured memory_bytes: 4136
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, A, B, C, D = [int(x) for x in input().split()]
    S = input().strip()

    def rock_check(start, end):
        for a, b in zip(S[start:end], S[start + 1:end]):
            if a == b == "#":
                return False
        else:
            return True

    def three_space_check(start, end):
        start -= 2
        end += 1
        for a, b, c in zip(S[start:end], S[start + 1:end], S[start + 2:end]):
            if a == b == c == ".":
                return True
        else:
            return False

    bfirst = False
    if C < D:
        bfirst = True

    if bfirst:
        if A > B:
            if rock_check(B, D) and rock_check(A, C) and three_space_check(A, C):
                print("Yes")
            else:
                print("No")
        else:
            if rock_check(B, D) and rock_check(A, C):
                print("Yes")
            else:
                print("No")
    else:
        if B > A:
            if rock_check(B, D) and rock_check(A, C) and three_space_check(B, D):
                print("Yes")
            else:
                print("No")
        else:
            if rock_check(B, D) and rock_check(A, C):
                print("Yes")
            else:
                print("No")


if __name__ == '__main__':
    main()


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

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

    int a = 800 * N;
    int b = N / 15;
    int c = b * 200;
    cout << a - c << endl;
}

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

int N, L[2005];

int main() {
    cin >> N;

    for(int i = 0; i < N; i++)
        cin >> L[i];

    sort(L, L + N);

    int ans = 0;
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            for(int k = j + 1; k < N; k++) {
                if(L[i] + L[j] > L[k]) ans++;
                else break;
            }
        }
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int H =0;
    int W =0;
    while(true){
     H = sc.nextInt();
     W = sc.nextInt();

//  System.out.println("");
   if(H != 0 && W != 0){
    for(int i = 0; i < H ; i++){
      for(int j = 0; j < W ; j++){
        System.out.print("#");
      }
      System.out.print("\n");
    }
    System.out.println("");
  }else{
    return;
  }

}
//  sc.close();
  //System.exit(0);

  }

}



Measured memory_bytes: 34888
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin>>N;
    map<string,int> mp;
    for(int i=0;i<N;i++){
        string S;
        cin>>S;
        mp[S]++;
    }
    int M; cin>>M;
    for(int i=0;i<M;i++){
        string S;
        cin>>S;
        mp[S]--;
    }

    int ans=0;
    for(auto i:mp){
        ans=max(ans,i.second);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define _rep(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define N 200005
int a[N],b[N],n;
int x,y;
std::vector<int> p,q;
int main(){
	std::ios::sync_with_stdio(0);
	std::cin.tie(0),std::cout.tie(0);
	std::cin>>n;
	rep(i,1,n) std::cin>>a[i],b[i]=a[i];
	std::sort(b+1,b+n+1);
	x=b[n>>1],y=b[(n>>1)+1];
	rep(i,1,n){
		if(a[i]>=y) std::cout<<x<<'\n';
		else std::cout<<y<<'\n';
	}
	return 0;
}

Measured memory_bytes: 5036
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; scanf("%lld", &x); return x;}
ld fin(){double x; scanf("%lf", &x); return x;}
char yuyushiki[1000010]; string stin(){scanf( "%s", yuyushiki ); return yuyushiki;}

// head

const ld EPS = 1e-8;

int main(){

  int n = in();
  vector<int> a(n);
  ld mean = 0;
  REP(i, n){
    a[i] = in();
    mean += a[i];
  }
  mean /= n;

  ld diff = INF;
  int ans = -1;
  
  REP(i, n){
    ld cur = abs(mean - a[i]);
    if(cur < diff - EPS){
      diff = cur;
      ans = i;
    }
  }

  cout << ans << endl;

  
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long W;
        W = sc.nextLong();
        long H;
        H = sc.nextLong();
        long x;
        x = sc.nextLong();
        long y;
        y = sc.nextLong();

        final Solver solver = new Solver();
        solver.solve(W, H, x, y);
    }
}

class Solver {
    public void solve(long W, long H, long x, long y) {
        final double area = W * H / 2.0;
        final int multiple = W == (x + x) && H == (y + y) ? 1 : 0;

        System.out.println(String.format("%f %d\n", area, multiple));
    }
}



Measured memory_bytes: 21844
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<ll> a(n), b(m);
  vector<ll> suma(n + 1, 0), sumb(m + 1, 0);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    suma[i + 1] = suma[i] + a[i];
  }
  for(int i = 0; i < m; i++) {
    cin >> b[i];
    sumb[i + 1] = sumb[i] + b[i];
  }
  ll t = 0;
  int ans = 0;
  int maxi = 0;
  for(int i = 0; i <= n; i++) {
    ll tmp = suma[i];
    
    int num = 0;
    num = distance(sumb.begin(), lower_bound(sumb.begin(), sumb.end(), k - tmp));
    num = min(num, m);
    while(sumb[num] + tmp > k && num > 0) {
      num--;
    }
    if(tmp + sumb[num] <= k){
      num += i;
    }
    maxi = max(maxi, num);
  }
  cout << maxi << endl;
  return 0;
}

Measured memory_bytes: 9548
import math
N, D = map(int, input().split())

def nolm(p):
    return math.sqrt(p[0] ** 2 + p[1] ** 2)

Ps = []
for _ in range(N):
    p = tuple(map(int, input().split()))
    if nolm(p) <= D:
        Ps.append(p)

print(len(Ps))

Measured memory_bytes: 30344
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
bool work[17][17];
int memo[17][17];
int C(int x, int y){
  if(x==0||y==0) return 0;
  if(x==1&&y==1) return 1;
  if(work[x][y]) return 0;
  if(memo[x][y]!=-1) return memo[x][y];
  return (C(x-1,y) + C(x,y-1));
}
int main(void){
  int a,b;
  while(cin>>a>>b){
    if(a==0) break;
    memset(work,0,sizeof(work));
    memset(memo,-1,sizeof(memo));
    int n,x,y;
    cin>>n;
    REP(i,n){
      cin>>x>>y;
      work[x][y]=true;
    }
    cout<<C(a,b)<<endl;
  }
  return 0;
}

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


int main(){
  string S;
  vector<int> A(4);

  cin >> S;
  for (int i=0; i<4; i++) A[i] = S[i] - '0';

  vector<char> op(3);
  for (int i=0; i<(1<<3); i++){
    int sum = A[0];
    for (int j=0; j<3; j++){
      if (i & (1 << j)){
        sum += A[j+1];
        op[j] = '+';
      } else {
        sum -= A[j+1];
        op[j] = '-';
      }
    }

    if (sum == 7){
      cout << A[0] << op[0] << A[1] << op[1] << A[2] << op[2] << A[3] << "=7" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
n, k = map(int,input().split())
arr = list(map(int,input().split()))
ans = []
for i in range(n - k + 1):
    ans.append(abs(arr[i]) + abs(arr[i + k - 1] - arr[i]))
    ans.append(abs(arr[i + k - 1]) + abs(arr[i + k - 1] - arr[i]))
print(min(ans))

Measured memory_bytes: 14384
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include<deque>
#include<stdlib.h>
//#include <algorithm>
#include<set>
#include <limits>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_5 100000
#define d9_7 1000000007
vector<vector<ll>> Combi(2001,vector<ll>(2001,-1));
long long combi(long long n, long long k) {
  //cout << n << "C" << k << endl;
  //cout <<"r";
  if(n<k){
    cout << "ERROR" << endl;
    return 0;
  }
  if(k<0){
    return 0;
  }
  if(Combi[n][k]!=-1){
    return Combi[n][k];
  }
  if (n == k || k == 0)
    return 1;
  else {
    Combi[n][k]=combi(n - 1, k - 1)%d9_7 + combi(n - 1, k)%d9_7;
    Combi[n][n-k]=Combi[n][k];
    return Combi[n][k];
  }
}
int main(void){
  ll N,K;
  cin >> N >> K;
  ll red = N-K;
  for(ll i=1;i<=K;i++){
    //青の入れ方
    ll kp = combi(K-1,K-i);//iHk-i,Kの並べ方
    if(i-1>red){
      cout << 0 << endl;
      continue;
    }
    if(i==1){
      cout<<red+1<<endl;
      continue;
    }
    //cout << "e" << kp << endl;
    ll rp0 = combi(red-1,red-i+1)%d9_7;//i-1Hred-(i-1)
    //cout << "c1" << endl;
    ll rp1 = combi(red-1,red-i)%d9_7;//iHred-(i)
    //cout << "c2" << endl;
    ll rp2 = combi(red-1,red-i-1)%d9_7;//i+1Hred-(i+1)
    cout<<(kp*(rp0+2*rp1+rp2))%d9_7<<endl;
  }
	return 0;
}

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

#define whole(xs) (xs).begin(),(xs).end()

vector< vector<int> > G1, G2;
int V;
vector<bool> used;
void init() {
    G1.clear(); G1.resize(V);
    G2.clear(); G2.resize(V);
    used.clear(); used.resize(V);
}
void addEdge(int from, int to) {
    G1[from].push_back(to);
    G2[to].push_back(from);
}
vector<int> vs;
void dfs1(int v) {
    used[v] = true;
    for (int i = 0; i < G1[v].size(); i++) {
        if (!used[ G1[v][i] ]) dfs1(G1[v][i]);
    }
    vs.push_back(v);
}
void dfs2(int v, int k, vector<int>& order) {
    used[v] = true;
    order[v] = k;
    for (int i = 0; i < G2[v].size(); i++) {
        if (!used[ G2[v][i] ]) dfs2(G2[v][i], k, order);
    }
}
/* ordに各頂点のトポロジカル順序を入れる. 返り値は強連結成分分解後のグラフの頂点数 */
int solve(vector<int>& ord) {
    fill(whole(used), false);
    vs.clear();
    for (int v = 0; v < V; v++) {
        if (!used[v]) dfs1(v);
    }
    fill(whole(used), false);
    int k = 0;
    ord.clear(); ord.resize(V, -1);
    for (int i = vs.size() - 1; i >= 0; i--) {
        if (!used[vs[i]]) dfs2(vs[i], k++, ord);
    }
    return k;
}

int E;
int main() {
    scanf("%d %d\n", &V, &E);
    init();
    for (int i = 0; i < E; i++) {
        int s, t; scanf("%d %d\n", &s, &t);
        addEdge(s, t);
    }
    int Q; scanf("%d\n", &Q);
    vector<int> ord;
    solve(ord);
    for (int q = 0; q < Q; q++) {
        int a, b; scanf("%d %d\n", &a, &b);
        printf("%d\n", (ord[a] == ord[b]));
    }
    return 0;
}

Measured memory_bytes: 2876