akhauriyash/Code-Regression huggingface dataset:
from collections import Counter
n = int(input())
l = [input() for _ in range(n)]

c = Counter(l)

d = c.most_common()[0][1]

ans = []
for k,v in c.items():
    if v < d:
        pass
    else:
       ans.append(k)
       
       
ans = sorted(ans)

print(*ans,sep = '\n')


Measured memory_bytes: 45040
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;


int main(){
  long a;string b;
  cin>>a>>b;
  cout<<(a*((b[0]-'0')*100+(b[2]-'0')*10+(b[3]-'0')))/100;
}



/* きょむ〜 */


Measured memory_bytes: 3624
n = int(input())
L = [tuple(map(int, input().split())) for _ in range(n)]
if n == 1:
    print(1)
    exit()
L.sort()
sub = lambda x, p: (x[0] - p[0], x[1] - p[1])
add = lambda x, p: (x[0] + p[0], x[1] + p[1])
def check(p):
    res = 0
    l = L[:]
    while len(l):
        res += 1
        e = l.pop(0)
        while add(e, p) in l:
            l.remove(add(e, p))
            e = add(e, p)
    return res
res = float('inf')
for i in range(n):
    for j in range(i + 1, n):
        res = min(res, check(sub(L[j], L[i])))
print(res)

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++)
    cin >> p[i];
  int c = 0;
  for (int i = 0; i < n; i++)
    if (p[i] != i + 1) ++c;
  cout << (c <= 2 ? "YES" : "NO") << endl;
  return 0;
}


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

int n;
vector<int> a;

int main() {
	cin >> n;
	a.resize(n);
	for (int i = 0; i < n; ++i) cin >> a.at(i);

	int o=0, f=0, e=0;

	for (int i = 0; i < n; ++i)
	{
		if (a.at(i)%4==0)
		{
			f++;
		} else if(a.at(i)%2==0){
			e=1;
		} else{
			o++;
		}
	}

	if ((o+e+f)/2<= f)
	{
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 640
#include<cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include<cmath>
#include<string.h>
#include<vector>

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	int s;
	for(s=ceil(a*12.5);;s++){
		if(floor(s*0.08)>a){
			printf("-1\n");
			break;
		}
		if(floor(s*0.1)==b){
			printf("%d\n",s);
			break;
		}
	}
	return 0;
}

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

int main(){
	int a[5];
	int b[5];
	int c[5];
	int k;
	int i, j;
	int bmin, ans;

	for(i = 0; i < 5;i++){
		cin >> a[i];
	}
	cin >> k;

	bmin = 10;
	for(i = 0; i < 5;i++){
		b[i] = a[i] % 10;
		if(b[i] == 0){
			c[i] = a[i];
		}else{
			c[i] = ((a[i] + 10) / 10) * 10;
			if(bmin > b[i]) bmin = b[i];
		}
	}

	ans = 0;
	for(i = 0; i < 5;i++){
		ans += c[i];
	}
	
	ans = ans - 10 + bmin;

	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int x,a,b;cin>>x>>a>>b;
  int ax=abs(a-x);
  int bx=abs(b-x);
  string ans="A";
  if(ax>bx)ans="B";
  cout(ans);
  
  return 0;
}

Measured memory_bytes: 125568
#include<stdio.h>

int main(void){

  int n,l[100];
  int i,j,k,tmp;
  int count=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&l[i]);
  }

  for(i=0;i<n;++i){
    for(j=i+1;j<n;++j){
      if(l[i]>l[j]){
        tmp = l[i];
        l[i]=l[j];
        l[j]=tmp;
      }
    }
  }

  //for(i=0;i<n;i++) printf("%d, ",l[i]);

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      for(k=j+1;k<n;k++){
        if( l[i]+l[j]>l[k] && l[i]!=l[j] && l[j]!=l[k]){
          //printf("%d %d %d, ",l[i],l[j],l[k]);
          count++;
        }
      }
    }
  }
  printf("%d\n",count);

  return 0;
}


Measured memory_bytes: 2136
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,i,j,x,f[1010][1010];
char a[1010][1010];
int main(){
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)scanf("%s",a[i]+1);
	memset(f,44,sizeof(f));
	if(a[1][1]=='.')f[1][1]=0;
	 else f[1][1]=1;
	for(i=1;i<=n;i++)
	 for(j=1;j<=m;j++){
	 	if(i<n){
	 		x=0;
	 		if(a[i+1][j]=='#'&&a[i][j]=='.')x=1;
	 		f[i+1][j]=min(f[i+1][j],f[i][j]+x);
	 	}
	 	if(j<m){
	 		x=0;
	 		if(a[i][j+1]=='#'&&a[i][j]=='.')x=1;
	 		f[i][j+1]=min(f[i][j+1],f[i][j]+x);
	 	}
	 }
	 printf("%d",f[n][m]);
}

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

signed main(){
  int D,T,S;
  cin>>D>>T>>S;
  if(D<=T*S)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3616
N, Y = map(int, input().split())

for x in range(N+1):
	for y in range(N+1):
		z = N -(x + y)
		if 0<=z<=N:
			en_sum = 10000*x + 5000*y + 1000*z
			if en_sum==Y:
				print(x, y, z)
				exit()
print(-1, -1, -1)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

bool flag[10000001];

int main(){
	int n = 0, ans = 0;
	
	for (int i = 0; i <= 1000000; i++){
		if (i <= 1) flag[i] = false;
		else flag[i] = true;
	}
	for (int i = 2; i <= 1001; i++){
		if(flag[i] == true){
			for(int j = i * 2; j <= 1000000; j += i){
				flag[j] = false;
			}
		}
	}
	while(cin >> n){
		ans = 0;
		for(int i = 0; i <= n; i++){
			if(flag[i] == true){
				ans++;
			}
		}
		cout << ans << endl;
	}
 }

Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    double x[10],y[10];
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    double d[10][10];
    double ans=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            d[i][j]=pow((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]),0.5);
            ans+=d[i][j];
        }
    }
    ans=(ans*2)/n;
    printf("%.10f",ans);
}


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

int main() {
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  if(2*c <= min(a,b)){
    cout << 2*c*(max(x,y)) << endl;
  }
  else if(2*c > min(a,b) && 2*c <= max(a,b)){
    if(a = min(a,b)){
      int ans = y*2*c;
      if(x>y){
        ans += a*(x-y);
      }
      cout << ans << endl;
    }
    else {
      int ans = 2*c*x;
      if(y>x){
        ans += b*(y-x);
      }
      cout << ans << endl;
    }
  }
  else if(2*c > max(a,b) && 2*c <= (a+b)){
    if(x>y){
      cout << 2*c*y + a*(x-y) << endl;
    }
    else {
      cout << 2*c*x + b*(y-x) << endl;
    }
  }
  else {
    cout << a*x + b*y << endl;
  }
  
     
  return 0;
}


Measured memory_bytes: 256
/*

*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<int,int> point;
#define rep(i,n) for(i,0,n)
 
int main() {
	// 入力
	string S_dash, T;
	cin >> S_dash >> T;
	
	// 解法
	int range = S_dash.size() - T.size();
	int align = -1;
	bool fit = false;
	for (int i = 0; i < range+1; ++i){
		for (int j = 0; j < T.size(); ++j){
			// printf("i:%d, j;%d, \n", i, j);
			// cout << S_dash.substr(range-i+j,1) << T.substr(j,1) << endl;
			if (S_dash.substr(range-i + j,1)!="?" 
				&& S_dash.substr(range-i + j,1)!=T.substr(j,1)){
				fit = false;
				break;
			}
			else fit = true;
		}
		if (fit){
			align = range - i;
			break;
		}
	}
	string S2;
	if (align!=-1){
		S2 = S_dash.substr(0,align) + T + S_dash.substr(align+T.size());
	}
	
	string S;
	if (align==-1) S = "UNRESTORABLE";
	else{
		for (int i = 0; i < S2.size(); ++i){
			if(S2.substr(i,1)=="?") S += "a";
			else S+= S2.substr(i,1);
		}
	}
	
	// printf("S:%d\n", align);
	cout << S;
		
}
 


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
l=[0]*(N+1)
l[-1]=A[-1]
for i in range(N-1,0,-1):
    l[i]=A[i]+l[i+1]
t=1
a=1
ma=10**15
for i in range(1,N+1):
    if 2*t<A[i]:
        a=-1
        break
    t=min(t*2,l[i])
    a+=t
    t-=A[i]
if A[0]!=0:
    a=-1
if N==0 and A[0]==1:
    a=1
print(a)

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

int main() {
  int n; cin >> n;
  set<int> vals;
  for (int i = 0; i < n; i++) {
    int x; cin >> x;
    vals.insert(x);
  }
  cout << vals.size() << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

            int N = int.Parse(Console.ReadLine());
            double c = 0;
            double odd = 0;
            for (int i = 1; i <= N; i++) {
                c++;
                if (i % 2 != 0) {
                    odd ++;
                }
            }
            Console.WriteLine(odd / c);


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13140
from collections import Counter
def main():
    n = int(input())
    A = list(map(int, input().split()))
    c = Counter(A)
    if c[0] == n:
        print('Yes')
    elif n % 3 == 0 and c[0] == n // 3 and len(set(A)) == 2:
        print('Yes')
    elif n % 3 == 0 and len(set(A)) == 3:
        x, y, z = list(set(A))
        if x ^ y ^ z == 0 and c[x] == c[y] == c[z]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')


if __name__ == '__main__':
    main()


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pcase cout<<"Case "<<++cs<<": "
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define mp make_pair
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))

int main()
{
    int i = 0, j = 0, cs = 0;
    string s; ll k; cin>>s>>k;
    if(s.size() == 1){
        cout << k/2 << endl;
        return 0;
    }
    ll cnt = 0, c = 0;
    int start = 0, end = s.size()-1;
    ll a = 0, b = 0;
    if(s[0] == s.back()){
        start++; a++;
        while(s[start] == s[0] && start < s.size()) start++,a++;
        if(start == s.size()){
            cout << (s.size()*k)/2 << endl;
            return 0;
        }
        end--; b++;
        while(s[end] == s.back() && end > start) b++, end--;
        c += (a+b)/2;
    }
//    watch(c);
    for(i = start; i < end; i++){
        int lol = 1;
        while(s[i] == s[i+1] && i < end) lol++, i++;
        cnt += lol/2;
    }
//    watch(cnt);
    cout << cnt * k + c*(k-1) + a/2 + b/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    ll A, B, C, D; cin >> A >> B >> C >> D;
    ll ans = B - A + 1;
    ll bic = B / C - (A - 1) / C, bid = B / D - (A - 1) / D;
    ll lc = C / __gcd(C, D) * D;
    ll bilc = B / lc - (A - 1) / lc;
    cout << ans - bic - bid + bilc << endl;
}

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

int main() {
	string s;
	cin >> s;
	int N, W, E, S;
	N = count(s.begin(), s.end(), 'N');
	W = count(s.begin(), s.end(), 'W');
	E = count(s.begin(), s.end(), 'E');
	S = count(s.begin(), s.end(), 'S');
	if (N)
		N = 1;
	if (W)
		W = 1;
	if (E)
		E = 1;
	if (S)
		S = 1;
	if (!(S ^ N) && !(E ^ W))
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}


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

using namespace std;

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

	int n;
	cin >> n;

	vector<long long> a(n + 1), b(n);

	for(int i = 0; i <= n; i++) {
		cin >> a[i];
	}

	for(int i = 0; i < n; i++) {
		cin >> b[i];
	}

	long long ans = 0;

	for(int i = 0; i < n; i++) {
		if(b[i] <= a[i]) {
			a[i] -= b[i];
			ans += b[i];
			b[i] -= a[i];
		}
		else {
			b[i] -= a[i];
			ans += a[i];
			a[i] = 0;
			long long temp = min(b[i], a[i+1]);
			ans += temp;
			a[i+1] -= temp;
			b[i] -= temp;
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <functional>

using namespace std;

static const int NMAX = 105;
static const int WMAX = 10005;
static const int DIAGONAL = 1;
static const int TOP = 0;

struct Item{
	int value, weight;
};

int N, W;
Item items[NMAX + 1];
int C[NMAX + 1][WMAX + 1], G[NMAX + 1][WMAX + 1];

int compute(){
	for (int w = 0; w <= W; w++) {
		C[0][w] = 0;
		G[0][w] = DIAGONAL;
	}

	for (int i = 1; i <= N; ++i) C[i][0] = 0;

	for (int i = 1; i <= N; ++i) {
		for (int w = 1; w <= W; ++w) {
			C[i][w] = C[i - 1][w];
			G[i][w] = TOP;
			if (items[i].weight > w) continue;
			if (items[i].value + C[i - 1][w - items[i].weight] > C[i - 1][w]) {
				C[i][w] = items[i].value + C[i - 1][w - items[i].weight];
				G[i][w] = DIAGONAL;
			}
		}
	}
	return C[N][W];
}

int main(){
	cin >> N >> W;
	for (int i = 1; i <= N; ++i) cin >> items[i].value >> items[i].weight;
	cout << compute() << endl;
	return 0;
}

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

int main(){
  vector<int> A(3);
  cin >> A.at(0) >> A.at(1) >> A.at(2);
  sort(A.begin(), A.end());
  int area = A.at(0)*A.at(1)/2; 
  cout << area << endl;
}

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

int main(){
    int N;
    cin >> N;
    vector<ll> a(N);
    ll sum =0;
    for(int i=0;i<N;i++){
        cin >> a[i];
        sum += a[i];
    }
    ll m = INF;
    for(int i=0;i<N;i++){
        m = min(m,abs(sum- N*a[i]));
    }
    for(int i=0;i<N;i++){
        if(abs(sum-N*a[i]) == m){
            cout << i << endl;
            break;
        }
    }
    return 0;
    
}

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

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

int main() {
  int N;
  cin >> N;
  vector<int> an(N);
  for (int& ai : an) cin >> ai;
  if (N == 2) {
    cout << max(an[0], an[1]) << endl;
    return 0;
  }
  
  vector<int> L(N);
  L[0] = an[0];
  L[1] = gcd(an[0], an[1]);
  for (int i = 2; i < N; i++) {
    L[i] = gcd(L[i - 1], an[i]);
  }
  vector<int> R(N);
  R[N - 1] = an[N - 1];
  R[N - 2] = gcd(an[N - 1], an[N - 2]);
  for (int i = N - 3; i >= 0; i--) {
    R[i] = gcd(R[i + 1], an[i]);
  }

  int maxgcd = R[1];
  for (int i = 0; i < N - 2; i++) {
    maxgcd = max(maxgcd, gcd(L[i], R[i + 2]));
  }
  maxgcd = max(maxgcd, L[N - 2]);

  cout << maxgcd << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
制約のn*mとn,mを読み違えない
操作の逆順を考える
オーバーフローしないか確かめる
Codeforcesではscanfを使う
modの引き算には+modをする
エラー出力は消す
エラー出力を消せ！！！！！
数値の区切り位置を誤読しない
木はn-1ノード
関数単位で調べる
cout << fixed;
cout << setprecision(n) << ans;
 */
int n,m,q;
int a[51],b[51],c[51],d[51];
int dfs(vector<int> v){
    if(sz(v)==n){
        int sc=0;
        rep(i,q){
            if(v[b[i]]-v[a[i]]==c[i])sc+=d[i];
        }
        return sc;
    }
    else{
        int sc=0;
        if(!sz(v)){
            for(int i=1;i<=m;i++){
                vector<int> vv=v;
                vv.pb(i);
                chmax(sc,dfs(vv));
            }
        }
        else{
            for(int i=v[sz(v)-1];i<=m;i++){
                vector<int> vv=v;
                vv.pb(i);
                chmax(sc,dfs(vv));
            }
        }
        return sc;
    }
}

int main() {
    cin >> n >> m >> q;
    rep(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    int ans=dfs({});
    cout << ans;


    
}

/*
*/



Measured memory_bytes: 3580
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
import decimal

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
a = map(int, raw_input().split())
cnt = 1
for num in a:
    if num == cnt:
        cnt += 1
if cnt == 1:
    print -1
else:
    print N - cnt + 1

Measured memory_bytes: 21328
/*
 ____________________________________________________________
|                                                            |
|                   Author: ay2306                           |
|____________________________________________________________|

*/
#include <bits/stdc++.h>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
using namespace std;

const ll maxn = 1e5;
int main(){
	ll r,g,b,n;
  cin >> r >> g >> b >> n;
  ll ans = 0;
  loop(i,0,3001){
  	loop(j,0,3001){
    	ll total = i*r + j*g;
    	if(total > n)continue;
      	ll rem = n-total;
      	if(rem%b != 0)continue;
      	ans++;
    }
  }
  cout << ans;
  return 0;
}


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

const int nax=405;
const int INF= 1e18L + 5;
int dp[nax][nax];

int sum(int a[],int x,int y)
{
   int ans=0;
   for(int i=x;i<=y;i++)
   {
       ans+=a[i];
   }
   return ans;
}

#undef int
int main() {
#define int long long
    int n;
    cin >> n;

    int a[n];

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

    for(int L=n-1;L>=0;L--)
    {
        for(int R=L;R<n;R++)
        {
                if(L==R)
                    dp[L][R]=0;
                else
                {
                    dp[L][R]=INF;
                    int s = sum(a, L, R);
                    for (int i = L; i < R; i++)
                        dp[L][R] = min(dp[L][R], dp[L][i] + dp[i + 1][R] + s);
                }
                
        }
    }
    cout << dp[0][n-1] << endl;
}

Measured memory_bytes: 1536
import java.util.*;
public class Main {
  public static void main(String[] args) {

	Scanner sc = new Scanner(System.in);

	int a = sc.nextInt();
	int b = sc.nextInt();

	int ans = a * b;

	if (ans % 2 == 0) {
		System.out.println("Even");
		
	} else {
		System.out.println("Odd");
	}	

	}
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 A,B,C;
    cin >> A >> B >> C;

    cout << min(C,B/A) << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

#define LIM 2000000
#define MAX 10000


int * countingSort(int A[], int n) {
  int B[MAX];
  int *C = (int *)malloc(sizeof(int) * n);
  
  for ( int i = 0; i < MAX; i++ ) B[i] = 0;
  for ( int i = 0; i < n; i++ ) B[A[i]]++;
  for ( int i = 1; i < MAX; i++ ) B[i] = B[i] + B[i - 1];

  for ( int i = n; i >= 0; --i ) {
    C[B[A[i]]] = A[i];
    B[A[i]]--;
  }
  return C;
}

int main() {
  int n, A[LIM], *C;
  C = (int *)malloc(sizeof(int) * n);

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

  C = countingSort(A, n);
  for ( int i = 1; i <= n; i++ ) {
    if (i > 1) printf(" ");
    printf("%d", C[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 18432
n=int(input())
p,x=[list(map(int,input().split())) for _ in [0]*2]
g=[[] for _ in [0]*n]
[g[j-1].append(i+1) for i,j in enumerate(p)]
d=[0]*n
q=[0]
while q:
 r=q.pop()
 for i in g[r]:
  if i!=0:
   d[i]=d[p[i-1]-1]+1
   q.append(i)
d=sorted([[-j,i] for i,j in enumerate(d)])
m=[[i,0] for i in x]
a,b=10003,5001
for _,i in d:
 y=x[i]+1
 e=[a]*y
 e[0]=0
 for j in g[i]:
  f=[a]*y
  p,q=m[j]
  for k in range(y-p):
   if e[k]!=a:f[k+p]=min(f[k+p],e[k]+q,b)
  for k in range(y-q):
   if e[k]!=a:f[k+q]=min(f[k+q],e[k]+p,b)
  e=f
 m[i][1]=min(e)
 if min(e)==a:
  print("IMPOSSIBLE")
  break
else:print("POSSIBLE")

Measured memory_bytes: 3572
from heapq import heappush,heappop
N = int(input())
table=[[]for i in range(N)]
for i in range(N-1):
    a,b,c=map(int,input().split())
    table[a-1].append([b-1,c])
    table[b-1].append([a-1,c])
Q,K=map(int,input().split())
Que=[[int(i) for i in input().split()] for i in range(Q)]
inf=10**17
dis=[inf]*N
dis[K-1]=0
kei=[]
heappush(kei,[0,K-1])
while kei:
    q,x=heappop(kei)
    if dis[x]<q:
        continue
    for i,d in table[x]:
        if dis[x]+d<dis[i]:
            dis[i]=dis[x]+d
            heappush(kei,[dis[i],i])
ans =[]
for x,y in Que:
    ans.append(dis[x-1]+dis[y-1])
print('\n'.join(map(str,ans)))

Measured memory_bytes: 79748
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define FOR(a,b,c) for(int a = (b); a <= (c); a++)
#define RFOR(a,b,c) for(int a = (b); a >= (c); a--)
#define all(x) (x).begin(), (x).end()
#define vi vector <int>
#define vvi vector <vi>
#define ll long long
#define vll vector <ll>
#define vvl vector <vll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ep emplace
#define fs first
#define sd second
using namespace std;

int main() {
    FIO;
    ll x, y, a, b,c;
    cin >> x >> y >> a >> b >> c;
    priority_queue <ll, vll, greater <ll>> pq;
    vll v = vll(a);
    FOR(i, 0, a - 1) cin >> v[i];
    sort(all(v));
    RFOR (i, a - 1, a - x) pq.ep(v[i]);
    v = vll(b);
    FOR(i, 0, b - 1) cin >> v[i];
    sort(all(v));
    RFOR(i,b - 1, b - y) pq.ep(v[i]);
    v = vll(c);
    FOR(i,0,c - 1) cin >> v[i];
    sort(all(v));
    RFOR(i, c - 1, 0){
        if(pq.top() >= v[i]) break;
        pq.pop();
        pq.ep(v[i]);
    }
    ll sum = 0;
    while(pq.size()) sum += pq.top(), pq.pop();
    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 4196
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t,d,k;
    cin>>n>>d;
    ll arr[n][d];
    for(i=0;i<n;i++) for(j=0;j<d;j++) cin>>arr[i][j];
    ll count=0;
    for(i=0;i<n;i++) for(j=0;j<n;j++)
    {
        ll sum=0;
        if(i!=j)
        {
            for(k=0;k<d;k++) 
            {
                b=abs(arr[i][k]-arr[j][k]);
                b*=b;
                sum+=b;
            }
            ld ss=sum;
            sum=sqrt(sum);
            ss=sqrt(ss);
            ss=ceil(ss);
            a=(ll)ss;
            if(a==sum) count++;
        }
    }
    count/=2;
    cout<<count;
}

Measured memory_bytes: 3508
n, m = [int(i) for i in input().split()]
A = [[] for i in range(n+1)]
B = [[] for i in range(n+1)]

for i in range(m):
    a, b = [int(i) for i in input().split()]
    A[a].append(b)
    B[b].append(a)

flag = [False] * (n+1)
flag[0] = True
cnt = 0

def dfs(i, flag):
    flag[i] = True
    for b in A[i]:
        if not flag[b]:
            dfs(b, flag[:])
    for b in B[i]:
        if not flag[b]:
            dfs(b, flag[:])
    if all(flag) == True:
        global cnt
        cnt += 1

dfs(1, flag[:])
print(cnt)

Measured memory_bytes: 3064
import numpy as np
N,M,C=[int(i) for i in input().split()]
B=np.array([int(i) for i in input().split()])
count=0
for j in range(N):
  A=np.array([int(i) for i in input().split()])
  if np.sum(A*B)+C>0:
    count+=1
print(count)

Measured memory_bytes: 18896
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}


#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;

main(){
    ll n=in(),k=in();
    vector<int> a;
    rep(i,n)a.pb(in());
    ll ans=0;
    rep(i,n)rep2(j,i,n-1){
        if(a[i]==a[j])continue;
        if(a[i]<a[j]){
            ans=(ans+k*(k-1)/2ll%MOD)%MOD;
        }
        else{
            ans=(ans+k*(k+1)/2ll%MOD)%MOD;
        }
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
program Project1;
     
{$APPTYPE CONSOLE}
     
uses
  SysUtils;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,min,ax,ay,bx,by:Integer;
  l:array of Integer;
  s,s123,s1,s2,s3:string;
  al:string = 'abcdefghijklmnopqrstuvwxyz';
  tf,tfl,tfr:Boolean;
begin
  try
    { TODO -oUser -cConsole メイン : ここにコードを記述してください }
    Read  (ax);
    Read  (ay);
    Read  (bx);
    Readln(by);
    count:=0;
    max  :=0;
    min  :=100;

    Write  (bx-(by-ay));
    Write  (' ');
    Write  (by+(bx-ax));
    Write  (' ');
    Write  (ax+ay-by);
    Write  (' ');
    Writeln(ay-(ax-bx));
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 128
#include <iostream>
#include<stdio.h>
using namespace std;
int main(void) {
	int a,n,i;
	int x=100000;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	    x=x*105/100;
	    if(x%1000!=0){
	        a=(x/1000)+1;
	        x=a*1000;
	    }
            else{
               x=x;}
	}
	cout<<x<<endl;
	return 0;
}
 


Measured memory_bytes: 3140
#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 - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n, k;
    cin >> n >> k;
    ll ub = (n - 1) * (n - 2) / 2;
    if(k > ub){
        cout << -1 << endl;
        return 0;
    }

    vector<P> p;
    REP(i, n - 1){
        p.push_back(P{1, i + 2});
    }
    ll m = p.size(), cnt = 0;
    cout << m + ub - k << endl;
    REP(i, m){
        cout << p[i].first << " " << p[i].second << endl;
    }
    REP(i, n){
        REP(j, n){
            if(i == 0 || j <= i) continue;
            if(cnt < ub - k){
                cout << i + 1 << " " << j + 1 << endl;
                cnt++;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n, l = na()

m = 1 << 60
res = 0
for i in range(n):
    q = l + i
    m = min(m, abs(q))
    res += q

if res < 0:
    res += m
else:
    res -= m

print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string str;
int cnt[26];
int main()
{
    cin >> str;
    int len = str.size();
    ll ans = 1;
    for(int i=0;i<len;i++){
        cnt[str[i]-'a']++;
    }
    int l = len;
    for(int j=0;j<len;j++){
        ans += l - cnt[str[j]-'a']--;
        l--;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 640
X = int(input())

ans = 1
for N in range(1, 10001):
    X_min = 100 * N
    X_max = 105 * N
    # print("#", N, X_min, X_max)
    if X_min <= X <= X_max: break
else:
    ans = 0

print(ans)
        

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll A, B;
	cin >> A >> B;
	string res;
	if(A==B){
		res = "Draw";
	}else if(A==1){
		res = "Alice";
	}else if(B==1){
		res = "Bob";
	}else{
		res = (A<B?"Bob":"Alice");
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

ll f(ll X){
    if(X<=0) return 0;
    ll Y = (X/4)*4;
    ll res = 0;
    for(ll x=Y;x<=X;x++) res ^= x;
    return res;
}

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

    ll A, B;
    cin >> A >> B;

    ll res = 0;
    res ^= f(B);
    res ^= f(A-1);
    
    cout << res << endl;
    return 0;
}

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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		int[] table = new int[100100];
		Arrays.fill(table, 0);
		for (int i = 0; i < M; i++) {
			table[sc.nextInt()]++;
			table[sc.nextInt() + 1]--;
		}


		for (int i = 1; i < table.length; i++) {
			table[i] += table[i - 1];
		}

		/*
		for (int i = 0; i < 10; i++) {
			System.out.println(table[i]);
		}
		*/

		int cnt = 0;
		for (int i = 0; i < table.length; i++) {
			if (table[i] == M) {
				cnt++;
			}
		}

		System.out.println(cnt);
	}
}


Measured memory_bytes: 63860
#include<stdio.h>

int main()
{
    int a,b,c,max,min,mid;
    scanf("%d%d%d",&a,&b,&c);

    min = a;
    mid = b;
    max = c;
    if (min > mid) { mid = a; min = b; }
    if (mid > max)
    {
        max = mid;
        mid = c;
        if (min > mid)
        {
            mid = min;
            min = c;
        }
    }


    printf("%d %d %d\n",min,mid,max);


}



Measured memory_bytes: 2128
#include<stdio.h>
#include<string.h>
int main(void){
      int i, len;
  char s[4096];
  fgets(s, sizeof(s), stdin);
  len = strlen(s);
  for(i = 0; i < len;i++) {
    if(s[i]>=65&&s[i]<=90)
    s[i] = s[i]+32;
    else if(s[i]>=97&&s[i]<=122)
      s[i]=s[i]-32;
    else
    s[i] = s[i];
  }
  printf("%s",s);
}



Measured memory_bytes: 2076
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int N;
  cin>>N;
  std::vector<int> v(N+1),a(2);
  int j=0;
  int b=0;
  int mm=0;
  for(int i=0;i<N;i++)cin>>v[i];
  v[N]=100000000000;
  sort(v.begin(),v.end());
  for(int i=N-2;;i--){
    if(v[i]==v[i+1]&&v[i+1]!=v[i+2]){
      a[j]=v[i];
      j++;
  }
  if(j==2)break;
  if(i==-1){b=1;break;}
}
for(int i=N-2;;i--){
  if(v[i+1]==v[i]&&v[i]==v[i-1]&&v[i-1]==v[i-2]){mm=v[i];break;}
  if(i==2)break;
}
if(b==1)cout<<0;
else cout<<max(a[0]*a[1],mm*mm);
cout<<endl;
}


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

int main(){
  int n;
  int flag=0;
  cin >> n;
  
  for(int i=0; i<=25; i++){
    for(int j=0; j<15; j++){
      if( 4*i+7*j == n){
		flag=1;
      }
    }
  }
  
  if(flag ==1){
	cout << "Yes" << endl;
  }else{
	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int S = sc.nextInt();
	int s34 = S%100;
	int s12 = S/100;

	if((1<=s12 && s12<=12) && (1<=s34 && s34<=12)){
	    System.out.print("AMBIGUOUS");
	}else if(1<=s12 && s12<=12){
	    System.out.print("MMYY");
	}else if(1<=s34 && s34<=12){
	    System.out.print("YYMM");
	}else{
	    System.out.print("NA");
	}
    }
}

Measured memory_bytes: 21972
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  static ll C[60][60];
  for (int n = 0; n < 60; n++) {
    C[n][0] = 1;
    for (int k = 1; k <= n; k++) {
      C[n][k] = C[n - 1][k] + C[n - 1][k - 1];
    }
  }
  int N, A, B;
  while (cin >> N >> A >> B) {
    vector<ll> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];
    sort(v.rbegin(), v.rend());
    map<ll, int> all, cur;
    for (ll x : v) ++all[x];
    ll sum = 0;
    for (int i = 0; i < A - 1; i++) {
      sum += v[i];
      ++cur[v[i]];
    }
    ll num = 0, den = 1, ways = 0;
    for (int i = A; i <= B; i++) {
      ll x = v[i - 1];
      sum += x;
      ++cur[x];
      ll w = 1;
      if (cur[x] < all[x]) {
        int n = all[x];
        int k = cur[x];
        w = C[n][k];
      }
      if (sum * den > num * i) {
        num = sum;
        den = i;
        ways = w;
      } else if (sum * den == num * i) {
        ways += w;
      }
    }
    printf("%.10f\n%lld\n", (double)num / den, ways);
  }
  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
west = [ 0 for i in range(n+1) ]
east = [ 0 for i in range(n+1) ]
for i in range(1,n+1):
    west[i] = west[i-1]
    east[i] = east[i-1]
    if s[i-1] == 'W':
        west[i] += 1
    if s[i-1] == 'E':
        east[i] += 1

ans = 1e9
for i in range(1,n+1):
    reqd_east_cnt = i-1
    got_east_cnt = east[i-1]
    reqd_west_cnt = n - i
    got_west_cnt = west[n] - west[i]
    # print(reqd_east_cnt,got_east_cnt,reqd_west_cnt,got_west_cnt)
    ans = min( ans, reqd_east_cnt - got_east_cnt + reqd_west_cnt - got_west_cnt)
print(ans)


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

#define deb(x) cout << #x << " " << x << endl;
#define fo(i, n) for(i = 0; i < n; i++)
#define Fo(i, k, n) for(i=k; i < n; i++)

template<typename... T>
void read(T&... args) {
	((cin >> args), ...);
}
template<typename... T>
void write(T&&... args) {
	((cout << args << " "), ...);
	cout << endl;
}

int main()
{
	long long n;
	cin >> n;
	
	string ans = "";
	while(n > 0) {
		n--;
		ans += (char)'a' + n % 26;
		n /= 26;		
	}
	
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
using namespace std;
#define ll long long
#include <cstdint>

int main() {
	int x, t, ans;
	cin >> x >> t;
	ans = x - t;
	if (ans < 0)ans = 0;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#pragma GCC optimize ("O3")
	#define NDEBUG
#endif
// #define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

const array<int, 4> dx = {0, 1, 0, -1};
const array<int, 4> dy = {1, 0, -1, 0};


typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n;
	while(cin >> n) {
		vector<LL> h(n);
		REP(i, n) cin >> h[i];
		int ans = 0;
		int p = 0;
		while(p < n) {
			int l = p;
			while(p + 1 < n and h[p] >= h[p + 1]) {
				p++;
			}
			p++;
			// if(l == p) p++;
			DEBUG(l); DEBUG(p);
			chmax(ans, p - l);
			// p++;
		}
		cout << ans - 1 << endl;
	}
	return 0;
}


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

typedef long long ll;

int main() {
  int N; cin >> N;
  int a[100010];
  ll sum = 0;  
  for ( int i = 0; i < N; i++ ) {
    cin >> a[i];
    sum += a[i]-1;
    //    cout << a[i]-1 << endl;
    //    cout << sum << endl;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n,i,j,temp;
	
	int alice = 0;
	int bob = 0;
	
	scanf("%d",&n);
	
	int a[n];
	
	for(i = 0; i < n; i++){
		scanf("%d",&a[i]);
	}
	
	int max = a[0];
	
	for(i = 0; i < n; i++){
		for(j = i+1; j < n; j++){
			if(a[i] > a[j]){
				temp = a[i];
				a[i] = a[j];
				a[j] = temp;
	}}}
	
	//aliceの得点
	
	for(i = n - 1; i >=0; i -= 2){
		alice = alice + a[i];
	}
	
	//bobの得点
	
	for(i = n - 2; i >= 0; i -= 2){
		bob = bob + a[i];
	}
	
	printf("%d",alice - bob);
	
	return 0;
	
}
		
		
	
	
	
	
	
	
	
	

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std; 
int main(){
  int i;
  string s;
  cin >> s;
  for(i=0;i<3;i++){
    if(s.at(i)=='9'){
      s.at(i)='1';
    }else{
      s.at(i)='9';
    }
  }
  cout << s;
}


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

int n,Ac,Pa[6005],To[6006];
bool v[6005];
char s[6005];
std::string f[6005];

int main()
{
    scanf("%d%s",&n,s+1),n<<=1;
    for(int i=1;i<=n;++i)if(s[i]=='a')Pa[++Ac]=i;
    Ac=0;
    for(int i=1;i<=n;++i)if(s[i]=='b')To[i]=Pa[++Ac],To[To[i]]=i;
    for(int i=n;i>=1;--i)
    {
        if(To[i]>i)
        {
            if(s[i]=='a')f[i]=std::string("a")+'b'+f[To[i]];
            else
            {
                int r=To[i];
                memset(v,0,sizeof v);
                v[i]=v[r]=true;
                for(int j=i+1;j<=r;++j)
                    if(s[j]=='b')
                        v[j]=v[To[j]]=true,r=To[j];
                for(int j=i;j<=r;++j)if(v[j])f[i]+=s[j];
                f[i]+=f[r+1];
            }
        }
        f[i]=std::max(f[i],f[i+1]);
    }
    std::cout<<f[1]<<std::endl;
    return 0;
}


Measured memory_bytes: 14720
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

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



Measured memory_bytes: 3560
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] height = new int[N];
        for(int i = 0; i < N; i++) {
        	height[i] = sc.nextInt();
        }
        HashSet<Integer> hs = new HashSet<Integer>();
        for(int j = 0; j < M; j++) {
        	int num1 = sc.nextInt();
        	int num2 = sc.nextInt();
        	if(height[num1 - 1] >height[num2 - 1]) {
        		hs.add(num2);
        	}
        	else if(height[num1 - 1] < height[num2 - 1]) {
        		hs.add(num1);
        	}
        	else {
        		hs.add(num1);
        		hs.add(num2);
        	}
        }
        System.out.println(N - hs.size());

    }

}


Measured memory_bytes: 63552