akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
int i,j;
int x[10000];
for(i=0; i<10000; i++){
  scanf("%d", &x[i]);

if(x[i]==0)
  break;
}

for(j=0; j<i; j++){
 printf("Case %d: %d\n", j+1, x[j]);
}

return 0;

}

Measured memory_bytes: 632
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	for (int L; cin >> L&&L;) {
		int LL = 0;
		bool flag = false;
		rep(i, 0, 12) {
			int M, N; cin >> M >> N;
			if (flag)continue;
			LL += M - N;
			if (LL >= L) {
				cout << i + 1 << endl; flag = true;
			}
			else if (i == 11)cout << "NA" << endl;
		}
	}
	return 0;
}

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

int n, a, b;
vector<int> vp;

void input() {
	cin >> n >> a >> b;
	for(int i = 0; i < n; i++){
	    int p;
	    cin >> p;
	    vp.push_back(p);
	}
}

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

	input();

    int underA = 0;
    int betweenAandB = 0;
    int upperB = 0;
    for(int i = 0; i < n; i++){
        if(vp.at(i) <= a) underA++;
        else if(vp.at(i) <= b) betweenAandB++;
        else upperB++;
    }
    
    cout << min(min(underA, betweenAandB), upperB) << "\n";

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h> 
 
#define $(x) (int)((x).size())
#define endl '\n'
#define x first
#define y second
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
 
#ifdef LOCAL
    #define dbg(x) cout << #x << " = " << x << endl;
#else 
    #define dbg(x)
#endif 
 
using namespace std;
 
void solve(); signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);                                       
    freopen("output.txt", "w", stderr);
#endif
    srand(time(0));
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(10);
    solve();    
}

const int MAXN = 10000 + 10, INF = 1e18;
int f[MAXN];
map<int, int> cost = {{1, 2}, {2, 5}, {3, 5}, {4, 4}, {5, 5},
                      {6, 6}, {7, 3}, {8, 7}, {9, 6}};
int n, m;
vector<int> dt;

void solve() {
    cin >> n >> m;
    dt.resize(m);
    for (int i = 0; i < m; ++i) {
        cin >> dt[i];
    }   

    for (int i = 1; i <= n; ++i) {
        f[i] = -INF;
    }
    for (int i = 1; i <= n; ++i) {
        for (auto k : dt) {
            if (i >= cost[k]) {
                f[i] = max(f[i - cost[k]] + 1, f[i]);
            }
        }
    }

    dbg(f[n]);

    int cur = n;
    for (int i = 0; i < f[n]; ++i) {
        int num = 0;
        for (auto k : dt) {
            if (cost[k] <= cur && f[cur - cost[k]] == f[cur] - 1 && k > num) {
                num = k;   
            }
        }
        cur -= cost[num];
        cout << num;
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

//#define int long long
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    int costa[1005] = {};
    fill(costa, costa + 1005, INF);
    rep(i, n) {
        int c;
        cin >> c;
        bool check = false;
        int mn = i + 1;
        rep2(j, 1, c + 1) {
            mn = min(mn, costa[j]);
        }
        costa[c] = mn;
    }
    int cnt[1005] = {};
    rep(i, m) {
        int c;
        cin >> c;
        int mn = INF;
        rep(j, c + 1) {
            mn = min(mn, costa[j]);
        }
        cnt[mn]++;
    }
    int mx = -1;
    int ans = 0;
    rep(i, 1005) {
        if (cnt[i] > mx) {
            mx = cnt[i];
            ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3120
#include <iostream>
#include <cstdlib>

struct data{
  long long int A, B;
};

using namespace std;

void swap2(struct data *a, struct data *b){
  struct data tmp;
  tmp = *a; *a = *b; *b = tmp;
}

int partition( struct data a[], int l, int r){
int i, j; struct data v;
v = a[l]; i= l; j = r + 1;
do {
do { i++; } while( a[i].A < v.A);
do { j--; } while( a[j].A > v.A);
if ( i< j ){ swap2( &a[i], &a[j] ); }
} while ( j > i);
a[l] = a[j]; a[j] = v;
return j;
}

void quicksort3( struct data a[], int l, int r){
int i;
if ( l < r ){
i= partition( a, l, r );
quicksort3( a, l, i-1 );
quicksort3( a, i+1, r);
}
}


int main(){
  int N, M, i, count=0;
  long long int ans=0;
  cin >> N >> M;
  struct data data[N];
  for(i=0; i<N; i++) cin >> data[i].A >> data[i].B;
  quicksort3(data, 0, N-1);
  for(i=0; i<N; i++){
    if(count + data[i].B >= M){
      ans += data[i].A*(M-count);
      break;
    }else{
      count += data[i].B;
      ans += data[i].A*data[i].B;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
using System;

class Program
{
    static void Main()
    {
        while(true)
        {
            string[] inputs = Console.ReadLine().Split(' ');
            int h = int.Parse(inputs[0]);
            int w = int.Parse(inputs[1]);
            
            if (h == 0 && w == 0) break;
            
            for (int i = 0; i < h; i ++)
            {
                for (int j = 0; j < w; j ++)
                {
                    Console.Write("#");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 15960
#include<stdio.h>
#include<math.h>
#include<string.h>
int main(){
  
  long long int n;
  scanf("%lld",&n);
  long long int m=ceil(sqrt(n));
  long long int min;
  
  for(long long int i=1;i<m+1;i++){
    if(n%i==0){
      min=n/i;
    }
  }
  long long int a=n/min;
  
  long long int ans=a+min-2;
  
  printf("%lld\n",ans);
}
  


Measured memory_bytes: 128
import itertools
n,m = map(int,input().split())
#n個偶数
#M個奇数
#偶数+偶数　 奇数+奇数
sum = m + n
gu = [2] * n
ki = [1] * m

num1 = list(itertools.combinations(gu,2))
num2 = list(itertools.combinations(ki,2))
result = int(len(num1)) + int(len(num2))
print(result)

Measured memory_bytes: 3700
import java.util.Scanner;

public class Main{

	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		int answer = a - b * 2;
		
		if(answer < 0) {
			System.out.println(0);
		} else {
			System.out.println(answer);
		}
		
	}
}

Measured memory_bytes: 24020
#include<bits/stdc++.h>
using namespace std;
#define rep(x,y,z) for (int x=y; x<=z; x++)
#define downrep(x,y,z) for (int x=y; x>=z; x--)
#define ms(x,y,z) memset(x,y,sizeof(z))
#define LL long long
#define repedge(x,y) for (int x=hed[y]; ~x; x=edge[x].nex)
inline int read(){
	int x=0; int w=0; char ch=0;
	while (ch<'0' || ch>'9') w|=ch=='-',ch=getchar();
	while (ch>='0' && ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w? -x:x;
}
const int maxn=105;
int n,a[maxn],x;
int main(){
	n=read(); x=read(); 
	rep(i,1,n) a[i]=read(); sort(a+1,a+n+1); int sum=0; int ans=0;
	rep(i,1,n){ 
	   sum+=a[i]; if (sum>x) break;
	   ans++;
	}
	if (sum<x) ans--; 
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const int INF=1<<29;

int main(){
	for(int cas=1,n;scanf("%d",&n),n;cas++){
		char s[100][101];
		int p[100],len[100];
		rep(i,n) scanf("%s%d",s[i],p+i), len[i]=strlen(s[i]);
		char tar[201]; scanf("%s",tar);

		int m=strlen(tar);
		int dp[201];
		rep(i,m+1) dp[i]=(i==0?0:-INF);
		rep(i,m+1){
			rep(j,n) if(i-len[j]>=0 && dp[i-len[j]]>=0 && strncmp(tar+i-len[j],s[j],len[j])==0) {
				dp[i]=max(dp[i],dp[i-len[j]]+p[j]);
			}
		}
		int sz=dp[m]; // tar = 10^sz テ」ツ?ィティツァツ」テゥツ?暗」ツ?陛」ツつ古」ツ??

		// knapsack
		int dp2[20001];
		rep(j,sz+1) dp2[j]=(j==0?0:INF);
		rep(i,n){
			rep(j,sz-p[i]+1) dp2[j+p[i]]=min(dp2[j+p[i]],dp2[j]+len[i]);
		}
		printf("Case %d: %d\n",cas,dp2[sz]);
	}

	return 0;
}

Measured memory_bytes: 1076
n = int(input())
num_list = []
count = 0

for _ in range(1, 1 + n):
    a, b = map(int, input().split())
    if a == b:
        count += 1
        if count == 3:
            break
    else:
        count = 0

print('Yes' if count == 3 else 'No')

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b) % 24 << endl;
}


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

int main()
{
ll w , h ;
cin >> w >> h ;
vector<pair<ll,ll>> v(w+h);
rep(i,w){
  cin >> v[i].first;
  v[i].second=1;
}
rep(i,h){
  cin >> v[i+w].first;
}
sort(v.begin(),v.end());
ll x=w+1,y=h+1;
rep(i,w+h){
  if(v[i].second){
    ans+=v[i].first*y;
    x--;
  }
  else{
    ans+=v[i].first*x;
    y--;
  }
}

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

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

int N, K;

int main() {
  cin >> N >> K;
  vector<int> V(N);
  rep(i, N) cin >> V[i];

  ll ans = 0;
  for (int l = 1; l <= K; ++l) {
    for (int k = min(l, N); k >= l - k; --k) {
      for (int i = 0; i <= k; ++i) {
        priority_queue<ll, vector<ll>, greater<ll>> pq;
        rep(j, i) pq.push(V[j]);
        rep(j, k - i) pq.push(V[N - 1 - j]);

        rep(j, l - k) if (pq.top() < 0) pq.pop();

        ll s = 0;
        while (!pq.empty()) {
          s += pq.top();
          pq.pop();
        }
        ans = max(ans, s);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<set>
 
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define fast() ios::base::sync_with_stdio(false); cin.tie(NULL);
typedef long long int ll;
//using ll = long long;
 
template<typename T>
inline T Abs(T a){return a < 0 ? -a : a; }
template<typename T>
inline T Max(T a, T b){return a < b ? b : a; }
template<typename T>
inline T Min(T a, T b){return a > b ? b : a; }
 
using namespace std;
 
int main(){
    //fast()
    
    int n; cin >> n;
    set<int> num;
    for(int i = 0; i < n; i++){
        int temp; cin >> temp;
        num.insert(temp);
    }
    if(n != num.size()) NO();
    else YES();
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define __ <<' '<<
#define ___ <<' '
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    cerr <<fixed<<setprecision(12);
}}IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    ll a, x;
    double b;
    string s;
    
    cin >> a >> s;
    for(auto&&i:s) i -= '0';
    x = s[0] * 100 + s[2] * 10 + s[3];
    
    cout << a * x / 100 << endl;
    


  
    return 0;
}



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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  if (m == 1) {
    cout << 0 << '\n';
    return 0;
  }
  if (n == 1) {
    cout << a[m - 1] - a[0] << '\n';
    return 0;
  }
  vector<int> v;
  for (int i = 0; i < m - 1; i++) {
    v.push_back(a[i + 1] - a[i]);
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  multiset<int> largest;
  for (int i = 0; i < min(n - 1, (int) v.size()); i++) {
    largest.insert(v[i]);
  }
  long long ans = 0;
  int start_point = 0;
  for (int i = 0; i < m - 1; i++) {
    if (!largest.empty()) {
      if (largest.find(a[i + 1] - a[i]) != largest.end()) {
        largest.erase(largest.find(a[i + 1] - a[i]));
        ans += a[i] - a[start_point];
        start_point = i + 1;
      }
    }
  }
  ans += a[m - 1] - a[start_point];
  cout << ans << '\n';
  return 0;
}

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

typedef long long ll;
vector<ll>pri;
vector<int>pp;
ll vis[1000005]={0};


void prime(){
	vis[1]=1;
	for(ll i=2;i<=1000000;i++){
		if(vis[i]==0){
			pri.push_back(i);
			for(ll j=2;i*j<=1000000;j++){
				vis[i*j]=1;
			}
		}
	}
	return;
}

int main()
{
	prime();
	ll n;
	cin>>n;
	int len=pri.size();
	for(int i=0;i<len&&n>=pri[i];i++){
		if(n%pri[i]==0){
			int temp=0;
			while(n>1&&n%pri[i]==0){
				temp++;
				n/=pri[i];
			}
			pp.push_back(temp);
		}
	}
	int si=pp.size();
	int sum=0;
	if(n!=1){
		sum++;
	}
	for(int i=0;i<si;i++){
//		cout<<pp[i]<<" ";
		int j;
		for(j=1;j*(j+1)/2<=pp[i];j++){
			
		}
		sum+=j-1;
	}
//	cout<<endl;
//	cout<<n<<endl;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 11976
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
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; }
template<class T>T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }

void _main() {
  int N, K;
  string S;
  cin >> N >> K >> S;

  vector<int> a{0};
  if (S[0] == '0') a.push_back(0);
  rep(i, 1, N) {
    if (S[i] != S[i-1]) a.push_back(i);
  }
  if (S[N-1] == '0') a.push_back(N);
  a.push_back(N);

  int ans = 0;
  int a_size = a.size();
  for (int i=0; i<a_size; i+=2) {
    chmax(ans, a[min(i+2*K+1, a_size-1)]-a[i]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
long long f[400] = {2ll}, n;
int main()
{
    scanf("%lld", &n);
    for (long long i = 1ll; i <= n; i++)
        f[i] = f[i - 1] * 2ll + 2ll;
    printf("%lld\n", f[n]);
    return 0;
}

Measured memory_bytes: 256
def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor:GCD)を求める
    計算量: O(log(min(a, b)))
    """
    if b == 0:
        return a
    return gcd(b, a%b)


def lcm(a, b):
    """a, bの最小公倍数(least common multiple:LCM)を求める
    計算量: O(log(min(a, b)))"""
    return (a * b) // gcd(a, b)


def multi_gcd(array: list) -> int:
    """arrayのGCDを求める
    計算量: O(Nlog)
    """
    n = len(array)
    ans = array[0]
    for i in range(1, n):
        ans = gcd(ans, array[i])
    return ans


def multi_lcm(array):
    """arrayのLCMを求める"""
    ans = array[0]
    for i in range(1, len(array)):
        ans = (ans * array[i]) // gcd(ans, array[i])
    return ans


n = int(input())
MOD = 10**9 + 7
a = list(map(int, input().split()))
lcm_ = multi_lcm(a) % MOD
ans = 0
for i in range(n):
    ans += lcm_ * pow(a[i], MOD - 2, MOD)
    ans %= MOD
print(ans % MOD)


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

int main(){
  int N;
  string S;

  cin>>N;
  cin>>S;

  int i;
  int cnt=0;
  vector<int> a;

  char now='E';
  for(i=0;i<S.size();i++){
      if(S.at(i)==now)
      cnt++;
      else{
      a.push_back(cnt);
      if(now=='E')
      now='W';
      else
      now='E';
      cnt=1;
    }
  }
  a.push_back(cnt);
  if(now=='W')
  a.push_back(0);

  int sumE,sumW,min;
  sumW=0;
  min=N;
  for(i=0;i<a.size();i+=2){
    sumE+=a.at(i);
  }

  for(i=0;i<a.size();i++){
    if(i%2==0){
      sumE-=a.at(i);
    }
    else{
      sumW+=a.at(i);
    }
    if(min>sumE+sumW)
    min=sumE+sumW;
  }

  cout<<min<<endl;
  // for(i=0;i<a.size()-1;i++)
  // cout<<a.at(i)<<" ";
  // cout<<a.at(a.size()-1)<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>

using namespace std;

int main(){
  int n,t,j,max;
  
  //N列（１以上１００以下の整数）
  cin>> n;
  //a[i][j](1以上１００以下の整数)
  int a[2][n];
  for(j=0;j<n;j++){
    cin>> a[0][j];
 //   cin>> a[1][j];
  }
  for(j=0;j<n;j++){
 //   cin>> a[0][j];
    cin>> a[1][j];
  }
  
  
  int x;
  max=1;
    
 for(t=0;t<n;t++){
    x=0;
  	for(j=0;j<=t;j++){
      x+=a[0][j];
    }
    for(j=t;j<n;j++){
      x+=a[1][j];
    }
    if(max<=x)
      max=x;
  }
  /*
  x = 0;
  x+=a[0][0];
   x+=a[0][1];
   x+=a[0][2];
   x+=a[0][3];
   x+=a[1][3];
   x+=a[1][4];
  max = x;
  */
  cout<< max <<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int q = int.Parse(Console.ReadLine());

			int max = 100001;
			var primes = new bool[max];
			for (int i = 2; i < max; i++) {
				primes[i] = true;
			}

			for (int i = 2; i < max; i++) {
				if (primes[i] == false) {
					continue;
				}

				int num = i * 2;
				while (num < max) {
					primes[num] = false;
					num += i;
				}
			}

			int[] ok = new int[max];
			for (int i = 3; i < max; i++) {
				if (primes[i] && primes[(i + 1) / 2]) {
					ok[i] = 1;
				}
			}

			var ruis = new int[max + 1];
			for (int i = 0; i < max; i++) {
				ruis[i + 1] = ruis[i] + ok[i];
			}

			var sb = new StringBuilder();
			for (int i = 0; i < q; i++) {
				var lr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				int val = ruis[lr[1] + 1] - ruis[lr[0]];
				sb.AppendLine(val.ToString());
			}

			Console.Write(sb.ToString());
		}
	}
}

Measured memory_bytes: 20024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

//Sliceconvtoi ...
func Sliceconvtoi() []int {
	strs := strings.Split(sc.Text(), " ")

	var ints []int
	var x int

	for _, s := range strs {
		x, _ = strconv.Atoi(s)
		ints = append(ints, x)
	}

	return ints
}

func isLeapYear(y int) bool {
	return (y%4 == 0 && y%100 > 0) || (y%4 == 0 && y%400 == 0)
}

func cntLeap(y []int) {
	cnt := 0

	for i := y[0]; i <= y[1]; i++ {
		if isLeapYear(i) {
			cnt++
			fmt.Println(i)
		}
	}

	if cnt == 0 {
		fmt.Println("NA")
	}
}

func main() {
	num := 0

	for sc.Scan() {
		y := Sliceconvtoi()

		if y[0] == 0 && y[1] == 0 {
			break
		}

		if num > 0 {
			fmt.Println()
		}

		cntLeap(y)
		num++
	}

}



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

int main()
{
  char input_st[200];
  char output_st[200];
  int shuffle_m, shuffle_h;
  int shuffle_sum = 0;
  int length;
  int counter_i, counter_j, counter_k;

  for(counter_i = 0 ; counter_i < 10 ; counter_i++)
  {
    scanf("%s", input_st);
    if(input_st[0] == '-')
      break;

    scanf("%d", &shuffle_m);
    for(counter_j = 0 ; counter_j < shuffle_m ; counter_j++)
    {
      scanf("%d", &shuffle_h);
      shuffle_sum += shuffle_h;
    }

    length = strlen(input_st);
    shuffle_sum %= length;

    for(counter_j = shuffle_sum, counter_k = 0 ;
      counter_j < length ; counter_j++, counter_k++)
    {
      output_st[counter_k] = input_st[counter_j];
    }
    for(counter_j = 0 ; counter_j < shuffle_sum
      ; counter_j++, counter_k++)
    {
      output_st[counter_k] = input_st[counter_j];
    }
    output_st[counter_k] = '\0';

    printf("%s\n", output_st);
    shuffle_sum = 0;
  }
}



Measured memory_bytes: 2060
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    int N;
    cin >> N;
    auto ans = 0;
    REP(i,N) {
        // 2で割れる回数を出す(log2)で出す、
        ll a;
        cin >> a;
        ll bit = 1;
        ll count = 0;
        while(true) {
            if (bit & a) break;
            count++;
            bit <<= 1;
            // cout << bit << endl;
        }
        ans+=count;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

int main()
{
  int N;cin>>N;
  vector<int> P(N+1);
  for (int i=1;i<=N;i++)
    cin>>P[i];
  
  int mn = N*2;
  int count=0;
  for (int i=1;i<=N;i++)
  {
    if (mn > P[i])
    {
      mn = P[i];
      count++;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main() {
  
  int n, a, b, passed = 0, bc = 0; cin >> n >> a >> b;
  string s; cin >> s;
  
  for(int i = 0; i < n; i++) {
    if(s.at(i) == 'a') {
      if(passed < a + b) {
        cout << "Yes" << endl;
        passed++;
      }
      else {
        cout << "No" << endl;
      }
    }
    if(s.at(i) == 'b') {
      bc++;
      if(passed < a + b && bc <= b) {
        cout << "Yes" << endl;
        passed++;
      }
      else {
        cout << "No" << endl;
      }
    }
    if(s.at(i) == 'c') {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 3724
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;

ll memo[30];
ll fact(int x) {
	//if (memo[x])return memo[x];
	ll ret = 1;
	for (int i = 1; i <= x; i++)ret *= i;
	//pe(x); print(ret);
	memo[x] = ret;
	return ret;
}
void solve() {
	int A, B; cin >> A >> B;
	if (A + B >= 10)print("error");
	else print(A + B);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}


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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);


ll gcd(ll a, ll b){  if(b==0){  return a; }   return gcd(b , a%b); }

ll sum_digit(ll n){
  ll value = 0;

  while(n!=0){
    value += n%10;
    n = n/10;
  }

  return value;
}


int main() {


int n;
cin>>n;

ll a[n];
ll minn = INT_MAX, maxx = INT_MIN;
for(int i=0;i<n;i++){
  cin>>a[i];

  minn = min(a[i],minn);
  maxx = max(a[i],maxx); 
}

cout<<abs(minn-maxx)<<"\n";



  
  return 0;
}


Measured memory_bytes: 3580
// このコードを見たあなた。あなたはこのコードを見て、このコードを見ています。

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
typedef long long ll;
const ll MOD = 1e9+7;

tuple<int,int,int> f(char dir, tuple<int,int,int> now){
    int y = get<0>(now), x = get<1>(now);
    int next = get<2>(now)+1;
    switch(dir){
        case 'u':
            return make_tuple(y-1,x,next);
        break;
        case 'r':
            return make_tuple(y,x+1,next);
        break;
        case 'd':
            return make_tuple(y+1,x,next);
        break;
        case 'l':
            return make_tuple(y,x-1,next);
        break;
    }
}

int main(){
    int h,w; cin >> h >> w;
    
    // bfs準備
    queue<tuple<int,int,int>> q;
    char a;
    rep(i,h) rep(j,w){
        cin >> a;
        if(a == '#') q.push(make_tuple(i,j,0));
    }

    vector<vector<int>> saba(h, vector<int>(w,-1)); // 元カノ

    // bfs
    while(!q.empty()){
        tuple<int,int,int> now = q.front();
        q.pop();int y = get<0>(now), x = get<1>(now);
        if(y > h-1 || y < 0 || x > w-1 || x < 0 || saba[y][x] != -1) continue;
        saba[y][x] = get<2>(now);
        q.push(f('l',now));
        q.push(f('u',now));
        q.push(f('r',now));
        q.push(f('d',now));
    }
    int ans = 0;
    rep(i,h) rep(j,w) ans = max(ans, saba[i][j]);
    cout << ans << endl;
}

Measured memory_bytes: 52552
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    vector<int> c(3);
    for (int i = 0; i < 3; ++i) cin >> c.at(i);
    sort(c.begin(), c.end());
    c.erase(unique(c.begin(), c.end()), c.end());
    cout << c.size() << endl;
    return 0;
}


Measured memory_bytes: 256
import math
n, k = map(int, input().split())

def calc(dise, k):
    return (1/2) ** math.ceil(math.log2(k/dise))

ans = 0

for i in range(n):
    if i+1 >= k:
        ans += 1/n
    else:
        ans += calc(i+1, k) / n
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
using namespace std;

int main(){
  int n, q;
  cin >> n >> q;
  vector<set<int>>tree(n);
  for(int i=0; i<n-1; i++){
    int a, b;
    cin >> a >> b;
    tree[a-1].insert(b-1);
    tree[b-1].insert(a-1);
  }
  vector<int>cnt(n);
  for(int i=0; i<q; i++){
    int p, x;
    cin >> p >> x;
    cnt[p-1]+=x;
  }
  stack<int>dfs;
  dfs.push(0);
  while(!dfs.empty()){
    int p=dfs.top();
    dfs.pop();
    for(int c: tree[p]){
      tree[c].erase(p);
      cnt[c]+=cnt[p];
      dfs.push(c);
    }
  }
  for(int i=0; i<n; i++)cout << cnt[i] << ' ';
  return 0;
}

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

int main() {
  long long int p;
long int a,b,c,d;
scanf("%ld %ld %ld %ld",&a,&b,&c,&d);
if(b<0 && d<0)
{long long int p=a*c;
printf("%lld\n",p);
}
else if(b<0 && d>=0)
{
  if(c>=0)
 { p=b*c;
   printf("%lld\n",p);}
   else
   {
     p=a*c;
      printf("%lld\n",p);
   }
}
else if(b>=0 && d<0)
{
  if(a>=0)
  {
    p=a*d;
    printf("%lld\n",p);
  }
  else
  {
    p=a*c;
    printf("%lld\n",p);
  }
}
else if(b>=0 && d>=0)
{

p=b*d;
long long int f=a*c;
if(p>f)
printf("%lld\n",p);
else
printf("%lld\n",f);
}

}

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

int main() {
    char b;
    cin >> b;
    if (b=='A') cout << 'T' << endl;
    else if (b=='T') cout << 'A' << endl;
    else if (b=='C') cout << 'G' << endl;
    else cout << 'C' << endl;
}

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

using namespace std;

const int N = 5 * 1000 + 17;
const int MOD = 2 * 1000 * 1000 * 1000 + 7;

struct item {
    int h, p;
    item() = default;
};

int n;
item a[N];
long long dp[N][N];

bool read() {
    if (!(cin >> n))
        return false;

    for (int i = 0; i < n; ++i)
        cin >> a[i].h >> a[i].p;

    return true;
}

void solve() {
    sort(a, a + n, [](item a, item b) { return a.h + a.p < b.h + b.p; });

    for (int i = 0; i < n; ++i)
        for (int j = 0; j <= n; ++j)
            dp[i][j] = MOD;

    dp[0][0] = 0;
    dp[0][1] = a[0].p;

    for (int i = 1; i < n; ++i)
        for (int j = 0; j <= i + 1; ++j) {
            dp[i][j] = dp[i - 1][j];

            if (j > 0 && dp[i - 1][j - 1] <= a[i].h)
                dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + a[i].p);
        }

    auto ans = 0;

    for (int i = 0; i <= n; ++i)
        if (dp[n - 1][i] < MOD)
            ans = i;

    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 196864
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	long long n, k, sum=0, br=0;
	cin >> n >> k;
	long long a[n+1];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
 
	sort(a, a+n, greater<int>());
 
	for(int i=0; i<n; i++){
		sum += a[i];
		if(sum < k) br++;
		else sum -= a[i], br=0;
	}
 
	cout << br;
 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

map<ll,ll> m;

ll pre[200005];

int main()
{ios_base::sync_with_stdio(false);

ll n,k,ans=0,s=0;
cin>>n>>k;
m[0]++;
rep(i,1,n)
{
	ll x;
	cin>>x;
	s+=x;
	pre[i]=s;
	if(i-k>=0)m[(pre[i-k]-(i-k))%k]--;
	ans+=m[(s-i)%k];
	m[(s-i)%k]++;
}
ol(ans);
return 0;
}



Measured memory_bytes: 14336
# B - Iron Bar Cutting
N = int(input())
A = list(map(int, input().split()))

left = 0
right = sum(A)
ans = right

for a in A:
	left += a
	right -= a
	
	diff = abs(right - left)
	ans = min(ans, diff)
	
	if left > right:
		break

print(ans)


Measured memory_bytes: 26224
from math import factorial
from collections import defaultdict

MOD = 10**9+7
n, x = map(int, input().split())
S = sorted(map(int, input().split()), reverse=True)
dp = [defaultdict(int) for _ in range(n+1)]
dp[0][x] = 1
for i in range(n):
  now = S[i]
  p = pow(n-i, MOD-2, MOD)
  q = p*(n-1-i)%MOD
  for j in dp[i]:
    dp[i+1][j%now] += dp[i][j] * p
    dp[i+1][j] += dp[i][j] * q
    dp[i+1][j%now] %= MOD
    dp[i+1][j] %= MOD
ans = 0
for k, v in dp[n].items():
  ans += k*v
  ans %= MOD
ans *= (factorial(n) % MOD)
ans %= MOD
print(ans)

Measured memory_bytes: 78228
#include<stdio.h>

static const int MAX = 500;
static const int INFTY = (1<<21);

int main(){
  int n, i, j, e, sum;
  int M[MAX][MAX];
  int d[MAX],p[MAX],v[MAX];
  int a=0;
  double point = 0;


  // reading part start

  scanf("%d", &n);

  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }
  //reading part end

  for(i=0;i<n;i++)
    {
      v[i] = 0;
      d[i]=INFTY;
      p[i]=-1;
    }
  d[0] = 0;
  while(1)
    {
      a = -1;
      point = INFTY;

      for(i=0;i<n;i++)
	{
	  if(d[i]<(int)point && !v[i])
	    {
	      a = i;
	      point = d[i];
	    }
	}
      if(a==-1)
	{
	  break;
	}
      v[a] = 1;
      for(j=0;j<n;j++)
	{
	  if(M[a][j] < d[j] && !v[j])
	    {
	      p[j] = a;
	      d[j] = M[a][j];
	    }
	}
    }

	   


  sum = 0;

  for ( i = 0; i < n; i++ ){
    if ( p[i] != -1 ) sum += M[i][p[i]];
  }

  printf("%d\n", sum);

  return 0;
}

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

int main(void)
{
    char str[12000];
    int i = 0;
    int cntJOI = 0, cntIOI = 0;


    while (scanf("%s", str) != EOF){
        for (i = 0; i < strlen(str); i++){
            if (str[i] == 'J' && str[i + 1] == 'O' && str[i + 2] == 'I'){
                cntJOI++;
            }
            if (str[i] == 'I' && str[i + 1] == 'O' && str[i + 2] == 'I'){
                cntIOI++;
            }
        }
        printf("%d\n", cntJOI);
        printf("%d\n", cntIOI);
        cntJOI = cntIOI = 0;
    }
    return (0);
}

Measured memory_bytes: 556
#include <bits/stdc++.h>
#ifdef LOC
#include "debuglib.h"
#else
#define deb(...)
#define DBP(...)
#endif
using namespace std;
using   ll         = long long;
using   Vi         = vector<int>;
using   Pii        = pair<int, int>;
#define pb           push_back
#define mp           make_pair
#define x            first
#define y            second
#define rep(i, b, e) for (int i = (b); i < (e); i++)
#define each(a, x)   for (auto& a : (x))
#define all(x)       (x).begin(), (x).end()
#define sz(x)        int((x).size())

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cout << fixed << setprecision(18);

	int n; cin >> n;
	vector<vector<Pii>> elems(n);

	each(e, elems) {
		int k; cin >> k;
		e.resize(k);

		each(t, e) {
			cin >> t.x >> t.y;
			t.x--;
		}
	}

	int ans = 0;

	rep(mask, 1, 1<<n) {
		bool ok = 1;

		rep(i, 0, n) if ((mask >> i) & 1) {
			each(t, elems[i]) {
				bool expect = ((mask >> t.x) & 1);
				bool got = t.y;
				if (expect != got) {
					ok = 0;
					break;
				}
			}
			if (!ok) break;
		}

		if (ok) {
			ans = max(ans, __builtin_popcount(mask));
		}
	}

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


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

class UF {
public:
    int par[100000];
    int _size[100000];
    UF(int n) {
        for (int i=0;i<n;i++) {
            par[i]=i;
            _size[i]=1;
        }
    }
    int find(int n) {
        if (par[n]==n)
            return n;
        return par[n]=find(par[n]);
    }
    void unite(int a,int b) {
        a=find(a);
        b=find(b);
        if (a==b)
            return;
        par[b]=a;
        _size[a]+=_size[b];
    }
    int size(int n) {
        return _size[find(par[n])];
    }
};

int main() {
    int n,m;cin>>n>>m;
    pair<int,int> e[m];
    UF uf(n);
    for (int i=0;i<m;i++) {
        int a,b;cin>>a>>b;a--,b--;
        e[i]={a,b};
    }
    ll ans[m];
    ans[m-1]=(ll)n*(n-1)/2;
    for (int i=m-1;i>=1;i--) {
        ans[i-1]=ans[i];
        int a=e[i].first,b=e[i].second;
        if (uf.find(a)!=uf.find(b))
            ans[i-1]-=uf.size(a)*uf.size(b);
        uf.unite(a,b);
    }
    for (int i=0;i<m;i++)
        cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 3712
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

int M, N;
int A[1000];
int sum;

int main()
{
    cin >> N >> M;
    rep(i, 0, N)
    {
        cin >> A[i];
        sum += A[i];
    }

    sort(A, A + N, greater<int>());

    int minvote = sum / (4 * M);

    for (int i = 0; i < M; i++)
    {
        if (A[i] * 4 * M < sum)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

int main(){
  vector<int> xd;
  vector<int> yd;
  int n, m, x, y, tmp;
  cin >> n >> m >> x >> y;
  xd.push_back(x);
  yd.push_back(y);
  for(int i = 0; i < n; i++){
    cin >> tmp;
    xd.push_back(tmp);
  }
  
  for(int i = 0; i < m; i++){
    cin >> tmp;
    yd.push_back(tmp);
  }
  
  sort(xd.begin(), xd.end());
  sort(yd.begin(), yd.end());
  if(xd.back() < yd.front()) cout << "No War" << endl;
  else cout << "War" << endl;
  return 0;
}

Measured memory_bytes: 256
N, X = gets.split.map(&:to_i)
ary = N.times.map{gets.to_i}.sort
x = X
total = 0
ary.each_with_index do |m, i|
    sum = i < ary.size - 1 ? ary[i+1..-1].inject(:+) : 0
    cnt = (x - sum).div(m)
    total += cnt
    x -= m * cnt
end
puts total

Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
using sl = signed long;
using sll = signed long long;

int main()
{
	sl n;
	sll sum =0;
	//sl tmp= 1;
	//vector<sl> p;
	cin >> n;
	sum = n*(n-1)/2;
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b) {
        cout << c << endl;
    } else if (b == c) {
        cout << a << endl;
    } else {
        cout << b << endl;
    }
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

ll gcd(ll a, ll b) {
    if (b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

void prime_map(map<ll, ll> &m, ll num) {

    if (num == 1) {
        return;
    }
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }
    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }

        return;
    }
    prime_map(m, num);
    return;
}


Measured memory_bytes: 256
//  __/\\\\____________/\\\\______/\\\\\\\\\______/\\\________/\\\___/\\\\\\\\/\\____/\\\\\\\\\\_|
//   _\/\\\\\\________/\\\\\\____/\\\\\\\\\\\\\___\/\\\________/\\\__\/\\\____\/\\\__\////\\\///__|
//    _\/\\\//\\\____/\\\//\\\___/\\\/////////\\\__\/\\\________/\\\__\/\\\____\/\\\\____\/\\\_____|
//     _\/\\\\///\\\/\\\/_\/\\\__\/\\\_______\/\\\__\/\\\\\\\\\\\\\\\__\/\\\____\/\\\\____\/\\\_____|
//      _\/\\\__\///\\\/___\/\\\__\/\\\\\\\\\\\\\\\__\/\\\/////////\\\__\/\\\____\/\\\\____\/\\\_____|
//       _\/\\\____\///_____\/\\\__\/\\\/////////\\\__\/\\\_______\/\\\__\/\\\____\/\\\_____\/\\\_____|
//        _\/\\\_____________\/\\\__\/\\\_______\/\\\__\/\\\_______\/\\\__\/\\\___/\\\\______\/\\\_____|
//         _\/\\\_____________\/\\\__\/\\\_______\/\\\__\/\\\_______\/\\\__\/\\\\\\/\\_____/\\\\\\\\\\__|
//          _\///______________\///___\///________\///___\///________\///___\/////////_____\//////////___|
#include<bits/stdc++.h>
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef vector< int > vi;
typedef vector< char > vc;
typedef vector< string > vs;
typedef vector< long long > vl;
typedef vector< pair< int , int > > vpi;
typedef pair< int , int > pii;
#define hurry ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define setp setprecision
#define popp pop_back()
#define pb push_back
#define mp make_pair
#define beg begin()
#define en end()
#define sc second
#define sz size()
#define fr first
#define endl '\n'
const int mod=1e9+7;
const long long INF=1e16+10;
const int Nn=1e8;
//=======================================================================================================================
//GLOBAL
//=======================================================================================================================
//FUNCTIONS
//=======================================================================================================================
//STRUCTS
//=======================================================================================================================
int main()
{
    ll n,m;
    cin>>n>>m;
    ll a[n];
    ll sum=0;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    sort(a,a+n);
    ll x;
    if(sum%(4*m)==0)
        x=sum/(m*4);
    else
        x=(sum/(m*4))+1;
    if(a[n-m]>=x)
        cout<<"Yes";
    else
        cout<<"No";
}
//=======================================================================================================================
//ifstream tin("input.txt");
//ofstream tout("output.txt");


Measured memory_bytes: 256
from collections import deque
n,q = map(int,input().split())
g = [[] for _ in range(n+1)]
v = [0]*(n+1)
ans = [0]*(n+1)
for _ in range(n-1):
	a,b = map(int,input().split())
	g[a].append(b)
	g[b].append(a)
for _ in range(q):
	p,x = map(int,input().split())
	v[p] += x
alr = [False]*(n+1)
ans[1] = v[1]
que = deque()
que.append(1)
while que:
	cur = que.popleft()
	alr[cur] = True
	for nxt in g[cur]:
		if not alr[nxt]:
			ans[nxt] = ans[cur] + v[nxt]
			que.append(nxt)
print(*ans[1:])	

Measured memory_bytes: 63596
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

map<int, int> a;

map<int, int> prime_factor(int n){
    map<int, int> res;
    for(int i = 2; i <= n; i++)
        while (n % i == 0){
            a[i]++;
            n /= i;
        }
    return res;
}

int main(void)
{
    int n;
    cin >> n;
    ll ans = 1;
    Rep(i,2,n+1){
        prime_factor(i);
    }

    for(auto&& ai : a){
        ans *= (ai.se + 1);
        ans %= MOD;
    }
    pr(ans);
}   

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=2000+10;
int n,x,y,sum;char s[N];
struct path{int y,nxt;}g[N<<1];int h[N];
struct node{int sz,mx,mn;}p[N];
node operator+(node a,int one){return node{a.sz,a.mx+a.sz,a.mn+a.sz};}
node operator+(node a,node b){
	node ans;ans.sz=a.sz+b.sz;ans.mx=a.mx+b.mx;
	if(a.mn>b.mn)swap(a,b);
	if(a.mx>b.mn)ans.mn=ans.mx&1;
	else ans.mn=b.mn-a.mx;return ans;
}
void dfs(int x,int dep,int fa){
	p[x]=node{0,0,0};
	for(int i=h[x];i;i=g[i].nxt)if(g[i].y!=fa){
		dfs(g[i].y,dep+1,x);
		p[x]=p[x]+(p[g[i].y]+1);
	}
	if(s[x]=='1'){p[x].sz++;sum+=dep;}
}
int ans=1e9;
int main(){
	//freopen("a.in","r",stdin);
	scanf("%d%s",&n,s+1);
	for(int i=1;i<n;i++){
		scanf("%d%d",&x,&y);g[i*2-1]=path{y,h[x]};h[x]=i*2-1;
		g[i*2]=path{x,h[y]};h[y]=i*2;
	}
	for(int i=1;i<=n;i++){
		sum=0;dfs(i,0,0);
		if(!p[i].mn)ans=min(ans,sum/2);
	}
	if(ans==1e9)puts("-1");else
	cout<<ans;
}

Measured memory_bytes: 512