akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#define LEN 100005
 
typedef struct pp{
  char name[100];
  int t;
}P;
 
P Q[LEN+1];
int head, tail, n;
 
void enqueue(P x){
  Q[tail]=x;
  if(tail>=LEN)tail=0;
  else tail++;
}
 
P dequeue(){
  P m;
  m=Q[head];
  if(head>=LEN)head=0;
  else head++;
  return m;
}
 
 
int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail=n+1;
  while(head!=tail){
    if(Q[head].t>q){
      elaps+=q;
      Q[head].t-=q;
      enqueue(dequeue());
    }
    else{
      elaps+=Q[head].t;
      printf("%s %d\n",Q[head].name,elaps);
      dequeue();
       
    } 
  }
  return 0;
}

Measured memory_bytes: 10756
#include<stdio.h>
#define N 8
#define FREE -1
#define NFREE 1
#define FALSE 0
#define TRUE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1],X[N][N];

void initialize(){
  int i;
  for( i = 0 ; i < N ; i++ ){
    row[i] = FREE;
    col[i] = FREE;
  }
  for( i = 0 ; i < 2*N-1 ; i++ ){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
}

void print_Board(){
  int i, j;
  for( i = 0 ; i < N ; i++ ){
    for( j = 0 ; j < N ; j++ ){
      if( X[i][j] ){
	if( row[i] != j ) return;
      }
    }
  }
  for( i = 0 ; i < N ; i++ ){
    for( j = 0 ; j < N ; j++ ){
      if( row[i] == j ) printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}

void recursive(int i){
  int j;
  if( i == N ){
    print_Board();
    return;
  }
  for( j = 0 ; j < N ; j++ ){
    if( NFREE == col[j] || NFREE == dpos[i+j] || NFREE == dneg[i-j+N-1] ) continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NFREE;
    recursive(i+1);
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
}

int main(){
  int i, j, k, r, c;

  for( i = 0 ; i < N ; i++ ){
    for( j = 0 ; j < N ; j++ ) X[i][j] = FALSE;
  }

  scanf("%d",&k);
  
  for( i = 0 ; i < k ; i++ ){
    scanf("%d%d",&r,&c);
    X[r][c] = TRUE;
  }

  recursive(0);

  return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define debug(x) #x << "=" << (x)

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc103/tasks/abc103_d 

int main() {
    int N, M; cin >> N >> M;
    vector<P> v;
    int a, b;
    REP(i, M) {
        cin >> a >> b;
        v.push_back({b, a});
    }

    sort(v.begin(), v.end());
    int end = 0;
    int ans = 0;
    for (P t : v) {
        if (t.second >= end) {
            ans++;
            end = t.first;
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, u, v;
  cin >> N >> u >> v;
  u--;
  v--;
  vector<vector<int>> G(N,vector<int>(0));
  for(int i=0; i<N-1; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  vector<int> U(N);
  vector<int> V(N);
  int INF = 100000000;
  for(int i=0; i<N; i++){
    if(i == u){
      U.at(i) = 0;
    }
    else{
      U.at(i) = INF;
    }
  }
  for(int i=0; i<N; i++){
    if(i == v){
      V.at(i) = 0;
    }
    else{
      V.at(i) = INF;
    }
  }
    
  queue<int> Q;
  Q.push(u);
  while(Q.size()){
    int x = Q.front();
    Q.pop();
    for(int i=0; i<G.at(x).size(); i++){
      int y = G.at(x).at(i);
      if(U.at(y) == INF){
        U.at(y) = U.at(x) + 1;
        Q.push(y);
      }
    }
  }
  Q.push(v);
  while(Q.size()){
    int x = Q.front();
    Q.pop();
    for(int i=0; i<G.at(x).size(); i++){
      int y = G.at(x).at(i);
      if(V.at(y) == INF){
        V.at(y) = V.at(x) + 1;
        Q.push(y);
      }
    }
  }
  
  int ans = 0;
  for(int i=0; i<N; i++){
    int x = 0;
    if(U.at(i) < V.at(i)){
      x = V.at(i);
    }
    ans = max(x-1,ans);
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 6656
let input = stdin.ReadLine().Split() |> Array.map int
let N = input.[0]
let M = input.[1]

let A = stdin.ReadLine().Split() |> Array.map int
let sum = A |> Array.sum

if ((A
     |> Array.filter (fun x -> x * 4 * M >= sum)
     |> Array.length) < M)
then "No"
else "Yes"
|> printfn "%s"


Measured memory_bytes: 14044
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            List<double> resultList = new List<double>();

            string input;
            while ((input = Console.ReadLine()) != null)
            {
                double minV = double.Parse(input);
                double minT = minV / 9.8;
                double minY = 4.9 * Math.Pow(minT, 2);
                int minFloor;
                if (minY == 0)
                {
                    minFloor = 1;
                }
                else
                {
                    minFloor = (int)Math.Floor(minY) / 5 + 2;
                }
                    
                resultList.Add(minFloor);

            }

            foreach (int a in resultList)
            {
                Console.WriteLine(a);
            }


        }


    }
}

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

int main()
{
    int w, h, n;
    cin >> w >> h >> n;
    int min_x = 0, max_x = w;
    int min_y = 0, max_y = h;

    rep(i, 0, n)
    {
        int x, y, a;
        cin >> x >> y >> a;

        if (a == 1)
            min_x = max(min_x, x);
        else if (a ==2)
            max_x = min(max_x, x);
        else if (a == 3)
            min_y = max(min_y, y);
        else if (a == 4)
            max_y = min(max_y, y);
    }

    if (max_x > min_x and max_y > min_y)
        cout << (max_x - min_x) * (max_y - min_y) << endl;
    else
        cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace std;
int main(){
    int n, t, distance;
    cin >> n;
    int T[n], X[n], Y[n];
  	T[0]=0;
  	X[0]=0;
  	Y[0]=0;
    for(int i=1;i<n+1;i++){
        cin >> T[i] >> X[i] >> Y[i];
    }
    string ans = "Yes";
    for(int i=0;i<n;i++){
        t = T[i+1] - T[i];
        distance = abs(X[i+1]-X[i]) + abs(Y[i+1] - Y[i]);
        if(distance>t || distance%2!=t%2){
            ans = "No";
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  ll x02 = 0;
  for (int i = 0; i < n; i++) if (i % 2 == 0) x02 += a[i]; else x02 -= a[i];
  vector<ll> x(n);
  x[0] = x02 / 2;

  for (int i = 1; i < n; i++)
    x[i] = a[i - 1] - x[i - 1];

  cout << x[0] * 2;
  for (int i = 1; i < n; i++) cout << " " << x[i] * 2;
  cout << endl;
  return 0;
}


Measured memory_bytes: 2944
// {{{ Headers
// vim:filetype=cpp:foldmethod=marker:foldmarker={{{,}}}

#include <cassert>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <deque>
#include <functional>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#include <fstream>
#include <iostream>
#include <sstream>

using namespace std;
// }}}

typedef long long int64;
const int INF = 0x3f3f3f3f;
template <class T> inline int len (const T &a) { return a.size (); }
#define ALL(x) (x).begin(), (x).end()

const int MX = 100 * 1000 + 5;
int a [MX];
int dp [MX];

int
main () {
    int N, K;
    scanf ("%d %d", &N, &K);
    for (int i = 0; i < N; i++) scanf ("%d", a + i);
    memset (dp, INF, sizeof (dp));
    dp [0] = 0;
    for (int i = 0; i < N; i++)
        for (int j = 1; j <= K; j++)
            if (i >= j)
                dp [i] = min (dp [i], dp [i - j] + abs (a [i] - a [i - j]));
    printf ("%d\n", dp [N - 1]);

#ifdef LOCALHOST
	cerr << "time: " << (int64) clock () * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
    return 0;
}



Measured memory_bytes: 1024
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

X, Y, A, B, C = map(int, input().split(' '))
p = sorted(list(map(int, input().split(' '))))
q = sorted(list(map(int, input().split(' '))))
r = sorted(list(map(int, input().split(' '))))

p = deque(p[-X:])
q = deque(q[-Y:])
r = deque(r)

while min(p[0], q[0]) < r[-1]:
    x = r.pop()
    if p[0] < q[0]:
        p.popleft()
        p.append(x)
    else:
        q.popleft()
        q.append(x)
    if len(r) == 0:
        break

cnt = 0
for x in p:
    cnt += x
for y in q:
    cnt += y

print(cnt)


Measured memory_bytes: 24644
#include <stdio.h>
int main()
{
    long a,b,i,k;
    scanf("%ld%ld",&a,&b);
    i=b-1;
    k=b;
    while(a!=1)
    {
        k=k*i;
        a--;
    }
    printf("%ld",k);
    return 0;
}


Measured memory_bytes: 128
n,a=open(0);n=int(n)+1;d,A,q=[0]*n+[1],1e+18,0
for b in a.split():b=int(b);q+=(b+1)//n;d[(b+1)%n]+=1
for r in range(n):q+=d[n-r]-1;A=min(A,max(q,0)*n+r)
print(A)

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

int main() {
  int n, i, a, c1 = 0, c2 = 0, c4 = 0;
  bool ans = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a;
    if (a % 2 == 0 && a % 4 != 0) {
      ++c2;
    } else if (a % 4 == 0) {
      ++c4;
    } else {
      ++c1;
    }
  }
  if (c2 == 0) {
    if (c4 >= c1 - 1) {
      ans = 1;
    }
  } else {
    if (c4 >= c1) {
      ans = 1;
    }
  }
  if (ans) {
    cout << "Yes"
         << "\n";
  } else {
    cout << "No"
         << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define pll pair<ll,ll>
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define M_PI 3.14159265358979323846
//#define int long long
const int mod=1000000007;
//const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.000000000000000000001;
using namespace std;
int main()
{
    speed
    ld a,b,c;
    cin>>a>>b>>c;
    ld x=a*b;
    x=sqrt(x)*2.0;
    if(a+b+x+eps<c)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;

int main()
{

	ll N, K;
	cin >> N >> K;

	vec A;
	for (ll i = 1; i <= sqrt(N); ++i)
	{
		A.emplace_back(N / i);
	}

	for (ll i = sqrt(N); i > 0; --i)
	{
		if (N/i==i)continue;
		A.emplace_back(i);
	}

	for (ll i = 0; i < A.size() - 1; ++i)
	{
		A[i] -= A[i + 1];
		A[i] %= MOD;
	}

	reverse(A.begin(), A.end());
	//sort(A.begin(), A.end());
	

	vec B(A.size() + 1,0);

	for(ll i=0;i<A.size();++i)
	{
		B[i] = A[i] % MOD;
	}

	for (ll i = 0; i < K-1; ++i)
	{
		vec tmp(B.size(), 0);
		for (ll j = 0; j < tmp.size(); ++j)
		{
			tmp[0] = (tmp[0] + B[j]) % MOD;
			tmp[tmp.size() - j - 1] = (tmp[tmp.size() - j - 1] - B[j] + MOD) % MOD;
		}

		for (ll j = 1; j < tmp.size(); ++j)
		{
			tmp[j] += tmp[j - 1];
			tmp[j] %= MOD;
		}

		for (ll j = 0; j < A.size(); ++j)
		{
			tmp[j] *= A[j];
			tmp[j] %= MOD;
		}
		
		for (ll j = 0; j < tmp.size(); ++j)
		{
			B[j] = tmp[j] % MOD;
		}
	}

	ll ans = 0;
	for (ll i = 0; i < A.size(); ++i)
	{
		ans += B[i];
		ans %= MOD;
	}
	cout << ans << endl;
	

	

	return 0;
}

Measured memory_bytes: 1912
#include <stdio.h>
int  main(void)
{
	int H, W, i, j;
	while (scanf("%d %d", &H, &W) != EOF) {
		if(H == 0 && W == 0) {
			break;
		}
		for (i = 1; i <= H; i++) {
            		for (j = 1; j <= W; j++){
            			if ((i + j) % 2 == 0)
            				printf("#");
            			else
            				printf(".");
            			}
            			printf("\n");
            		}
            		printf("\n");
		}
	return 0;
}



Measured memory_bytes: 2032
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,ii> iii;
typedef pair<int, iii> iiii;
typedef pair<double, ii> dii;
typedef long long ll;
typedef pair<ll, ii> lii;
const int INF = 1000000000;
const double EPS = 1e-9;
#define LSOne(S) (S & (-S))
int mods(int a, int b) { return (b + (a%b)) % b; }

int n, W, maxVal, ans, val, w[105], v[105];
ll dp[100005];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    cin >> n >> W;

    for (int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
        maxVal += v[i];
    }

    for (int i = 0; i <= maxVal; i++)
        dp[i] = INF;

    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        val = v[i];
        for (int j = maxVal - val; j >= 0; j--)
            dp[j+val] = min(dp[j+val], dp[j] + w[i]);
    }

    for (int i = 0; i <= maxVal; i++)
        if (dp[i] <= W) ans = max(ans, i);

    cout << ans << '\n';

    return 0;
}


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

struct UnionFind {
    vector<int> data;
    int sz;
    UnionFind(int sz) : data(sz, -1), sz(sz) { }
    bool unionSet(int x, int y) {
        if ((x = root(x)) == (y = root(y))) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y]; data[y] = x;
        sz--;
        return true;
    }
    bool findSet(int x, int y) { return root(x) == root(y); }
    int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
    int size(int x) { return -data[root(x)]; }
    int size() {return sz;}
};

int main() {
	int N, M;
	cin >> N >> M;
	int A[M], B[M];
	for (int i = 0; i < M; ++i) cin >> A[i] >> B[i];

	for (int i = 0; i < M; ++i) A[i]--, B[i]--;

	UnionFind uf(N);
	for (int i = 0; i < M; ++i) uf.unionSet(A[i], B[i]);
	set<int> st;
	for (int i = 0; i < N; ++i) st.insert(uf.root(i));

	cout << st.size() - 1 << endl;
	return 0;
}

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

const int MOD=998244353;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

/*
#include <atcoder/segtree>
using namespace atcoder;
*/

ll ppow(ll a,ll b){
	a%=MOD;
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}

class Fact{
	vector<ll>fact;
	vector<ll>inv;
public:
	Fact(){}
	Fact(int n){
		n=n*2+10;
		fact=inv=vector<ll>(n);
		fact[0]=inv[0]=1;
		for(int i=1;i<n;i++){
			fact[i]=(fact[i-1]*i)%MOD;
		}
		inv[n-1]=ppow(fact[n-1],MOD-2);
		for(int i=n-2;i>=0;i--){
			inv[i]=(inv[i+1]*(i+1))%MOD;
		}
	}
	ll get(int n){
		return fact[n];
	}
	ll get_inv(int n){
		return inv[n];
	}
	ll nPr(int n,int r){
		return fact[n]*inv[n-r]%MOD;
	}
	ll nCr(int n,int r){
		return nPr(n,r)*inv[r]%MOD;
	}
	ll nrP(int n,int r){
		return nPr(n+r,n);
	}
	ll nrC(int n,int r){
		return nCr(n+r,n);
	}
};

const int r=3;

void dft(vector<ll>&f,bool inv=false){
	int n=f.size();
	rep(i,n){
		int b=31-__builtin_clz(n);
		int j=0;
		rep(k,b){
			if(i>>k&1)j|=1<<(b-k-1);
		}
		if(i<j)swap(f[i],f[j]);
	}
	for(int i=2;i<=n;i<<=1){
		ll w=ppow(r,(MOD-1)/i);
		if(inv)w=ppow(w,MOD-2);
		for(int k=0;k<n;k+=i){
			ll x=1;
			rep(j,i/2){
				ll t=x*f[k+j+i/2]%MOD,u=f[k+j];
				f[k+j]=(u+t)%MOD;
				f[k+j+i/2]=(u+MOD-t)%MOD;
				(x*=w)%=MOD;
			}
		}
	}
	if(inv){
		ll n_inv=ppow(n,MOD-2);
		rep(i,n)(f[i]*=n_inv)%=MOD;
	}
}
 
vector<ll>multiply(vector<ll>A,vector<ll>B){
	int m=A.size()+B.size();
	int N=1;while(N<A.size()+B.size())N<<=1;
	A.resize(N);B.resize(N);
	dft(A,0);
	dft(B,0);
	vector<ll>f(N);
	rep(i,N)f[i]=A[i]*B[i]%MOD;
	dft(f,1);
	f.erase(f.begin()+m-1,f.end());
	return f;
}

int h[200000];
int d[200000];

int main(){
	int n;cin>>n;
	rep(i,2*n){
		scanf("%d",&h[i]);
		d[h[i]]++;
	}
	Fact fac(2*n);
	vector<ll>v(1);
	v[0]=1;
	vector<vector<ll>>bs;
	bs.push_back(v);
	rep(i,100001){
		if(d[i]==0)continue;
		vector<ll>B;
		rep(j,d[i]/2+1){
			ll X=fac.nCr(d[i],j*2)*fac.get(2*j)%MOD*fac.get_inv(j)%MOD;
			B.push_back(X);
		}
		bs.push_back(B);
	}
	while(bs.size()>1){
		vector<vector<ll>>nbs;
		for(int i=0;i<bs.size();i+=2){
			if(i+1>=bs.size())nbs.push_back(bs[i]);
			else{
				nbs.push_back(multiply(bs[i],bs[i+1]));
			}
		}
		bs=nbs;
	}
	v=bs[0];
	ll U=0;
	for(ll i=0;i<=min(n,(int)v.size()-1);i++){
		ll X=v[i]*fac.nCr(n,i)%MOD*fac.get(i)%MOD*fac.get(2*n-2*i)%MOD;
		//~ cout<<"X: "<<X<<endl;
		if(i%2==0)(U+=X)%=MOD;
		else (U+=MOD-X)%=MOD;
	}
	//~ cout<<U<<endl;
	ll ans=U*fac.get_inv(n)%MOD*ppow(ppow(2,n),MOD-2)%MOD;
	cout<<ans<<endl;
}

Measured memory_bytes: 15676
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
typedef long long ll;
#define M 1000000007
ll n,m,ans;
ll dp[305][305][305];
ll z[305];
int main(void){
    cin>>n>>m;
    for(int i=1;i<=m;i++)z[i]=z[i-1]*n%M;
    dp[0][n-1][1]=1;
    for(ll i=0;i<m;i++){
        for(ll j=0;j<n;j++){
            for(ll k=1;k<=n;k++){
                dp[i+1][j-1][k]=(dp[i+1][j-1][k]+dp[i][j][k]*j%M)%M;
                dp[i+1][j][k]=(dp[i+1][j][k]+dp[i][j][k]*(n-j-k)%M)%M;
                dp[i+1][j][n-j]=(dp[i+1][j][n-j]+dp[i][j][k]*k)%M;
            }
        }
    }
    cout<<dp[m][0][n]<<endl;
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main()
{
    LL n,x,t;cin>>n>>x>>t;
    cout<<((n+x-1)/x)*t<<endl; 
    
    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 3648
# -*- coding: utf-8 -*-

N, M = map(int, input().split())
cnt = [0]*(M+1)

for i in range(N):
    l = [int(i) for i in input().split()]
    for a in l[1:]:
        cnt[a] += 1
res = sum([1 for c in cnt if c == N])
print(res)


Measured memory_bytes: 3060
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <iterator>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <deque>
#include <iostream>
#include <iomanip>
#include <limits>
#include<functional>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <numeric>
//#include<unordered_map>
#define inf  2e9
#define seed 131
#define pi acos(-1)
#define mem(a,b) memset(a,b,sizeof(a))
#define lowbit(x) ((x)&(-x))
#define lrtnb srand(unsigned(time(NULL)))
#define lrtlh ios::sync_with_stdio(0)
#define lowb(a,n,x) lower_bound(a,a+n,x) - a
#define uppb(a,n,x) upper_bound(a,a+n,x) - a
#define lson l,mid,i<<1;
#define rson mid+1,r,i<<1|1;
#define ALL(x) x.begin(),x.end()
#define inv inline void
#define INS(x) inserter(x,x.begin())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef priority_queue<int> pqi;
typedef priority_queue<ll> pql;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef stack<int> si;
typedef stack<ll> sl;
typedef set<int> Si;
typedef set<ll> Sl;
ll gcd(ll n, ll m) { long long r; if (n < m)swap(n, m); while (m) { r = n % m; n = m; m = r; }return n; }
ll lcm(ll b, ll y) { return b * y / gcd(b, y); }
double dis(double x1, double y1, double x2, double y2) { double ans = (x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2); return sqrt(ans); }
double random(double start, double en) { return start + (en - start)*rand() / (RAND_MAX + 1.0); }
void read(int &n) { char c = '+'; int x = 0; bool flag = 0; while (c<'0' || c>'9') { c = getchar(); if (c == '-')flag = 1; }while (c >= '0'&&c <= '9')x = x * 10 + c - 48, c = getchar(); n = flag == 1 ? -x : x; }
int main() {
	int n;
	cin >> n;
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		sum += i;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n; cin>>n;
	vector<int> a(n);
	for (int &x: a) cin>>x;
    sort(a.begin(), a.end());
    long long res=0;
    for (int i=a.size()-1; i>=2; --i) {
        int l=0, r=i-1;
        while (l<r) {
            if (a[l]+a[r]>a[i]) {
                res+=(long long)(r-l);
                --r;
            } else {
                ++l;
            }
        }
    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 256
import heapq
from bisect import bisect_left
n, m = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]
l.sort()
b = 0
hq = []
ans = 0
for d in range(1, m + 1):
    idx = bisect_left(l, [d + 1, -1])
    for i in range(b, idx):
        heapq.heappush(hq, -l[i][1])
    if hq:
        ans += -heapq.heappop(hq)
    b = idx
print(ans)

Measured memory_bytes: 31612
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

struct UnionFind {
    //自身が親であれば，その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;

    UnionFind(int n) {
        r = vector<int>(n, -1);
    }

    int root(int x) { //木の根を調べる（どのグループに属しているか）
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y) { //xとyの属する集合を併合
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    int size(int x) { //xが属する集合の頂点数を調べる
        return -r[root(x)];
    }

    bool same(int x, int y) { //xとyが同じ集合に属するか否か
        return root(x) == root(y);
    }
};
 
int main() {
    int n; cin >> n;
    map<string, int> mp;

    rep(i,n) {
        string s; cin >> s;
        mp[s] += 1;
    }

    int mx = 0;
    for (auto x : mp) {
        int v = x.second;
        if (v > mx) mx = v;
    }

    for (auto it=mp.begin(); it!=mp.end(); it++) { //mapではキーが昇順になるよう要素がソートされてる
        if (it->second == mx) {
            cout << it->first << endl;
        }
    }
}


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


int main() {
    int n;
    cin >> n;
    ll ans = 0;
    rep(i,n) {
        int a;
        cin >> a;
        ans += (a-1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define ll long long
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int n,h[100010];
int dp[100010];
signed main(){
	cin>>n;
	rep(i,n)cin>>h[i];
	fill(dp,dp+n,INF);
	dp[0]=0;
	for(int i=1;i<n;i++){
		if(i==1)dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
		else dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
n=int(input())

l=[int(x) for x in input().split()]

for i in range(n):
    j=i
    while j>0 :
        if l[j-1]>l[j]:
            a=l[j]
            l[j]=l[j-1]
            l[j-1]=a
            j-=1
        else :
            break

    print(*l)



Measured memory_bytes: 5984
cnt = 0
def merge(A, left, mid, right):
    global cnt
    L = A[left:mid] + [10 ** 10]
    R = A[mid:right] + [10 ** 10]
    i = j = 0
    for k in range(left, right):
        cnt += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
def merge_sort(A, left, right):
    if left + 1 < right:  # 1 < right - left
        mid = (left + right) // 2
        merge_sort(A, left, mid)
        merge_sort(A, mid, right)
        merge(A, left, mid, right)
    return A

n = int(input())
A = list(map(int, input().split()))
print(*merge_sort(A, 0, n))
print(cnt)


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

int main(){
    int a, b;
    string c;
    cin >> a >> c >> b;
    if (c == "+"){
        cout << a + b << endl;
    }
    else{
        cout << a - b << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int calc(string s) {
    int n = s.length();
    int same = 0;
    int tmp = 1;
    rep(i, n-1) {
        if (s[i] == s[i+1]) {
            tmp++;
        } else {
            same += tmp/2;
            tmp = 1;
        }
    }
    same += tmp/2;
    return same;
}

int main() {
    string s;
    ll k;
    cin >> s >> k;

    ll ans;
    string s2 = s + s;
    string s3 = s + s + s;
    int same1 = calc(s);
    int same2 = calc(s2) - same1;
    int same3 = calc(s3) - same1*2;
    if (k%2==1) ans = same1 * (k/2+1) + same3 * (k/2);
    else {
        ans = same1 * (k/2) + same3 * (k/2-1) + same2;
    }

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

Measured memory_bytes: 256
#include<iostream>
#pragma warning(disable:4786)
#include<map>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	string a;
	map<string, vector<int>> d;
	while(getline(cin, a)){
		string b, h = "";
		int c, sum = 0;
		a += " ";
		for (int i = 0; i < a.length(); i++) {
			if (a[i] == ' ') {
				if (sum == 0)
					b = h;
				else
					c = atoi(h.c_str());
				sum++;
				h = "";
			}
			else
				h += a[i];
		}
		d[b].push_back(c);
	}
	map<string, vector<int>>::iterator t = d.begin();
	while (t != d.end()) {
		string k = (*t).first;
		sort(d[k].begin(), d[k].end());
		cout << k << endl;
		vector<int>::iterator ite = d[k].begin();
		for(ite=d[k].begin();ite!=d[k].end();++ite) {
			if (ite == d[k].begin())
				cout << *ite;
			else
				cout << " " << *ite;
		}
		cout << "\n";
		t++;
	}
}

Measured memory_bytes: 2996
from collections import deque

dxs = [1,0,-1,0]
dys = [0,1,0,-1]
def bfs(x,y,c):
    q = deque([(x,y)])
    while q:
        x,y = q.popleft()
        for dx,dy in zip(dxs,dys):
            nx,ny = x+dx,y+dy
            if nx < 0 or nx >= W or ny < 0 or ny >= H: continue
            if src[ny][nx] != '.' or mem[c][ny][nx]: continue
            q.append((nx,ny))
            mem[c][ny][nx] = 1

while True:
    W,H = map(int,input().split())
    if W == 0: break
    src = [input() for i in range(H)]
    mem = [[[0 for w in range(W)] for h in range(H)] for c in range(2)]
    for y in range(H):
        for x in range(W):
            if src[y][x] == '.': continue
            c = (0 if src[y][x] == 'B' else 1)
            bfs(x,y,c)
    b = w = 0
    for y in range(H):
        for x in range(W):
            bm,wm = mem[0][y][x], mem[1][y][x]
            if bm and not wm: b += 1
            elif wm and not bm: w += 1
    print(str(b) + ' ' + str(w))

Measured memory_bytes: 6052
#include "bits/stdc++.h"
using namespace std;
 
int n;
bool f = false;
void buy(int m){
	if(m == n)
		f = true;
	else{
		if(!f && m + 4 <= n)
			buy(m + 4);
		if(!f && m + 7 <= n)
			buy(m + 7);
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>n;
	if(n < 4)
		cout<<"No";
	else{
		buy(0);
		if(f)
			cout<<"Yes";
		else
			cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
w = [0] * n
e = [0] * n
for i in range(1,n):
  if s[i-1] == 'W':
    w[i] = w[i-1] + 1
  else:
    w[i] = w[i-1]
for i in range(n-2,-1,-1):
  if s[i+1] == "E":
    e[i] = e[i+1] + 1
  else:
    e[i] = e[i+1]
m = n
for i in range(n):
  m = min(m,e[i]+w[i])
print(m)

Measured memory_bytes: 45796
loop do
    h, w = gets.chomp.split.map(&:to_i)
    if (h + w).zero?
        break
    end
    (0...h).each do |y|
        line = ""
        (0...w).each do |x|
            line = (y + x).even? ? line + "#" : line + "."
        end
        puts line
    end
    puts
end


Measured memory_bytes: 7244
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    P = list()
    for i in range(N):
        P.append([A[i], i+1])
    P = sorted(P, key=lambda x: x[0])
    for i in range(N):
        stu = P[i]
        print(stu[1], end=" ")
    print()
if __name__ == "__main__":
    main()

Measured memory_bytes: 23076
import sys
input = sys.stdin.readline
H, W = map(int, input().split())
res = float("inf")

if H * W % 3:
  for x in range(1, H):
    a = x * W
    b = (H - x) * (W // 2)
    c = (H - x) * W - b
    t = max(a, b, c) - min(a, b, c)
    res = min(res, t)
    #print(a,b,c)
  for x in range(1, W):
    a = x * H
    b = (W - x) * (H // 2)
    c = (W - x) * H - b
    t = max(a, b, c) - min(a, b, c)
    res = min(res, t)
    #print(a,b,c)
  for x in range(1, H):
    a = x * W
    b = W * ((H - x) // 2)
    c = (H - x) * W - b
    t = max(a, b, c) - min(a, b, c)
    res = min(res, t)
    #print(a,b,c)
  for x in range(1, W):
    a = x * H
    b = H * ((W - x) // 2)
    c = (W - x) * H - b
    t = max(a, b, c) - min(a, b, c)
    res = min(res, t)
  print(res)
else:
  print(0)

Measured memory_bytes: 42864
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll n,kt=26;
  cin >> n;
  string v="";
  for(ll i=1;;i++){
    if(n>kt){
      n -= kt;
    }else{
      n-=1;
      for(ll j=0;j<i;j++){
        v += 'a'+(n%26);
        n /= 26;
      }
      break;
    }
    kt *= 26;
  }
  reverse(v.begin(),v.end());
  cout << v << endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5;
ll arr[N];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for (int i=0;i<n;i++)
        cin>>arr[i];
    for (int i=1;i<n;i++)
        arr[i]+=arr[i-1];
        ll minn=1e18;
    for (int i=0;i<n-1;i++){
            ll tem=arr[n-1]-arr[i];
        minn=min(minn,abs(tem-arr[i]));
    }
    cout<<minn;
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()

#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef		long long       ll;
typedef		vector<ll>      vll;

int main()
{
  string s,ss;
  ll n,i=0,j=0;
  cin>>s; cin>>n;
  for(i=0;i<s.size();i+=n)
    cout<<s[i];

    return 0;
}


Measured memory_bytes: 256
a, b, c = map(int,input().split())
ans = 0

if a == b == c and a%2 == 0:
    print(-1) #無限
    exit()

while a%2 == 0 and b%2 == 0 and c%2 == 0:
    ans += 1

    x = b//2 + c//2
    y = a//2 + c//2
    z = a//2 + b//2
    
    a = x
    b = y
    c = z

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define cout_db cout << fixed

#define MOD 1000000007LL
#define PI 3.1415926

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n, l[10], MAX = -1, sum = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> l[i];
		sum += l[i];
		if(l[i] > MAX) MAX = l[i];
	}
	if(MAX < sum-MAX) cout << "Yes" << endl;
	else cout << "No" << endl;

	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 n=sc.nextInt();
		long arr[]=new long[n];
		long allsum=0;
		for(int i=0;i<n;i++)
			{
				arr[i]=sc.nextLong();
				allsum+=arr[i];
				allsum%=1000000007;
			}
		long sum=0;
		for(int i=0;i<n;i++)
		{
			allsum-=arr[i];
			if (allsum < 0) allsum += 1000000007;
			sum+=(allsum*arr[i]);
			sum%=1000000007;
		
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 61600
i = int(input())
p = 0
while i != 0:
    k =[ [0]*100]*20
    ma = 0
    mi = 1000
    for pp in range(i):
        l = int(input())
        k[p][pp] = l
        ma = max(ma,l)
        mi = min(mi,l)
    su = sum(k[p]) - ma - mi
    l = i -2
    print(su // l)
    p += 1
    i = int(input()) 


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

typedef long long ll;
typedef long double ld;
typedef vector<ll> v1;
typedef vector<v1> v2;
typedef vector<v2> v3;

typedef unordered_map<ll, unordered_map<ll, ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

ll m,d;
ll ans;

int main(){
    cin >> m >> d;
    for(ll i = 1;i <= m;i++){
        for(ll j = 10;j <= d;j++){
            ll d1 = (j%10);
            ll d10 = (j/10);
            if(d1*d10 == i && d1 >= 2 && d10 >= 2){
                // cerr << i << " " << j << endl;
                ans++;
            }
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	char d,b,c;
	int a=0;
	cin>>d>>b>>c;
  if(a=='1')
    d++;
  if(b=='1')
    d++;
  if(c=='1')
    d++;
  cout<<d<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int ans = n * (n - 1) / 2 + m * (m - 1) / 2;
        System.out.println(ans);
    }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

void solve(int w,int h){
	int in;
	vvb tate(h,(vb(w-1)));
	vvb yoko(h-1,(vb(w)));
	rep(i,2*h-1){
		if(i%2==0){
			rep(j,w-1){
				cin>>in;
				tate[i/2][j]=(in==1);
			}
		}
		else{
			rep(j,w){
				cin>>in;
				yoko[i/2][j]=(in==1);
			}
		}
	}
	vvi vv(h+2,vi(w+2,-1));
	rep(i,h)rep(j,w)vv[i+1][j+1]=INF;
	vv[1][1]=1;
	queue<pii> q;
	q.push(pii(1,1));
	while(!q.empty()){
		int i,j;
		tie(i,j)=q.front();q.pop();
		if(i==h&&w==j){
			cout<<vv[i][j]<<endl;
			return;
		}
		if(vv[i][j]+1<vv[i][j+1]&&tate[i-1][j-1]==false){
			vv[i][j+1]=vv[i][j]+1;
			q.push(pii(i,j+1));
		}
		if(vv[i][j]+1<vv[i][j-1]&&tate[i-1][j-2]==false){
			vv[i][j-1]=vv[i][j]+1;
			q.push(pii(i,j-1));
		}
		if(vv[i][j]+1<vv[i+1][j]&&yoko[i-1][j-1]==false){
			vv[i+1][j]=vv[i][j]+1;
			q.push(pii(i+1,j));
		}
		if(vv[i][j]+1<vv[i-1][j]&&yoko[i-2][j-1]==false){
			vv[i-1][j]=vv[i][j]+1;
			q.push(pii(i-1,j));
		}
	}
	cout<<0<<endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w;
	while(cin>>w>>h,h)solve(w,h);
}


Measured memory_bytes: 3108
import java.util.*;

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

    int min=Math.min(a+b,a+c);
        min=Math.min(min,b+c);

    System.out.println(min);
  }
}


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


int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    if(n==k){
        cout<<1<<endl;
    } 
    else{
        cout<<(n-1)/(k-1)+(int)((n-1)%(k-1)!=0)<<endl;
    }

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int H, W, A, B;
	cin >> H >> W >> A >> B;

	rep(i, B) {
		rep(j, A) cout << 0;
		for (int j = A; j < W; j++) cout << 1;
		cout << "\n";
	}
	for (int i = B; i < H; i++) {
		rep(j, A) cout << 1;
		for (int j = A; j < W; j++) cout << 0;
		cout << "\n";
	}

	


	Would you please return 0;
}

Measured memory_bytes: 1280
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
  ll n; cin >> n; ll an = 1e18;
  for(ll i=1; i*i<=n; i++) {
    if (n%i == 0) an = min(an, i-1 + n/i-1 );
  }
  cout << an << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        char[] S = scanner.next().toCharArray();
        char[] T = scanner.next().toCharArray();
        
        int count = 0;
        for (int i = 0 ; i < S.length ; i++) {
            if (S[i] != T[i]) {
                count++;
            }
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 41772
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp;
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// [beg, end)の範囲を，添え字indexでループするfor文に置換します
#define range(index, beg, end) for (ll index = beg; index < N; ++index)
#define times(N) for (ll i = 0; i < N; i++)
#define rev_range(N) for (ll i = N-1; i >= 0; i--)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

ll powMod(ll a, ll n, ll mod){
    if(n == 0) return 1;
    if(n%2 == 0)
        return powMod(a, n/2, mod) * powMod(a, n/2, mod) % mod;
    else
        return a * powMod(a, n-1, mod)% mod;
}

ll ncrMod(ll n, ll r, ll mod){
    ll x=1, y=1;
    for(ll i = 1; i <= r; ++i){
        x *= n-i+1;
        x %= mod;
        y *= i;
        y %= mod;
    }
    return x * powMod(y, mod-2, mod) % mod;
}

int main() {
    string S;

    cin >> S;

    if (S.length() < 2 || S.length() % 2 != 0) {
        cout << "No";
        return 0;
    } else {
        times(S.length()) {
            if (i % 2 == 0 && S[i] != 'h') {
                cout << "No"; break;
            } else if (i % 2 == 1 && S[i] != 'i') {
                cout << "No"; break;
            } else if (i == S.length() - 1) {
                cout << "Yes";
            }
        }
    }


    return 0;
}



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

int main() {
	int num,sum=0;
	cin >> num;
	for (int i = num; i!= 0;i/=10) sum += i % 10;
	if (num%sum == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
// Phoenix

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

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

const int maxn=1e5+10,mod=1e9+7;
const ll inf=1e18;

int a[maxn];

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    for(int i=0;i<2*n;i++)
	cin>>a[i];
    sort(a,a+2*n);
    int ans=0;
    for(int i=0;i<n;i++)
	ans+=a[2*i];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
def collaz(n):
    if n%2 == 0:
        return n//2
    else:
        return int(3*n+1)

s = int(input())

box = [-1]*(int(1e6+1))

box[s] = 1

i = 1

while 1:
    if box[collaz(s)] == 1:
        print(i+1)
        break
    else:
        box[collaz(s)] = 1
        s = collaz(s)
        i += 1
    

Measured memory_bytes: 10868
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = int.Parse(line[0]);
        var b = int.Parse(line[1]);
        if (a == 1) a = 14;
        if (b == 1) b = 14;
        string res;
        if (a > b) res = "Alice";
        else if (a < b) res = "Bob";
        else res = "Draw";
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 13140