akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define itn int
#define all(c) c.begin(),c.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define ll long long
#define ull unsigned long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std; 

const double PI = 3.1415926536;
int days[13] = {0, 31, 28, 31, 30, 31,30, 31, 31, 30, 31, 30, 31};

template<typename T>
ostream& operator <<(ostream& out, const vector<T>& mas) {
    for (const auto& x : mas) {
        out << x << ' ';
    }
    return out;
}

void ok() {
    cout << "YES" << '\n';
}

void no() {
    cout << "NO" << '\n';
}

inline ll nxt() {
    ll x;
    cin >> x;
    return x;
} 

const int N = 1e6 + 5;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    vector<vector<int>> erat(N);
    for (int i = 1; i < N; i++) {
        for (int j = i; j < N; j += i) {
            erat[j].push_back(i);
        }
    }

    int n = nxt();
    vector<int> a(n);
    generate(all(a), nxt);
    vector<int> cnt(N);
    for (int i = 0; i < n; i++) {
        int x = a[i];
        cnt[x]++;
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int cur_ans = 0;
        for (auto x : erat[a[i]]) {
            cur_ans += cnt[x];
        } 
        ans += (cur_ans == 1);
    }
    cout << ans;
    return 0;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = 1LL << 60;
ll MOD = 1000000007LL;
using vc = vector<char>;
using vi = vector<int>;

vector<vi> graph;
vi mult;

int N, K;

void dfs(int cur, int par, int grands) {
    mult[cur] = K - (par != -1) - grands;
    int tot = (par != -1);
    for (int n : graph[cur]) {
        if (n != par) dfs(n, cur, tot++);
    }
}
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    cin >> N >> K;
    graph.resize(N);
    mult.resize(N);

    F0R(i, N - 1) {
        int a, b; cin >> a >> b; --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    dfs(0, -1, 0);
    ll ans = 1;
    F0R(i, N) {
        ans *= mult[i];
        ans %= MOD;
    }
    cout << endl;
    cout << ans << endl;
    
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,m;
    cin>>n>>m;
    if(n>m)
    {
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }


  return 0;


}


Measured memory_bytes: 3608
#include <stdio.h>
typedef long long ll;
int main() {
	int n;
	ll sum = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			sum += i;
		}
	}
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 1732
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int t = scan.nextInt();
        int[] array = new int[t];
        int[] copy = new int[t];
        for (int count = 0; count < t; count++) {
            int n = scan.nextInt();
            array[count] = n;
            copy[count] = n;
        }
        scan.close();
        Arrays.sort(copy);
        int counter = 0;
        for (int count = 0; count < t; count++) {
            if(array[count] != copy[count]) {
                counter++;
            }
        }
        if(counter < 3) {
            System.out.println("YES");
        }
        else
            System.out.println("NO");
    }

}

Measured memory_bytes: 35712
#include <cstdio>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
int H, W, a[2009][2009], t[2009][2009], dp[2009][2009], pl[2009], pr[2009];
int main() {
	scanf("%d %d", &H, &W);
	int vl = inf, vr = -1;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			char c = getchar();
			while (c < 48 || 57 < c) c = getchar_unlocked();
			while (48 <= c && c <= 57) a[i][j] = 10 * a[i][j] + c - 48, c = getchar_unlocked();
			vl = min(vl, a[i][j]);
			vr = max(vr, a[i][j]);
		}
	}
	int ret = inf;
	for (int i = 0; i < 4; i++) {
		pr[W] = 0;
		for (int j = 0; j < H; j++) {
			for (int k = 1; k <= W; k++) pl[k] = max(pl[k - 1], a[j][k - 1] - vl);
			for (int k = W - 1; k >= 0; k--) pr[k] = max(pr[k + 1], vr - a[j][k]);
			int curmin = inf;
			for (int k = 0; k <= W; k++) {
				curmin = min(curmin, dp[j][k]);
				dp[j + 1][k] = max({ curmin, pl[k], pr[k] });
			}
		}
		ret = min(ret, *min_element(dp[H], dp[H] + W + 1));
		for (int j = 0; j < H; j++) {
			for (int k = 0; k < W; k++) {
				t[k][H - j - 1] = a[j][k];
			}
		}
		swap(H, W);
		for (int j = 0; j < H; j++) {
			for (int k = 0; k < W; k++) {
				a[j][k] = t[j][k];
			}
		}
	}
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 49820
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    vector<int> a(3);
    for(int i = 0;i < 3;i++)
        cin >> a.at(i);
    sort(a.begin(),a.end());
    if(a.at(2) == a.at(0) + a.at(1))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
} 

Measured memory_bytes: 256
# Atcoder Problem Solving
H,W=map(int,input().split())
c=[list(map(int,input().split())) for i in range(H)]
b=[list(map(int,input().split())) for i in range(H)]
a=[[0 for i  in range(W)] for j in range(H)]

for i in range(H):
    for j in range(W):
        a[i][j]=abs(c[i][j]-b[i][j])
        
dp=[[0 for i in range(W)] for j in range(H)]

# Bitset演算
# 答えは絶対値が絶対-80から80以内に収まる

X=3200

dp[0][0]= (1<<(X+a[0][0]))  | (1<<(X-a[0][0]))
# 初期化の条件

for i in range(H):
    for j in range(W):
        if 0<=i<H and 0<=j+1<W:
            dp[i][j+1]|=(dp[i][j]<<a[i][j+1])
            dp[i][j+1]|=(dp[i][j]>>a[i][j+1]) 
            
        if 0<=i+1<H and 0<=j<W:
            dp[i+1][j]|=(dp[i][j]<<a[i+1][j])
            dp[i+1][j]|=(dp[i][j]>>a[i+1][j])
            
A=str(bin(dp[H-1][W-1]))[::-1]
L=len(A)
ans=3200
for i in range(L):
    if A[i]=="1":
        ans=min(ans,abs(i-X))
print(ans)

Measured memory_bytes: 12404
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void){
    float n;
    float sum=0;
    cin >> n;
    vector<float> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        sum+=a[i];
    }
    sum/=n;
    float dif=1000000;
    int key=-1;
    for(int i=0; i<n; i++){
        if(dif>fabs(sum-a[i])){
            dif=fabs(sum-a[i]);
            key=i;
        }
    }
    cout << key << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
    uint64_t m,n,q = 1000000007,nl;
    std::cin >> m >> n;

    uint64_t r = 1;
    uint64_t m2 = m*m;
    uint64_t m4 = m2*m2;
    uint64_t i = 0;
    nl = n-i;
    for(uint64_t j=0;j<nl/4;j++)
    {
        r = (r*m4) %q;
        i += 4;
    }
    for(;i<n;i++)
    {
        r = (r*m) %q;
    }
    std::cout << r << "\n";
    return 0;
}




Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}


int main(){
  int a,b,c,d;
  int input;
  cin >> input;
  d = input%10;input/=10;
  c = input%10;input/=10;
  b = input%10;input/=10;
  a = input%10;input/=10;
  //0 : + ,1: -
  int res = 0;
  string ans;
  for(int op1 = 0;op1<2;op1++){
    int res = 0;
    string tmp;
    for(int op2=0;op2<2;op2++){
      for(int op3=0;op3<2;op3++){
        if(op1 == 0){
          res = a+b;
          tmp = to_string(a);
          tmp+="+";
          tmp+=to_string(b);
        }else{
          res = a-b;
          tmp = to_string(a);
          tmp+="-";
          tmp+=to_string(b);
        }
        if(op2 == 0){
          res+=c;
          tmp += "+";
          tmp+=to_string(c);
        }else{
          res-=c;
          tmp+="-";
          tmp+=to_string(c);
        }
        if(op3 == 0){
          res+=d;
          tmp+="+";
          tmp+=to_string(d);
        }else{
          res-=d;
          tmp+="-";
          tmp+=to_string(d);
        }
        if(res == 7) {
          cout << tmp << "=7" << endl;
          return 0;
        } 
      }
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    vec<int> x(5);
    rep(i, 5) cin >> x[i];
    rep(i,5) {
        if(x[i] == 0){
            cout << i+1 << endl;
        }
    }
}


Measured memory_bytes: 3544
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
using namespace std;

int main() {

    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    double res = -1;
    int max_all = 0, max_sugar = 0;

    for (int a = 0; a*100*A <= F; a++) {
        for (int b = 0; b*100*B <= F; b++) {

            int s = (a*A + b*B) * E; //水に溶ける砂糖の最大量
            
            for (int c = 0; c*C <= s; c++) {
                for (int d = 0; d*D <= s; d++) {

                    int sugar = c*C + d*D; //砂糖の量
                    int all = 100*a*A + 100*b*B + sugar; //全体量
                    if (sugar > E*(a*A + b*B)) continue;
                    if (all > F) continue;
                    if (res < 100*sugar / (double)all) {
                        res = 100*sugar / (double)all;
                        max_all = all;
                        max_sugar = sugar;
                    }
                }
            }
        }
    }

    cout << max_all << " " << max_sugar << endl;

    return 0;   

}


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

int func_sum_digit(int num) {
  if (num < 10) {
    return num;
  }
  return (num % 10) + func_sum_digit(num / 10);
}
// num=1234, return=1+2+3+4

int main() {
  int N;
  cin >> N;
  int sum_digit = func_sum_digit(N);
  string ans = "No";
  if (N % sum_digit == 0) {
    ans = "Yes";
  }
  cout << ans << endl;
  return 0;
}





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

int main(int argc, const char * argv[]) {
    int n,i;
    double xa,ya,ra,xb,yb,rb,d;
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%lf %lf %lf %lf %lf %lf",&xa,&ya,&ra,&xb,&yb,&rb);
        d=sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
        //printf("d:%lf\n",d);
        if(d>ra+rb)
            printf("0\n");
        else if(fabs(d-(ra+rb))<0.000001)
            printf("1\n");
        else if(ra>=rb){
            if(ra>d+rb)
                printf("2\n");
            else
                printf("1\n");
        }
        else if(ra<rb){
            if(rb>d+ra)
                printf("-2\n");
            else
                printf("1\n");
        }
    }
    return 0;
}

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

int main() {
    string S, T;
    cin >> S;
    T = "ATGC";

    int l = 0;
    bool flag;
    for (int f=0; f<S.size(); f++) {
        for(int b=f; b<S.size(); b++) {
            for (int i=f; i<=b; i++) {
                flag = false;
                for (int j=0; j<T.size(); j++) {
                    if (S[i]==T[j]) {
                        flag = true;
                        break;
                    }
                }
                if (!flag) {
                    break;
                }
            }
            if (flag) {
                l = max(b-f+1, l);
            }
        }
    }

    cout << l << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
char s[10];
int main()
{
    int n;
    cin >> n;
    int a=0,b=0,c=0,d=0;
    for(int i=0;i<n;i++){
        cin >> s;
        if(s[0]=='A')
            a++;
        else if(s[0]=='W')
            b++;
        else if(s[0]=='T')
            c++;
        else if(s[0]=='R')
            d++;
    }
    cout << "AC x "<<a << endl;
    cout << "WA x "<<b << endl;
    cout << "TLE x "<<c << endl;
    cout << "RE x "<<d << endl;

}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
using namespace std ;
string s1,s2;
int n;
int count(string s,string t){
    int m=s.size(),p=t.size(),maxi=0;
    int x[1001][1001];
    for(int i=0;i<=m;i++) x[i][0]=0;
    for(int i=1;i<=p;i++) x[0][i]=0;
    s=' '+s; t=' '+t;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=p;j++){
            if(s[i]==t[j]) x[i][j]=1+x[i-1][j-1];
            else x[i][j]=max(x[i-1][j],x[i][j-1]);
        }
    }
    return x[m][p];
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s1>>s2;
        cout<<count(s1,s2)<<endl;
    }
    return 0;
}


Measured memory_bytes: 7088
#include <string.h>
#include <iostream>
using namespace std;
int main() {
	int num1;
	int num2;
	string s;
	cin >> num1 >> s >> num2;
	if (s == "+") {
		cout << (num1 + num2) << endl;
	}
	if(s=="-"){
		cout << (num1 - num2) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    string s1,s2;
    s1.clear();
    s2.clear();
    char c1=(char)(a+48);
    char c2=(char)(b+48);
    for(int i=1;i<=a;i++)
        s1+=c2;
    for(int i=1;i<=b;i++)
        s2+=c1;
    if(s1>s2)
        cout<<s2<<endl;
    else
        cout<<s1<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


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

    int n ,m , xs, ys;
    cin >> n >> m >> xs >> ys ;
    vi x(n);
    vi y(m);
    rep(i,n){
        cin >> x[i];
    }
    rep(i,m){
        cin >> y[i];
    }
    if(max(xs,maxel(x)) < min(ys,minel(y))) cout << "No War" << endl;
    else cout << "War" << endl;

    return 0;
}
    

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

using namespace std;
using ll = long long;
const long long INF = 1LL<<60;

typedef pair<ll,ll> Pair;
int main(){

ll N,K;

cin >> N >> K;

vector<Pair> A(N+1);

for(ll i = 1;i <= N;++i){
    cin >> A[i].first;
    A[i].second = 0;
}

A[1].second = 1;
ll index = A[1].first;
ll telcnt = 0;
ll ans;
  
while(A[index].second != 2 && K > telcnt){
    //cout << index << endl;
    ans = index;
    ++A[index].second;
    index = A[index].first;
    ++telcnt;
}

if(K == telcnt) cout << ans << endl;
else{

K = K - telcnt;
  
ll count = 0;

for(ll i = 1;i <= N;++i){

  if(A[i].second == 2) ++count;

}
  
K = K%count;
telcnt = 0;
  
while(K > telcnt){
    //cout << index << endl;
    ans = index;
    ++A[index].second;
    index = A[index].first;
    ++telcnt;
}

cout << ans << endl;
  

}
  
  
/*  
for(ll i = 1;i <= N;++i){
    cout << "A.first = " << A[i].first << " : A.second = " << A[i].second << endl;
}
*/




return 0;

}


Measured memory_bytes: 6364
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

int main(){
    int n, k;
    cin >> n >> k;
    int p[n];
    rep(i, n){
        cin >> p[i];
    }
    sort(p, p + n);
    int ans = 0;
    rep(i, k){
        ans += p[i];
    }
    cout << ans << endl;
}

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

int main(){
    int H, W;
    cin >> H >> W;
    
    string S[H];
    string tempS[H];
    
    for(int i = 0; i < H; i++){
        cin >> S[i];
        tempS[i] = S[i];
    }
    
    
    
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            int count = 0;
            if(tempS[i][j] == '.'){
                //左上
                if(i - 1 >= 0 && j - 1 >= 0){
                    if(tempS[i - 1][j - 1] == '#'){
                        count++;
                    }
                }
                
                //上
                if(i - 1 >= 0){
                    if(tempS[i - 1][j] == '#'){
                        count++;
                    }
                }
                
                //右上
                if(i - 1 >= 0 && j + 1 < W){
                    if(tempS[i - 1][j + 1] == '#'){
                        count++;
                    }
                }
                
                //左
                if(j - 1 >= 0){
                    if(tempS[i][j - 1] == '#'){
                        count++;
                    }
                }
                
                //右
                if(j + 1 < W){
                    if(tempS[i][j + 1] == '#'){
                        count++;
                    }
                }
                
                //左下
                if(i + 1 < H && j - 1 >= 0){
                    if(tempS[i + 1][j - 1] == '#'){
                        count++;
                    }
                }
                
                //下
                if(i + 1 < H){
                    if(tempS[i + 1][j] == '#'){
                        count++;
                    }
                }
                
                //右下
                if(i + 1 < H && j + 1 < W){
                    if(tempS[i + 1][j + 1] == '#'){
                        count++;
                    }
                }
                S[i][j] = count + '0';
            }
        }
    }
    
    for(int i = 0; i < H; i++){
        cout << S[i] << endl;
    }
    
    cout << endl;

}

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

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    //int t=1 ; cin>>t ; while(t--)
    {
    	int n, a, b;
    	cin >> n >> a >> b;
    	
    	int ans = min((b - a) / 2 + a, (b - a) / 2 + n - b + 1);
    	if((b - a) % 2 == 0)
    		ans = (b - a) / 2;

    	cout << ans << '\n';


    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int N, i;
  scanf("%d",&N);
  
  int a[N];
  for(i=0;i<N;i++){
    scanf("%d",&a[i]);
  }
  int res = 0;
  int all_even = 1;
  while(all_even) {
    for(i=0;i<N;i++){
      if(a[i]%2==0){
      a[i]=a[i]/2; 
      }else{
       all_even = 0; 
      }
      
    }
    if(all_even==1){
    res+=1;
    }
  }
  printf("%d",res);
  
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void);

int main(void)
{
    int a, b, i;
    char op;

    /* opは+, -, *, /のいずれか */
    for(i = 1; i > 0; i++){
        scanf("%d %c %d", &a, &op, &b);
        if(op == '+'){
            printf("%d\n", a + b);
        }
        else if(op == '-'){
            printf("%d\n", a - b);
        }
        else if(op == '*'){
            printf("%d\n", a * b);
        }
        else if(op == '/'){
            printf("%d\n", a / b);
        }
        else if(op == '?'){
            break;
        }
    }
    return(0);
}


Measured memory_bytes: 2088
N, M = map(int,input().split())
a = list(map(int, input().split()))
lim = sum(a)/(4*M)
c = 0
for k in range(N):
    if a[k] >=lim:
        c+=1
    if c ==M:
        break

if c ==M:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,a[5],ans,p;
main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i],ans+=a[i];
  sort(a,a+n,greater<int>());
  if(n==1)cout<<ans<<endl;
  else if(n==2)cout<<ans-1<<endl;
  else if(n==3)cout<<ans-3<<endl;
  else if(n==4){
    if(a[0]==2)cout<<ans-4<<endl;
    else if(a[3]==2)cout<<ans-5<<endl;
    else cout<<ans-6<<endl;
  }
  else{
    if(a[0]<=3){
      if(ans<12)cout<<ans-6<<endl;
      else if(ans<14)cout<<ans-7<<endl;
      else cout<<ans-8<<endl;
    }
    else{
      if(a[3]==2)cout<<ans-7<<endl;
      else if(ans<=20)cout<<ans-8<<endl;
      else cout<<ans-6-min(a[4],4LL)<<endl;
    }
  }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<int, Pii> P1;

#define rep(i, n) for (int i = 0; i < n; i++)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define mp1(a, b, c) P1(a, P(b, c))
#define get_arsize(a) (sizeof(a) / sizeof(a[0]))

const ll MOD = 1000000007;
const double EPS = 1e-10;
const int INF = 1001001001;

int main()
{
  int n, x, y;
  cin >> n >> x >> y;
  x--;
  y--;
  vector<int> ans(n);

  // iは始点
  rep(i, n)
  {
    queue<int> q;
    // 各終点ノードへの距離を格納する。
    vector<int> dist(n, INF);
    // distを更新する。queueに新規更新したnodeをメモ
    auto update = [&](int k, int d) {
      if (dist[k] != INF)
        return;
      dist[k] = d;
      q.push(k);
    };
    update(i, 0);
    while (!q.empty()) {
      // ターゲットポイントを取る
      int target = q.front();
      q.pop();
      int d = dist[target];
      // ターゲットポイントから1歩で進める場所について更新
      if (target - 1 >= 0) {
        update(target - 1, d + 1);
      }
      if (target + 1 < n) {
        update(target + 1, d + 1);
      }
      if (target == x) {
        update(y, d + 1);
      }
      if (target == y) {
        update(x, d + 1);
      }
    }
    rep(i, n) {
      ans[dist[i]]++;
    }
  }

  rep(i,n) {
    ans[i] /= 2;
  }

  for(int i = 1; i <= n-1; ++i) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
 
def main(N, S):
    num_e = S.count("E")
    num_w = 0
    res = num_e
    for s in S:
        if(s=="E"):
            num_e -= 1
        else:
            num_w += 1
        res = min(res, num_e + num_w)
    print(res)
    
if(__name__ == "__main__"):
    N = int(input())
    S = input()
    
    main(N, S)

Measured memory_bytes: 3700
import math
a,b,x=map(int,input().split())
#theta傾いているときの最大容量
def f(theta):
    if math.tan(theta)<b/a:
        #あまり傾いてないとき
        return (a*b-((a*a*math.tan(theta))/2))*a
    else:
        return (b*b/math.tan(theta)/2)*a
low=0
high=math.pi/2
while(high-low>1e-15):
    mid=(low+high)/2
    #print(low,high,f(mid),x)
    if f(mid)>x:
        low=mid
    else:
        high=mid
print(math.degrees(low))

Measured memory_bytes: 38512
#include<iostream>
#include<utility>
#include<string>
#include<algorithm>
int main(){
    int N;
    std::cin >> N;
    std::pair<std::pair<std::string,int>,int> S[N];
    for(int i=0; i<N; i++) {
        std::string s;int p;std::cin>>s>>p;
        S[i] = std::make_pair(std::make_pair(s,-p),i);
    }
    std::sort(S,S+N);
    for(auto x: S) std::cout<<x.second+1 << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YN(x)         cout << ((x) ? "YES" : "NO") << endl
#define Yn(x)         cout << ((x) ? "Yes" : "No") << endl
#define yn(x)         cout << ((x) ? "yes" : "no") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  // 10^18 くらいまでいける

// for DP
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 ll INF = 1LL << 60;

int main(){

  int n;
  cin >> n;
  vector<ll> L(n);
  rep(i, n) cin >> L[i];

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

  ll ans = 0;
  for(int i=0; i<n-2; i++){
    for (int j=i+1; j<n-1; j++){
      ll ij = L[i] + L[j];  // 2辺を決めて, c < a+b なので
      ll r = lower_bound(L.begin(), L.end(), ij) -L.begin();  // ij以上の最初の要素の添字を返す
      ll l = j+1;
      // c = [l, r)
      ans += r-l;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int s=a*b;
	if(s<=c)
	{
		cout<<s<<endl;
	}
	if(s>c)
	{
		cout<<c<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
X, K, D = map(int, input().split())

N = abs(X) // D
O = abs(X) - N * D

if O <= (D - O):
    pass
else:
    N += 1
    O = D - O
    
if N >= K:
    print(abs(X) - K * D)
else:
    if (K - N) % 2 == 0:
        print (O)
    else:
        print(D - O)

Measured memory_bytes: 61752
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

void ninetan(vector<int> &a){
	int n = a.size();
	rep(i, n) a[i] *= 9;
	a.push_back(0);
	rep(i, n){
		a[i+1] += a[i]/10;
		a[i] %= 10;
	}
	if(a.back()==0) a.pop_back();
}

void add(vector<int> &a, int x){
	a[0] += x;
	rep(i, a.size()-1){
		if(a[i]<10) return;
		a[i+1] += a[i]/10;
		a[i] %= 10;
	}
}

void dec(vector<int> &a){
	a[0]--;
	rep(i, a.size()-1){
		if(a[i]>=0) return;
		a[i] += 10;
		a[i+1]--;
	}
}

int main(){
	string s;
	cin>>s;
	reverse(all(s));
	int n = s.size();
	vector<int> a(n);
	rep(i, n) a[i] = s[i]-'0';
	ninetan(a);
	ll res = 0;
	while(a.size()>1){
		int x = a.back();
		add(a, x+1);
		if(a.back()==x){
			dec(a);
		}
		res += a.back();
		a.pop_back();
	}
	res += a[0]/9;
	cout<<(res+8)/9<<endl;
	return 0;
}


Measured memory_bytes: 6532
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int b,r,g,c,s,t;
	while(cin>>b>>r>>g>>c>>s>>t,b||r||g||c||s||t){
	int kati=(15*5*b)+(15*b)+(15*3*r)+(15*r)+7*g+c*2+s*3;
	cout<<kati-(3*t)+(b*5+r*3)+100<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var a = cin.ReadDouble;
            var b = cin.ReadDouble;
            var x = cin.ReadDouble;

            var ans = 0.0;
            if (a * a * b < x * 2)
            {
                ans = Atan(2.0 / Pow(a, 3) * (Pow(a, 2) * b - x)) * 180.0 / PI;
            }
            else
            {
                ans = 90 - Atan(2.0 * x / (b * b * a)) * 180.0 / PI;
            }

            
            Console.WriteLine(ans);
        }
    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11348
#include <iostream>
#include <string.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <vector>
#include <map>

using namespace std;

#define cn cout << '\n'
#define cio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long
#define ii pair < int, int >
#define iii pair < int, ii >
#define INF 987654321
#define LINF 987654321987654321

ll bin(ll N, ll K, vector<ll> H) {
    if (K > N) return 0;
    ll l = 0;
    sort(H.begin(), H.end(), greater<>());
    for (int i = 0; i < N; ++i) {
        if (K > 0) K--;
        else l += H[i];
    }
    return l;
}

int main() {
    cio;
    ll N, K;
    cin >> N >> K;
    vector<ll> H(N);
    for (size_t i = 0; i < N; ++i) {
      cin >> H[i];
    }
    cout << bin(N, K, H);
    cn;
}


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

using namespace std;

using ll = long long;

#define READ freopen("input.txt", "r", stdin)
#define ROUT freopen("output.txt", "w", stdout)
#define pb push_back
#define endl '\n'

void fileIO()
{
    READ;
    ROUT;
}

void fasterIO()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main()
{
    ///fileIO();
    fasterIO();

    int n, d;

    cin>>n>>d;

    if(n%(2*d+1)==0)
        cout<<n/(2*d+1)<<endl;
    else
        cout<<(n/(2*d+1))+1<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// g++ test.cpp && ./a.out < in
#pragma GCC optimize("O3")
using namespace std;
#define fi first
#define se second
#define pb push_back
#define loop(i, a, b) for (int i=a; i<(b); i++)
typedef long long ll;
typedef pair<int,int> pi;
const int INF = 1e9;
const int MOD = 1000000007;



void test_case() {
	int n; cin>>n;
	int ans = 0;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		if(i&1 && x&1) ans++;
	}
	cout<<ans<<endl;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	// cin >> t;
	for (int i = 1; i <= t; i++) {
		test_case();
	}
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <vector>

using namespace std;

int main(){

    //vector<char> N;
    //char N[100]={0};
    string str;
    int sumofnum=0;
    int num[30]={0}; //a~z 何個あるか
    int cnt=0;
    int N=0;
    int Y;
    string alpha="abcdefghijklmnopqrstuvwxyz";
    //cout << alpha[2]; 0~25 a~z
    //文字数NはΣnum[k]
    cin >> N >> Y;
  //  cout<<N<<Y;
    //N=p+q+r Y=10000p+5000q+1000(N-p-q)
    int p,q=0;
    if(1<=N && N<=2000&&1000<=Y&&Y<=20000000&&Y%1000==0){
      for(p=0;p<=N;p++){
        for(q=0;q<=N;q++){
          int r=N-p-q;
          if(10000*p+5000*q+1000*(N-p-q)==Y){
            //r=N-p-q;
            if(r>=0){
              //cout << p <<Y;
              //cout << "b";
              cout<<p<<" "<<q<<" "<<N-p-q<<endl;
              return 0;
            }
          }
        }
      }

    }

    //cout << "wut";
    //cout<<p<<q<<r;
    cout<<"-1 -1 -1";
    return 0;
    }


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

int n, s, res[10][330] = { 0 };
bool num[10] = { 0 };
void combinations(int c, int sum) {
	if (c == 11) return ;
	for (int i = 0; i < 10; i++) {
		if (num[i]) continue;
		num[i] = 1;
		++res[c + 1][sum + i * (c + 1)];
		combinations(c + 1, sum + i * (c + 1));
		num[i] = 0;
	}
}

int main() {
	combinations(0, 0);
	while (cin >> n) {
		cin >> s;
		if (n > 10 || s > 330) {
			n = 0;
			s = 0;
		}
		cout << res[n][s] << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
import itertools
N, M, Q    = [ int(i) for i in input().strip().split(' ')]

data = []
for n in range(Q):
    data.append([ int(i) for i in input().strip().split(' ')])

x = [ 1+i for i in range(M)]
max_total = 0
for A in itertools.combinations_with_replacement(x, N):
    total = 0
    for a,b,c,d in data:
        if A[b-1] - A[a-1] == c:
            total += d
    
    if max_total < total:
        max_total = total
print(max_total)

Measured memory_bytes: 9100
#include <bits/stdc++.h>
#define pai 3.14159265
using namespace std;

int main(void){
    int A,B;
    string S;
    cin>>A>>B>>S;
    for(int i=0;i<A;i++){
        if(S[i]-'0'>9||S[i]-'0'<0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    if(S[A]!='-'){
        cout<<"No"<<endl;
        return 0;        
    }
    for(int i=A+1;i<A+B+1;i++){
        if(S[i]-'0'>9||S[i]-'0'<0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> as(n);
	for (auto &&a : as)
	{
		cin >> a;
		a--;
	}

	vector<bool> done(n, false);
	for (int x = 0, cnt = 0; !done[x]; cnt++, x = as[x])
	{
		if (x == 1)
		{
			cout << cnt << endl;
			return 0;
		}

		done[x] = true;
	}

	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 3684
lis=[]
for i in range(5):
    x=int(input())
    if x%10!=0:
        lis.append([x%10,x])
    else:
        lis.append([10,x])
lis1=sorted(lis,reverse=True)
t=0
for i in range(4):
    if lis1[i][0]!=0:
        t+=lis1[i][1]+10-lis1[i][0]
    else:
        t+=lis1[i][1]
print(t+lis1[4][1])


Measured memory_bytes: 3060
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N, M;
    scan(N, M);
    auto P = new long[](M);
    auto Y = new long[](M);
    long[] I = iota(M).array;
    foreach (i; 0 .. M)
        scan(P[i], Y[i]);
    zip(Y, P, I).sort();
    // writeln(Y);
    // writeln(P);
    // writeln(I);
    auto ans = new string[](M);
    auto cnt = new long[](N);
    foreach (i; 0 .. M)
    {
        long x = ++cnt[P[i] - 1];
        long p = P[i];
        ans[I[i]] = format("%06d%06d", p, x);
    }
    foreach (a; ans)
        writeln(a);
}


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

int main()
{
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int ans = 0;
	for(int i = 0; i <= a; i++){
		for(int j = 0; j <= b; j++){
			for(int k = 0; k <= c; k++){
				if(i * 500 + j * 100 + k * 50 == x)	ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;
int a[N], pos[N];
int main() {
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    map<int, int> mp;
    mp[0] = 1;
    int t = 0;
    ll ans = 0;
    ll s = 0;
    for(int i = n-1; i >= 0; i--) {
        if(i+k <= n) {
            mp[pos[i+k]]--;
        }
        t++;
        t%=k;
        s += a[i];
        s %= k;
        ll x = (s - t + k) % k;
        ans += mp[x];
        mp[(s-t+k)%k]++;
        pos[i] = (s-t+k)%k;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 11264
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n;
	cin>>n;
	int N=1<<n;
	vi in(N);
	rep(i,N)cin>>in[i];
	rep(i,n){
		vi ne;
		rep(j,N){
			int a=in[j];
			int b=in[++j];
			if(a<b)swap(a,b);
			if(a==b)ne.pb(a);
			else ne.pb(a-b);
		}
		N/=2;
		in=ne;
	}
	cout<<in[0]<<endl;
}









Measured memory_bytes: 2044
#include<stdio.h>

int main(){
  int H,i;
  int A[250];

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

  for(i=1; i<H+1; i++){
    if(i==1){
      printf("node %d: key = %d, left key = %d, right key = %d, \n",i,A[i],A[i*2],A[i*2+1]);
    }
    
    if(i*2<H && i!=1){
      printf("node %d: key = %d, parent key = %d, left key = %d, right key = %d, \n",i,A[i],A[i/2],A[i*2],A[i*2+1]);
    }
    
    if(i*2==H){
      printf("node %d: key = %d, parent key = %d, left key = %d, \n",i,A[i],A[i/2],A[i*2]);
    }
    
    if(i*2>H){
      printf("node %d: key = %d, parent key = %d, \n",i,A[i],A[i/2]);
    }
  }
  
  return 0;
}



Measured memory_bytes: 2104
#!/usr/bin/env python3
n = int(input())
p = list(map(int, input().split()))
ans = 0

for i in range(1, n - 1):
  if p[i - 1] < p[i] < p[i + 1] or p[i - 1] > p[i] > p[i + 1]:
    ans += 1

print(ans)


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

int n,num,flag;
long int shine[4000],tannka,kosu;

int main(){
	while(1){
		cin>>n;
		if(n==0){break;}
		for(int i=0;i<n;i++){
			cin>>num>>tannka>>kosu;
			shine[num]+=tannka*kosu;
			if(shine[num]>=1000000){
				cout<<num<<endl;
				flag++;
			}
		}
		if(flag==0){cout<<"NA"<<endl;}
		else{flag=0;}
		for(int i=0;i<4000;i++){
			shine[i]=0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1192
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int x[] = new int[3];
		x[0] = in.nextInt();
		x[1] = in.nextInt();
		x[2] = in.nextInt();
		Arrays.sort(x);
		int sum=x[0]+x[1]+x[2];
		if(sum%2==(x[2]*3)%2) {
			int n=(x[2]*3-sum)/2;
			System.out.print(n);
		}else {
			int n=((x[2]+1)*3-sum)/2;
			System.out.print(n);
		}
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

// oox xxoxxxoo
// 123 45678901
int n, k, c;
string s;
int dp[200000];
int dq[200000];
int prv[200000];

int f(int i, int* dp)
{
    if (i >= n)
        return 0;

    int& sol = dp[i];
    if (sol != -1)
        return dp[i];
    
    sol = f(i + 1, dp);
    if (s[i] == 'o')
        sol = max(sol, 1 + f(i + 1 + c, dp));
    return sol;
}

int main()
{
    cin >> n >> k >> c >> s;
    memset(dp, -1, sizeof dp);
    memset(dq, -1, sizeof dq);
    f(0, dp);
    reverse(all(s));
    f(0, dq);
    reverse(dq, dq + n);
    reverse(all(s));
    int curr = 0;
    for (int i = 1; i < n; ++i)
    {
        if (dq[i] != dq[i - 1])
            curr = i;
        prv[i] = curr;
    }
    // for (int i = 0; i < n; ++i)
    //     cout << dp[i] << ' ';
    // cout << endl;
    // for (int i = 0; i < n; ++i)
    //     cout << dq[i] << ' ';
    // cout << endl;
    // for (int i = 0; i < n; ++i)
    //     cout << prv[i] << ' ';
    // cout << endl;

    for (int i = 0; i < n; ++i)
    {
        if (s[i] == 'o')
        {
            int nx = max(i + 1, i ? prv[i - 1] + c + 1 : 0);
            int sum = (i ? dq[i - 1] : 0);
            if (nx < n)
                sum += dp[nx];
            if (sum < k)
            {
                cout << i + 1  << '\n';
            }
        }
    }
}


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

struct rob {
    int x;
    int l;
};

int main(void) {

    int N;
    vector<rob> ROB;

    cin >> N;
    rep(i, N) {
        rob r;
        cin >> r.x >> r.l;
        ROB.push_back(r);
    }

    sort(ALLOF(ROB), [](const rob& l, const rob& r){ return r.l + r.x > l.l + l.x; });

    vector<rob> candidates;
    candidates.push_back(ROB[0]);
    REP(i, 1, N) {
        if ((candidates.back().x + candidates.back().l) <= (ROB[i].x - ROB[i].l) ) {
            candidates.push_back(ROB[i]);
        }
    }

    cout << candidates.size() << endl;


    return 0;
}

Measured memory_bytes: 2548
N, M, Q = [int(v) for v in input().split()]
p = []
q = []
x = [[0] * (N+1) for i in range(N+1)]
c = [[0] * (N+1) for i in range(N+1)]

for i in range(M):
    l, r = [int(v) for v in input().split()]
    x[l][r] += 1
for i in range(1, N+1):
    for j in range(1, N+1):
        c[i][j] = c[i][j-1] + x[i][j]
for i in range(Q):
    a, b = [int(v) for v in input().split()]
    p.append(a)
    q.append(b)

for i in range(Q):
    ans = 0
    for j in range(p[i], q[i]+1):
        ans += c[j][q[i]] - c[j][p[i]-1]
    print(ans)

Measured memory_bytes: 80344
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T = int>inline T in() { T x; cin >> x; return x; }
#define REP(i,n) for(ll i=0;i<(n);++i)
#define REP1(i,n) for(ll i=1;i<=(n);++i)
#define REPI(i,ini,n) for(ll i=(ini);i<(n);++i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b) (((a)+(b)-1)/(b))
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1e9
#define INFL static_cast<ll>(INF)
bool solve_amida(int col, int row, char**pass, int s, int g)
{
	int x = s;
	REP(y, row)
	{
		if (x != 1 && pass[y][x - 2] == '1')--x;
		else if (x != col && pass[y][x - 1] == '1')++x;
	}
	return x == g;
}
int main()
{
	while (true)
	{
		int col = in(); if (col == 0)break;
		int s = in(), g = in(), row = in();
		char**pass = new char*[row];
		REP(i, row)
		{
			pass[i] = new char[col - 1];
			REP(j, col - 1)pass[i][j] = in<char>();
		}
		if (solve_amida(col, row, pass, s, g))cout << '0' << endl;
		else
		{
			REP(i, row)
			{
				REP(j, col - 1)
				{
					if (pass[i][j] == '0' && (j == 0 || pass[i][j - 1] == '0') && (j == col - 2 || pass[i][j + 1] == '0'))
					{
						pass[i][j] = '1';
						if (solve_amida(col, row, pass, s, g))
						{
							cout << i + 1 << ' ' << j + 1 << endl;
							goto roop_end;
						}
						pass[i][j] = '0';
					}
				}
			}
			cout << '1' << endl;
		roop_end:;
		}
	}
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

LL dp[101][8];

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int h, w, k;
    cin >> h >> w >> k;
    dp[0][0] = 1;
    inc(i, 0, h){
        inc(bit, 0, 1 << (w-1)){
            bool flag = false;
            inc(j, 0, w-1){
                if(((bit >> j) & 1) && ((bit >> (j+1)) & 1)){
                    flag = true;
                }
            }
            if(flag) continue;

            inc(j, 0, w){
                if((bit >> (j-1)) & 1){
                    MODA(dp[i+1][j], dp[i][j-1]);
                }else if((bit >> j) & 1){
                    MODA(dp[i+1][j], dp[i][j+1]);
                }else{
                    MODA(dp[i+1][j], dp[i][j]);
                }
            }
        }
    }
    cout << dp[h][k-1] << endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for p in range(n)]
cd = [list(map(int, input().split())) for q in range(m)]
for i in range(n):
    x = 10**10
    ans = 0
    for j in range(m):
        if abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]) < x:
            ans = j+1
            x = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
    print(ans)

Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N;
    cin >> N;
    int a[N];
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    sort(a , a + N , greater<int>());
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans += a[i] * (i & 1 ? -1 : 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256