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

const long long MOD = 1000000007;

typedef long long ll;

void solve(long long N, std::vector<long long> A, std::vector<long long> B){
    for (int i = 0; i < N; i++) {
        if (A[i] == 0 && B[i] == 0) continue;
        if (A[i] == 0) {
            B[i] = 1;
            continue;
        }
        if (B[i] == 0) {
            A[i] = 1;
            continue;
        }
        long long g = gcd(A[i], B[i]);
        g = A[i] < 0 ? -g : g;
        A[i] /= g;
        B[i] /= g;
    }

    unordered_map<string, long long> counts;
    for (int i = 0; i < N; i++) {
        string s = to_string(A[i]) + "*" + to_string(B[i]);
        counts[s]++;
    }

    unordered_map<string, bool> used;
    long long result = 1;
    for (long long i = 0; i < N; i++) {
        // cout << A[i] << " " << B[i] << endl;
        if (A[i] == 0 && B[i] == 0) {
            continue;
        }
        long long b = B[i] < 0 ? -B[i] : B[i];
        long long a = B[i] < 0 ? -A[i] : A[i];
        string s1 = to_string(b) + "*" + to_string(b == 0 ? 1 : -a);
        string s2 = to_string(A[i]) + "*" + to_string(B[i]);
        if (used[s2]) continue;
        // cout << s1 << " " << s2 << endl;
        used[s1] = true;
        used[s2] = true;
        long long c1 = counts[s1];
        long long c2 = counts[s2];
        // cout << c1 << " " << c2 << endl;

        long long n = 0;
        long long res = 1;
        while (c1--) {
            res *= 2;
            res %= MOD;
        }
        n += res-1;
        n %= MOD;

        res = 1;
        while (c2--) {
            res *= 2;
            res %= MOD;
        }
        n += res;
        n %= MOD;

        // cout << n << endl;
        result *= n;
        result %= MOD;
    }
    result += counts["0*0"] % MOD;
    result %= MOD;
    cout << ((result-1+MOD) % MOD) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 102160
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int N;
	cin >> N;
	vector<int> V(N), C(N);
	for(int i = 0; i < N; i += 1) cin >> V[i];
	for(int i = 0; i < N; i += 1) cin >> C[i];
	int ans = 0;
	for(int i = 0; i < N; i++)
	{
		ans += V[i] - C[i] > 0 ? V[i] - C[i] : 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include <math.h>//pow(x,y)=x^y
#include <algorithm>//sort(a.begin(), a.end());reverse(a.begin(), a.end());
#define rep(i,n) for (int i=0; i <(n);i++)
#define ll long long
#define rev(s) reverse(s.begin(),s.end())
#define sor(v) sort(v.begin(),v.end())

using namespace std;


int main() {
int n,k;
cin >>n>>k;
vector<int> a(n);
rep(i,n){
    cin >> a.at(i);
}

int bf = 1;
int af = 1;

for(int i=k; i <(n);i++){
    if(a.at(i-k)<a.at(i)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    //cout << a.at(i-k)<< "LLL"<< a.at(i)<< endl; 
}

}


Measured memory_bytes: 4000
#include <cstdio>

const int mod=1e9+7;

inline void add(int& a,int b){
	a+=b; if(a>=mod) a-=mod;
}

const int N=3e3+5;

int n,m,f[N][N][2],ans=0;

int main(){
	scanf("%d%d",&n,&m); f[0][0][1]=1; for(int j=1;j<=n;++j) f[0][j][0]=1;
	for(int i=0;i<m;++i) for(int j=0;j<=n;++j) for(int k=0;k<2;++k){
		if(j) add(f[i+1][j][k|(j==1)],f[i][j][k]),add(f[i+1][j-1][k|(j==1)],f[i][j][k]);
		if(n-j) add(f[i+1][j][k],f[i][j][k]),add(f[i+1][j+1][k],f[i][j][k]);
	}
	for(int j=0;j<=n;++j) add(ans,f[m][j][1]); printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 70656
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s = sc.next();

		if(a>=3200) {
			System.out.println(s);
		}else {
			System.out.println("red");
		}

	}
}

Measured memory_bytes: 21588
import java.util.BitSet;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static IntStream INS(int n) {return REPS(n).map(i->getInt());}
	static Scanner s=new Scanner(System.in);
	static int getInt(){return Integer.parseInt(s.next());}
	public static void main(String[]$){
		BitSet b=new BitSet();
		s.next().chars().forEach(b::set);
		char c=(char)b.nextClearBit('a');
		System.out.println(c<='z'?c:"None");
	}
}


Measured memory_bytes: 28248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(string S){
	ll c = 0, res = 0;
	rep(i, S.length()) {
		if (S[i] == 'B') c++; else res += c;
	}
	cout << res << endl;
}

int main(){	
	string S;
	cin >> S;
	solve(S);
	return 0;
}



Measured memory_bytes: 772
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long a,b;
  cin>>a>>b;
  if(a>b)
  {
    for(int i=0;i<a;i++)
      cout<<b;
  }
  else 
  {
    for(int i=0;i<b;i++)
      cout<<a;
  }
  return 0;
}

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

typedef long long ll;

typedef pair<ll,ll> P;
constexpr ll INF = INT_MAX;

int main(){
    ll n, m;
    cin >> n >> m;
    vector<P> ls;
    for(int i=0;i<n;i++){
        int l, r;
        cin >> l >> r;
        ls.push_back(P(l,+1));
        ls.push_back(P(r+1,-1));
    }
    sort(ls.begin(), ls.end());
    ll cnt = 0, cmax = 0, lmin = INF, rmax = 0;
    for(int i=0;i<n*2;i++){
        cnt += ls[i].second;
        if(ls[i].second > 0){
            if(cnt > cmax){
                cmax = cnt;
                lmin = ls[i].first;
            }
            else if(cnt == cmax){
                lmin = min(lmin, ls[i].first);
            }
        }
        else{
            if(cnt+1 == cmax){
                rmax = max(rmax, ls[i].first-1);
            }
        }
    }
    //cout << cmax << " " << lmin << " " << rmax << endl;
    if(cmax%2){
        cout << (cmax-1)*m + rmax << endl;
    }
    else{
        cout << (cmax-1)*m + (m-lmin) << endl;
    }
}


Measured memory_bytes: 11216
# 自分より左のWと右のEを数える
# 累積和だけど自分自身は見ない

n = int(input())
s = input()
lw, re = [0] * n, [0] * n
for i in range(1, n):
    if s[i - 1] == "W":
        lw[i] = lw[i - 1] + 1
    else:
        lw[i] = lw[i - 1]
for i in range(n - 2, -1, -1):
    if s[i + 1] == "E":
        re[i] = re[i + 1] + 1
    else:
        re[i] = re[i + 1]
ans = 10**10
for i in range(n):
    ans = min(ans, lw[i] + re[i])
print(ans)

Measured memory_bytes: 17616
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
using namespace std;

int main(){

    int N, M;
    int P[100000], Y[100000];
    cin >> N >> M;
    for( int i = 0; i < M; i++ ) cin >> P[i] >> Y[i];


    vector<int> name[100001];
    for( int i = 0; i < M; i++ ) name[P[i]].push_back(Y[i]);

    for( int i = 0; i < N; i++ ){
        sort( name[i+1].begin(), name[i+1].end() );
    }
    
    for( int i = 0; i < M; i++ ){
        cout << setw(6) << setfill('0') << P[i];
        vector<int>::iterator itr = lower_bound( name[P[i]].begin(), name[P[i]].end(), Y[i] );
        cout << setw(6) << setfill('0') << distance( name[P[i]].begin(), itr ) + 1 << endl;
    }
    return 0;

}

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

void solve() 
{
    ll n;cin>>n;
    cout<<n*(n-1)/2<<endl;
}

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

Measured memory_bytes: 256
n, m = map(int, input().split())

wa = [0]*n
ac = [0]*n

for i in range(m):
  p, s = input().split()
  if s == "AC":
    if ac[int(p)-1] == 0:
      ac[int(p)-1] += 1
  if s == "WA":
    if ac[int(p)-1] != 1:
      wa[int(p)-1] += 1
      
sum_ac = sum(ac)
sum_wa = 0
for i in range(n):
  if ac[i] == 1:
    sum_wa += wa[i]
    
print(sum_ac, sum_wa)

Measured memory_bytes: 4596
import sys

input = sys.stdin.readline

def main():
    N = int(input())
    Z = []; W = []
    for i in range(N):
        x, y = map(int, input().split())
        z = x + y
        w = x - y
        Z.append(z)
        W.append(w)
    ans = max(max(Z) - min(Z), max(W) - min(W))
    print(ans)

if __name__ == "__main__":
    main()


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

int main() {
	long long N;
  string S;
	cin >> N >> S;

  int count = 0;

  for (int i = 0; i < N - 2; i++) {
    if (S.at(i) == 'A' && S.at(i+1) == 'B' && S.at(i+2) == 'C') {
      count++;    
    }
  }
  cout << count;
}

Measured memory_bytes: 256
N = int(input())
S = list(input())

R = []
G = []
B = []
r = 0
g = 0
b = 0
for i, s in enumerate(S):
    if s == "R":
        r += 1
    elif s == "G":
        g += 1
    else:
        b += 1
    R.append(r)
    G.append(g)
    B.append(b)

ans = 0
for i in range(N-1):
    if S[i] == "R":
        for j in range(i+1, N):
            #print("i", i, "j", j, ans)
            #print(S[i], S[j])
            if S[j] == "G":
                if 2*j - i < N and S[2*j - i] == "B":
                    ans += (B[N-1] - B[j] - 1)
                else:
                    ans += (B[N-1] - B[j])
            if S[j] == "B":
                if 2*j - i < N and S[2*j - i] == "G":
                    ans += (G[N-1] - G[j] - 1)
                else:
                    ans += (G[N-1] - G[j])
    if S[i] == "G":
        for j in range(i, N):
            if S[j] == "R":
                if 2*j - i < N and S[2*j - i] == "B":
                    ans += (B[N-1] - B[j] - 1)
                else:
                    ans += (B[N-1] - B[j])
            if S[j] == "B":
                if 2*j - i < N and S[2*j - i] == "R":
                    ans += (R[N-1] - R[j] - 1)
                else:
                    ans += (R[N-1] - R[j])
    if S[i] == "B":
        for j in range(i, N):
            if S[j] == "G":
                if 2*j - i < N and S[2*j - i] == "R":
                    ans += (R[N-1] - R[j] - 1)
                else:
                    ans += (R[N-1] - R[j])
            if S[j] == "R":
                if 2*j - i < N and S[2*j - i] == "G":
                    ans += (G[N-1] - G[j] - 1)
                else:
                    ans += (G[N-1] - G[j])
print(ans)




Measured memory_bytes: 69144
n = int(input())
S = []
for _ in range(n):
    S.append(input())

def word2dic(word):
    dic = {}
    for c in word:
        if c in dic:
            dic[c] += 1
        else:
            dic[c] = 1
    return dic

def dp(dic, dic_add):
    for key in dic_add.keys():
        if key in dic:
            dic[key] = min(dic[key], dic_add[key])
    dic_keys = list(dic.keys())
    for key in dic_keys:
        if not key in dic_add:
            del dic[key]
    return dic

dic = word2dic(S[0])
for s in S[1:]:
    dic = dp(dic, word2dic(s))
    
result = ''
for key in sorted(dic.keys()):
    for _ in range(dic[key]):
        result += key
print(result)

Measured memory_bytes: 3064
x=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
dep=100
import math
ans=0
while True:
    ans+=1
    dep=math.floor(dep*1.01)
    if dep>=x:
        break
print(ans)






Measured memory_bytes: 9160
A, V = (int(x) for x in input().split())
B, W = (int(x) for x in input().split())
T = int(input())

if A < B:
    if A + V * T >= B + W * T:
        print("YES")
    else:
        print("NO")
else:
    if A - V * T <= B - W * T:
        print("YES")
    else:
        print("NO")


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

typedef long long ll;
using namespace std;

int j,y;
int m;

void dfs(int a,int b,string s){
	if(j == a && y == b){
		cout << s;
		if(m == 0) cout << endl;
		else if(m == 1)cout << "A" << endl;
		else if(m == 2)cout << "B" << endl;
		else if(m == 3)cout << "AA" << endl;
		else if(m == 4)cout << "BB" << endl;
		else cout << "AB" << endl << s << "BA" << endl;
		return;
	}
	else if(j == a) dfs(a,b+1,s+'B');
	else if(y == b) dfs(a+1,b,s+'A');
	else{ dfs(a+1,b,s+'A');  dfs(a,b+1,s+'B');}
	return;
}

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

	cin >> j >> y;

	m = 0;

	if(j == 6) m = 3;
	else if(y == 6) m = 4;
	else if(y == 5 && j == 5)m = 5;
	else if(y >= 5 && j <= 4) m = 2;
	else if(j >= 5 && y <= 4) m = 1;

	j = min(j,4);
	y = min(y,4);

	dfs(0,0,"");

	return 0;

}



Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}

void mainsolve(){


	ll n,m;
	cin >> n >> m;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	sort(a.begin(), a.end());
	vector<ll> ss(n+1);
	rep(i,n) ss[i+1] = ss[i] + a[i];

	// x以上の幸福度を得られる握手がm通り以上あればtrue
	auto isOK = [&](ll x){
		ll cnt = 0;
		rep(i,n){
			// 左手は固定
			ll left = a[i];
			ll j = lower_bound(a.begin(), a.end(), x-left) - a.begin();
			cnt += n-j;
		}
		return cnt >= m;
	};

	auto binsearch = [&](){
		ll ok = 2*a[0]-1;
		ll ng = 2*a[n-1]+1;
		ll mid = (ng+ok)/2;
		while(abs(ng-ok)>1){
			if(isOK(mid)) ok = mid;
			else ng = mid;
			mid = (ng+ok)/2;
		}
		return ok;
	};

	ll c = binsearch();
	ll res = 0;

	// c+1まではまとめて数える
	rep(i,n){
			// 左手は固定
			ll left = a[i];
			ll j = lower_bound(a.begin(), a.end(), c+1-left) - a.begin();
			if(j <= n-1){
				res += (n-j)*left;
				res += ss[n]-ss[j];
				m -= n-j;
			}
			
	}
	
	// 残りは全部c
	res += m*c;
	cout << res << endl;
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << "NO" << endl;return 0
#define MM <<" "<<
#define Endl endl


signed main(void){
    int K,X;
    cin >> K >> X;
    for(int i=X-K+1;i<=X+K-1;i++){
        if(i!=X-K+1)cout << " ";
        cout << i;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
def main():

#---------------------------------------------------------

    N = int(input())
    ans = 0
    for i in range(1, N + 1):
        n = N // i  # 項数n
        cnt = (n * (2 * i + (n - 1) * i)) // 2  # 初項i, 項数n の等差数列の和の公式
        ans += cnt
    print(ans)

#---------------------------------------------------------

if __name__ == '__main__':
   main()


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    int N ,M;
    cin >> N >> M;
    vector<int> X(N);
    vector<int> R(M);
    vector<int> S(M);
    map<int, int> ma;
    REP(i,N){
        int x;
        cin >> x;
        X[i] = x;
        R[x % M]++;
        ma[x]++;
    }

    for(auto&& p : ma){
        int x = p.first;
        int n = p.second;
        if(n < 2) continue;
        S[x % M] += n/2;
    }

    int ans = 0;
    ans += R[0]/2;
    R[0] -= 2*ans;

    if(M % 2 == 0){
        int tmp;
        tmp = R[M/2]/2;
        R[M/2] -= 2*tmp;
        ans += tmp;
    }

    REPi(x, 1, (M-1)/2+1){
        int tmp;
        tmp = min(R[x], R[M-x]);
        R[x] -= tmp;
        R[M-x] -= tmp;
        ans += tmp;
    }

    //cout << ans << endl;

    REP(x,M){
        if(R[x] >= 2){
            int tmp = 0;
            tmp = min(R[x]/2, S[x]);  
            R[x] -= tmp*2;
            S[x] -= tmp;
            ans += tmp;
        }
    }

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


Measured memory_bytes: 6144
def is_match(i, Sd, T):
    for j in range(len(T)):
        if Sd[i + j] != T[j] and Sd[i + j] != '?':
            return False
    return True


Sd = input()
T = input()
diff = len(Sd) - len(T)
len_t = len(T)
matches = []
for i in range(diff + 1):
    if Sd[i] == T[0] or Sd[i] == '?':
        # Sd[i+j]とT[j]を比較してokならappend list
        if is_match(i, Sd, T):
            matches.append(Sd[:i] + T + Sd[i + len_t:])

# print(matches)
tmps = []
for m in matches:
    s = []
    for i in range(len(m)):
        if m[i] == '?':
            s.append('a')
        else:
            s.append(m[i])
    tmps.append(''.join(s))
print(min(tmps, default='UNRESTORABLE'))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#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++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;ll k;cin>>n>>k;
    vll a(n+1);
    rep(i,n){
        cin>>a[i+1];
        a[i+1]+=a[i];
    }
    rep(i,n+1)a[i]-=i;
    map<ll,int> r;
    ll ans=(ll)0;
    rep(i,n+1){
        if(i>=k)r[a[i-k]%k]--;
        ans+=r[a[i]%k];
        r[a[i]%k]++;
    }
    cout<<ans<<endl;
}

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

int main(void) {
    int n;
    string s;
    cin >> n >> s;

    ll ctHash = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == '#') ctHash++;
    }
    ll ctDot = n - ctHash;

    ll minCost = min(ctHash, ctDot);
    ctHash = 0;

    for (int i = 0; i < n; i++) {
        if (s[i] == '#') {
            ctHash++;
        } else {
            ctDot--;
        }
        minCost = min(minCost, ctHash + ctDot);
    }

    cout << minCost << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = 1e9+7;

int mod(int n, int m = MOD){
    n %= m;
    return n < 0 ? n+m : n;
}

signed main(){
    int n, k, ans = 1;
    cin>>n>>k;
    vector<int> arr(n);

    for(int i=0; i<n; i++)
        cin>>arr[i];

    sort(arr.begin(), arr.end());

    if(arr[0]>=0){
        for(int i=0; i<k; i++) ans = mod(arr[n-1-i]*ans);
        return cout<<ans<<endl, 0;
    } else if(arr[n-1] <= 0){
        for(int i=0; i<k; i++) ans = mod(ans * arr[(k % 2 ? n - 1 - i : i)]);
        return cout<<ans<<endl, 0;
    }

    int l=0, r=n-1, xl, xr;
    if(k%2){
        ans = mod(ans*arr[r]);
        r--, k--;
    }

    while(k > 0){
        xl = arr[l] * arr[l+1];
        xr = arr[r] * arr[r-1];

        if(xl >= xr){
            ans = mod(ans * mod(xl));
            l+=2;
        } else{
            ans = mod(ans * mod(xr));
            r-=2;
        }
        k-=2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4808
n, k = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
left = 0
right = a.max

while (right-left).abs > 1 do
    mid = (right + left) / 2
    c = 0
    n.times do |i|
        c += (a[i] + (mid-1)) / mid - 1
    end
    if c <= k then
        right = mid
    else
        left = mid
    end
end

puts right

Measured memory_bytes: 29844
import Control.Monad

func :: [(Int,Int)] -> (Int,Int)-> (Int,Int)
func [] result  = result
func ((l,r):rest) (_l,_r) =
    func rest (max l _l, min r _r)


main :: IO ()
main = do
    [n , m] <- map (read) . words <$> getLine :: IO [Int]
    lines <- replicateM m getLine 
    let array = do
        line <- lines
        let [l, r] = map read $ words line :: [Int]
        return (l, r)

    let (l,r) = func array (minBound,maxBound)
    
    print $ max 0 (r - l + 1)






Measured memory_bytes: 107900
///By Stephan Ramirez dsramirezc@unal.edu.co
#include<bits/stdc++.h>
#define ms(a,v) memset(a,v,sizeof a)
#define ll long long
#define N 100005
using namespace std;
int n,k;
char s[N];
int main(){
	#ifdef LOCAL
		freopen("in.txt","r",stdin);
		//freopen("out.txt","w",stdout);
	#endif
    scanf("%d %d",&n,&k);
    scanf("%s",s);
    int ans=0;
    int x=0;
    for(int i=0;i<n-1;i++){

        if(s[i]==s[i+1]){
            x++;
        }else{
            ans+=x;
            x=0;
        }
    }
    ans+=x;
    cout<<min(n-1,ans+k*2)<<endl;
	return 0;
}



Measured memory_bytes: 384
/*input
5 5
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000


*/ 
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 
    
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
#define endl "\n"
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 1000000001;
const int MAX = 1e5+1;
    

 
int32_t main() {
    IOS;
	int n,w;cin>>n>>w;
	int value[n],weight[n];
	for(int i=0;i<n;i++){
		cin>>weight[i]>>value[i];
	}
	int dp[n+1][w+1];
	for(int i=0;i<=n;i++){
		dp[i][0] = 0;
	}
	for(int i=0;i<=w;i++){
		dp[0][i] = 0;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=w;j++){
			dp[i][j] = dp[i-1][j];
			if(j-weight[i-1]>=0){
				dp[i][j] = max(dp[i-1][j],dp[i-1][j-weight[i-1]]+value[i-1]);	
			}

			
		}
	}
	// for(int i=0;i<=n;i++){
	// 	for(int j=0;j<=w;j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	cout<<dp[n][w]<<endl;
	return 0;
}




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

int main() {
  int n, a;
  cin >> n;
  int min = 1000000, max = -1000000;
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    if (a < min) min = a;
    if (a > max) max = a;
    sum += a;
  }
  cout << min << " " << max << " " << sum << endl;

  return 0;
}


Measured memory_bytes: 3132
#!/usr/bin/env python3
import sys


def solve(x: "List[int]"):
    for i in range(len(x)):
        if x[i] == 0:
            print(i+1)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    x = [int(next(tokens)) for _ in range(5)]  # type: "List[int]"
    solve(x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9052
#include <iostream>
#include <string>
#include <cmath>
#include <vector>

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

using namespace std;

int max(int a, int b){
  return a > b? a : b;
}

// bool dfs(int x, int depth){
//   if(depth > 2) return false;
//   if(depth == 2 && x == n) return true;

//   REP(i, v[x].size()){
//     if(dfs(v[x][i], depth + 1)) return true;
//   }
//   return false;
// }

int N = 50;
vector<long long> v(50, 49);

int main(){
  long long k;
  cin >> k;
  
  cout << N << endl;

  long long plus = k / N;
  long long r = k % N;
  REP(i, N){
    v[i] += plus;
    if(r != 0){
      if(i < r) v[i] += N - r + 1;
      else v[i] -= r;
    }
    cout << v[i] << " ";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%d%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 200;
const int R_MAX = 8;
const int INF = 1e+9;

int N, R;
int r[R_MAX];

int d[N_MAX][N_MAX];
int dp[1 << R_MAX][R_MAX];

void warshall_floyd() {
  REP(k, N) REP(i, N) REP(j, N)
    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

void tsp() {
  int S = 1 << R;
  fill(dp[0], dp[S], INF);
  fill(dp[S - 1], dp[S - 1] + R, 0);
  for (int s = S - 2; s >= 0; s --) {
    REP(i, R) {
      int v = r[i];
      REP(j, R) {
        if (s >> j & 1) continue;
        int u = r[j];
        dp[s][i] = min(dp[s][i], dp[s | 1 << j][j] + d[v][u]);
      }
    }
  }
}

void solve() {
  warshall_floyd();
  tsp();
  int ans = INF;
  REP(i, R) ans = min(ans, dp[0][i]);
  printf("%d\n", ans);
}

void input() {
  int M;
  scanf("%d%d%d", &N, &M, &R);
  REP(i, R) {
    scanf("%d", r + i);
    r[i]--;
  }
  fill(d[0], d[N], INF);
  REP(i, N) d[i][i] = 0;
  REP(i, M) {
    int A, B, C;
    scanf("%d%d%d", &A, &B, &C);
    d[A - 1][B - 1] = d[B - 1][A - 1] = C;
  }
}

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


Measured memory_bytes: 384
MODE = "stdio"
require 'matrix'
include Math
line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = '10 20 20 40 50 50
  20 10 40 50 50 20'.split("\n")
  tmp.each{|s|
    line << s.strip
  }
end
class Dice
  attr_accessor :top, :front, :right, :left, :back, :bottom
  def initialize(arr)
    @top = arr[0]
    @front = arr[1]
    @right = arr[2]
    @left = arr[3]
    @back = arr[4]
    @bottom = arr[5]
  end

  def get_arr
    [@top, @front, @right, @left, @back, @bottom]
  end

  def set_arr(arr)
    @top = arr[0]
    @front = arr[1]
    @right = arr[2]
    @left = arr[3]
    @back = arr[4]
    @bottom = arr[5]
  end

  def roll(s)
    case s
    when "E"
      @top, @right, @bottom, @left = @left,@top, @right, @bottom
    when "W"
      @top, @right, @bottom, @left = @right, @bottom, @left, @top
    when "N"
      @top, @back , @bottom, @front = @front,@top, @back , @bottom
    when "S"
      @top, @back , @bottom, @front = @back , @bottom, @front,@top
    end
    [@top, @front, @right, @left, @back, @bottom]
  end

  def rolls(s)
    s.chars.each do|s|
      roll(s)
    end
    [@top, @front, @right, @left, @back, @bottom]
  end

  def spin
    @front, @right, @back, @left = @left, @front, @right, @back
    [@top, @front, @right, @left, @back, @bottom]
  end

  def equal?(dice)
    tmp = self.get_arr
    cmd = ["", "E","W","N","S","EE"]
    cmd.each do |c|
      self.set_arr(tmp)
      self.rolls(c)
      if(self.top == dice.top)
        4.times do
          if(self.get_arr == dice.get_arr)
            return true
          else
            self.spin
          end
        end
      end
    end
    return false
  end
end

arr1 = line[0].split(" ").map(&:to_i)
arr2 = line[1].split(" ").map(&:to_i)
dice1 = Dice.new(arr1)
dice2 = Dice.new(arr2)

r = dice1.equal?(dice2)
puts "Yes" if r
puts "No" if !r

Measured memory_bytes: 9280
#![allow(unused_imports)]

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)*}
    };
}

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)*}
    };
}

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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

use std::cmp::{min, max};
use std::collections::{HashMap, HashSet, VecDeque, BinaryHeap};

fn main() {
    input!{
        n: usize,
        v: [usize; n + 1]
    }
    if v[0] > 1 {
        println!("-1");
        return;
    } else if v[0] == 1 {
        if n == 0 {
            println!("1");
        } else {
            println!("-1");
        }
        return;
    }
    let mut ls = v.clone();
    let mut us = v.clone();
    for i in (0..n).rev() {
        ls[i] += (ls[i + 1] + 1) / 2;
        us[i] += us[i + 1];
        let mut b = 0;
        while 1 << b < us[i] {
            b += 1;
        }
        if b > i {
            us[i] = 1 << i;
        }
        if ls[i] > us[i] {
            println!("-1");
            return;
        }
    }
    let mut ans = 1;
    let mut l = 1;
    for i in 1..=n {
        if l * 2 < ls[i] {
            println!("-1");
            return;
        }
        l = min(2 * l, us[i]);
        ans += l;
        l -= v[i];
    }
    println!("{}", ans);
}


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

int main() {
  string a;
  int b=15;
  cin>>a;
  for(int i=0;i<a.size();i++){
    if(a[i]=='x')b--;
  }
  if(b>=8){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
// 2014/06/20 Tazoe

#include <iostream>
#include <string>
using namespace std;

int main()
{
	string S;
	cin >> S;

	int N;
	cin >> N;

	int cnt = 0;

	for(int i=0; i<N; i++){
		string R;
		cin >> R;

		R = R+R;

		if(R.find(S)!=string::npos){
			cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1212
import itertools
N = int(input())
L = map(int, input().split())
count = 0

for a, b, c in list(itertools.combinations(L,3)):
  if (a == b ) or (b == c) or ( c == a):
    continue
  if ( a + b > c ) and ( b + c > a ) and ( c + a > b ):
    count += 1

print(count)

Measured memory_bytes: 20540
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	
	int a,b,c,d;
    while(cin>>a>>b>>c>>d)
    {
    	if (b>c)
    {
    	if(d>b)
    	{
	    	if (a<c)
	    	cout<<b-c;
	    	else
	    	cout<<b-a;
	    }
	    else
	    {
    		if(a<c)
    		cout<<d-c;
    		else
    		{
		    	if (a>d)
		    	cout<<0;
		    	else
		    	cout<<d-a;
		    }
    	}
    }
    else
	{
		cout<<0;
	} 
    };
    
    
	return 0;
}


Measured memory_bytes: 256
n=int(input())
a,b,c=[],[],[]
for i in range(n):
    x,y,z=map(int,input().split(" "))
    a.append(x)
    b.append(y)
    c.append(z)
dp=[[0,0,0] for i in range(n)]
for i in range(n):
    if(i==0):
        dp[i][0]=a[0]
        dp[i][1]=b[0]
        dp[i][2]=c[0]
    else:
        dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i])
        dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i])
        dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i])
print(max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])))

Measured memory_bytes: 34580
import java.io.PrintWriter;
import java.util.*;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc  = new Scanner(System.in);

    public static void main(String[] args){
        int N = nextInt();

        double sum = 0;
        for(int i=0; i<N; i++){
            sum += 1.0/nextInt();
        }

        println(1/sum);
    }

    //各桁の和
    public static int sumDigits(long n) {
        int sum = 0;
        while (n != 0) {
            sum += n % 10;
            n /= 10;
        }
        return sum;//合計を返す
    }

    //最大公約数gcd
    static long gcd (long a, long b) {
        long temp;
        while ((temp = a % b) != 0) {
            a = b;
            b = temp;
        }
        return b;
    }
    //最小公倍数lcm
    static long lcm (long a, long b) {
        long temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return (c/b);
    }
    static int nextInt(){
        return Integer.parseInt(next());
    }
    static Long nextLong(){
        return Long.parseLong(next());
    }
    static String next(){
        return sc.next();
    }
    static void println(Object o){
        PrintWriter out = new PrintWriter(System.out);
        out.println(o);
        out.flush();
    }
   static void print(Object o){
       PrintWriter out = new PrintWriter(System.out);
       out.print(o);
       out.flush();
    }
}


Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}

//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int s, w;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int p = (c + b - 1) / b, q = (a + d - 1) / d;
	if (p <= q)puts("Yes");
	else puts("No");
	ggr
}

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

long long solve(long long L, long long N, vector<long long> &X) {
    vector<long long> ac(N+1);
    ac[0] = 0;
    for (int i=0; i<N; ++i) {
        ac[i+1] = ac[i] + X[i];
    }

    long long ans = max(X[N-1], L-X[0]);
    
    for (int i=0; i<N-1; ++i) {
        int rest = N - i;
        int l = rest / 2 + rest % 2;
        int r = rest - l;
        long long d = (ac[i+l] - ac[i]) * 2LL + (L * r - (ac[i+l+r] - ac[i+l])) * 2LL;
        if (rest % 2 == 0) {
            d -= (L - X[i+l]);
        } else {
            d -= X[i+l-1];
        }
        ans = max(ans, d);
    }

    return ans;
}

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

    long long L, N;
    cin >> L >> N;

    vector<long long> X(N);
    for (int i=0; i<N; ++i) {
        cin >> X[i];
    }
    
    vector<long long> Xrev(N);
    for (int i=0; i<N; ++i) {
        Xrev[i] = L - X[N-1-i];
    }

    cout << max(solve(L, N, X), solve(L, N, Xrev)) << endl;

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
int n;
ll k, a[N], f[N], prod[N], b[N];

int check(ll x)
{
	ll cnt = 0; 
	for (int i = 1; i <= n; i++) {
		b[i] = x / f[i];
	}
	ll sum = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] - b[i] > 0)
			sum += a[i] - b[i];
	}
	if (sum > k)
		return 0;
	return 1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> f[i];
	}
	sort(a + 1, a + 1 + n);
	sort(f + 1, f + 1 + n, greater<ll>());
	ll max_prod = 0;
	for (int i = 1; i <= n; i++) {
		prod[i] = a[i] * f[i];
		max_prod = max(max_prod, prod[i]);
	}
	ll l = -1, r = max_prod + 1;
	while (l + 1 < r) {
		ll mid = (l + r) >> 1;
		if (check(mid))
			r = mid;
		else
			l = mid;
	}
	cout << r;
	return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll H[100];

int main()
{
    int N;
    cin >> N;
    REP(i, N)
    {
        cin >> H[i];
    }

    int ans = 0;
    REP(i, N)
    {
        bool e = true;
        REP(j, i)
        {
            if (H[j] > H[i])
                e = false;
        }
        if (e)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#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> pint;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;


int main() {
    int n, m; cin >> n >> m;
    vector<int> cnt(n);
    rep(i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        cnt[a]++;
        cnt[b]++;
    }
    rep(i, n) {
        cout << cnt[i] << endl;
    }
    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 REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int x; cin >> x;
    int n = x / 100;
    int d = x - 100 * n;
    if (d > 5 * n) cout << 0 << endl;
    else cout << 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin>>S;
  int CN;
  bool ans=true;
  bool pre=true;
  int sz=S.size();
  if(S.at(0)!='A') ans=false;
  for(int i=2;i<sz-1;i++){
    if(S.at(i)=='C'){
      pre=false;
      CN=i;
      break;
    }
  }
  if(pre){
  ans=false;
  }
  for(int i=0;i<sz;i++){
    if(i==0||i==CN){
      continue;
    }
    if('A'-'a'<=S.at(i)-'a'&&S.at(i)-'a'<='Z'-'a'){
      ans=false;
    }
  }
  if(ans) cout<<"AC"<<endl;
  else cout<<"WA"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>

using namespace std;
const int N = 6e5 + 500;
const int LN = 21;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 57;

long long n, m, u, v, k, t, q, a, x, d, b;

vector <int> adj[N];
int P[N];
vector <int> child[N];

void dfs(int v, int p) {
   P[v] = p;
   for (int u: adj[v]) {
      if (u == p) continue;
      child[v].push_back(u);
      dfs(u, v);
   }
}

int main() {
   ios::sync_with_stdio(false);cin.tie(0);
   cin >> n >> k;
   
   for (int i = 0; i < n - 1; ++i) {
      cin >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
   }
   
   dfs(1, 0);
   long long sol = 1;
   for (int i = 1; i <= n; ++i) {
      long long cur = k;
      if (P[i] != 0) {
         cur -= child[P[i]].size();
         child[P[i]].pop_back();
      }
      if (P[P[i]] != 0) cur--;
      if (cur < 0) cur = 0;
      sol *= cur;
      sol %= mod;
   }
   
   cout << sol << endl;
}







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

#define int long long
const int mod = 1e9 + 7;
const int MAX = 234567;
int fac[MAX], finv[MAX], inv[MAX];
inline int mul(int x, int y) {
	return x * y % mod;
}
inline int inverse(int x) {
	x %= mod;
	if (x < 0) x += mod;
	int y = mod, u = 0, v = 1;
	while (y) {
		int t = y / x;
		y -= t * x; swap(x, y);
		u -= t * v; swap(u, v);
	}
	if (u < 0) u += mod;
	return u;
}
inline void f() {
	fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = mul(fac[i - 1], i);
		inv[i] = mod - mul(inv[mod % i], mod / i);
		finv[i] = mul(finv[i - 1], inv[i]);
	}
}
inline int comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return mul(fac[n], mul(finv[k], finv[n - k]));
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	f();
	int n, m;
	cin >> n >> m;
	map<int, int> mp;
	for (int i = 2; i * i <= m; i++) {
		while (m % i == 0) {
			mp[i]++;
			m /= i;
		}
	}
	if (m != 1) mp[m]++;
	int ans = 1;
	for (auto &p : mp) {
		ans *= comb(p.second + n - 1, p.second);
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5760
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            consoleReader.ReadLine();
            var vals = consoleReader.ReadLineSplitInt32();
            var costs = consoleReader.ReadLineSplitInt32();

            return Enumerable.Zip(vals, costs, (v, c) => Math.Max(v - c, 0)).Sum();
        }

        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader)
        {
            this.consoleReader = consoleReader;
        }
        static void Main() => Console.WriteLine(new Program().Calc());
    }

    public class ConsoleReader
    {
        public virtual string ReadLine() => Console.ReadLine();
        public int ReadLineInt32() => int.Parse(ReadLine());
        public long ReadLineInt64() => long.Parse(ReadLine());
        public ulong ReadLineUInt64() => ulong.Parse(ReadLine());
        public double ReadLineDouble() => double.Parse(ReadLine());
        public string[] ReadLineSplit() => ReadLine().Split().ToArray();
        public int[] ReadLineSplitInt32() => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public long[] ReadLineSplitInt64() => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public ulong[] ReadLineSplitUInt64() => ReadLine().Split().Select(s => ulong.Parse(s)).ToArray();
        public double[] ReadLineSplitDouble() => ReadLine().Split().Select(s => double.Parse(s)).ToArray();

        public IEnumerable<string> RepeatReadLines(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLine();
        }
        public IEnumerable<int> RepeatReadLinesInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLineInt32();
        }
        public IEnumerable<string[]> RepeatReadLinesSplit(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLineSplit();
        }
    }
    static class DicExt
    {
        public static double GetOrDefault(this Dictionary<int, double> dic, int key)
        {
            double val;
            return dic.TryGetValue(key, out val) ? val : 1;
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 5;

int a[N];
int cnt[N];
int n,sum;

signed main()
{
    //freopen("file.inp","r",stdin);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        cnt[a[i]]++;
    }
    for (int i = 1; i <= n; i++)
    {
        sum += cnt[i] * (cnt[i] - 1) / 2;
    }
    for (int i = 1; i <= n; i++)
    {
        int ans = sum - cnt[a[i]] * (cnt[a[i]] - 1) / 2 + (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2;
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 4736