akhauriyash/Code-Regression huggingface dataset:
n = int(input())
b = list(map(lambda x:int(x),input().split()))

a = []
for i in range(n):
    if i == 0:
        a.append(b[i])
    elif i == n-1:
       a.append(b[i-1])
    else:
        if b[i-1]<b[i]:
            a.append(b[i-1])
        else:
            a.append(b[i])


#print(a)


def sum(list):
    lsum = 0
    for i in range(len(list)):
        lsum = lsum+list[i]

    return lsum

print(sum(a))



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

int main(){
  int N;cin >> N;
  vll A(N);
  vector<vector<int>> vx(N),vy(N);
  rep(i,N){
    cin>>A[i];
    rep(j,A[i]){
      int x,y;cin>>x>>y;x--;
      vx[i].push_back(x);
      vy[i].push_back(y);
    }
  }
  int ans = 0;
  vector<int> v(N,0);
  rep(i,N){
    //cout<< "i " << i << endl;
    rep(f,v.size()) v[f]=1;
    rep(k,i) v[k]=0;
    do{
      bool flag = true;
      rep(i,N){
        if(v[i]==0) continue;
        rep(j,A[i]){
          if(v[vx[i][j]]!=vy[i][j]){
            flag=false;
          }
        }
      }
      //rep(t,v.size()) cout<<v[t];
      //cout<<endl;
      if(flag) ans = max(ans,accumulate(all(v),0));
    }while(next_permutation(all(v)));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint(){
    int x=0,p=1;char c=getchar();
    while (c<=32)c=getchar();
    if(c==45)p=-p,c=getchar();
    while (c>32)x=x*10+c-48,c=getchar();
    return x*p;
}
using namespace std;
//ruogu
const int N=5e5+10;
int n,pre[2][N];
char s[N];
//
void getfail(int *fail){
	fail[1]=0;
	for(int i=2,j=0;i<=n;i++){
		while(j>0&&s[j+1]!=s[i])j=fail[j];
		if(s[j+1]==s[i])j++;
		fail[i]=j;
	}
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	getfail(pre[0]);
	reverse(s+1,s+1+n);
	getfail(pre[1]);
	int len=n-pre[0][n];
	if(n%len!=0||len==n){
		printf("%d\n%d\n",1,1);
		return 0;
	}
	int c=n/len;
	if(c==n){
		printf("%d\n%d\n",n,1);
		return 0;
	}
	reverse(s+1,s+1+n);
	int res=0;
	for(int i=1;i<n;i++){
		int x=i-pre[0][i];
		if(i%x==0&&x<i)continue;
		 x=(n-i)-pre[1][n-i];
		if((n-i)%x==0&&x<n-i)continue;
		res++;
	}
	printf("%d\n%d\n",2,res);
	return 0;
}

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

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  sort(p.begin(),p.end());
  int x = 0;
  int y = 0;
  int z = 0;
  rep(i,n){
    if(p[i] <= a) ++x;
    else if(p[i] <= b) ++y;
    else ++z;
  }
  cout << min(min(x,y),z) << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N; cin >> N;
  ll A[N]; rep(i,N) cin >> A[i];
  ll result = 0;
  ll dp[N/2+1][3] = {};
  rep(i,N/2+1) fill_n(dp[i],3,-1*LLINF); dp[0][0] = 0;
  rep(i,N/2) {
    dp[i+1][0] = dp[i][0] + A[i*2];
    dp[i+1][1] = *max_element(dp[i],dp[i]+2) + A[i*2+1];
    if (N%2==1) dp[i+1][2] = *max_element(dp[i],dp[i]+3) + A[i*2+2];
  }
  // rep(i,N/2+1) debug(dp[i],dp[i]+3);
  result = *max_element(dp[N/2],dp[N/2]+3);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 7556
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e09;

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

  int x, y;
  cin >> x >> y;

  int g[13] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};

  cout << ((g[x] == g[y]) ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N = I()
A = III()

for i in range(N):
    A[i] = str(format(A[i],'b')).zfill(60)

ans = 0
for i in range(60):
    zc = 0
    oc = 0
    for j in range(N):
        if A[j][59-i]=='0':
            zc += 1
        else:
            oc += 1
    ans += 2**i*zc*oc
    ans %= mod
print(ans)

Measured memory_bytes: 135952
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
#define FOR(i, a, b) for (ll i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (ll i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 1000005
int n;
ll a[MN];
ll sm[MN];
ll pmb[MN];
ll bruh[MN];
ll smsqs[MN];

int sie[MN];
int mob[MN];
void gms(){
    FOR(i, 2, MN-1){
        if(sie[i] == 0){
            for(int j=i; j<MN; j+=i){
                sie[j] = i;
            }
        }
    }
    sie[1] = 1;
    mob[1] = 1;
    FOR(i, 2, MN-1){
        int cnt = 0;
        int x = i;
        while(x != 1){
            int fac = sie[x];
            x /= fac;
            if(x % fac == 0){
                mob[i] = 0;
                break;
            }
            ++cnt;
        }
        if(x == 1){
            if(cnt % 2 == 0){
                mob[i] = 1;
            } else{
                mob[i] = -1;
            }
        }
    }
}

pll gcd(ll a, ll b){ //a*first+b*second=gcd
    if(a == 0){
        return mp(0, 1);
    }

    pll prev = gcd(b%a, a);

    return mp(prev.s-(b/a)*prev.f, prev.f);
} //using ll's just to be safe wrt overflow issues
ll modInv(ll x){ //return x^-1 % MOD
    pll res = gcd(x, MOD);

    res.f = (res.f+MOD)%MOD;

    //cout << "modinv of " << x << " is " << res.f << "\n";

    return res.f;
}
ll modDiv(ll x, ll y){
    return (x*modInv(y))%MOD;
}

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

    gms();
    /*FOR(i, 1, 10) cout << mob[i] << " ";
    cout << "\n";*/
    cin >> n;
    FOR(i, 1, n){
        int x;
        cin >> x;
        a[x] += x;
        //smsqs[x] += 1LL*x*x;
        a[x] %= MOD; //smsqs[x] %= MOD;
    }

    FOR(i, 1, MN-1){
        for(int j=i; j<=MN-1; j+=i){
            sm[i] = (sm[i]+a[j])%MOD;
            smsqs[i] = (smsqs[i]+a[j]*j)%MOD;
        }
        //if(sm[i] != 0) cout << i << " " << sm[i] << "\n";
        //if(smsqs[i] != 0) cout << i << " " << smsqs[i] << "\n";
    }
    //cout << "pmb\n";
    FOR(i, 1, MN-1){
        pmb[i] = (sm[i]*sm[i]-smsqs[i]);
        pmb[i] = ((pmb[i]%MOD)+MOD)%MOD;
        pmb[i] = modDiv(pmb[i], 2);
        //if(pmb[i] != 0) cout << i << " " << pmb[i] << "\n";
    }
    //cout << "bruh\n";
    FOR(i, 1, MN-1){
        for(int j=1; j*i <= MN-1; j++){
            bruh[i] += pmb[i*j]*mob[j];
            bruh[i] = (bruh[i]+MOD)%MOD;
        }
        //if(bruh[i] != 0) cout << i << " " << bruh[i] << "\n";
    }

    ll ans = 0;
    FOR(i, 1, MN-1){
        ll cont = modDiv(bruh[i], i);
        //if(cont != 0) cout << i << " " << cont << "\n";
        ans = (ans+cont)%MOD;
    }
    cout << ans << "\n";

    return 0;
}


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

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

Measured memory_bytes: 3648
package main

import (
	. "fmt"
	"os"
	"sort"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	buf := make([]byte, 4096)
	_i := len(buf)
	rc := func() byte {
		if _i == len(buf) {
			os.Stdin.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b || b > '9'; b = rc() {
		}
		for ; '0' <= b && b <= '9'; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}
	type pair struct{ x, y int }
	var ll, rr []pair
	d := 0
	for n := r(); n > 0; n-- {
		l, r := 0, 0
		b := rc()
		for ; b < '('; b = rc() {
		}
		for ; b >= '('; b = rc() {
			if b == '(' {
				l++
			} else if l > 0 {
				l--
			} else {
				r++
			}
		}
		if r < l {
			ll = append(ll, pair{r, l})
		} else {
			rr = append(rr, pair{l, r})
		}
		d += l - r
	}
	sort.Slice(ll, func(i, j int) bool { return ll[i].x < ll[j].x })
	sort.Slice(rr, func(i, j int) bool { return rr[i].x < rr[j].x })
	f := func(ps []pair) bool {
		s := 0
		for _, p := range ps {
			if s < p.x {
				return false
			}
			s += p.y - p.x
		}
		return true
	}
	if d == 0 && f(ll) && f(rr) {
		Print("Yes")
	} else {
		Print("No")
	}
}


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

int main() {
  string s;
  cin >> s;
  bool yy=false;
  bool mm=false;
  if(s[0]*10+s[1]-11*'0'<=12&&s[0]*10+s[1]-11*'0'>0)mm=true;
  if(s[2]*10+s[3]-11*'0'<=12&&s[2]*10+s[3]-11*'0'>0)yy=true;
  if(mm&&yy)cout << "AMBIGUOUS";
  else if(mm)cout << "MMYY";
  else if(yy)cout << "YYMM";
  else cout << "NA";
  cout << endl;
}


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

int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
	int K;
	scanf("%d", &K);
	printf("%d\n", a[K - 1]);
	return 0;
}

Measured memory_bytes: 256
main = input => {
	input = (input.split('\n'))[0];
    result = '';
    if (input === 'Sunny') {
        result = 'Cloudy';
    } else if (input === 'Cloudy') {
        result = 'Rainy';
    } else {
        result = 'Sunny';
    }
    console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));




Measured memory_bytes: 7372
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <queue>
#include <stack>
typedef long long ll;
using namespace std;

int main(){
  ll i,j,k,n,m;
  cin >> n >> m;
  ll a[m]={};
  for(i=0;i<n;i++){
    ll t;
    cin >> t;
    for(j=0;j<t;j++){
      cin >> k;
      a[k-1]++;
    }
  }
  ll ret = 0;
  for(i=0;i<m;i++)if(a[i]==n)ret++;
  cout << ret << endl;
  string s;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,N) for(int (i)=0;(i)<(N);(i)++)
#define REPR(i,N) for(int (i)=(N);i>=0;i--)
#define FOR (i,m,n) for(int (i)=m;(i)<(n);(i)++)

int main(){
  int num, K, termx, ans=0;
  cin >> num >> K;
  REP(i,num){
    cin >> termx;
    if(termx<K-termx)ans+=2*termx;
    else ans+=(K-termx)*2;
  }
  cout << ans;
}

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

int abs(int x){
  int y;
  if(x < 0){
    y = -x;
  }else{
    y = x;
  }
  return y;
}

int main(){
  int N,L;
  int min = 99999;
  int sum = 0;
  int save = 0;
  scanf("%d %d",&N,&L);
  for(int i = 1; i < N+1; i ++){
    sum += L+i-1;
  }
  for(int j = 1; j < N+1; j ++){
    int tmp = sum-(L+j-1);
    if(abs(tmp-sum) < min){
      min = abs(tmp-sum);
      save = j;
    }
  }
  printf("%d\n",sum-(L+save-1));
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
#include<map>//map
using namespace std;
typedef long long LL; 
typedef pair<LL,LL> P;//Pでpair<-,->を表す。
const LL MAX=2000010;
const LL MOD=1000000007;
typedef map<LL,LL>::iterator Itr;

/*ここから*/
LL Euclid(LL a,LL b){
    while(1){
        if(a<b){int c=a;a=b;b=c;}
        if(a%b==0){return b;}
        else{a=a%b;}
    }
}
/*ここまで*/

int main()
{ 
    LL k;
    LL sum=0;
    cin>>k;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int l=1;l<=k;l++){
                LL x=Euclid(i,j);
                sum=sum+Euclid(x,l);
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3636
N,M = list(map(int,input().split()))
X = list(map(int,input().split()))
sortedX = sorted(X)
deltaList = []
for i in range(len(sortedX) - 1):
    delta = sortedX[i + 1] - sortedX[i]
    deltaList.append(delta)
sortedDeltaList = sorted(deltaList)
answer = 0
count = M - 1 - N + 1
if count <= 0:
    answer = 0
else:
    for i in range(count):
        answer += sortedDeltaList[i]
print(answer)

Measured memory_bytes: 20480
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define name(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int N=(int)1e6+7;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a  >> b;
    if(a >= 13)cout << b << '\n';
    else {
        cout << ( a < 6 ? 0 : b / 2) << '\n';
    }

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y<a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[1101];
int l[1111];
int j[1];

long long x,y,z,mod=1000000007;
//string r;
char r[1];

P u[1];
queue<int> q;
stack<P> s;
vector<int> v[1111];

bool as(P a,P b)
{
  return a.x<b.x;
}

void f(int n)
{
  int dd[5010],k=0;
  memset(dd,0,sizeof(dd));
  dd[0]=1;
  for(int h=0;h<v[n].size();h++)
  {
    int s[5010];
    memset(s,0,sizeof(s));
    f(v[n][h]);
    k+=l[v[n][h]];
    for(int t=0;t<=o[n];t++)
    {
      if(t>=o[v[n][h]]) s[t]=max(s[t],dd[t-o[v[n][h]]]);
      if(t>=l[v[n][h]]-o[v[n][h]]) s[t]=max(s[t],dd[t-l[v[n][h]]+o[v[n][h]]]);
    }
    for(int t=0;t<=o[n];t++)
      dd[t]=s[t];
  }
  //l[n]=k;
  for(int t=o[n];t>=0;t--)
    if(dd[t])
    {
      //printf("%d %d\n",n,t);
      l[n]=k+o[n]-t;
      return;
    }
  //printf("@@%d\n",n);
  puts("IMPOSSIBLE");
  exit(0);
}

int main()
{
  scanf("%d",&a);
  for(int t=2;t<=a;t++)
  {
    scanf("%d",&n);
    v[n].push_back(t);
  }
  for(int t=1;t<=a;t++)
    scanf("%d",&o[t]);
  f(1);
  //for(int t=1;t<=a;t++)
  //printf("%d ",l[t]);
  puts("POSSIBLE");
}
//3




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

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  int ans = X * A + Y * B;
  for (int nc = 2; nc <= 2 * X || nc <= 2 * Y; nc += 2) {
    int na = X - nc / 2; if (na < 0) na = 0;
    int nb = Y - nc / 2; if (nb < 0) nb = 0;
    int price = na * A + nb * B + nc * C;
    if (price < ans) {
      ans = price;
    }
  }
  cout << ans << endl;
}

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

#define LIMIT 100001

int N, Q, K;
vector<map<long long, long long>> nodeDis(LIMIT);
vector<long long> kToNode(LIMIT);
vector<bool> check(LIMIT);
vector<unordered_set<int>> vg(LIMIT);

void makeDistance(int k, long long dis){
  check[k] = true;
  kToNode[k] = dis;
  for(auto x: vg[k]){
    if(check[x]){
      continue;
    }
    makeDistance(x, dis + nodeDis[k].at(x));
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  cin >> N;
  for(int i = 0; i < N-1; i++){
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    nodeDis[a][b] = c;
    nodeDis[b][a] = c;
    vg[a].insert(b);
    vg[b].insert(a);
  }
  cin >> Q >> K;
  K--;
  makeDistance(K, 0);
  /*
  for(int i = 0; i < N; i++){
    cout << i << " " << kToNode[i] <<endl;
  }
  //*/
  for(int i = 0; i < Q; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    cout << kToNode[a] + kToNode[b] <<endl;
  }
}


Measured memory_bytes: 40672
#include <stdio.h>
#define N  2000001

int B[N],C[N];

void CountingSort(int A[],int B[],int k,int n){
  int i,j;

for(i=0; i<=k; i++){
  C[i] = 0;
 }

     /* C[i] に i の出現数を記録する */
for(j=1; j<=n; j++){
  C[A[j]]++;
	   }

     /* C[i] に i 以下の数の出現数を記録する*/
for(i= 1; i<=k; i++){
  C[i] = C[i] + C[i-1];
 }

for(j=n; j>=1; j--){
  B[C[A[j]]] = A[j];
  C[A[j]]--;
 }

for(i=1; i<=n; i++){
  printf("%d",B[i]);
  if(i != n) printf(" ");
 }
printf("\n");

}

int main(){
 
  int A[N];
  int k=0,n, i, j;

  scanf("%d", &n);
for(i=1; i<=n; i++){
  scanf("%d",&A[i]);
  if(k<A[i]) k=A[i];
 }

 CountingSort(A,B,k,n);


  return 0;
}





Measured memory_bytes: 17428
MOD = (10**9) + 7

n = int(input())
a = list(map(int, input().split()))

cnt = [0] * 60
for num in a:
    for j in range(60):
        cnt[j] += (num >> j) % 2

ans = 0
for b in range(60):
    ans += cnt[b] * (n - cnt[b]) << b
    ans %= MOD

print(ans)



Measured memory_bytes: 122936
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N,R;cin>>N>>R;
  
  if(N<10){
    cout<<R+100*(10-N)<<endl;
  }
  else{
    cout<<R<<endl;
  }
}

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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------

//main
//------------------------------------------
signed main(){
  int X;
  int A;
  cin >> X >> A;

  if(X<A){
    cout << 0 << endl;
  }else{
    cout << 10 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


class UnionFind:
    def __init__(self, size):
        self.parent = [-1] * size
        self.rank = [1] * size
        self.groups = size

    def get_root(self, node):
        parent = self.parent[node]
        if parent == -1:
            root = node
        else:
            root = self.get_root(parent)
            self.parent[node] = root  # 同じnodeへの2回目以降のget_rootを高速にするために、直接rootに繋いでおく
        return root

    def in_same_group(self, node1, node2):
        root1 = self.get_root(node1)
        root2 = self.get_root(node2)
        return root1 == root2

    def unite(self, node1, node2):
        if self.in_same_group(node1, node2):
            return
        main_root = self.get_root(node1)
        sub_root = self.get_root(node2)
        if self.rank[main_root] < self.rank[sub_root]:  # rankの大きい方をmain_rootにする
            main_root, sub_root = sub_root, main_root

        self.parent[sub_root] = main_root
        self.rank[main_root] += self.rank[sub_root]
        self.groups -= 1


n, m, k = map(int, input().split())
uf = UnionFind(n)
minus_count = [1] * n
# friend
for _ in range(m):
    a, b = map(int, input().split())
    uf.unite(a-1, b-1)
    minus_count[a-1] += 1
    minus_count[b-1] += 1

for _ in range(k):
    a, b = map(int, input().split())
    if uf.in_same_group(a-1, b-1):
        minus_count[a-1] += 1
        minus_count[b-1] += 1

result = []
for i in range(n):
    parent = uf.get_root(i)
    count = uf.rank[parent]
    ans = count - minus_count[i]
    result.append(ans)

print(*result)

Measured memory_bytes: 14984
#include <stdio.h>

int main(void)
{
	int a, b, d, r;
	double f;
	scanf("%d %d",&a, &b);
	
	d = a / b;
	r = a % b;
	f = (double)a / b;
	
	printf("%d %d %f", d, r, f);
	
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long int ll;
 
 
 ll N = 1000005;
const ll mod = 998244353;
const long long int inf = 1e10+5;
#define pp pair<ll,ll>
 
typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++) 
#define mtrace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<i->first<<" "<<i->second<<endl;   
void fastIO(void);
 
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);

 




int main(){
    ll a,b;
    cin>>a>>b;
    ll c =1;
    while(c==a || c==b) c++;
    cout<<c<<endl;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	string A;
	cin >> A;
	if (A[0] >= 'A' && A[0] <= 'Z') puts("A");
	else puts("a");
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    for (int i = a; i <= b; i++)
    {
        if (c % i == 0)
            ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3116
#include<iostream>
#include<complex>
#include<vector>
#include<algorithm>

using namespace std;

typedef complex<double> P;

double dot(P a,P b){
  return (a*conj(b)).real();
}

int main(){
  for(int H,R;cin>>H>>R,H;){
    P h[100];
    for(int i=0;i<H;i++){
      int x,y;
      cin>>x>>y;
      h[i]=P(x,y);
    }
    int UMS[3],dums[3];
    cin>>UMS[0]>>UMS[1]>>UMS[2]>>dums[0]>>dums[1]>>dums[2];
    P ums[3][10];
    for(int i=0;i<3;i++){
      for(int j=0;j<UMS[i];j++){
	int x,y;
	cin>>x>>y;
	ums[i][j]=P(x,y);
      }
    }
    int nr[100]={};
    for(int i=0;i<R;i++){
      int w,a;
      cin>>w>>a;
      auto reach=[=](P s,P d,int ang){
	P v=d-s;
	return abs(v)<a&&acos(min(1.,max(-1.,dot(v,polar(1.,w*acos(0)/90))/abs(v))))<ang*acos(0)/90/2;
      };
      for(int j=0;j<H;j++){
	if(reach(P(0,0),h[j],dums[0])){
	  bool f=false;
	  for(int k=0;k<3;k++){
	    for(int l=0;l<UMS[k];l++){
	      f|=reach(ums[k][l],h[j],dums[k]);
	    }
	  }
	  nr[j]+=!f;
	}
      }
    }
    auto m=*max_element(nr,nr+H);
    if(m==0){
      cout<<"NA"<<endl;
    }else{
      vector<int> v;
      for(int i=0;i<H;i++){
	if(m==nr[i]){
	  v.push_back(i+1);
	}
      }
      for(int i=0;i<v.size();i++){
	cout<<v[i]<<" \n"[i==v.size()-1];
      }
    }
  }
}

Measured memory_bytes: 1292
N = int(input())
ans = 1
A=[]
for i in range(N): 
    A.append(input())

for i in range(1, N):
    if A[i-1][-1] == A[i][0]:
        ans *= 1
    else:
        ans *= 0    
    
if all(A.count(i) == 1 for i in A):
    ans *= 1
else:
    ans *= 0  
    
print("Yes" if ans == 1 else "No")

Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int H = scan.nextInt();
		int N = scan.nextInt();
		int sum = 0;
		for (int count = 0; count < N; count++) {
			int x = scan.nextInt();
			sum += x;
			
		}
		if(H <= sum) {
			System.out.println("Yes");

		}
		else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 49064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using ll=long long;
using namespace std;
int main(){
 long double a,b,h,m;
  long double ans,c,dis;
  long double pi=3.141592653589793;
  cin>>a>>b>>h>>m;
  dis=abs(h*30+m/2-6*m);//角度は正になるように
  c=cos(dis*pi/180);//cosC
  ans=sqrt(a*a+b*b-2*a*b*c);
  cout<<fixed<<setprecision(10)<<ans<<endl;//fixed で小数点以下だよと教えてあげる。 setprecision で小数点以下の長さを指定してあげる。
}
  

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

int main(){
    int n, m, x;
    cin >> n >> m >> x;

    int c[n];
    int a[n][m];
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= m; j++){
            if(j == 0){
                cin >> c[i];
            }else{
                cin >> a[i][j - 1];
            }
        }
    }


    int ans = -1;
    for(int bit = 0; bit < (1<<n); ++bit){
        int  che[m];
        int k = 0;
        for(int i = 0; i < m; i++){
            che[i] = 0;
        }

        vector<int> s;
        for (int i = 0; i < n; ++i) {
            if (bit & (1<<i)) {
                s.push_back(i);
            }
        }

        for(int i = 0; i < s.size(); i++){
            for(int j = 0; j < m; j++){
                che[j] += a[s[i]][j];
            }
            k += c[s[i]];
        }

        int flag = 0;
        for(int i = 0; i < m; i++){
            if(che[i] < x){
                flag = 1;
                break;
            }
        }

        if(flag == 0){
            if(ans == -1 || ans > k){
                ans = k;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(ix,v.size())cout<<" "<<v[ix];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))

const int INF = 2125252830;

int r,c,n;
int xy[252521];
int val[125252];

int xmin[125252];
vector<pii> ys[125252];
vector<pii> g[125252];
ll dist[125252];
bool used[125252];

bool po[125252];
int a;
int node[125252];
int vere[125252];

bool check(){
  REP(i,a)vere[node[i]] = i;
  REP(i,a)dist[i] = 0;
  REP(i,a)used[i] = false;
  dist[0] = 0;
  used[0] = true;
  queue<int> Q;
  Q.push(0);
  while(!Q.empty()){
    int p = Q.front(); Q.pop();
    int id = node[p];
    ll d = dist[p];
    REP(i,g[id].size()){
      int to = vere[g[id][i].first];
      ll cost = (ll)g[id][i].second;
      ll nd = d+cost;
      if(used[to]){
        if(dist[to]!=nd)return false;
      }else{
        dist[to] = nd;
        used[to] = true;
        Q.push(to);
      }
    }
  }
  // negative check
  ll sm = *min_element(dist,dist+a);
  REP(i,a){
    if(sm + (ll)xmin[node[i]] < 0){
      return false;
    }
    if(i==a-1)break;
    sm -= dist[i+1]-dist[i];
  }
  return true;
}
 
bool valid(int n){
  REP(i,125252)po[i]=false;
  REP(i,n){
    if(po[i])continue;
    a = 0;
    po[i] = true;
    node[a++] = i;
    queue<int> Q;
    Q.push(i);
    while(!Q.empty()){
      int p = Q.front(); Q.pop();
      REP(j,g[p].size()){
        int to = g[p][j].first;
        if(po[to])continue;
        po[to] = true;
        node[a++] = to;
        Q.push(to);
      }
    }
    sort(node,node+a);
    if(!check())return false;
  }
  return true;
}

int Sx[125252],Sy[125252];
int Mx[125252],My[125252];
 
int main(){
  scanf("%d%d%d",&r,&c,&n);
  REP(i,n){
    scanf("%d%d%d",xy+2*i,xy+2*i+1,val+i);
    Sx[i] = xy[2*i];
    Sy[i] = xy[2*i+1];
  }
  sort(Sx,Sx+n);
  sort(Sy,Sy+n);
  r = unique(Sx,Sx+n)-Sx;
  c = unique(Sy,Sy+n)-Sy;
  REP(i,r)Mx[Sx[i]]=i;
  REP(i,c)My[Sy[i]]=i;

  REP(i,125252)xmin[i] = INF;
  REP(i,n){
    int x,y;
    x=Mx[xy[2*i]];
    y=My[xy[2*i+1]];
    CHMIN(xmin[y],val[i]);
    ys[x].emplace_back(y,val[i]);
  }
  // graph
  REP(i,r){
    sort(ALL(ys[i]));
    vector<pii> &vec = ys[i];
    REP(j,vec.size()-1){
      int s,t;
      s = vec[j].first;
      t = vec[j+1].first;
      int sa = vec[j+1].second - vec[j].second;
      g[s].emplace_back(t,sa);
      g[t].emplace_back(s,-sa);
    }
  }
  if(!valid(r)){
    puts("No");
    return 0;
  }
  // ok
  puts("Yes");
  return 0;
}


Measured memory_bytes: 13952
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	int min = 0;
	int max = 0;
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	min = a[0];
	sort(a.rbegin(), a.rend());
	max = a[0];
	for (int i = 0; i < n; i++) {
		sum += a[i];
	}
	cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;




int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    if(s.length()%2==1){
        out("No");
        return 0;
    }else{
        for(int i=0;i<n/2;i++){
            if(s[i]!=s[i+n/2]){
                out("No");
                return 0;
            }
        }
        out("Yes");
        return 0;
    }
}


Measured memory_bytes: 256
macro_rules! read {
    () => {{
        let mut input = String::new();
        std::io::stdin().read_line(&mut input).unwrap();
        input
    }};
}

fn read_to_vec<T: std::str::FromStr>() -> Vec<T> {
    read!().split_whitespace()
        .map(|e| e.parse::<T>().ok().unwrap())
        .collect()
}

fn main() {
    let val: Vec<i32> = read_to_vec();
    let (x, a) = (val[0], val[1]);

    println!("{}", if x < a {0} else {10});
}

Measured memory_bytes: 4352
#include<stdio.h>

#define N 200000

int main()
{
  int R[N],i,j,k,mim,max;

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

  max=R[1]-R[0];
  mim=R[0];

  for(j=1;j<k;j++){

    max=(max>R[j]-mim)? max :R[j]-mim;
    mim=(mim<R[j])? mim :R[j];
  }

  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 1376
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#define rep(i,n) for(ll i=0;i<n;i++)
#define repn(i,n) for(ll i=1;i<=n;i++)
using namespace std;
typedef long long ll;

const ll MOD=1'000'000'007;
const ll c[7]={1,2,3,5,8,13,21};
ll H,W,K;
ll dp[101][8];

int main(){
    rep(i,101) fill(dp[i],dp[i]+8,0);
    dp[0][0]=1;
    cin>>H>>W>>K;

    repn(i,H){
        rep(j,W){
            if(j==0) 
                dp[i][j]=dp[i-1][j]*c[max((ll)0,W-2)]
                        +dp[i-1][j+1]*c[max((ll)0,W-3)];
            else if(j==W-1) 
                dp[i][j]=dp[i-1][j]*c[max((ll)0,W-2)]
                        +dp[i-1][j-1]*c[max((ll)0,W-3)];
            else 
                dp[i][j]=dp[i-1][j-1]*c[max((ll)0,j-2)]*c[max((ll)0,W-j-2)]
                        +dp[i-1][j]*c[max((ll)0,j-1)]*c[max((ll)0,W-j-2)]
                        +dp[i-1][j+1]*c[max((ll)0,j-1)]*c[max((ll)0,W-j-3)];
            dp[i][j]%=MOD;
        }
    }

    ll ans=dp[H][K-1]>=0?dp[H][K-1]:dp[H][K-1]+MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<unordered_map>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
ll ans = 0;
int main() {
	cin >> N >> M;
	vector<int>flag(M, 0);
	for (int i = 0; i < N; i++) {
		cin >> K;
		for (int j = 0; j < K; j++) {
			cin >> A;
			flag[A - 1]++;
		}
	}
	for (int i = 0; i < M;i++) {
		if (flag[i] == N)ans++;
	}
	cout << ans << endl;
}

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

# check
# 考え方参考：https://note.com/tanon_cp/n/n6b51b9a57076
kill_monsters = 0
for i in range(N):
    if A[i] >= B[i]:
        kill_monsters += B[i]
        continue
    else:
        kill_monsters += A[i]
        B[i] -= A[i]
        if A[i + 1] > B[i]:
            kill_monsters += B[i]
            A[i + 1] -= B[i]
        else:
            kill_monsters += A[i + 1]
            A[i + 1] = 0

print(kill_monsters)

Measured memory_bytes: 19116
#include <stdio.h>

int main(void) {
  int h = 0;
  int w = 0;
  int i = 0;
  int j = 0;

  scanf("%d", &h);
  scanf("%d", &w);

  while (!((h == 0) && (w == 0))) {
    for(i = 0; i < h; i++) {
      for(j = 0; j < w; j++) {
	if ((i == 0) || (i == (h - 1))) {
	  printf("#");
	} else if ((j == 0) || (j == (w - 1))) {
	  printf("#");
	} else {
	  printf(".");
	}
      }
      printf("\n");
    }

    printf("\n");
          
    scanf("%d", &h);
    scanf("%d", &w);    
  }
  
  return 0;
}

Measured memory_bytes: 572
// Why am I so dumb? :c
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

char s[305][305], t[305][305];

int n, ans;

void solve() {                   
	scanf("%d", &n);

    for (int i = 0; i < n; ++i) {
    	scanf("%s", s[i]);
    }

    for (int b = 0; b < n; ++b) {
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				t[i][(j + b) % n] = s[i][j];
			}
		}    		

		bool good = 1;

		for (int i = 0; i < n; ++i) {
			for (int j = i; j < n; ++j) {
				good &= (t[i][j] == t[j][i]);				
			}
		}

		ans += good;
    }                      

    printf("%d\n", ans * n);
}

int main() {    
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <numeric>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
ll MOD = 1000000007;
const int mod = 1000000007;
ll INF = 1LL << 60;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
   for (auto &v : vec)
      is >> v;
   return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec)
{
   os << "[";
   for (auto v : vec)
      os << v << ",";
   os << "]";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const deque<T> &vec)
{
   os << "deq[";
   for (auto v : vec)
      os << v << ",";
   os << "]";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{
   os << "(" << pa.first << "," << pa.second << ")";
   return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const map<TK, TV> &mp)
{
   os << "{";
   for (auto v : mp)
      os << v.first << "=>" << v.second << ",";
   os << "}";
   return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp)
{
   os << "{";
   for (auto v : mp)
      os << v.first << "=>" << v.second << ",";
   os << "}";
   return os;
}
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
   fill((T *)array, (T *)(array + N), val);
}

int a[101010];
int solve()
{
   ll n;
   cin >> n;
   for(int i=0; i < n; i++){
      cin >> a[i];
   }
   sort(a, a + n);
   ll t = 0,r = 0;
   for(int i=0; i < n; i++){
      if(a[i+1] > (a[i]+t)*2 ){
         r = i + 1;
      }
      t += a[i];
   }

   cout << n - r << endl;

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

   solve();
}

Measured memory_bytes: 640
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int high = 0;
        int num = -1;
        for(int i=1;i<=N;i++){
            int A = sc.nextInt();
            int B = sc.nextInt();
            if(A>high){
                high = A;
                num = B;
            }
        }
        int ans = high+num;
        System.out.println(ans);
    }
}

Measured memory_bytes: 64676
#include<bits/stdc++.h>
using namespace std;
char s[100001];
int main()
{
    int a,b;
    cin>>a>>b;
    for(int i=1;i<=a+b+1;i++) cin>>s[i];
    for(int i=1;i<=a+b+1;i++)
    {
        if(s[i]<48&&i!=a+1||s[i]>58&&i!=a+1)
        {
            cout<<"No"<<endl;
            return 0;
        }
        if(i==a+1&&s[i]!='-')
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N=int(input())
abc = [list(map(int, input().split())) for _ in range(N)]

dp = [[0]*3 for _ in range(N)]
for j in range(3):
    dp[0][j] = abc[0][j]
for i in range(1,N):
    for j in range(3):
        dp[i][j] = max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+abc[i][j]
print(max(dp[N-1]))

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

using namespace std;

int main(){
  int i,j,n;
  int a[10];
  int we[10]={1,2,4,8,16,32,64,128,256,512};
   
  while(cin>>n){
    i=0; 
    while(n!=1){
      a[i]=n%2;
      i++;
      n/=2;
    }
    a[i]=1;
    while(i!=9){
      i++;
      a[i]=0;    
    }
    i=0;
    for(j=0;j<10;j++){
      if(i&&a[j]==1)cout<<" ";
      if(a[j]==1){
	cout<<we[j];
	i=1;
      }
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,h,w;
    cin>>n>>h>>w;
    
    int a=n-h+1;
    int b=n-w+1;
    int ans=a*b;
    
    cout1(ans)
    
    
    
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, os
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
if os.environ.get("USER") == "shun":
    def debug(*args): print(*args, file=sys.stderr)
else:
    print("NO DEBUG", file=sys.stderr)
    def debug(*args): pass
def exit(): sys.exit(0)
import math


n, p = map(int, input().split())


primes = {}
q = 2
while p != 1:
    if q**2 > p:
        primes[p] = 1
        break
    while p % q == 0:
        p = p // q
        if q in primes:
            primes[q] += 1
        else:
            primes[q] = 1
    q += 1


ans = 1
for q in primes:
    ans *= q**(primes[q] // n)
print(ans)


Measured memory_bytes: 39536
#include <iostream>
#define ll long long
using namespace std;
const ll mdo = 1000000007;
ll dp[101][100001]={},ar[101]={};
ll md(ll b,ll m)
{
	if (b<0) {return m+(b%m);} else {return b%m;}
}
int main()
{
	ll n,k;cin>>n>>k;
	for (int i=0;i<n;i++) {cin>>ar[i];}
	for (ll i=0;i<=k;i++)
	{
		if (i<=ar[0]) {dp[1][i]=1;}
		if (i>0) {dp[1][i]+=dp[1][i-1];}
		dp[1][i]%=mdo;
	}
	for (int i=2;i<=n;i++)
	{
		for (int j=0;j<=k;j++)
		{
			dp[i][j] = dp[i-1][j];
			if (j>0) {dp[i][j] += dp[i][j-1];}
			if (j>ar[i-1]) {dp[i][j] -= dp[i-1][j-ar[i-1]-1];}
			dp[i][j] = md(dp[i][j],mdo);
			//if (j>=k-50&&j<=k) {cout<<i<<" "<<j<<" "<<dp[i][j]<<"\n";}
		}
	}
	cout<<md(dp[n][k]-dp[n][k-1],mdo)<<"\n";
	return 0;
}

Measured memory_bytes: 78336
char W[9],V[9];Z[7*24*60],S,N,T,P,M;main(){
	int i,j,k,l,r,d;
	for(;scanf("%d%d%d%s%s%d%d",&S,&N,&T,W,V,&P,&M),S;printf("%.9f\n",1-pow(1-1.0/P,N*r))){
		memset(Z,0,sizeof(Z));
		l=*W=='A'?2:1;
		d=24*60*(*W=='A'?1:7);
		//i=0,l=1;
		if(*V=='A')for(i=0;i<l;i++)for(j=0;j<24*60;j++)Z[i*24*60+j]=1;
		if(*V=='D')for(i=0;i<l;i++)for(j=0;j<12*60;j++)Z[(i*24+6)*60+j]=1;
		if(*V=='N')for(i=0;i<l;i++)for(j=0;j<6*60;j++)Z[i*24*60+j]=Z[(i*24+18)*60+j]=1;
		for(r=j=0;j<24*60;r=r>l?r:l,j++)for(k=j,l=i=0;i<M;i++){
			if(k<24*60)l+=Z[(k+S)%(7*24*60)]&Z[k];
			k=(k+T)%(d);
		}
}exit(0);}

Measured memory_bytes: 736
#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: i64,
        k: i64,
    }
    let result = (1 .. n + 1).into_iter().map(|v| {
        let k = k as f64;
        let n = n as f64;
        let v = v as f64;
        if v >= k {
            return 1f64 / n;
        }
        let div = (k / v).log2().ceil();
        // println!("  v: {}, div: {}", v, div);
        1f64 / n / 2f64.powf(div)
    }).fold(0f64, |sum, a| sum + a);
    println!("{}", result);
}


Measured memory_bytes: 4352
N = int(input())
xy = [0]*N
A = []
ans = 0
cnt = 0
hatan = 0
for i in range(N):
    A.append(int(input()))
    xy[i] = [list(map(int,input().split())) for i in range(A[i])]
for i in range(2**N):
    cnt = 0
    hatan = 0
    bits = "0" + str(N) + "b"
    Honest_line = str(format(i,bits))
    for people in range(N):
        if(Honest_line[people] == "1"):
            cnt += 1
            for syougen in range(A[people]):
                if(int(Honest_line[xy[people][syougen][0]-1]) != xy[people][syougen][1]):
                    hatan = 1
    if(hatan == 0):
        ans = max(ans,cnt)
print(ans)

Measured memory_bytes: 3064