akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int ans;
    ans=max(n+m,n-m);
    ans=max(ans,n*m);
    cout<<ans<<endl;
    return 0;
}



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

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

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

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y,a,b,c; cin>>x>>y>>a>>b>>c;
    vector<pll> t;
    rep(i,a){
        ll p; cin>>p;
        t.emplace_back(p,0);
    }
    rep(i,b){
        ll q; cin>>q;
        t.emplace_back(q,1);
    }
    rep(i,c){
        ll r; cin>>r;
        t.emplace_back(r,2);
    }
    sort(rall(t));
    int n = t.size();
    int k = x+y;
    int cx=0,cy=0,cnt=0;
    ll ans=0;
    rep(i,n){
        if (t[i].se==0 && cx<x) ans+=t[i].fi, cx++, cnt++;
        if (t[i].se==1 && cy<y) ans+=t[i].fi, cy++, cnt++;
        if (t[i].se==2) ans+=t[i].fi, cnt++;
        if (cnt==k) break;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 10604
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
for i in range(n):
    c.append(a[i] - b[i])
for i in range(n):
    if c[i] < 0 and c[i] % 2 == 1:
        c[i] = 2 * (c[i] // 2 + 1)
d = 0
for i in range(n):
    if c[i] < 0:
        d = d - c[i]//2
e = 0
for i in range(n):
    if c[i] > 0:
        e = e + c[i]
f = max(d, e)
g = 0
for i in range(n):
    g = g - c[i]
if f > g:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	ll x;
	cin >> x;
	ll ans = x / 11;
	ans *= 2;
	x %= 11;
	if(x > 0) {
		ans++;
		x -= 6;
	}
	if(x > 0) ans++;
	cout << ans << "\n";
}

Measured memory_bytes: 3608
from heapq import heappop as pop
from heapq import heappush as push
INF = 10 ** 20
n, k = map(int, input().split())

clst = []
rlst = []

for i in range(n):
  c, r = map(int, input().split())
  clst.append(c)
  rlst.append(r)

edges = [[0] * n for i in range(n)]

for i in range(k):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  edges[a][b] = edges[b][a] = 1

costs = [INF for i in range(n)]
costs[0] = 0

used = [False for i in range(n)]
def make_to_lst(s_num):
  loop = rlst[s_num]
  temp = {i for i in range(n) if edges[s_num][i]}
  ret = {i for i in temp}
  while loop:
    new = set()
    for p in temp:
      pto = {i for i in range(n) if edges[p][i]}
      new = new | pto
    ret = ret | temp
    temp = new - ret
    if not temp:
      break
    loop -= 1
  return ret

used[0] = True
costs[0] = 0
break_flag = 0
que = [(clst[0], 0)]

while que and not break_flag:
  next_cost, s_num = pop(que)
  to_lst = make_to_lst(s_num)
  for num in to_lst:
    costs[num] = next_cost
    if num == n - 1:
      break_flag = 1
      break
    if not used[num]:
      push(que, (costs[num] + clst[num], num))
      used[num] = True

print(costs[n - 1])


Measured memory_bytes: 202648
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int a, b;
string s;
/**********************************************/

int main(){
    cin >> a >> b;
    cin >> s;
    bool flag = true;
    REP(i, s.size()){
        int num = (int)(s[i] - '0');
        if(i != a && (num < 0 || num > 9)){
            flag = false;
        }
        if(i == a && s[i] != '-'){
            flag = false;
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>


int main() {
	int n,b,f,r,v;
	int S[4][3][10] = { {{}} };
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d%d%d", &b, &f, &r, &v);
			S[b - 1][f - 1][r - 1] += v;
	}

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				printf(" %d", S[i][j][k]);
			}
			printf("\n");
		}
		if (i != 3)printf("####################\n");
	}
	

	return 0;
}

Measured memory_bytes: 2728
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	int N;
	string S;
	cin >> N >> S;
	vector<int> R(N+1,0),G(N+1,0),B(N+1,0);
	int i,j;
	for(i=0;i<N;i++) {
		R[N-i-1] = R[N-i];
		G[N-i-1] = G[N-i];
		B[N-i-1] = B[N-i];
		if(S[N-i-1] == 'R')R[N-i-1]++;
		else if(S[N-i-1] == 'G')G[N-i-1]++;
		else B[N-i-1]++;
	}
	long long ans = 0;
	for(i=0;i<N-2;i++) {
		for(j=i+1;j<N-1;j++) {
			if(S[i] != S[j]) {
				if((2*j-i<N)?S[2*j-i]!=S[i]&&S[2*j-i]!=S[j]:false) {
					if(S[i] != 'R' && S[j] != 'R')ans += max(R[j+1]-1,0);
					else if(S[i] != 'G' && S[j] != 'G')ans += max(G[j+1]-1,0);
					else ans += max(B[j+1]-1,0);
				}
				else {
					if(S[i] != 'R' && S[j] != 'R')ans += R[j+1];
					else if(S[i] != 'G' && S[j] != 'G')ans += G[j+1];
					else ans += B[j+1];
				}
			}
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int main() {
	int A, B;	cin >> A >> B;
	vector<int> num;

	num.push_back(A + B);
	num.push_back(A - B);
	num.push_back(A*B);

	cout << *max_element(num.begin(), num.end()) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D, E, x;
  cin>>A>>B>>C>>D>>E;
  if (A < 0){
    x=-1*A *C + D + E*B ;
    cout<<x<<endl;
  }
  else if(A > 0){
     x=E*(B-A) ;
     cout<<x<<endl;
  }
  else if(A == 0){
     x=D + E*B;
     cout<<x<<endl;
  }
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,m,R;
    cin >> n >> m >> R;
    vi r(R);
    rep(i,R) cin >> r[i];
    rep(i,R) r[i]--;
    sort(all(r));
    vvi dist(n,vi(n,inf));
    rep(i,n) dist[i][i] = 0;
    rep(_,m) {
        int a,b,c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }
    rep(k,n) rep(i,n) rep(j,n) {
        chmin(dist[i][j],dist[i][k]+dist[k][j]);
    }
    ll ans = linf;
    do {
        ll now = 0;
        rep(i,R-1) {
            now += dist[r[i]][r[i+1]];
        }
        chmin(ans,now);
    } while (next_permutation(all(r)));
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define N	 100
void solve(){
	string s;
	cin>>s;
	s[3] = '8';
	cout<<s<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}



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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;

  int dx = x2-x1,dy = y2-y1;
  int x3 = x2-dy,y3 = y2+dx;
  int x4 = x3-dx,y4 = y3-dy;

  printf("%d %d %d %d\n",x3,y3,x4,y4);
  
  return 0;
}


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

  
int main() {
  int k,s;
  cin >> k>>s;
 
  
  int count=0;
  for(int x=0; x<k+1; x++){
    for(int y=0; y<k+1; y++){
      if (s-x-y>=0 && s-x-y<=k) count++;
    }
  }
  
  cout << count  << endl;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(void){
  string s;
  cin >> s;
  int r = 0;
  int b = 0;
  for(int i = 0; i < s.length(); i++){
    if(s[i] == '0') r++;
    else b++;
  }
  cout << 2 * min(r, b) << endl;
  return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;	//Scannerクラス：Java標準入力を取得する

class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
		int n = sc.nextInt();
		int v = 0;
		int[][][] member = new int[4][3][10];
		int r = 0;
		int f = 0;
		int b = 0;

		for(int i = 0;i < n;i++) {
		r = sc.nextInt();
		f = sc.nextInt();
		b = sc.nextInt();
		v = sc.nextInt();
		member[r-1][f-1][b-1] += v;
		}

		for(int j = 0;j < 4;j++) {
			for(int k = 0;k < 3;k++) {
				for(int l = 0;l < 10;l++) {

					if(member[j][k][l] == 0) {
						System.out.print(" ");
						System.out.print(0);
					}else {
						System.out.print(" ");
						System.out.print(member[j][k][l]);
							}
						}
				System.out.println();
				if(k == 2 && j < 3)
					System.out.println("####################");
					}
				}
			}
		}
	}



Measured memory_bytes: 30200
n = int(input())
a = [int(x) for x in input().split()]
MOD = 1000000007
ans = 0
for digit in range(60):
    ones = 0
    for num in a:
        if num >> digit & 1:
            ones += 1
    zeroes = n - ones  # Zeros?
    ans = (ans + ones * zeroes * pow(2, digit, MOD)) % MOD

print(ans)


Measured memory_bytes: 122808
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
vector<long> fact_inv, inv, Com;
void init_nCk(int n,int k){
  fact_inv.resize(k+5);
  inv.resize(k+5);
  fact_inv[0]=fact_inv[1]=1;
  inv[1]=1;
  for(int i=2;i<k+5;i++){
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    fact_inv[i]=fact_inv[i-1]*inv[i]%MOD;
  }
  Com.resize(k+5);
  Com[0]=1;
  for(int i=1;i<k+5;i++){
    Com[i]=Com[i-1]*((n-i+1)*inv[i]%MOD)%MOD;
  }
}
int a,K,i;
long x=1,ans=0;
int nCk(int k){
  if(a>=2*k){return Com[k];}
  else{return Com[a-k];}
}
int main(){
  string S;
  cin>>K>>S;
  a=K+S.size();
  init_nCk(a,min(a/2,K));
  for(i=0;i<=K;i++){
    ans+=x*nCk(i);
    ans%=MOD;
    x*=25;
    x%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 27736
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    ll ans = 0;
    for (int i = 0; i < n; i++) ans += a[i] - 1;
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int i,n,q,tail,head,hz,notime=0;
		String hzn;
	Scanner sc = new Scanner(System.in);
	n=sc.nextInt();
	q=sc.nextInt();
	tail=n;
	//System.out.println(tail);
	head=0;
    String name[]=new String[n+1];
    int time[]=new int[n+1];
    for(i=0;i<n;i++){
    	name[i]=sc.next();
    	time[i]=sc.nextInt();
    }
    while(true){
    	if(tail==head)break;
    	
    	if(q<=time[head]){
    	hz=time[head]-q;
    	notime+=q;
    	}else{
        hz=0;
        notime+=time[head];
    	}
    	hzn=name[head];
    	if(head+1==n+1){
    		head=0;
    	}else{
    		head++;
    	}
    	if(hz==0){
    		System.out.println(hzn+" "+notime);
    		continue;
    	}
    	time[tail]=hz;
    	name[tail]=hzn;
    	if(tail+1 ==n+1){
    		tail=0;
    	}else{
    		tail++;
    	}
    	}
    
	}
}



Measured memory_bytes: 70356
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    int n,m;
    cin>>n>>m;
    string a[n],b[m];
    rep(i,n){
        cin>>a[i];
    }
    rep(i,m){
        cin>>b[i];
    }
    for(int i=0;i+m-1<n;i++){
        for(int j=0;j+m-1<n;j++){
            bool flag=true;
            for(int k=0;k<m;k++){
                for(int l=0;l<m;l++){
                    if(a[i+k][j+l]!=b[k][l]) flag=false;
                }
            }
            if(flag){cout<<"Yes"<<endl;return 0;}
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pii pair<ll,ll>
#define sc(x) scanf("%lld",&x)
vector<ll>v1,v2;

void get_sum(ll n){
	ll s=0;
	for(ll i=1;i<=n;i++){
		v1[i]=s+i;
		s=v1[i];
	}
	
	s=0;
	
	for(ll i=n;i>=1;i--){
		v2[i]=s+i;
		s=v2[i];
	}
	
	return ;
}


int main(){
	io;
	ll n,k;
	cin>>n>>k;
	v1.resize(n+1),v2.resize(n+1);
	get_sum(n);
	ll ans=0,m=1e9+7;
	while(k<=n){
		ll a=v1[k-1];
		ll b=v1[n]-v1[n-k];
		//cout<<k<<" "<<v1[n]<<" "<<v1[k-1]<<" "<<v1[n-k]<<endl;;
		ans+=(b-a+1);
		ans%=m;
		k++;
	}
	ans++;
	cout<<ans;
	return 0;
}
	


Measured memory_bytes: 6340
#include <cstdio>

constexpr int MAX_NM = 50;

int N, M;
int road[MAX_NM][MAX_NM];

int main(){
	scanf("%d%d", &N, &M);

	for(int i = 0; i < M; ++i){
		int a, b;
		scanf("%d%d",&a, &b);
		--a, --b;

		++road[a][b], ++road[b][a];
	}

	for(int i = 0; i < N; ++i){
		int sum = 0;
		for(int j = 0; j < N; ++j){
			sum += road[i][j];
		}
		printf("%d\n", sum);
	}
	return 0;
}


Measured memory_bytes: 128
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var dp = new long[10][][];
            for (var i = 0; i < 10; ++i)
            {
                dp[i] = new long[10][];
                for (var j = 0; j < 10; ++j)
                    dp[i][j] = new long[10];
            }
            for (var f = 1; f < 10; ++f)
            {
                for (var l = 1; l < 10; ++l)
                {
                    if (f == l && f <= N)
                        dp[f][l][1] = 1;
                    var kei = 10;
                    var km = 0;
                    for (var i = 2; i < 7; ++i)
                    {
                        var bsmin = f * kei + l;
                        var bsmax = bsmin + km;
                        var cnt = 0L;
                        if (bsmax <= N)
                            cnt = km / 10 + 1;
                        else if (bsmin <= N)
                            cnt = (N - bsmin) / 10 + 1;
                        else
                            cnt = 0;
                        dp[f][l][i] = cnt;
                        km = (km + 9) * 10;
                        kei *= 10;
                    }
                }
            }
            var ans = 0L;
            for (var f = 1; f < 10; ++f)
            {
                for (var l = 1; l < 10; ++l)
                {
                    ans += dp[f][l].Sum() * dp[l][f].Sum();
                }
            }
            WriteLine(ans);
            //Out.Flush();
        }

    }
}

Measured memory_bytes: 13524
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n;
	cin>>n;
	int x[8],y[8];
	vector<int> v(n);
	fori(n){cin>>x[i]>>y[i];v[i]=i;}

	double sum=0;int c=0;
	do{
		++c;
		fori(n-1){
			sum+=sqrt(pow(x[v[i]]-x[v[i+1]],2)+pow(y[v[i]]-y[v[i+1]],2));
		}
	}while(next_permutation(v.begin(),v.end()));

	cout<<fixed<<setprecision(10)<<sum/c;
}

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

int n;

int main(){
  cin >> n;
  string s;
  int ans[4]; for (int i=0;i<4;i++) ans[i]=0;
  for (int i=0; i<n;i++) {
    cin >> s;
    if (s == "AC") {
      ans[0]++;
    } else if (s == "WA") {
      ans[1]++;
    } else if (s == "TLE") {
      ans[2]++;
    } else if (s == "RE") {
      ans[3]++;
    }
  }
  cout << "AC x " << ans[0] << endl;
  cout << "WA x " << ans[1] << endl;
  cout << "TLE x " << ans[2] << endl;
  cout << "RE x " << ans[3] << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main(){
    int a;
    cin>>a;
    int arr[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<arr[a-1]<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
 
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	ll g=gcd(a,b);
	return a/g*b;
}
 
ll digitsum(ll a){
	ll x=0;
	while(a>0){
		x+=a%10;
		a/=10;
	}
	return x;
}
int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	if(min(a,c)==a&&max(b,c)==b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
}

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

int main() {
	int n;
	cin>>n;
	int arr[n-1],a[n];
	for(int i=0;i<n-1;i++)
	{
	    cin>>arr[i];
	    
	}
	int sum=arr[0];
	for(int i=0;i<n-2;i++)
	{
	    a[i+1]=min(arr[i],arr[i+1]);
	    sum+=a[i+1];
	}
	sum=sum+arr[n-2];
	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

struct BIT{
	int N;
	vector<int> dat;
	BIT() {}
	BIT(int n) {
		N = n;
		dat.resize(N + 1);
	}
	void add(int k, int x){
		k++;
		while(k <= N){
			dat[k] += x;
			k += k&-k;
		}
	}
	int sum(int k){
		int s = 0;
		while(k > 0){
			s += dat[k];
			k -= k&-k;
		}
		return s;
	}
	int query(int a, int b){
		return sum(b) - sum(a);
	}
};

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n, q;
	string s;
	cin >> n >> s >> q;
	vector<BIT> b(26, BIT(n));
	REP(i, n){
		b[s[i] - 'a'].add(i, 1);
	}
	while(q--){
		int t;
		cin >> t;
		if(t == 1){
			int i;
			char c;
			cin >> i >> c;
			i--;
			if(s[i] != c){
				b[s[i] - 'a'].add(i, -1);
				b[c - 'a'].add(i, 1);
				s[i] = c;
			}
		}else{
			int l, r;
			cin >> l >> r;
			l--; r--;
			int ans = 0;
			REP(i, 26){
				int tmp = b[i].query(l, r + 1);
				if(tmp) ans++;
			}
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 106396
import sys
import math
from collections import Counter
import itertools
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

n = int(input())
p=LI()

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

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;

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

  string s0, s1;
  rep(i, s.size()/2){
    s0 += '0';
    s0 += '1';
  }
  if(s.size()%2 == 1) s0 += '0';
  rep(i, s.size()/2){
    s1 += '1';
    s1 += '0';
  }
  if(s.size()%2 == 1) s1 += '1';

  int c0 = 0;
  int c1 = 0;
  rep(i, s.size()){
    if(s.at(i) != s0.at(i)){
      c0++;
    }
    if(s.at(i) != s1.at(i)){
      c1++;
    }
  }

  cout << min(c0, c1) << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

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

    sort(A.begin(), A.end());
    sort(F.rbegin(), F.rend());
    
    ll ng = -1;
    ll ok = 1e12;
    while(abs(ok-ng)>1){
        ll mid = (ok+ng) / 2;
        ll count = 0;
        rep(i,N){
            count += max(0ll, A[i] - mid/F[i]);
        }
        if(K >= count) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}

Measured memory_bytes: 4852
d , g = map(int , input().split())
p = [0] * d
c = [0] * d
for i in range(d):
    p[i] , c[i] = map(int , input().split())

ans = float("inf")

for bit in range(1<<d):
  sum=0
  count=0
  nokori=set(range(1,d+1))
  for i in range(d):
    if bit&(1<<i):
      sum += p[i]*100*(i+1)+c[i]
      count+= p[i]
      nokori.discard(i + 1)
  if sum<g:
    a=g-sum
    num=max(nokori)
    n=min(p[num-1],-(-a//(num*100)))
    count+=n
    sum+=n*num*100
  if sum>=g:
    ans=min(ans,count)
    
print(ans)

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

  int now = 0;
  int cnt = 0;
  int ans = 0;
  for ( int i = 0; i < N; i++ ) {
    int a;
    cin >> a;
    if ( a <= now ) {
      cnt++;
      now = a;      
    } else {
      now = a;
      ans = max(ans, cnt);
      cnt = 0;
    }
  }

  ans = max(ans, cnt);

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


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

using namespace std;

#define INF 2140000000
#define MOD 1000000007

int main() {
	int n;
	cin >> n;
	vector<int> v(n);

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

	int ans = 1;

	for (int i = 1; i < n; ++i) {
		bool flag = 1;
		for (int j = 0; j < i; ++j) {
			if (v[j] > v[i]) {
				flag = 0;
			}
		}

		if (flag) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
import java.io.*;
import java.util.*;
  
class Main {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            String s1 = sc.nextLine();
            String s2 = sc.nextLine();
            String s3 = s1 + s1;
            if (s3.contains(s2)) {
                    System.out.println("Yes");
            }else{
                    System.out.println("No");
            }
        }
}

Measured memory_bytes: 17308
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define dd double
#define f0(i, n) for(int i = 0; i < n; i++)
#define fab(i,a,b) for(int i=a;i<b;i++)
#define f1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second





int main() {


	ios_base::sync_with_stdio(false);
	cin.tie(NULL);



//ios_base& scientific (ios_base& str);

	int n;
	cin >> n;

	double p[n + 1];

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

	double dp[n + 1][n + 1] ;
	memset(dp, 0.0, sizeof(dp));


	dp[0][0] = 1.0;

	for (int i = 1; i <= n; i++) {

//first i coins
		for (int j = 0; j <= i; j++) {
			//j heads

			if (j == 0) {
				dp[i][j] = dp[i - 1][j] * (1.0 - p[i]);
			}
			else {

				dp[i][j] = dp[i - 1][j - 1] * p[i] + dp[i - 1][j] * (1.0 - p[i]);
			}


		}
	}


	// for (int i = 0; i <= n; i++) {

	// 	for (int j = 0; j <= n; j++) {

	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }1


	double ans = 0.0;

	for (int i = (n + 1) / 2; i <= n; i++) {

		ans += dp[n][i];
	}
	cout << setprecision(10) << fixed;
	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 70656
#include<iostream>
using namespace std;
int main(){
  int a,b; cin >> a >> b;
  if(a ==b)
    cout << "Draw" << endl;
  else if(a==1)
    cout << "Alice"<< endl;
  else if(b == 1)
    cout << "Bob" << endl;
  else if(a > b)
    cout << "Alice"<< endl;
  else if(b >a)
    cout << "Bob" << endl;
    
}

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

#define MAX_N 10000

int main() {
    vector<int> v;

    int num;
    while (cin >> num) {
        v.push_back(num);
    }

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

    int n = 3;
    for (int i = v.size() - 1 ; i >  v.size() - (n + 1) ; i--) {
        cout << v[i] << endl;
    }
    return 0;
}



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

struct Node{
    int key;
    Node *lch,*rch;
    Node(int key):key(key),lch(nullptr),rch(nullptr){}
};

class BinarySearchTree
{
 private:
    Node* root;
 public:
    BinarySearchTree():root(nullptr){}
    Node* find(int key){
        Node* cur=root;
        while(cur!=nullptr and key!=cur->key){
            if(key<cur->key) cur=cur->lch; else cur=cur->rch;
        }
        return cur;
    }
    void insert(int key){
        if(find(key)!=nullptr) return;
        root=insert(root,key);
    }
    Node* insert(Node* cur,int key){
        if(cur==nullptr) return new Node(key);

        if(key<cur->key) cur->lch=insert(cur->lch,key);
        else cur->rch=insert(cur->rch,key);
        return cur;
    }
    void erase(int key){
        if(find(key)==nullptr) return;
        root=erase(root,key);
    }
    Node* erase(Node* cur,int key){
        if(key<cur->key) cur->lch=erase(cur->lch,key);
        else if(key>cur->key) cur->rch=erase(cur->rch,key);
        else{
            if(cur->lch==nullptr or cur->rch==nullptr){
                Node* tmp=(cur->lch==nullptr? cur->rch:cur->lch);
                delete cur; return tmp;
            }else{
                Node* target=getMinNode(cur->rch);
                cur->key=target->key;
                cur->rch=erase(cur->rch,target->key);
            }
        }
        return cur;
    }
    Node* getMinNode(Node* node){
        Node* res=node;
        while(res->lch!=nullptr) res=res->lch;
        return res;
    }
    void print();
    void inorder(Node*);
    void preorder(Node*);
};

void BinarySearchTree::print(){
    assert(root!=nullptr);
    inorder(root); puts("");
    preorder(root); puts("");
}
void BinarySearchTree::inorder(Node* node){
    if(node->lch!=nullptr) inorder(node->lch);
    printf(" %d",node->key);
    if(node->rch!=nullptr) inorder(node->rch);
}
void BinarySearchTree::preorder(Node* node){
    printf(" %d",node->key);
    if(node->lch!=nullptr) preorder(node->lch);
    if(node->rch!=nullptr) preorder(node->rch);
}

int main()
{
    BinarySearchTree tree;
    int Q; cin>>Q;
    while(Q--){
        string s; cin>>s;
        if(s=="print") tree.print();
        else{
            int x; cin>>x;
            if(s=="insert") tree.insert(x);
            else if(s=="find") cout<<(tree.find(x)!=nullptr? "yes":"no")<<endl;
            else tree.erase(x);
        }
    }
    return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;

int main() {
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    //abピザを何枚買う?
    ll ans=10000000000000;
    ll num=max(x,y)*2;
    for (int i=0;i<num+1;i++){
        ll ans1=0;
        ans1+=i*c;
        if (x>i/2){
            ans1+=(x-i/2)*a;
        }
        if (y>i/2){
            ans1+=(y-i/2)*b;
        }
        ans=min(ans,ans1);
    }
    cout<<ans<<endl;

    return 0;
}

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


using namespace std;
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
 /* #ifndef ONLINE_JUDGE
  freopen ("input.txt", "r", stdin);
  freopen ("output.txt", "w", stdout);
  #endif */
  string t;
  int n,k,r,s,p;
  cin>>n>>k>>r>>s>>p>>t;

string st="";
ll sum=0;


for(int i=0;i<t.size();i++)
{
    
    if(t[i]=='r' && i-k<0)
    {
        st+='p';
    }
    else if( t[i]=='r' &&  st[i-k]!='p')
        st+='p';

    else  if(t[i]=='r')
    {
        if(i+k<t.size() && t[i+k]=='s')
        {
            st+='s';
        }
        else st+='r';
    }

 
    else if(t[i]=='s' && (i-k<0))
    {
        st+='r';
    }
    else if(t[i]=='s' && st[i-k]!='r')
    {
        st+='r';
    }

    else if(t[i]=='s')
    {
        if(i+k<t.size() && t[i+k]=='r')
        {
            st+='s';
        }
        else st+='p';
    }



    else if(t[i]=='p' && i-k<0 )
    {
        st+='s';
    }
    else if(t[i]=='p'  && st[i-k]!='s')
        st+='s';

    else if(t[i]=='p')
    {
        if(i+k<t.size() && t[i+k]=='r')
        {
            st+='r';
        }
        else st+='p';
    }



}



for(int i=0;i<st.size();i++)
{
    if(t[i]=='r' && st[i]=='p')
    {
       sum+=p;
    }

    else if(t[i]=='s' && st[i]=='r')
    {
        sum+=r;
     }
     else if(t[i]=='p' && st[i]=='s')
     {
        sum+=s;
     }
     
}

cout<<sum<<endl;



}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(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)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
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;}



signed main(){
    int k, x;
    cin >> k >> x;
    FOR(i, x - k + 1, x + k){
        cout << i << " ";
    }
    cout << endl;
    return 0;
}


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

using namespace std;

int upcmp(const void *p,const void *q){
    return *(int*)p-*(int*)q;
}

int downcmp(const void *p,const void *q){
  return *(int*)q-*(int*)p;
}

int main(void){
  char S[100000];
  char *p1,*p2;
  cin >> S;
  int L=strlen(S);
  int ans[L],countR=0,countL=0;
  for(int i=0;i<L;i++){
    countR=0,countL=0;
    if(S[i]=='R' && S[i+1]=='L'){
      p1=&S[i],p2=&S[i+1];
      while(*p1=='R'){
        countR++;
        p1--;
      }
      while(*p2=='L'){
        countL++;
        p2++;
      }
      if((countR%2==0 && countL%2==0) || (countR%2==1 && countL%2==1)){
        cout << (countL+countR)/2 <<" "<< (countL+countR)/2 << " ";
      }
      else if(countR%2==1 && countL%2==0){
        cout << ((countL+countR)/2)+1 << " " << (countL+countR)/2 <<" ";
      }
      else{
        cout << ((countL+countR)/2) << " " << (countL+countR)/2+1 <<" ";
      }
      i++;
    }
    else{
      cout << "0 ";
    }
  }
}
      

Measured memory_bytes: 512
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
ans = a.inject(:+)
sa = 10000000000000000000000000000
count  = 0
a.each_with_index do |i,j|
	count += i
    tmp = ans -  count
    # puts "UU"
    # p count
    # p ans
    # puts "II"
    all = tmp - count
  	if j != n - 1
        sa = [sa,all.abs].min
    end
end
puts sa


Measured memory_bytes: 28584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;

signed main(){
    int n,m; cin>>n>>m;
    vector<P> s(n),c(m);
    rep(i,n) cin>>s.at(i).F>>s.at(i).S;
    rep(i,m) cin>>c.at(i).F>>c.at(i).S;
    
    rep(i,n){
        int sum=INF,ans=-1;
        rep(j,m){
            int tmp=abs(c.at(j).F-s.at(i).F)+abs(c.at(j).S-s.at(i).S);
            if(tmp<sum){
                sum=tmp;
                ans=j;
            }
        }
        cout<<ans+1<<endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        int[] A = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(A[0] + A[1] == A[2] + A[3] ? "Balanced" : (A[0] + A[1] > A[2] + A[3] ? "Left" : "Right"));
    }
}

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

int gcd(int a, int b) {
    while (b) {
        int tmp = b;
        b = a % b;
        a = tmp;
    }
    return a;
}

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

    int T;
    cin >> T;
    LL res = 0;
    for (int i = 1; i <= T; i++) {
        for (int j = 1; j <= T; j++) {
            for (int k = 1; k <= T; k++) {
                res += gcd(gcd(i, j), k);
            }
        }
    }
    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
    
int main() {
  char boin;
  cin >> boin;

  if ( boin == 'a' || boin == 'e' || boin == 'i' || boin == 'o' || boin == 'u')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}

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

int main(){
 int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int left = A + B;
  int right = C + D;
  
  if(left == right) {
	cout << "Balanced" << endl;
  }
  else if (left > right){
	cout << "Left" << endl;
  }
  else{
	cout << "Right" << endl;
  }
 
}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

int64_t F[100][5][2];
int64_t P[100][11];

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

  int64_t N;
  cin >> N;
  for (int64_t i = 0; i < N; ++i) {
    for (int64_t j = 0; j < 5; ++j) {
      for (int64_t k = 0; k < 2; ++k) {
        cin >> F[i][j][k];
      }
    }
  }
  for (int64_t i = 0; i < N; ++i) {
    for (int64_t c = 0; c <= 10; ++c) {
      cin >> P[i][c];
    }
  }
  int64_t result = -kInf;
  for (int64_t b = 1; b < (1 << 10); ++b) {
    bitset<10> bs(b);
    vector<int64_t> C(N, 0);
    for (int64_t j = 0; j < 5; ++j) {
      for (int64_t k = 0; k < 2; ++k) {
        if ((bs[k + j * 2])) {
          for (int64_t i = 0; i < N; ++i) {
            if (F[i][j][k]) {
              ++C[i];
            }
          }
        }
      }
    }
    int64_t temp = 0;
    for (int64_t i = 0; i < N; ++i) {
      temp += P[i][C[i]];
    }
    result = max(result, temp);
  }
  cout << result << endl;
  return 0;
}


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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n, k;
  cin >> n >> k;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) { cin >> v[i]; }
  sort(v.begin(), v.end());
  ll ans = 0;
  for (int i = 0; i < n - k; i++) {
    ans += v[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if X == a*500 + b*100 + c*50:
                ans += 1
 
print(ans)


Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))
A.sort()

if N == 2:
    print((A[0]+A[1])/2)

else:
    ans = A[0]/(2**(N-1))
    for i in range(N-1):
        ans = ans + A[i+1]/(2**(N-i-1))
    print(ans)

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	long long int n;
	cin >> n;
	vector<long long int> input(n);

	long long int ans = 1000;
	long long int stock = 0;
	
	rep(i, n){
		cin >> input[i];
	}

	rep(i, n - 1){
		if(0 < stock){
			ans += stock * input[i];
			stock = 0;
		}

		if(input[i] < input[i + 1]){
			stock += ans / input[i];
			ans -= stock * input[i];
		}
	}

	if(0 < stock) ans += stock * input[n - 1];

	cout << ans;

	return 0;
}

Measured memory_bytes: 3604
n = int(input())
c = list(input())
ans = 0
counta=0
a = [0 for i in range(n)]
b = [0 for i in range(n)]
for i in range(n):
	if c[i]=='R':
		a[i] = 1

w = a.count(0)
r = a.count(1)
for j in range(r):
	b[j] = 1
if a==b:
	pass
else:
	for k in a:
		counta+=1
		if k==0:
			ans+=1
		if counta==r:
			break
print(ans)

Measured memory_bytes: 13916
#include<stdio.h>

int main(void){
  int i,j,k;
  char str[15],ring[15];
  int digit,n;
  int trueflag,count=0;

  scanf("%s%d",str,&n);
  for(i=0;str[i];i++){}
  digit=i;
  for(i=0;i<n;i++){
    scanf("%s",ring);
    for(j=0;j<10;j++){
      if(str[0]==ring[j]){
        trueflag=1;
        for(k=1;k<digit;k++)
          if(str[k]!=ring[(j+k)%10]){
            trueflag=0;
            break;
          }
        if(trueflag==1){
          count++; 
          break;
        }
      }
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 0
// Problem : P - Independent Set
// Contest : AtCoder - Educational DP Contest
// URL : https://a...content-available-to-author-only...r.jp/contests/dp/tasks/dp_p?lang=en
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://g...content-available-to-author-only...b.com/cpeditor/cpeditor)

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define watch(x) cout << #x << " = " << x << endl;
#define RT(x) return cout << (x), 0;
#define Accepted 0
#define INF 0x3f3f3f3f3f3f3f3fLL
typedef long long ll;
typedef vector<int> vi;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
void Open()
{
#ifndef ONLINE_JUDGE 
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
const int mod = ll(1e9 + 7), N = 1e5 + 5;
//“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent
int n;
vector<vector<int>>g;
int cnt = 0;
ll mem[N][2];
ll dfs(int node, int par, int lst) {
	ll& ret = mem[node][lst];
	if (~ret)return ret;
	ret = 1;
	for (int nxt : g[node]) {
		ll cur = 0;
		if (nxt != par) {
			cur += dfs(nxt, node, 0) % mod;
			if (lst != 1)
			{
				cur += dfs(nxt, node, 1) % mod;
			}
			ret *= cur % mod;
			ret %= mod;
		}
	}
	return ret;
}
int main()
{
	Ma7moud_7amdy;
	Open_Sesame;
	clr(mem, -1);
	cin >> n;
	g = vector<vector<int>>(n + 1);
	for (int i = 1, u, v; i < n; i++) {
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	ll ans = dfs(1, -1, 1);
	ans += dfs(1, -1, 0);

	cout << ans %mod<< endl;
}


Measured memory_bytes: 19996
#include <stdio.h>

int main(void) {
	int a,b,i=15;
	scanf("%d",&a);
	scanf("%d",&b);
	if(i==a+b){
		putchar('+');
	}else if(i==a*b){
		putchar('*');
	}else{
		putchar('x');
	}
	return 0;
}

Measured memory_bytes: 128
<?php
 
while($line = fgets(STDIN)){
	list($d, $w, $h) = explode(" ", trim($line));
	if($d == 0 && $w == 0 && $h == 0){
		break;
	}
	
	$n = intval(fgets(STDIN));
	for($i = 0; $i < $n; $i++){
		$r = intval(fgets(STDIN));
		$l = 4*$r*$r;	// ?????????????¨?????????????????????????????????´??????????????????????±?????????????
		
		// ?????¢???????§???????????????? 2*r ??\??????????????? 1?????§???????????°????????§??????
		$x = $d*$d + $w*$w;
		if($x < $l){
			echo "OK\n";
			continue;
		}
		
		$x = $w*$w + $h*$h;
		if($x < $l){
			echo "OK\n";
			continue;
		}
		
		$x = $h*$h + $d*$d;
		if($x < $l){
			echo "OK\n";
			continue;
		}
		
		echo "NA\n";
	}
}

Measured memory_bytes: 15296
#include<iostream>
using namespace std;
int main()
{
    char a[101][101];  
    int i,j,n,m,sum=0;  
    cin>>n>>m;  
    for(i=0;i<n;i++){  
        for(j=0;j<m;j++) cin>>a[i][j]; 
    } 
    for(i=0;i<n;i++){
    	if(i>=1) cout<<endl;
    	for(j=0;j<m;j++){
    		sum=0;
			if(a[i][j]=='#') cout<<"#";
			else{
                if ((i>0)&&(j>0)) 
                  if(a[i-1][j-1]=='#')  sum++; 
                if (i>0)    
                  if(a[i-1][j]=='#')  sum++; 
                if ((i>0)&&(j<m-1))  
                  if(a[i-1][j+1]=='#')  sum++; 
                if (j>0)   
                  if(a[i][j-1]=='#')  sum++;  
                if (j<m-1)    
                  if(a[i][j+1]=='#')  sum++;  
                if ((i<n-1)&&(j>0))                     
                  if(a[i+1][j-1]=='#')  sum++; 
                if (i<n-1)                                                            
                  if(a[i+1][j]=='#')  sum++;  
                if ((i<n-1)&&(j<m-1))    
                  if(a[i+1][j+1]=='#')  sum++; 
                cout<<sum;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n,m = nm()
a = nl()
a.sort(reverse=True)
if a[m-1]*4*m < sum(a):
    print('No')
else:
    print('Yes')


Measured memory_bytes: 3060