akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll N;
    cin >> N;
    vector<ll> xs(N, 0);
    for (auto &&i: boost::irange(0LL, N)){
        cin >> xs.at(i);
    }
    vector<ll> xs_original(xs.begin(), xs.end());
    sort(xs.begin(), xs.end());
    ll former = N / 2 - 1;
    ll latter = N / 2;
    ll threshold = (xs.at(former) + xs.at(latter)) / 2;
    for (auto &&i: boost::irange(0LL, N)){
        if (xs_original.at(i) <= threshold){
            cout << xs.at(latter) << endl;
        } else {
            cout << xs.at(former) << endl;
        }
    }
    return 0;
}

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

int main () {
    //入力
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    //高橋君が倒すのに必要な攻撃回数
    int ma = 0;
    ma = c / b;
    if (c % b) ma++;

    //青木君が倒すのに必要な攻撃回数
    int ato = 0;
    ato = a / d;
    if (a % d) ato++;

    //攻撃回数が少ないと勝つ
    if (ma <= ato) cout << "Yes" << endl;
    else cout << "No" << endl;

    //デバグ
    // cout << ato << endl;
    // cout << ma << endl;
    // cout << c / a;

}

Measured memory_bytes: 3616
h,w=map(int,input().split())
s=[input() for _ in range(h)]
from collections import deque
di=[-1,0,1,0]
dj=[0,-1,0,1]
INF=1001001001
ans=0
for si in range(h):
    for sj in range(w):
        if s[si][sj]=='#': continue
        dist=[[INF]*w for _ in range(h)]
        dist[si][sj]=0
        q=deque([(si,sj)])
        while len(q)>0:
            i,j=q.popleft()
            for dir in range(4):
                ni=i+di[dir]
                nj=j+dj[dir]
                if(ni<0 or ni>=h or nj<0 or nj>=w): continue
                if(s[ni][nj]=='#'): continue
                if(dist[ni][nj]!=INF): continue
                q.append((ni,nj))
                dist[ni][nj]=dist[i][j]+1
        for i in range(h):
            for j in range(w):
                if dist[i][j]==INF: continue
                ans=max(ans,dist[i][j])
print(ans)


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

int main() {
  int N, T, min_cost = 1200;
  int c[110], t[110];
  cin >> N >> T;

  for(int i=0; i<N; ++i)
    cin >> c[i] >> t[i];

  for(int i=0; i<N; ++i) {
    if(t[i] <= T) {
      if(min_cost > c[i]) min_cost = c[i];
    }
  }

  if(min_cost != 1200) cout << min_cost << "\n";
  else cout << "TLE";

  return 0;
}


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

using namespace std;

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

	int x, n;
	cin >> x >> n;
	set<int> s;
	for(int i=0, num; i<n; i++){
        cin >> num;
        s.insert(num);
	}

	int ans, diff=1e9;

	for(int i=0; i<=101; i++){
        if(s.find(i)==s.end()){
            if(abs(i-x)<diff){
                ans=i;
                diff=abs(i-x);
            }
        }
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3652
n, m = map(int, input().split())
matrix1 = []
matrix2 = []
ans = []

for _ in range(n):
    matrix1.append(list(map(int, input().split())))
    
for _ in range(m):
    matrix2.append([int(input())])

for i in range(n):
    elem = 0
    for j in range(m):
        elem += matrix1[i][j] * matrix2[j][0]
    ans.append([elem])

for row in ans:
    for column in row:
        print(column)


Measured memory_bytes: 6024
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
	double xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2;
	vector<string> r;
	while(cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2)
	{
		if ((xa1 <= xb2) && (xa2 >=  xb1) && (ya1 <= yb2) && (ya2 >=  yb1))
		{
			r.push_back("YES");
		} else {
			r.push_back("NO");
		}
	}
	for (int i=0; i<r.size(); i++)
	{
		cout << r[i] << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <cstring>
#include <set>
#include <map>
#include <algorithm>  
#include <cmath>
#include <iomanip>
#define ll long long
using namespace std;
ll dp[3002][3002];
string s,t;
ll n,m;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>s>>t;
    m=s.size();
    n=t.size();
    memset(dp,0,sizeof(dp));
    for(ll i=1;i<=m;++i)
    {
        dp[1][i]=dp[1][i-1];
        if(t[0]==s[i-1])
        {
            dp[1][i]=1;
        }
    }
    for(ll i=1;i<=n;++i)
    {
        dp[i][1]=dp[i-1][1];
        if(s[0]==t[i-1])
        {
            dp[i][1]=1;
        }
    }
    for(ll i=2;i<=n;++i)
    {
        for(ll j=2;j<=m;++j)
        {
            if(t[i-1]==s[j-1])
            {
                dp[i][j]=1+dp[i-1][j-1];
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    string nas="";
    ll i=n;ll j=m;
    while(i>0 && j>0)
    {
        if(s[j-1]==t[i-1])
        {
            nas=s[j-1]+nas;
            --i;--j;
        }
        else
        {
            if(dp[i-1][j]>dp[i][j-1])
            {
                --i;
            }
            else
            {
                --j;
            }
        }
    }
    cout<<nas<<endl;
}






































Measured memory_bytes: 74056
N = int(input())

l = []
for i in range(N):
  a, b = map(int, input().split())
  l.append((a,b))

l.sort(key = lambda x: x[1])

s = 0
result = True
for v in l:
  s += v[0]
  if s > v[1]:
    result = False
    break

if result:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 31860
#include <iostream>
#include <math.h>
#include <limits>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <map>
using namespace std;
#define rep(i, n) for (int i =0; i < (int)(n); i++)
typedef pair<int, string> P;



int main() {
    int n;
    cin >> n;
    int A[111];
    int B[111];
    int ans = 0;
    rep(i, n - 1)cin >> B[i];
    for (int i = 1; i < n-1;i++) {
        ans += min({ B[i],B[i - 1] });
    }
    ans += B[n - 2]+B[0];
    cout << ans << endl;
}


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

A_left =[]
A_right = []

for i in A:
  if i < X:
    A_left.append(i)
  elif i > X:
    A_right.append(i)
print(min(len(A_left),len(A_right)))      

  

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        sc.close();

        int hugCount = 0;
        int readFinish = S.length() / 2;
        if (S.length() % 2 != 0) {
            readFinish++;
        }
        for (int i = 0; i < readFinish; i++) {
            char a = S.charAt(i);
            char b = S.charAt(S.length() - 1 - i);
            if (a != b) {
                hugCount++;
            }
        }

        System.out.println(hugCount);

    }

}

Measured memory_bytes: 21844
#include<iostream>
#include<string>
#include<stack>

using namespace std;

string str;
stack<char> stk;

int main() {
    cin >> str;
    for(auto s : str) {
        switch(s) {
            case '0':
            case '1':
                stk.push(s);
                break;
            case 'B':
                if(!stk.empty())
                    stk.pop();
        }
    }
    string ans;
    while(!stk.empty()) {
        ans = stk.top() + ans;
        stk.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;

int main()
{
    int n, m;
    cin>>n>>m;
    int x=0, y=0, z=0;
    while (m%5000)
    {
        m-=1000;
        z++;
    }
    y=m/5000;
    while ((x+y+z)!=n)
    {
        int d=x+y+z;
        if (d<n)
        {
            d=n-d;
            if (d%4)
            {
                y=y-d/4-1;
                z=z+(d/4+1)*5;
            }
            else
            {
                y=y-d/4;
                z=z+(d/4)*5;
            }
            if (y<0)
            {
                cout<<-1<<' '<<-1<<' '<<-1;
                return 0;
            }
        }
        else
        {
            d-=n;
            y-=(2*d);
            x+=d;
            if (y<0)
            {
                cout<<-1<<' '<<-1<<' '<<-1;
                return 0;
            }
        }
    }
    cout<<x<<' '<<y<<' '<<z;
    return 0;
}
 

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int n;
    int min = 1000000;
    int max = -1000000;
    long sum = 0;
    
    scanf("%d",&n);
    int i;
    for(i=0;i<n;i++){
        int t;
        scanf("%d",&t);
        
        if(min > t){
            min = t;
        }
        
        if(max < t){
            max = t;
        }
        
        sum+= t;
    }
    
    printf("%d %d %ld\n",min,max,sum);
    
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)

int d[30][30];
int main(){
    int n,m;
    while(cin>>n>>m && n){
        rep(i,30)rep(j,30)d[i][j]=1<<29;
        rep(i,30)d[i][i]=0;
        rep(i,m){
            string s;
            cin>>s;
            for(char &c:s)if(c==',')c=' ';
            stringstream ss(s);
            int a,b,d1,d2;
            ss>>a>>b>>d1>>d2;
            d[a][b]=d1; d[b][a]=d2;
        }
        int x1,x2,y1,y2;
        string s;cin>>s;
        for(char &c:s)if(c==',')c=' ';
        stringstream ss(s);
        ss>>x1>>x2>>y1>>y2;
        //printf("aa %d %d %d %d\n",x1,x2,y1,y2);
        rep(k,30)rep(i,30)rep(j,30)d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
        cout << y1 - d[x1][x2] - d[x2][x1] - y2 << endl;
    }
}

Measured memory_bytes: 1228
from heapq import heapify, heappop, heappush

n = int(input())
x_loc, y_loc = [], []
for i in range(n):
    x, y = map(int, input().split())
    x_loc.append((x, i))
    y_loc.append((y, i))
x_loc.sort()
y_loc.sort()
links = [set() for _ in range(n)]
for (x1, i1), (x2, i2) in zip(x_loc, x_loc[1:]):
    dist = x2 - x1
    links[i1].add((dist, i2))
    links[i2].add((dist, i1))
for (y1, i1), (y2, i2) in zip(y_loc, y_loc[1:]):
    dist = y2 - y1
    links[i1].add((dist, i2))
    links[i2].add((dist, i1))

# プリム法
visited = {0}
queue = list(links[0])
heapify(queue)
total = 0
while True:
    cost, i = heappop(queue)
    if i in visited:
        continue
    visited.add(i)
    total += cost
    if len(visited) == n:
        break
    for cost2, j in links[i]:
        if j in visited:
            continue
        heappush(queue, (cost2, j))
print(total)

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

int main(){
    int n;
    int ma = 1000000;
    cin >> n;
    vector<int>dp(n+1,ma);
    dp[n] = 0;
    for(int i = n;i>0; i--){
        dp[i-1] = min(dp[i]+1, dp[i-1]);
        for(int j=1;j<7;j++){
            if(i-pow(6,j)>=0)
            {
                dp[i-pow(6,j)] = min(dp[i]+1, dp[i-pow(6,j)]);
            }
            if(i-pow(9,j)>=0)
            {
                dp[i-pow(9,j)] = min(dp[i]+1, dp[i-pow(9,j)]);
            }
        }
        //cout << i << ":" <<dp[i] << endl;
    }
    cout << dp[0] << endl;
    return 0;
}

Measured memory_bytes: 4036
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };


signed main() {
	ll N;
	vector<ll>list;
	ll cnt = 0;
	vector<bool>flag2(200000,false);

	cin >> N;

	for (int i = 0; i < N; i++) {
		ll num;
		cin >> num;
		list.push_back(num);
	}

	sort(list.begin(), list.end());
	int index = 0;
	bool flag = false;

	for (int i = 0; i < N - 1; i++) {
		if (list[i] * 2 < list[i + 1]) {
			index = i;
			flag = true;
			flag2[i] = true;
		}
		else {
			//list[i + 1] += list[i];
			cnt++;
		}
		list[i + 1] += list[i];
	}

	int cnt2 = 0;
	bool flag3 = false;

	for (int i = 0; i < N; i++) {
		if (flag2[i] == true) {
			if (flag3 == false) {
				cnt2++;
			}
			flag3 = true;
		}
		else {
			flag3 = false;
		}
	}

	if (list[N - 2] * 2 <= list[N - 1]) {

	}

	if (flag == true) {
		//cout << N - cnt2 << endl;
		cout << N - (index + 1) << endl;
	}
	else {
		cout << N << endl;
	}
	
	
	return 0;
}

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

using namespace std;

int main(){
	while(true){
		int h,w;
		cin >> h >> w;
		if(h==0)break;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(i==0 || i==h-1 || j==0 || j==w-1)cout << '#';
				else cout << '.';
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
	long long int n, d, x, y,a=0;
	cin >> n>>d;
	for (int i = 1; i <= n; i++) {
		cin >> x >> y;
		if (x * x + y * y <= d*d)
			a++;
	}
	cout << a<<endl;
}

Measured memory_bytes: 3616
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<=n;i++)
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;


/// 各桁の和
int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;    
    }
    return sum;
}
/// 最大公約数 
int gcd(int x, int y){
      if(x<y){
          int temp = x;
          x = y;
          y = temp;
      }
      int r = x % y;
       while(r!=0){
           x = y;
           y = r;
           r = x % y;
       }
      return y;
   }

int mod = 1'000'000'007;
int dp[101][4][4][4];
int main(){
int N;
cin >> N;
dp[0][3][3][3] = 1;
for(int len = 0; len < N; len++){
    for(int c1 = 0; c1 < 4; c1++){
        for(int c2 = 0; c2 < 4; c2++){
            for(int c3 = 0; c3 < 4; c3++){
                if(dp[len][c1][c2][c3] == 0)continue;
                for(int a = 0; a < 4; a++){
                    if(a == 2 && c1 == 1 && c2 == 0)continue;
                    if(a == 2 && c1 == 0 && c2 == 1)continue;
                    if(a == 1 && c1 == 2 && c2 == 0)continue;
                    if(a == 2 && c1 == 1 && c3 == 0)continue;
                    if(a == 2 && c2 == 1 && c3 == 0)continue;

                    dp[len+1][a][c1][c2] += dp[len][c1][c2][c3];
                     dp[len+1][a][c1][c2] %= mod;
                    }
    
}
}
}
}
int ans = 0;
for(int c1 = 0; c1 < 4; c1++){
        for(int c2 = 0; c2 < 4; c2++){
            for(int c3 = 0; c3 < 4; c3++){
            
            ans += dp[N][c1][c2][c3];
            ans%=mod;
            }
        }
}
cout << ans << endl;
}

Measured memory_bytes: 256
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <algorithm>
#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int main(){
  const int n = getInt();
  const int x = getInt();
  vector<int> a(n);
  REP(i,n) a[i] = getInt();

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

  int ans = 0;
  int cur = 0;
  for(; ans < n;){
    if(cur + a[ans] <= x){
      cur += a[ans];
      ans++;
    }else{
      break;
    }
  }

  if(ans == n && cur < x) ans--;
  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> p;

int main(){
    int n, m;
    cin >> n >> m;
    vector<p> v;
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        v.push_back(p(b, a));
    }
    sort(v.begin(), v.end());
    int cnt = 1, prev = v[0].first - 1;
    for(int i = 1; i < m; i++){
        if(v[i].second > prev){
            cnt++;
            prev = v[i].first - 1;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
char grid[1010][1010];
int N;

const string c4[4] = {
        "aabc",
        "ddbc",
        "efgg",
        "efhh"
};

const string c5[5] = {
        "..abc",
        "..abc",
        "ddeef",
        "ggh.f",
        "iihjj"
};
const string c6[6] = {
        "aabc..",
        "ddbc..",
        "..aabc",
        "..ddbc",
        "bc..aa",
        "bc..dd"
};

const string c7[7] = {
        "aabbcc.",
        "ddeef..",
        "gg..fhh",
        "..ij..k",
        "..ij..k",
        "....lmn",
        "....lmn"
};

void print() {
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (grid[i][j] == 0) {
                putchar('.');
            } else {
                putchar(grid[i][j]);
            }
        }
        putchar('\n');
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    if (N%3 == 0) {
        for (int i = 0; i < N; i += 3) {
            grid[i][i] = 'a';
            grid[i][i+1] = 'a';
            grid[i+1][i+2] = 'a';
            grid[i+2][i+2] = 'a';
        }
        print();
        return 0;
    }
    if (N > 3) {
        int tmp = 0;
        const int surplus = N % 4;
        if (surplus == 1) {
            const int c = 5;
            for (int i = 0; i < c; ++i) {
                for (int j = 0; j < c; ++j){
                    grid[i][j] = c5[i][j];
                }
            }
            tmp = c;
        } else if (surplus == 2) {
            const int c = 6;
            for (int i = 0; i < c; ++i) {
                for (int j = 0; j < c; ++j){
                    grid[i][j] = c6[i][j];
                }
            }
            tmp = c;
        } else if (surplus == 3) {
            const int c = 7;
            for (int i = 0; i < c; ++i) {
                for (int j = 0; j < c; ++j){
                    grid[i][j] = c7[i][j];
                }
            }
            tmp = c;
        }
        while (tmp < N) {
            const int c = 4;
            for (int i = 0; i < c; ++i) {
                for (int j = 0; j < c; ++j){
                    grid[tmp+i][tmp+j] = c4[i][j];
                }
            }
            tmp += 4;
        }
        print();
        return 0;
    }
    puts("-1");
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define inf 1000000007
#define ll long long
using namespace std;
ll dp[2140][2140];
ll sum[2140][2140];
signed main(){
	ll n,m;
	cin>>n>>m;
	vector<ll> s,t;
	for(ll i=0;i<n;i++){ll x;cin>>x;s.pb(x);}
	for(ll i=0;i<m;i++){ll x;cin>>x;t.pb(x);}
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=m;j++){
			if(s[i-1] == t[j-1]){
				dp[i][j] = sum[i-1][j-1]+1;
				sum[i][j] = sum[i-1][j]+sum[i][j-1]+dp[i][j]-sum[i-1][j-1];
				dp[i][j] += inf;
				sum[i][j] += inf;
				dp[i][j] %= inf;
				sum[i][j] %= inf;
			}
			else{
				sum[i][j] = sum[i-1][j]+sum[i][j-1]+dp[i][j]-sum[i-1][j-1];
				sum[i][j]+=inf;
				sum[i][j] %= inf;
			}
			//cout<<dp[i][j]<<endl;
		}
	}
	cout<<(sum[n][m]+1)%inf<<endl;
	return 0;
}

Measured memory_bytes: 69888
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
 
N,M=map(int,input().split())
primes0=prime_factorize(M)
keys=list(set(primes0))
primes={}
for i in range(len(keys)):
  k=keys[i]
  primes[k]=0
  for j in range(len(primes0)):
    if primes0[j]==k:
      primes[k]+=1
 
def cmb(n, k, mod, fac, ifac): #calc nCk under mod
    if n < k or n < 0 or k < 0:
        return 0
    else: 
        k = min(k, n-k)
        return fac[n] * ifac[k] * ifac[n-k] % mod
 
def make_tables(mod, n): #Make factorial and inverse tables under mod 
    fac = [1, 1] # factorial table
    ifac = [1, 1] #factorial of inverse table
    inverse = [0, 1] #inverse
 
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac
 
mod=10**9+7
fac,ifac=make_tables(mod,N*10)
ans=1
for i in range(len(keys)):
  ans*=cmb(N+primes[keys[i]]-1, primes[keys[i]], mod, fac, ifac)
  ans%=mod
print(ans)

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

int main(int argc, char const *argv[])
{
	int A[5];
	for(int i=0; i<5; i++)
		cin>>A[i];
	for(int i=0; i<5; i++)
		if(A[i] == 0){
			printf("%d\n",i+1 );
		}
	return 0;
}

Measured memory_bytes: 3564
#include<stdio.h>
using namespace std;


int main() {
	int A[100][100] = {0},m,n,a,b[100];
	
	scanf("%d %d", &m, &n);
	for (int i = 0; i < m; i++)
	{
		for (int j = 0; j < n; j++)
		{
			scanf("%d", &a);
			A[i][j] += a;
		}
	}
	for (int k = 0; k < n; k++)
	{
		scanf("%d", &a);
		b[k] = a;
	}
	for (int p = 0; p < m; p++)
	{
		int num=0;
		for (int h = 0; h < n ; h++)
		{
			num += A[p][h] * b[h];
		}
		printf("%d\n", num);
	}
}



Measured memory_bytes: 2792
D, G = map(int, input().split())
cp = [list(map(int, input().split())) for i in range(D)]
ans = []

for j in range(2 ** D):
    check = 0
    con = 0
    rest = -1
    for i in range(D):
        p, c = cp[i]
        if j & (2**i):
            check += p * 100 * (i + 1) + c
            con += p
        else:
            rest = i

    if G <= check:
        ans.append(con)
    else:
        p1 = 100 * (rest + 1)
        pn = cp[rest][0] - 1
        for i in range(pn + 1):
            if G <= check + p1 * i:
                ans.append(con + i)
                break
print(min(ans))

Measured memory_bytes: 3064
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.List.Split
import Data.Char
import Data.Ord
import Data.Array.IO
import Data.IORef

readInt = read :: String -> Int
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete

wf arr range = forM_ range $ \k -> forM_ range $ \i -> forM_ range $ \j -> update <$> readArray arr (i,j) <*> readArray arr (i,k) <*> readArray arr (k,j) >>= writeArray arr (i,j)
  where
    update a b1 b2 = min a $ b1 + b2

cost arr (-1) = return 0
cost arr n = readArray arr (n,1)

main = do
    [h, w] <- getInts
    arr <- concat <$> replicateM 10 getInts >>= newListArray ((0,0),(9,9)) :: IO (IOUArray (Int,Int) Int)
    wf arr [0..9]
    concat <$> replicateM h getInts >>= sequence . map (cost arr) >>= print . sum



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

typedef long long ll;
 
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++) cin >> a[i];
  int cnt = 0;
  while(true){
    bool ok = true;
    for(int i=0; i<n; i++){
      if(a[i]%2==0) a[i]/=2;
      else ok=false;
    }
    if(!ok) break;
    cnt++;
  }
  
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n
# a, b
# s = input()


N = int(input())
d = list(map(int, input().split()))
d.sort()

half = N // 2
ans = d[half] - d[half-1]
print(ans)


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

int main(){
	long long a, b, ans = 1;
	cin >> a >> b;
	long long g = __gcd(a, b);
	for(long long i = 2; i * i <= g; i++){
		if(g % i == 0){
			ans++;
			while(g % i == 0) g /= i;
		}
	}
	if(g > 1) ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

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();
        
        if(N%2==0){
        	for(int i=N-1;i>=0;i-=2)System.out.println(a[i]);
        	for(int i=0;i<N;i+=2)System.out.println(a[i]);
        }else{
        	for(int i=N-1;i>=0;i-=2)System.out.println(a[i]);
        	for(int i=1;i<N;i+=2)System.out.println(a[i]);
        }
    }
}

Measured memory_bytes: 94144
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def dijkstra(E, start):
    N_d = len(E)
    dist = [INF] * N_d
    dist[start] = 0
    q = [(0, start)]
    while q:
        dist_v, v = heappop(q)
        if dist[v] != dist_v:
            continue
        for u, dist_vu in E[v]:
            dist_u = dist_v + dist_vu
            if dist_u < dist[u]:
                dist[u] = dist_u
                heappush(q, (dist_u, u))
    return dist

N, M = MAP()
L = [LIST() for i in range(M)]
graph = defaultdict(list)

q = deque([0])
for a, b in L:
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)


# put = [0] * N
visited = [False] * N
goto = [INF] * N
dist = [INF] * N

dist[0] = 0
while q:
    a = q.popleft()
    visited[a] = True
    for node in graph[a]:
        if dist[node] > dist[a] + 1:
            dist[node] = dist[a] + 1
            # print("node, a", node, a, dist[node], dist[a])
            goto[node] = a
            q.append(node)

if False in visited:
    print("No")
else:
    print("Yes")
    for g in goto[1:]:
        print(g+1)

# print(dist)
# print(goto)
# print(visited)




Measured memory_bytes: 81088
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())

print(a[K-1])

Measured memory_bytes: 3060
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize,
        aa: [usize; n]
    };
    let mut count = 0;
    for i in (0..n).step_by(2) {
        count += (aa[i] % 2 == 1) as i32;
    }
    println!("{}", count);
}


Measured memory_bytes: 2128
#ifdef _WIN32
#include "stdc++.h"
#else
#include <bits/stdc++.h>
#endif

// 継承可能な型
template <class Type>
struct IN : Type
{
	IN()
	{
		std::cin >> *this;
	}
};

// 継承不可能な型
template <class Type>
struct IN_
{
	Type val;

	IN_()
	{
		std::cin >> val;
	}

	operator Type&()
	{
		return val;
	}

	IN_<Type>& operator=(const Type& _value)
	{
		val = _value;
		return *this;
	}
};

template <class Char, class Type>
std::basic_ostream<Char>& operator <<(std::basic_ostream<Char>& os, const IN_<Type>& value)
{
	return os << value.val;
}

template <class Char, class Type>
std::basic_istream<Char>& operator >>(std::basic_istream<Char>& is, IN_<Type>& value)
{
	return is >> value.val;
}

template <class Type>
void OUT(const Type& value)
{
	std::cout << value << std::endl;
}

template <class Type, class ... Args>
void OUT(const Type& value, const Args& ... args)
{
	std::cout << value << ' ';
	OUT(args...);
}

void Yes()
{
	OUT("Yes");
}
void No()
{
	OUT("No");
}

using ll = long long;
using inll = IN_<ll>;
using vll = std::vector<ll>;
using setll = std::set<ll>;
using msetll = std::multiset<ll>;
using instr = IN<std::string>;

#define FOR(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define REP(i, n) for (ll (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for (ll (i) = (n); (i) >= 0; --(i))
#define ITRREP(it, v) for (auto (it) = (v).begin(); (it) != (v).end(); ++(it))
#define ITRREPR(it, v) for (auto (it) = (v).rbegin(); (it) != (v).rend(); ++(it))
#define DIVUP(a, b) (((a) + (b) - 1) / (b))

void Main();

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

	Main();

#ifdef _DEBUG
	system("pause");
#endif

	return 0;
}

using namespace std;

//////////////////////////////

void Main()
{
	inll n;

	vll x;
	vll x2;
	REP(i, n)
	{
		inll x_;
		x.push_back(x_);
		x2.push_back(x_);
	}

	if (n == 2)
	{
		cout << x[1] << endl << x[0] << endl;
		return;
	}

	sort(x2.begin(), x2.end());
	ll mid = (x2[n / 2] + x2[n / 2 - 1]) / 2;

	ITRREP(it, x)
	{
		cout << (*it <= mid ? x2[n / 2] : x2[n / 2 - 1]) << endl;
	}
}


Measured memory_bytes: 5604
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] arr = sc.next().toCharArray();
		int[] lefts = new int[n];
		int[] rights = new int[n];
		for (int i = 1; i < n; i++) {
		    lefts[i] = lefts[i - 1];
		    if (arr[i - 1] == 'W') {
		        lefts[i]++;
		    }
		    rights[n - i - 1] = rights[n - i];
		    if (arr[n - i] == 'E') {
		        rights[n - i - 1]++;
		    }
		}
		int min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
		    min = Math.min(min, lefts[i] + rights[i]);
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 31148
N, K = map(int, input().split())
p = list(map(int, input().split()))

m = [(e + 1) / 2 for e in p]
for i in range(1, N):
    m[i] += m[i - 1]

result = m[K - 1]
for i in range(N - K):
    t = m[K + i] - m[i]
    if t > result:
        result = t
print(result)


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

int main() {
int A, B, C = 0 , D, E ;
cin >> A;
B = A / 10;
B++;
E  = A ;

 for (int i = 0; i < B; i++) {
    C+= A % 10;
A/=10;
}

D =E % C;
if ( D == 0 ){
cout << "Yes" << endl;
}
else {
cout << "No" << endl;
}

}


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

int main()
{
    int total = 0;
    string s;
    cin >> s;
    stack<int> S;
    stack< pair<int, int> > S1;
    for(int i = 0; i < s.length(); i++)
    {
        if(s[i] == '\\')
            S.push(i);
        else if(s[i] == '/' && S.size() > 0)
        {
            int j = S.top();
            S.pop();
            int temp = i - j;
            total = total + temp;
            while(S1.size() > 0 && S1.top().first > j)
            {
                temp += S1.top().second;
                S1.pop();
            }
            S1.push(make_pair(j, temp));
        }
    }
    vector<int> ans;
    while(S1.size() > 0)
    {
        ans.push_back(S1.top().second);
        S1.pop();
    }
    reverse(ans.begin(), ans.end());
    cout << total << endl;
    cout << ans.size();
    for(int i = 0; i < ans.size(); i++)
    {
        cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3332
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;

int main() {
	ll l;
	cin >> l;
	double x = (double)l / 3;
	double y = (double)l / 3;
	double z = (double)l - x - y;
	double sum = x * y * z;
	printf("%.12f\n", sum);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
int check[51][26];
string s[51];
int ans[26];
int main(int argc, const char * argv[]) {
   
    int n;
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++) cin >> s[i];
    
    for(int i=0;i<n;i++){
        for(int j=0;j<s[i].size();j++){
            check[i][s[i][j]-'a']++;
        }
    }
    
    for(int i=0;i<26;i++){
        ans[i]=100000000;
        for(int j=0;j<n;j++){
            ans[i] = min(ans[i],check[j][i]);
        }
    }
    bool c = false;
    for(int i=0;i<26;i++){
        for(int j=0;j<ans[i];j++){
            printf("%c",i+'a');
            c=true;
        }
    }
    if(!c){
        printf("");
    }
    return 0;
}

Measured memory_bytes: 256
// abc167_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string S, T;
    cin >> S >> T;

    T.pop_back();
    if (S == T){
        print("Yes");
    } else {
        print("No");
    }


    return 0;
}


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

vector<ll> res;
vector<vector<pair<ll,ll>>>uv;

void dfs(ll n,ll p,ll c){
    res[n] = c;
    for(auto e : uv[n]){
        if(e.first == p)continue;
        if(e.second & 1)dfs(e.first,n,1-c);
        else dfs(e.first,n,c);
    }
}

int main(){
    ll n;
    cin>>n;
    //uv.assign(n, vector<pair<ll,ll>>());
    uv.resize(n);
    ll u[n],v[n],w[n];
    //ll res[n];
    res.resize(n);
    for(ll i=1;i<n;i++){
        cin>>u[i]>>v[i]>>w[i];
//        uv[i] = make_pair(u[i],v[i]);
        u[i]--;v[i]--;
        uv[u[i]].push_back(make_pair(v[i], w[i]));
        uv[v[i]].push_back(make_pair(u[i], w[i]));
    }
    //res.assign(n, 0);
    dfs(0, -1, 1);
    for (auto v : res) cout << v << endl;
}

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

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

  SORT(a, n);
  cout << a[n - 1] - a[0];

}


Measured memory_bytes: 256
n = int(input())
x = list(map(int,input().split()))
x.sort()
ans = 10**9
for i in range(x[0],x[-1]+1):
  k = 0
  for j in range(len(x)):
    k += (i-x[j])**2
  ans = min(k,ans)
print(ans)
    

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define f0(i,a,n) for(ll i=a;i<n-1;i++)
#define f(i,a,n) for(ll i=a;i<n;i++)
#define f1(i,a,n) for(ll i=a;i<=n;i++)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define T ll t=1; cin>>t; while(t--)
#define c(a) cin>>a;

int main()
{
    fast;
    int a=0,b=0,c=0,d=0;
    T{
        string s;
        c(s)
        if (s=="AC") a++;
        if (s=="WA") b++;
        if (s=="TLE") c++;
        if (s=="RE") d++;
    }
    cout<<"AC x "<<a<<endl;
    cout<<"WA x "<<b<<endl;
    cout<<"TLE x "<<c<<endl;
    cout<<"RE x "<<d<<endl;
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N;
ll A[105000];
ll ans[105000];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    ll ok = 0;
    ll ng = 2e9;
    while(ng - ok > 1) {
        ll mid = (ng + ok) / 2;
        ll before = mid;
        //cerr << mid << endl;
        for(int i = 1; i < N; i++) {
            before = A[i] - before;
            //cerr << i << " " << before << endl;
        }
        if(before + mid <= A[0]) ok = mid;
        else ng = mid;
    }
    cerr << ok << endl;
    ans[1] = ok * 2;
    ll before = ok;
    for(int i = 1; i < N; i++) {
        before = A[i] - before;
        ans[(i+1) % N] = 2 * before;
    }
    for(int i = 0; i < N; i++) cout << ans[i] << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 2944
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
from math import pi, sin, cos

COS_PI_3 = cos(pi / 3.0)
SIN_PI_3 = sin(pi / 3.0)


def koch_curve(s, e, n):
    if not n:
        return (s, e)
    x = (e[0]-s[0]) / 3.0
    y = (e[1]-s[1]) / 3.0
    p1 = (s[0] + x, s[1] + y)
    p2 = (x*COS_PI_3 - y*SIN_PI_3 + p1[0], x*SIN_PI_3 + y*COS_PI_3 + p1[1])
    p3 = (e[0] - x, e[1] - y)
    return (koch_curve(s, p1, n-1) + koch_curve(p1, p2, n-1)[1:] +
            koch_curve(p2, p3, n-1)[1:] + koch_curve(p3, e, n-1)[1:])


n = int(stdin.readline())
for x, y in koch_curve((0, 0), (100, 0), n):
    print('{:.8f} {:.8f}'.format(x, y))

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n,m;
    cin >> n >> m;
    if (n==1 && m==1)
    {
        cout << 1 << endl;
        return 0;
    }
    if(n==1)
    {
        cout << m-2 << endl;
        return 0;
    }
    if(m==1)
    {
        cout << n-2 << endl;
        return 0;
    }
    cout << (ll)(n - 2) * (ll)(m - 2) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        new Main().run();
    }
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == -1){
				break;
			}
			String ans = "";
			while(true){
				ans = n%4 + ans;
				n /= 4;
				if(n == 0){
					break;
				}
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 23648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);

		//入力表示
		int A = scanner.nextInt();
		int B = scanner.nextInt();
		int ans = 0;
		
      	//9以下の数字の場合
		if (A <= 9 && B <= 9) {
			ans = A * B;
			System.out.println(ans);
		//9以上の数字の場合	
		}else {
			System.out.println(-1);
		}
	}
}

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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
vector<int> A;

int main()
{
	scanf("%d",&N);
	int x = 0,y = 0,z = 0;
	A.assign(N,0);
	FOR(i,0,N){
		scanf("%d",&A [i]);
		if(A [i] % 4 == 0){
			x++;
		}
		else if(A [i] % 2 == 0){
			y++;
		}
		else{
			z++;
		}
	}

	if(y == 0){
		puts(z <= x + 1 ? "Yes" : "No");
	}
	else{
		puts(z <= x ? "Yes" : "No");
	}

	return 0;
}


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

typedef long long s64;
#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=3e5+5;
int a[N];

int main()
{
	//freopen("1.in","r",stdin);
	int m;
	cin>>m;
	int n=m*3;
	rep(i,1,n)scanf("%d",a+i);
	sort(a+1,a+n+1);
	s64 ans=0;
	rep(i,1,m)ans+=a[n+1-2*i];
	cout<<ans;
}

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

using namespace std;

void solve(void)
{
	int n;
	cin >> n;
	vector<int> as(n);
	for (int &a : as)
		cin >> a;
	bool f = 1;
	for (int k = 0; k < n - 1; k++)
	{
		if (as[k] > as[k + 1])
			f = 0;
	}
	if (f)
	{
		cout << "YES" << endl;
		return;
	}
	for (int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
		{
			swap(as[i], as[j]);
			f = 1;
			for (int k = 0; k < n-1; k++)
			{
				if (as[k] > as[k+1])
					f = 0;
			}
			if (f)
			{
				cout << "YES" << endl;
				return;
			}
			swap(as[i], as[j]);
		}
	cout << "NO" << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define PUTS(x) cout << (x) << endl;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define ALL(v) (v).begin(), (v).end()
int main() {
    Int n;
    cin >> n;
    vector<pair<int, int>> v;
    rep(i, n) {
        Int x, l;
        cin >> x >> l;
        v.PB(MP(x - l, x + l));
    }

    sort(ALL(v), [&](const auto &a, const auto &b) {
        return a.S < b.S;
    });

    Int ans = 0;
    Int current = -1e10;
    rep(i, n) {
        if (current > v[i].F) continue;
        ans++;
        current = v[i].S;
    }
    PUTS(ans);
}


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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,x) for(auto& a: x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int > vi;

int main(){
	int a,b;
	cin>>a>>b;
	if(a<10 && b<10 && a>=1 && b>=1)cout<<a*b;
	else cout<<-1;
}

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

int main(void){
    int n;
    cin >> n;
    vector<vector<vector<int>>> official_house(4 ,vector<vector<int>>(3, vector<int>(10, 0)));
    for(int i=0;i<n;i++){
        int b,f,r,v;
        cin >> b >> f >> r >> v;
        official_house[b-1][f-1][r-1] += v;
    }
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                cout << " " << official_house[i][j][k];
            }
            cout << endl;
        }
        if(i<3)
        cout << "####################" << endl;
    }
}


Measured memory_bytes: 3108
#include<iostream>
#include<vector>
int main()
{
	while (!std::cin.eof())
	{
		int n;
		std::cin >> n;
		if (n == 0)
		{
			break;
		}
		std::vector<int>a(n);
		for (auto&i : a)
		{
			std::cin >> i;
		}
		int max = -100001;
		for (int i = 0; i < n; i++)
		{
			int max_temp = 0;
			for (int j = 0; j < n - i; j++)
			{
				max_temp += a[i + j];
				if (max < max_temp)
				{
					max = max_temp;
				}
			}
		}
		std::cout << max << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

using namespace std;
using pii=pair<int,int>;
using ll=long long;

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

    int n,a,b;
    cin>>n>>a>>b;
    if(n*a<b) cout<<n*a;
    else cout<<b;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0; }
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path; vl A, T;
//***********//
int main() {
	ll A, B;
	cin >> A >> B;
	cin >> K;
	if (K <= A) {
		cout << A - K << endl;
		cout << B;
	}
	else {
		ll z = 0;
		cout << 0 << endl << max(z, B - (K - A));
	}
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

def judge(config , info):
    config = config.split()
    monster_physical = int(config[0])
    deathblow = int(config[1])
    
    info = info.split()
    
    deathblow_num = 0
    for num in info:
        deathblow_num = deathblow_num + int(num)
    
    if monster_physical <= deathblow_num:
        print("Yes")
    else:
        print("No")
    
def main():
    configration = input()
    information = input()
    
    judge(configration , information)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9944
# ライブラリ改変テスト
class Combi():
    def __init__(self, N, mod):
        self.power = [1 for _ in range(N+1)]
        self.rev = [1 for _ in range(N+1)]
        self.mod = mod
        for i in range(2, N+1):
            self.power[i] = (self.power[i-1]*i) % self.mod
        self.rev[N] = pow(self.power[N], self.mod-2, self.mod)
        for j in range(N, 0, -1):
            self.rev[j-1] = (self.rev[j]*j) % self.mod

    def com(self, K, R):
        if K < R:
            return 0
        else:
            return ((self.power[K])*(self.rev[K-R])*(self.rev[R])) % self.mod

    def pom(self, K, R):
        if K < R:
            return 0
        else:
            return (self.power[K])*(self.rev[K-R]) % self.mod


######################
N, M, K = map(int, input().split())
mod = 998244353
ans = 0
C = Combi(2*10**5, mod)
for i in range(K+1):
    ans += M*C.com(N-1, i)*pow(M-1, N-1-i, mod)
print(ans % mod)
######################

Measured memory_bytes: 103052
#include<stdio.h>
int main(void){
int W,H,x,y,r;
scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
if(x+r>W||x-r<0||y+r>H||y-r<0)printf("No\n");
else printf("Yes\n");
return 0;
}


Measured memory_bytes: 2000
import scala.io.Source.stdin

object Main {
  type Vector = (Double,Double)
  def v(x:Vector,y:Vector):Vector = (x,y) match { case ((x0,y0),(x1,y1)) => (x1-x0,y1-y0) }
  def cross(x:Vector,y:Vector) = (x,y) match { case ((x0,y0),(x1,y1)) => x0*y1-x1*y0 }

  def main(args:Array[String]) = {
    val b = new StringBuilder

    for(l<-stdin.getLines.map(s=>s.split(",").map(_.toDouble))) {
      val v01 = v((l(0),l(1)), (l(2),l(3)))
      val v02 = v((l(0),l(1)), (l(4),l(5)))
      val v03 = v((l(0),l(1)), (l(6),l(7)))
      val v10 = v((l(2),l(3)), (l(0),l(1)))
      val v12 = v((l(2),l(3)), (l(4),l(5)))
      val v13 = v((l(2),l(3)), (l(6),l(7)))
      if(cross(v02, v01)*cross(v02,v03) < 0
          && cross(v13,v12)*cross(v13,v10) < 0)
        b.append("YES\n")
      else
        b.append("NO\n")
    }
    print(b.result)
  }
}

Measured memory_bytes: 44104
n = int(input())
li = list(map(int,input().split()))
h = li[0]
for i in range(n):
    if li[i] > h:
        h = li[i]
    elif li[i] < h:
        if li[i]+1 < h:
            print("No")
            exit()
        #elif li[i]+1 == h:
            #h = li[i]+1
print("Yes")

Measured memory_bytes: 14396