akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#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++)
#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)
#define INF 999999999
using namespace std;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<string> vst;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
 
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};


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

    int mini=INF,mininum;
    while(true){
        int num=s%1000;
        if(abs(num-753)<mini){
            mininum=num;
            mini=abs(num-753);
        }
        s/=10;
        if(s/100==0)break;
    }

    cout << mini << endl;
    

    return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*-
from itertools import combinations
import copy

def solve():
    N, M = list(map(int, input().split()))
    K = []
    S = []
    for i in range(M):
        _in = list(map(int, input().split()))
        K.append(_in[0])
        S.append(_in[1:])
    P = list(map(int, input().split()))


    def dfs(switch_stats):
        if len(switch_stats)==N:
            is_ok = True
            for i in range(M):
                on_num = 0
                for switch_i in S[i]:
                    on_num += 1 if switch_stats[switch_i-1] == 1 else 0
                if on_num%2 == P[i]:
                    continue
                else:
                    is_ok = False
                    break
            
            if is_ok:
                return 1
            else:
                return 0
        switch_stats1 = copy.deepcopy(switch_stats)
        switch_stats1.append(0)
        ret1 = dfs(switch_stats1)
        switch_stats2 = copy.deepcopy(switch_stats)
        switch_stats2.append(1)
        ret2 = dfs(switch_stats2)
        return ret1 + ret2

    ans = dfs([])
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3568
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
string N;

int main(int argc, char const *argv[])
{
    cin >> N;
    int sum=0;
    for (size_t i = 0; N.size() > i; i++)
    {
        sum+=N[i]-'0';
    }
    int int_N=stoi(N);
    if(int_N%sum==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}


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

int main(){
  long N;
  int K;
  cin >> N >> K;
  long count=0;
  for(long i=0; i<N; i++){
    int h; cin >> h;
    if(h>=K) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define pi 3.14159265359
int main(){
	double input;
	scanf("%lf", &input);
	printf("%lf %lf\n",(double)pi*input*input, (double)2*pi*input);
	return 0 ;
}


Measured memory_bytes: 2112
#include <iostream>
#include <stdio.h>
using namespace std;
bool work(int a, int b, int c)
{
    if(a + b == c) return true;
    if(a + c == b) return true;
    if(c + b == a) return true;
    return false;
}
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(work(a, b, c)) puts("Yes");
    else
        puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

template<typename T> void swap(T & x, T & y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, a;

int main() {
	scanf("%lld%lld", &n, &a);
	
	LL mi = n;
	inc1(i, 40) {
		LL r = static_cast<LL>(pow(n, 1.0 / i));
		decII(j, 0, i) {
			LL p = 1;
			inc(k, i) {
				p *= r + (k >= j);
			}
			if(p >= n) {
				setmin(mi, (r + 1) * i - j + a * (i - 1));
				break;
			}
		}
	}
	
	printf("%lld\n", mi);
	
	return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using PLL = pair<LL,LL>;
using VPI = vector<PII>;
using VPL = vector<PLL>;
using VB = vector<bool>;
using VVB = vector<VB>;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define RREP(i,m,n) for(int i=(m);i>=(n);i--)

int main(){
  int n,k;
  cin >> n >> k;
  VI l(k),r(k);
  VLL dp(n+10,0);
  REP(i,0,k){
    cin >> l[i] >> r[i];
  }
  dp[1] = 1; //足した後はそのマスまで移動する方法の個数を表す
  dp[2] = -1; //足されるまでは前項との差を表す
  //最初は{1,0,0,…}なので"dp[2]=-1"
  
  REP(i,1,n+1){
    dp[i] += dp[i-1]; //ここで前項との差から方法の個数になる
    dp[i] %= 998244353;
    if(dp[i]<0){dp[i] += 998244353;}
    REP(j,0,k){
      if(i+l[j] <= n){
        dp[i+l[j]] += dp[i];
        dp[i+l[j]] %= 998244353;
      }
      if(i+r[j]+1 <= n){
        dp[i+r[j]+1] -= dp[i];
      }
    }
  }
  
  cout << dp[n] << endl;
  
  return 0;
}


Measured memory_bytes: 4776
parseInt(x) = parse(Int, x)
min1=9
minsoe=1
array=[0 for i in 1:5]
for i in 1:5
    array[i]=parseInt(readline())
    if (array[i]%10)<=(min1%10) && array[i]%10>0
        min1=array[i]
        minsoe=i
    end
end
time=0
for i in 1:5
   if i != minsoe
        time+=div(array[i]+9,10)*10
    end
end
time+=array[minsoe]
println(time)

Measured memory_bytes: 165408
#include <stdio.h>
#include <stdlib.h>

typedef struct{
    int x;
    int y;
} treasure;
treasure treasures[5000];
int comp(const void *a, const void *b);

int main(void){
    int number_of_treasures;
    int number_of_regions;
    scanf("%d %d", &number_of_treasures, &number_of_regions);

    int i,j,k,l;
    for(i=0;i<number_of_treasures;i++){
        scanf("%d %d", &(treasures[i].x), &(treasures[i].y));
    }
    qsort(treasures, number_of_treasures, sizeof(treasure),comp);
    
    for(i=0;i<number_of_regions;i++){
        int x1,x2,y1,y2,count;
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        count=0;
        for(j=0;j<number_of_treasures;j++){
            if(treasures[j].x>=x1) break;
        }
        for(;j<number_of_treasures;j++){
            if(treasures[j].x>x2) break;
            if(y1<=treasures[j].y&&treasures[j].y<=y2) count++;
        }
        printf("%d\n", count);
    }
    return 0;
}

int comp(const void *c1, const void *c2){
    treasure *a = (treasure *)c1;
    treasure *b = (treasure *)c2;
    return a->x - b->x;
}

Measured memory_bytes: 716
#include<iostream>
#include<cstring>
using namespace std;
typedef long long ll;
const ll maxn=1e6+0;
char s[maxn];
ll n,ans;
void dfs(ll num)
{
	if(num==n)
	{
		for(int i=0;i<n;i++)
			cout<<s[i];
		cout<<endl;
		return;
	}
	for(int i=0;i<=ans;i++)
	{
		s[num]='a'+i;
		ll tmp=ans;
		if(i==ans) ans++;
		dfs(num+1);
		ans=tmp;
	}
}

int main()
{
	cin>>n;
	dfs(0);
	return 0;
}

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

int tbl[128];

int main(){
	tbl['I'] = 1;
	tbl['V'] = 5;
	tbl['X'] = 10;
	tbl['L'] = 50;
	tbl['C'] = 100;
	tbl['D'] = 500;
	tbl['M'] = 1000;

	string s;
	while(getline(cin, s)){
		s += '$';
		int u = 0;
		for(int i = 0; i + 1 < s.size(); ++i){
			if(tbl[s[i]] < tbl[s[i+1]]){
				u -= tbl[s[i]];
			}
			else{
				u += tbl[s[i]];
			}
		}
		cout << u << '\n';
	}
}

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

using namespace std;
int main(){
  int a,b,tmp;
  while (true){
    cin>>a>>b;
    	if (a==0 && b==0)
    	    break;
    	if(a<b)
      	    cout<<a<<" "<<b<<endl;
      	else 
      	    cout<<b<<" "<<a<<endl;
    	
  }
  return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;            //

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

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

    bool isVaried = true;
    for (int i = 0, j = i + 1; i < S.size() - 1; i++, j++)
    {
        // printf("%c %c\n", S[i], S[j]);
        if (S[i] == S[j])
        {
            isVaried = false;
            break;
        }
    }

    if (isVaried == true)
    {
        cout << "yes" << endl;
    }
    else
    {
        cout << "no" << endl;
    }

    return (0);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.MathContext;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		for(int i = 0; i < n; i++){
			String tmp = br.readLine();
			
			if(tmp == null){
				break;
			}
			String[] tmpArray = tmp.split(" ");
			
			BigDecimal[][] points = new BigDecimal[4][2];
			float [][] fpoints = new float[4][2];
			for(int j = 0; j < points.length ;j++){
				points[j][0] = new BigDecimal(tmpArray[j*2]);
				points[j][1] = new BigDecimal(tmpArray[j*1]);
				fpoints[j][0] = Float.parseFloat(tmpArray[j*2]);
				fpoints[j][1] = Float.parseFloat(tmpArray[j*2+1]);
			}
			
			
			//System.out.println("AB:"+points[1][1].subtract(points[0][1]).divide(points[1][0].subtract(points[0][0]), MathContext.DECIMAL64).doubleValue());
			//System.out.println("AB:"+((fpoints[1][1]-fpoints[0][1])/(fpoints[1][0]-fpoints[0][0])));
			/*
			//????????????????????§????????§??????????????£??????NO
			if((points[0][0] == points[1][0] ) || points[2].equals(points[3]))){
				System.out.println("NO");
			}
			
			else*/ 
			if((fpoints[1][0]==(fpoints[0][0])) || (fpoints[3][0]==( fpoints[2][0])) ){
				if((fpoints[1][0]==(fpoints[0][0])) && (fpoints[3][0]==( fpoints[2][0])) ){
					System.out.println("YES");
				}
				else {
					System.out.println("NO");
				}
			}
			/*
			else if(line1.ptLineDist(points[2]) == line1.ptLineDist(points[3])){
				System.out.println("YES");
			}*/
			/*
			float ab = (fpoints[1][1]-fpoints[0][1])/(fpoints[1][0]-fpoints[0][0]);
			float cd = (fpoints[3][1]-fpoints[2][1])/(fpoints[3][0]-fpoints[2][0]);
			*/
			else if((fpoints[1][1]-fpoints[0][1])/(fpoints[1][0]-fpoints[0][0])
					== (fpoints[3][1]-fpoints[2][1])/(fpoints[3][0]-fpoints[2][0])){
				System.out.println("YES");
			}
			/*
			
			//???????????????????????????????°???????
			else if((points[1][1] - points[0][1])*(points[3][0] - points[2][0]) == (points[3][1] - points[2][1])*(points[1][0] - points[0][0])){
				System.out.println("YES");
			}
			*/
			else{
				System.out.println("NO");
			}
		}
	}

}

Measured memory_bytes: 25176
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int64_t f(int64_t x,int64_t y){
if(y==0)
  return 1;
  else if(y%2==0)
    return (f(x,y/2)*f(x,y/2))%mod;
  else
    return (x*((f(x,y/2)*f(x,y/2))%mod))%mod;
}
int main(){
int N;
  cin>>N;
  int ans=N+N*N+N*N*N;
  cout<<ans<<endl;
  
  return 0;
}

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

int main() {
  char c;
  cin >> c;
  
  int f = 0;
  if (c == 'a') f = 1;
  if (c == 'i') f = 1;
  if (c == 'u') f = 1;
  if (c == 'e') f = 1;
  if (c == 'o') f = 1;
  
  if (f) {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 2000005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    ll n = s.length();
    ll ans = 0;
    rep(i,n){
        if (s[i] != t[i]) ans++;
    }
    PRINT(ans);
}


Measured memory_bytes: 3796
#include<bits/stdc++.h>
#define ll long long 
#define clr(c) memset(c,0,sizeof(c))
#define inf 0x7fffffff
const int mod=1e9+7;
const int M=4e5+5;
const int N=1e4+10;
using namespace std;
inline ll read()
{
	ll sum=0,b=1;char c=getchar();
	while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
	while(isdigit(c)){sum=sum*10+c-'0';c=getchar();}
	return b*sum;
}
int t,n,m,k;
int a[N],b[N];
ll sum[M],ans;
int main()
{
	int i,j;
	n=read();m=read();
	if(n>=10)
	{
		printf("%d",m);
	}
	else {
		printf("%d",100*(10-n)+m);
	}
//	t=read();
//	while(t--)
//	{
//		ans=0;
//		bool f=false;
//		n=read();
//		for(i=1;i<=n;i++){
//			a[i]=read();
//		}
//		
//		if(f) printf("YES");
//		else printf("NO");
//		printf("\n");
//	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
    string s;
    cin >> s;
    if(s[s.length()-1] == 's') cout << s+"es" << endl;
    else cout << s+"s" << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a,b)<<" "<<(a+b<=n?0:a+b-n)<<endl;
}

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

int main(){
  int N,K;
  string S;
  cin >> N >> S >> K;
  char c;
  c=S[K-1];
  for(int i=0;i<N;i++){
    if(S[i]!=c)
      S[i]='*';
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int linear_search(int a[], int key, int n);
int main()
{
    int i, j, n, q, c = 0;
    int s[100000], t[100000];
 
    cin >> n;
    for (i = 0; i < n; i++) cin >> s[i];
     
    cin >> q;
    for (i = 0; i < q; i++) cin >> t[i];
 
    for (i = 0; i < q; i++) {
        c = c + linear_search(s, t[i], n);
    }
    cout << c << endl;
 
}
int linear_search(int a[], int key, int n)
{
    int i = 0;
    a[n] = key;
    while (a[i] != key) {
        i++;
    }
    if (i >= n) {
        return 0;
    }
    else {
        return 1;
    }
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c; cin>>a>>b>>c;
    if (a<=c && c<=b){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


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

int main() {
    int a,b,c,x;
    int count = 0;

    cin >> a >> b >> c >> x;

    for(int i = 0; i <= a; i++) {
        int sum_i = i * 500;
        if(sum_i > x) break;

        for(int j = 0; j <= b; j++) {
            int sum_j = sum_i + j*100;
            if (sum_j > x) break;

            for(int k = 0; k <= c; k++) {
                int sum_k = sum_j + k * 50;
                if(sum_k == x) count++;
                else if (sum_k > x) break;
            }
        }
    }

    cout << count << endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

// 約数列挙
vector<ll> divisor(ll N) {
    vector<ll> res;
    for (ll i = 1L; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            ll j = N / i;
            if (j != i)  {
                res.push_back(j);
            }
        }
    }
    sort(res.begin(), res.end());
    return res;
}


void Main() {
    ll A, B, K; cin >> A >> B >> K;
    vector<ll> x = divisor(__gcd(A, B));
    sort(x.begin(), x.end());
    cout << *(x.begin() + (x.size() - K)) << endl;
}

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


Measured memory_bytes: 3668
n,m=list(map(int,input().split()))
ac,wa=0,0
aclis=[0]*n
walis=[0]*n

for i in range(m):
  p,s=input().split()
  p = int(p)  
  if s == "AC" and aclis[p-1] == 0:
    aclis[p-1] = 1
    ac += 1
    wa += walis[p-1]
  elif s == "WA" and aclis[p-1] == 0:
    walis[p-1] += 1
print(ac,wa)

Measured memory_bytes: 4596
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a // gcd(a, b) * b
#print(lcm(lcm(1000000,999999),999998))
#print(999998//2*999999)


#print(1000000*999999*999998%mod)
n=I()
lis=LI()
promod=1
LCM=1
for i in range(n):
    LCM=lcm(lis[i],LCM)
#print(LCM)
for i in range(n):
    promod=(promod*(lis[i]%mod))%mod
smmod=0
for i in range(n):
    smmod=(smmod+promod*pow(lis[i],mod-2,mod))%mod
#print(smmod)
x=(promod*pow(LCM,mod-2,mod))%mod
ans=(smmod*pow(x,mod-2,mod))%mod
print(ans)
    
    


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

#define int long long
const int _ = 200003;
int N , L , arr[_] , val1[_] , val2[_] , sum1[_] , sum2[_];

signed main(){
	ios::sync_with_stdio(0);
	cin >> L >> N; for(int i = 1 ; i <= N ; ++i) cin >> arr[i];
	int ans = arr[N] , tl1 = 0 , tl2 = 0;
	for(int i = N ; i ; --i){++tl1; sum1[tl1] = sum1[tl1 - 1] + (val1[tl1] = L - arr[i]);}
	while(tl1){
		if(tl1 == tl2) ans = max(ans , 2 * (sum1[tl1] + sum2[tl2]) - min(val1[tl1] , val2[tl2]));
		else
			if(tl1 > tl2){
				ans = max(ans , 2 * (sum1[tl1] - sum1[tl1 - tl2 - 1] + sum2[tl2]) - val1[tl1]);
				ans = max(ans , 2 * (sum1[tl1] - sum1[tl1 - tl2] + sum2[tl2]) - val2[tl2]);
			}
			else{
				ans = max(ans , 2 * (sum2[tl2] - sum2[tl2 - tl1 - 1] + sum1[tl1]) - val2[tl2]);
				ans = max(ans , 2 * (sum2[tl2] - sum2[tl2 - tl1] + sum1[tl1]) - val1[tl1]);
			}
		++tl2; sum2[tl2] = sum2[tl2 - 1] + (val2[tl2] = L - val1[tl1--]);
	}
	cout << ans; return 0;
}

Measured memory_bytes: 8064
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
using namespace std;

int main(){
  int h,w;
  char m[6];

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

  for(int i=1;i<=h;i++){
    for(int j=0;j<w;j++){
      scanf(" %s",m);
      if(strcmp(m,"snuke")==0){
        char a='A'+j;
        cout << a << i << endl;
      }
    }
  }

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e17;
const long double PI=acos(-1);



void solve(int T){
    ll n,k;
    cin>>n>>k;
    vector<ll>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    int i=n-1;
    while(k && i>=0){
        i--;
        k--;
    }
    ll  ans=0;
    if(i>=0){
        while(i>=0){
            ans+=a[i];
            i--;
        }
    }
    cout<<ans<<"\n";
}

int main() {
    fastio
    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}




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

#define REP(i, a) for(int64 i = 0; i < (a);i++)
#define FOR(i, a, b) for(int64 i = (a); i < (b); i++)
#define INF (int64)1e9
#define INF_LL (int64)1e18
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int32_t;
using int64 = int64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

template<typename A, typename B> inline void chmin(A &a, B b) { if (a > b) a = b;}
template<typename A, typename B> inline void chmax(A &a, B b) { if (a > b) a = b;}

template<typename CommutativeMonoid>
class FenwickTree{
public:
  using value_structure = CommutativeMonoid;
  using value_type = typename CommutativeMonoid::value_type;
  using size_type = ::std::size_t;

private:
  ::std::vector<value_type> tree;
  size_type N;

  static value_type calc(const value_type& a, const value_type& b){
    return value_structure::operation(a, b);
  }

public:
  FenwickTree(){}
  FenwickTree(const size_type& N):N(N+10), tree(N+11, value_structure::identity()){}
  FenwickTree(const FenwickTree& bit):tree(bit.tree), N(bit.N){}

  void update(size_type k, const value_type& diff){ // update k in [1, N]
    for(;k <= N;k += k & -k){
      tree[k] = calc(tree[k], diff);
    }
  }

  value_type query(size_type k) const { // sum of [1, k]
    value_type res = value_structure::identity();
    for(;k > 0;k -= k & -k){
      res = calc(res, tree[k]);
    }
    return res;
  }

  void updatez(size_type k, value_type v){ // 0-indexed
    update(k+1, v);
  }

  value_type queryz(size_type k) const { // [0, k)
    return query(k);
  }

  size_type search(const std::function<bool(value_type)>& f) const { // Find k :[0, k) -> True, [0, k-1) -> False
    if(f(value_structure::identity()))
      return 0;
    if(!f(query(N)))
      return N+1;
    value_type x = value_structure::identity();
    size_type k = 1, idx = 0;
    while(k <= N) k <<= 1;
    k >>= 1;
    for(;k > 0;k >>= 1){
      if((idx|k) <= N && !f(tree[idx|k]+x))
        x = calc(x, tree[idx |= x]);
    }
    return idx+1;
  }

  size_type size() const {return N;}
};

class v_monoid {
public:
  using value_type = int64;
  static const value_type identity() { return 0; }
  static const value_type operation(const value_type& a, const value_type& b) {
    return a + b;
  }
};

int main(void) {
  int64 N, Q;
  cin >> N >> Q;
  vector<int64> A(N);
  REP(i, N) cin >> A[i];
  sort(all(A));
  REP(i, Q) {
    int64 l, r;
    cin >> l >> r;
    cout << upper_bound(all(A), r) - lower_bound(all(A), l)  << endl;
  }
}




Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <climits>
#include <math.h>
 
using namespace std;
typedef unsigned long ul;
typedef pair<long, int> P;

typedef struct {
	int i;
	string name;
	int point;
} X;

bool cmp(const X &a, const X &b)
{
    return a.name == b.name ? a.point > b.point : a.name < b.name;
}

int main() {
	int n;
	cin>>n;
	vector<X> data;
	for(int i=1;i<=n;i++) {
		X x;
		x.i = i;
		cin>>x.name>>x.point;
		data.push_back(x);
	}
	sort(data.begin(), data.end(), cmp);
	for(int i=0;i<n;i++) {
		cout<<data[i].i<<endl;
	}
}

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

int main() {
  string S;
  cin>>S;
  int d;
  if (S == "SUN") d = 7;
  else if (S == "MON") d = 6;
  else if (S == "TUE") d = 5;
  else if (S == "WED") d = 4;
  else if (S == "THU") d = 3;
  else if (S == "FRI") d = 2;
  else d = 1;
  cout<<d<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	char c1[4],c2[4];
	int i;
	scanf("%s",c1);
	scanf("%s",c2);
	
	if(c1[0]==c2[2] && c1[1]==c2[1] && c1[2]==c2[0]){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	return 0;
}

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

typedef long long ll;

#define MOD 1000000007

long long mod_pow(long long a, long long n, long long mod) {
    if (n == 0) {
        return 1;
    }
    long long t = mod_pow(a * a % mod, n / 2, mod);
    if (n % 2 != 0) {
        t = t * a % mod;
    }
    return t;
}

ll n, m;
vector<ll> q;

ll ans = 1;

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

    ll tmp = m;
    for (ll i = 2; i * i <= m; i++) {
        if (tmp % i == 0) {
            q.push_back(0);
        }
        while (tmp % i == 0) {
            q[q.size() - 1] += 1;
            tmp /= i;
        }
    }
    if (tmp > 1) {
        q.push_back(1);
    }

    for (int i = 0; i < q.size(); i++) {
        ll c = 1;
        for (int j = 1; j <= q[i]; j++) {
            c = c * (n + q[i] - j) % MOD * mod_pow(j, MOD - 2, MOD) % MOD;
        }
        ans = ans * c % MOD;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_DISABLE_PERFCRIT_LOCKS
#define POPCNTI(a) __builtin_popcount(a)
#define fs  first  
#define sc  second
#define ARR array
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#include <bits/stdc++.h>
using namespace  __gnu_pbds; 
using namespace std;
 
 
// #ifndef _LOCAL_DEFINE
// inline int getchar_unlocked(){return _getchar_nolock();}
// inline void putchar_unlocked(char c) {_putchar_nolock(c);}
// #endif
 
typedef long long ll;  
inline void WRITE_CHAR(char c)  {putchar_unlocked(c);} 
template<typename T> 
inline bool READn (T &result) {
  int minus = 1;
  char ch;
  result=0;
  ch = (char) getchar_unlocked();
  while (!isdigit(ch) && ch!=EOF) minus = (ch == '-'? -1 : minus),ch= (char) getchar_unlocked();
 
  if(ch==EOF) return false;
  while (isdigit(ch))  result = result*10 + (int) (ch - '0'),ch = (char) getchar_unlocked();
  
  result *= minus;
  return ch != '\n';
}
template<typename T>
inline void WRITEn(T x) {
  if (x < 0) {putchar_unlocked('-'); x = -x; }
  char writeBuffer[20], *writePtr = writeBuffer;
  do {
    *writePtr++ = (char)('0' + x % 10);
    x /= 10;
  }
  while (x);
  do  { putchar_unlocked(*--writePtr); }
  while (writePtr > writeBuffer);
}
inline bool Read_CHAR(char &c)
{
  char READ_CHARACTER = (char)getchar_unlocked();
  while ((READ_CHARACTER == '\n' || READ_CHARACTER == '\t' || READ_CHARACTER == ' ')) READ_CHARACTER = (char)getchar_unlocked();
  if(READ_CHARACTER == EOF) return false;
  c = READ_CHARACTER;
  return true;
} 
inline bool READ_CHAR_ARRAY(char *x) {
  char READ_CHARACTER = (char)getchar_unlocked();
  while ((READ_CHARACTER == '\n' || READ_CHARACTER == '\t' || READ_CHARACTER == ' ')) READ_CHARACTER = (char)getchar_unlocked();
  if(READ_CHARACTER == EOF) return false;
  char *ptr = &x[0];
  while ((READ_CHARACTER != '\n' && READ_CHARACTER != '\t' && READ_CHARACTER != ' ' && READ_CHARACTER != EOF)) *ptr++ = READ_CHARACTER, READ_CHARACTER = (char)getchar_unlocked();
 
  *ptr = '\0';
  return true;
}
inline void WRITE_CHAR_ARRAY(const char *x) {
  while(*x != '\0')
    putchar_unlocked(*x++);
}
inline void WRITE_STRING(string &x) {
  for(char c: x) 
    putchar_unlocked(c);
}
const ll OOl = 1e18 ;
const int N = 1e6+1,OO = 1e9,OOm = 0x3f3f3f3f, MOD = 1e9 + 7;
ll psum[N];

int main()
{
  
  int n,m;
  ll k;
  READn(n),READn(m),READn(k);
  for(int i=1;i<=n;++i)
  {
    READn(psum[i]);
    psum[i]+=psum[i-1];
  }
  int tot = 0;
  int ans = 0;
  for(int i=1;i<=m;++i)
  {
    int x;
    READn(x);
    tot+=x;
    if(tot>k) break;
    int idx = lower_bound(psum,psum+n+1,k-tot)-psum;
    //cerr<<tot-k<<' '<<psum[idx]<<endl;
    if(psum[idx]>(k-tot)) idx--;
    ans=max(ans,idx+i);
  }
  int idx = lower_bound(psum,psum+n+1,k)-psum;
  if(psum[idx]>k) idx--;
  ans = max(ans,idx);
  WRITEn(ans);
  
  
  return 0; 
}

Measured memory_bytes: 5120
n, m = map(int, input().split())
h = [int(s) for s in input().split()]
ab = []

for i in range(m):
    ab.append([int(s) for s in input().split()])

h2 = []
for p in ab:
    if h[p[0] - 1] <= h[p[1] - 1]:
        h2.append(p[0] - 1)
    if h[p[0] - 1] >= h[p[1] - 1]:
        h2.append(p[1] - 1)

print(len(h) - len(list(set(h2))))


Measured memory_bytes: 36204
from collections import defaultdict
N = int(input())
sorted_s_list = defaultdict(int)
count = 0
s_list = []
for _ in range(N):
    s = str(sorted(list(input())))
    if sorted_s_list[s] > 0:
        count += sorted_s_list[s]
        sorted_s_list[s] += 1
    else:
        sorted_s_list[s] = 1
print(count)

Measured memory_bytes: 22372
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto s = readln.chomp;
  auto r = ['R', 'U', 'D'];
  auto l = ['L', 'U', 'D'];

  bool f;
  foreach (i; 0..s.length) {
    if (i % 2 && l.find(s[i]).empty) {
      f = true;
    } else if (i % 2 == 0 && r.find(s[i]).empty) {
      f = true;
    }
  }

  if (f) {
    writeln("No");
  } else {
    writeln("Yes");
  }
}


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

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};
static const int ddx[8]={1,-1,0,0,1,1,-1,-1};
static const int ddy[8]={0,0,1,-1,1,-1,1,-1};

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

int a,b,c,d;

signed main(){
    cin>>a>>b>>c>>d;
    int ans=max(a*c,max(a*d,max(b*c,b*d)));
    if((a<=0&&b>=0)||(c<=0&&d>=0))chmax(ans,0ll);
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
from collections import Counter

N = int(input())
X = input().split()

counter = Counter(X)

Keys = [int(key) for key in counter]
max = max(Keys)
min = min(Keys)

S_max = 1
for i in range(min, max+1):
  S = counter[str(i-1)] + counter[str(i)] + counter[str(i+1)]
  if S > S_max:
    S_max = S

    
print(S_max)
  

Measured memory_bytes: 15724
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M = 1002;
int ct[M][M],D;
vector<int> eth[M],bth[M];
int ind[M],deg[M];
bool f[M],fl[M];
int getVal(int z)
{
	set<int> st;
	multiset<int> mlt;
	int c = 0;
	for(int i=0;i<D;i++)
		if(fl[i])
			c++;
	for(int j=0;j<D;j++)
	{
		deg[j] = ind[j];
		if(deg[j] || f[j])
			st.insert(j);
	}
	for(auto it = st.begin(); it != st.end(); it++)
	{
		auto prev = it;
		if(it == st.begin())
			prev = --st.end();
		else
			prev--;
		int df = (*prev)-(*it)+D;
		mlt.insert(df%D);
	}
	int res = D;
	for(int j=0;j<D;j++)
	{
		int x = (z+j)%D;
		for(auto u: eth[x])
		{
			deg[u]--;
			if(deg[u] || f[u])
				continue;
			auto it = st.find(u);
			auto prev = it;
			auto next = it;
			if(it == st.begin())
				prev = --st.end();
			else
				prev--;
			if(it == --st.end())
				next = st.begin();
			else
				next++;
			int d1 = ((*prev)-(*it)+D)%D;
			int d2 = ((*it)-(*next)+D)%D;
			int d3 = ((*prev)-(*next)+D)%D;
			auto p = mlt.find(d1);
			if(p != mlt.end())
				mlt.erase(p);
			p = mlt.find(d2);
			if(p != mlt.end())
				mlt.erase(p);
			st.erase(u);
			if(sz(st))
				mlt.insert(d3);
		}
		if(fl[x])
			c--;
		if(c==0)
		{
			if(sz(mlt))
				res = min(res, max(j,*mlt.begin()));
			else
				res = min(res, j);
		}
	}
	return res;
}
int solve(int len)
{
	for(int i=0;i<D;i++)
	{
		for(int j=0;j<D;j++)
		{
			if(len*1LL*len >= ct[i][j])	
				continue;
			if((len+1)*1LL*len >= ct[i][j])
			{
				eth[i].pb(j);
				ind[j]++;
				continue;
			}
			if((len+1)*1LL*(len+1) >= ct[i][j])
			{
				f[j] = 1;
				fl[i] = 1;
				continue;
			}
			return -1;
		}
	}
	int res = D;
	for(int i=0;i<D;i++)
		res = min(res, getVal(i));
	return res;
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n>>D;
	for(int i=1;i<=n;i++)
	{
		int x,y;
		cin>>x>>y;
		ct[x%D][y%D]++;
	}
	int v = 0;
	for(int i=0;i<D;i++)
	{
		for(int j=0;j<D;j++)
		{
			int t = ceil(sqrt(ct[i][j]));
			v = max(v, t);
		}
	}
	// v*D is always possible , try for (v-1)*D + some shit
	int p = solve(v-1);
	if(p != -1)
		v = D*(v-1)+p;
	else
		v = v*D;
	cout<<v<<"\n";
	return 0;
}

Measured memory_bytes: 7628
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b;
	cin >> a >> b;
	string s = "Impossible";
	if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0) s = "Possible";
	cout << s << endl;
}

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

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 dp[20010];
const int INF=INT_MAX;

int main(){
  int h,n;
  cin>>h>>n;
  vector<P> p(n);
  rep(i,n){
    int a,b;
    cin>>a>>b;
    p[i]=make_pair(a,b);
  }

  for(int i = 1; i <=h+10000; i++){
    dp[i]=INF;
  }
  dp[0]=0;

  for(int damage = 1; damage <=h+10000; damage++){
    rep(i,n){
      int d,c;
      tie(d,c)=p[i];
      if(d > damage) continue;
      if(dp[damage-d]==INF) continue;
      chmin(dp[damage],dp[damage-d]+c);
    }
  }

  int ans = INF;
  for(int i = h; i <= h+10000; i++){
    ans = min(dp[i],ans);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3708
# ABC089D - Practical Skill Test
def main():
    # find cumulative sum using a period of D O(N) -> O(1) for each query
    H, W, D, *X = map(int, open(0).read().split())
    memo = [None] * (H * W + 1)  # memo[x] := coordinate of x
    for i, a in enumerate(zip(*[iter(X[: H * W])] * W), 1):
        for j, x in enumerate(a, 1):
            memo[x] = (i, j)
    dist = [0] * (H * W + 1)  # dist[x] := distance to x from 1
    for r in range(D + 1, H * W + 1):
        (rx, ry), (lx, ly) = memo[r], memo[r - D]
        dist[r] = dist[r - D] + abs(rx - lx) + abs(ry - ly)
    ans = []
    for l, r in zip(*[iter(X[H * W + 1 :])] * 2):
        ans.append(dist[r] - dist[l])
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()

Measured memory_bytes: 36552
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n, k;
	cin >> n >> k;
	vector<ll> p(n);
	for (ll i = 0; i < n; i++) cin >> p[i];
	sort(all(p));
	ll ans = 0;
	for (ll i = 0; i < k; i++) ans += p[i];
	cout << ans << endl;
}

Measured memory_bytes: 3660
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, Bs):
    Bss = [Bs[0]] + Bs + [Bs[-1]]
    As = []
    for i in range(len(Bss) - 1):
        As.append(min(Bss[i], Bss[i + 1]))
    print(sum(As))


if __name__ == '__main__':
    # S = input()
    N = int(input())
    # N, M = map(int, input().split())
    # As = [int(i) for i in input().split()]
    Bs = [int(i) for i in input().split()]
    solve(N, Bs)


Measured memory_bytes: 9184
#include <stdio.h>

int main(void)
{
    int n, m, sum=0;
    int a[100];

    scanf("%d%d", &n, &m);

    for (int i=0; i<n; i++)
        scanf("%d", &a[i]);

    sum = 0;
    for (int i=0; i<n; i++)
        sum += a[i];

    int c=0;
    for (int i=0; i<n; i++) {
        if (a[i]>=sum/(4.0*m))  c++;
    }

    if (c>=m)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
//他の方のを参考にしました(>_<)
int main(){
  int K, S, ans=0;
  cin >> K >> S;
  
  for(int i=0 ; i<=K ; i++)
    for(int j=max(0, S-K-i) ; j<=min(K, S-i) ; j++) //←ここは自分で考えました、結構いい感じだと思います
      if(S-K<=i+j && i+j<=S)              //←ここはパクリました
        ans++;
  
  cout << ans << endl;
}


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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < 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 debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> inline void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> inline void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

int main() {
    int n; cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];

    ll yen = 1000;
    ll kabu = 0;
    rep(i, n) {
        if(i==n-1) {
            yen += a[i] * kabu;
            continue;
        } 

        if(i==0 && a[i+1]>a[i]) {
            kabu = yen / a[i];
            yen %= a[i];
            continue;
        }

        if(a[i+1]>a[i]) {
            kabu += yen / a[i];
            yen %= a[i];
        } else if (a[i] > a[i-1]) {
            yen += kabu * a[i];
            kabu = 0;
        }
    }
    print(yen);
    return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }

lint N, D, dis_max;
const lint MOD = 998244353;

template <std::int_fast64_t Modulus>
class modint
{
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept
	{
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept
	{
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept
	{
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept
	{
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept
	{
		a += rhs.a;
		if (a >= Modulus)
		{
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept
	{
		if (a < rhs.a)
		{
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept
	{
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept
	{
		u64 exp = Modulus - 2;
		while (exp)
		{
			if (exp % 2)
			{
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
typedef modint<MOD> ModInt;

ModInt mod_pow(ModInt x, ModInt n) {
	ModInt ret = 1;
	while (n.a > 0) {
		if (n.a & 1) (ret *= x);
		(x *= x);
		n.a >>= 1;
	}
	return ret;
}
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	vector<lint> cnt(N);
	REP(i, N) {
		cnt[i] = 0;
	}
	cin >> D;
	if (D != 0) {
		cout << 0;
		return 0;
	}
	cnt[D]++;
	REP(i, N - 1) {
		cin >> D;
		cnt[D]++;
		dis_max = max(dis_max, D);
	}
	if (cnt[0] != 1) {
		cout << 0;
		return 0;
	}

	ModInt ans = 1;
	REP(i, dis_max) {
		ModInt mul = mod_pow(cnt[i], cnt[i + 1]);
		ans *= mul;
	}
	cout << ans.a;
}


Measured memory_bytes: 1024
#![allow(non_snake_case, unused_mut)]
//use petgraph::unionfind::UnionFind;
//use proconio::marker::Usize1;
use proconio::{fastout, input};
//use proconio::marker::*;
//use std::collections::*;

const MOD: i64 = 1_000_000_000 + 7;

#[fastout()]
fn main() {
    input! {
        n:usize,k:usize
    }
    // n-1 <=k のように、kが十分大きければ、全パターン。
    // すなわち n人と仕切りn-1で組み合わせなので、2n-1 choose n-1
    let mut fact = vec![1i64; n * 2];
    let mut ifact = vec![1i64; n * 2];
    for i in 1..2 * n as usize {
        fact[i] = fact[i - 1] * (i as i64) % MOD;
        ifact[i] = modInv(fact[i]);
    }
    let choose = |n, r| fact[n] * ifact[n - r] % MOD * ifact[r] % MOD;
    if n - 1 <= k {
        let ans: i64 = choose(2 * n - 1, n - 1);
        println!("{}", ans);
        return;
    }
    // k < n-1 の時は、0人の部屋の数を i とすると、0の位置がchoose(n,i)
    // i人がn-i個の部屋に分散したと考えるとその分け方は、H(n-i,i) =　choose(n-i+i-1,n-i-1)
    let mut ans = 0;
    for i in 0..=k {
        let tmp = choose(n, i) * choose(n - 1, n - i - 1) % MOD;
        //println!("i={}, choose={}", i, tmp);
        ans = (ans + tmp) % MOD;
    }
    println!("{}", ans);
}

fn modPow(x: i64, a: i64) -> i64 {
    if a == 0 {
        1
    } else {
        if a % 2 != 0 {
            modPow(x, a - 1) * x % MOD
        } else {
            let y = modPow(x, a / 2);
            y * y % MOD
        }
    }
}
fn modInv(x: i64) -> i64 {
    modPow(x, MOD - 2) % MOD
}


Measured memory_bytes: 8368
import java.util.Scanner;

public class Main {

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

		int[] a = new int[N];
		for(int i=0; i<N; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		int tmp=0;
		boolean flag = true;
		for(int i=0; i<N; i++) {

			if(i+1 != a[i]) {
				if(tmp == 0) {
					tmp = a[i];
				}else if(tmp == i+1){

				}else {
					flag = false;
					break;
				}
			}
		}

		if(flag == true) {
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include <vector>
using namespace std;
using vi = vector<int>;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

int main() {
  int N, K;
  ins(N, K);

  vi A(N);
  rep(i, N) cin >> A[i];
  rep(k, K) {
    vi B(N+1, 0);
    rep(i, N) {
      ++B[max(0, i-A[i])];
      --B[min(i+A[i]+1, N)];
    }
    rep(i, N) B[i+1] += B[i];
    B.pop_back();
    bool ok = true;
    rep(i, N) {
      if (B[i] != N)
        ok = false;
    }
    swap(A, B);
    if (ok)
      break;
  }
  cout << A[0];
  rep(i, N-1) cout << " " << A[i+1];
  cout << endl;

  return 0;
}


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

int main(){
  int n;
  long long int ans=0,sum=0,ans2=0;
  long long int avg;
  int p,f;
  int l,r;
  int a[100000];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  avg=sum/n;
  sort(a,a+n);
  f=a[0];
  if(n>=3){
    ans+=a[n-1]-f;
    ans+=a[n-2]-f;
  }
  else if(n==2) ans=a[1]-a[0];
  l=1;r=n-3;
  while(1){
    if(r<l) break;
    else if(r<l+1){
      ans+=a[l+2]-a[l];
      l++;
    }
    else{
      ans+=a[r+1]-a[l];
      ans+=a[r+2]-a[l+1];
      l+=2;
    }
    if(r<l) break;
    else if(r<l+1){
      ans+=a[r]-a[r-2];
      r--;
    }
    else{
      ans+=a[r]-a[l-1];
      ans+=a[r-1]-a[l-2];
      r-=2;
    }
    
  }
  
  
  f=a[n-1];
  if(n>=3){
    ans2+=f-a[0];
    ans2+=f-a[1];
  }
  else if(n==2) ans2=a[1]-a[0];
  l=2;r=n-2;
  while(1){
    if(r<l) break;
    else if(r<l+1){
      ans2+=a[r]-a[r-2];
      r--;
    }
    else{
      ans2+=a[r]-a[l-1];
      ans2+=a[r-1]-a[l-2];
      r-=2;
    }
    if(r<l) break;
    else if(r<l+1){
      ans2+=a[l+2]-a[l];
      l++;
    }
    else{
      ans2+=a[r+1]-a[l];
      ans2+=a[r+2]-a[l+1];
      l+=2;
    }
    
  }
  
  cout<<max(ans,ans2)<<endl;
  return 0;
}


Measured memory_bytes: 768