akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    int H, W;
    string S[500];
    cin >> H >> W;
    for(int i=0; i<H; i++) cin >> S[i];

    string ansR[500], ansB[500];
    for(int i=0; i<H; i++) ansR[i] = ansB[i] = string(W, '.');

    for(int i=0; i<H; i++) ansR[i][0] = '#';
    for(int i=1; i<H; i++) for(int j=1; j<W-1; j++) if(i%2 == 0 || S[i][j] == '#') ansR[i][j] = '#';
    for(int i=0; i<H; i++) ansB[i][W-1] = '#';
    for(int i=1; i<H; i++) for(int j=1; j<W-1; j++) if(i%2 == 1 || S[i][j] == '#') ansB[i][j] = '#';

    for(int i=0; i<H; i++) cout << ansR[i] << endl;
    cout << endl;
    for(int i=0; i<H; i++) cout << ansB[i] << endl;
}

Measured memory_bytes: 1536
/*
⣿⣿⣿⣿⣿⣿⡷⣯⢿⣿⣷⣻⢯⣿⡽⣻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠸⣿⣿⣆⠹⣿⣿⢾⣟⣯⣿⣿⣿⣿⣿⣿⣽⣻⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣻⣽⡿⣿⣎⠙⣿⣞⣷⡌⢻⣟⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣿⣿⡄⠹⣿⣿⡆⠻⣿⣟⣯⡿⣽⡿⣿⣿⣿⣿⣽⡷⣯⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣟⣷⣿⣿⣿⡀⠹⣟⣾⣟⣆⠹⣯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢠⡘⣿⣿⡄⠉⢿⣿⣽⡷⣿⣻⣿⣿⣿⣿⡝⣷⣯⢿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣯⢿⣾⢿⣿⡄⢄⠘⢿⣞⡿⣧⡈⢷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣧⠘⣿⣷⠈⣦⠙⢿⣽⣷⣻⣽⣿⣿⣿⣿⣌⢿⣯⢿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣟⣯⣿⢿⣿⡆⢸⡷⡈⢻⡽⣷⡷⡄⠻⣽⣿⣿⡿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣏⢰⣯⢷⠈⣿⡆⢹⢷⡌⠻⡾⢋⣱⣯⣿⣿⣿⣿⡆⢻⡿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⡎⣿⢾⡿⣿⡆⢸⣽⢻⣄⠹⣷⣟⣿⣄⠹⣟⣿⣿⣟⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⡇⢸⣯⣟⣧⠘⣷⠈⡯⠛⢀⡐⢾⣟⣷⣻⣿⣿⣿⡿⡌⢿⣻⣿⣿
⣿⣿⣿⣿⣿⣿⣧⢸⡿⣟⣿⡇⢸⣯⣟⣮⢧⡈⢿⣞⡿⣦⠘⠏⣹⣿⣽⢿⣿⣿⣿⣿⣯⣿⣿⣿⡇⢸⣿⣿⣾⡆⠹⢀⣠⣾⣟⣷⡈⢿⣞⣯⢿⣿⣿⣿⢷⠘⣯⣿⣿
⣿⣿⣿⣿⣿⣿⣿⡈⣿⢿⣽⡇⠘⠛⠛⠛⠓⠓⠈⠛⠛⠟⠇⢀⢿⣻⣿⣯⢿⣿⣿⣿⣷⢿⣿⣿⠁⣾⣿⣿⣿⣧⡄⠇⣹⣿⣾⣯⣿⡄⠻⣽⣯⢿⣻⣿⣿⡇⢹⣾⣿
⣿⣿⣿⣿⣿⣿⣿⡇⢹⣿⡽⡇⢸⣿⣿⣿⣿⣿⣞⣆⠰⣶⣶⡄⢀⢻⡿⣯⣿⡽⣿⣿⣿⢯⣟⡿⢀⣿⣿⣿⣿⣿⣧⠐⣸⣿⣿⣷⣿⣿⣆⠹⣯⣿⣻⣿⣿⣿⢀⣿⢿
⣿⣿⣿⣿⣿⣿⣿⣿⠘⣯⡿⡇⢸⣿⣿⣿⣿⣿⣿⣿⣧⡈⢿⣳⠘⡄⠻⣿⢾⣽⣟⡿⣿⢯⣿⡇⢸⣿⣿⣿⣿⣿⣿⡀⢾⣿⣿⣿⣿⣿⣿⣆⠹⣾⣷⣻⣿⡿⡇⢸⣿
⣿⣿⣿⣿⣿⣿⣿⣿⡇⢹⣿⠇⢸⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠻⡇⢹⣆⠹⣟⣾⣽⣻⣟⣿⣽⠁⣾⣿⣿⣿⣿⣿⣿⣇⣿⣿⠿⠛⠛⠉⠙⠋⢀⠁⢘⣯⣿⣿⣧⠘⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⡈⣿⡃⢼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡙⠌⣿⣆⠘⣿⣞⡿⣞⡿⡞⢠⣿⣿⣿⣿⣿⡿⠛⠉⠁⢀⣀⣠⣤⣤⣶⣶⣶⡆⢻⣽⣞⡿⣷⠈⣿
⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠘⠁⠉⠉⠉⠉⠉⠉⠉⠉⠉⠙⠛⠛⢿⣄⢻⣿⣧⠘⢯⣟⡿⣽⠁⣾⣿⣿⣿⣿⣿⡃⢀⢀⠘⠛⠿⢿⣻⣟⣯⣽⣻⣵⡀⢿⣯⣟⣿⢀⣿
⣿⣿⣿⣟⣿⣿⣿⣿⣶⣶⡆⢀⣿⣾⣿⣾⣷⣿⣶⠿⠚⠉⢀⢀⣤⣿⣷⣿⣿⣷⡈⢿⣻⢃⣼⣿⣿⣿⣿⣻⣿⣿⣿⡶⣦⣤⣄⣀⡀⠉⠛⠛⠷⣯⣳⠈⣾⡽⣾⢀⣿
⣿⢿⣿⣿⣻⣿⣿⣿⣿⣿⡿⠐⣿⣿⣿⣿⠿⠋⠁⢀⢀⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣌⣥⣾⡿⣿⣿⣷⣿⣿⢿⣷⣿⣿⣟⣾⣽⣳⢯⣟⣶⣦⣤⡾⣟⣦⠘⣿⢾⡁⢺
⣿⣻⣿⣿⡷⣿⣿⣿⣿⣿⡗⣦⠸⡿⠋⠁⢀⢀⣠⣴⢿⣿⣽⣻⢽⣾⣟⣷⣿⣟⣿⣿⣿⣳⠿⣵⣧⣼⣿⣿⣿⣿⣿⣾⣿⣿⣿⣿⣿⣽⣳⣯⣿⣿⣿⣽⢀⢷⣻⠄⠘
⣿⢷⣻⣿⣿⣷⣻⣿⣿⣿⡷⠛⣁⢀⣀⣤⣶⣿⣛⡿⣿⣮⣽⡻⣿⣮⣽⣻⢯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⢀⢸⣿⢀⡆
⠸⣟⣯⣿⣿⣷⢿⣽⣿⣿⣷⣿⣷⣆⠹⣿⣶⣯⠿⣿⣶⣟⣻⢿⣷⣽⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢀⣯⣟⢀⡇
⣇⠹⣟⣾⣻⣿⣿⢾⡽⣿⣿⣿⣿⣿⣆⢹⣶⣿⣻⣷⣯⣟⣿⣿⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⢀⡿⡇⢸⡇
⣿⣆⠹⣷⡻⣽⣿⣯⢿⣽⣻⣿⣿⣿⣿⣆⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⢸⣿⠇⣼⡇
⡙⠾⣆⠹⣿⣦⠛⣿⢯⣷⢿⡽⣿⣿⣿⣿⣆⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠃⠎⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⢀⣿⣾⣣⡿⡇
⣿⣷⡌⢦⠙⣿⣿⣌⠻⣽⢯⣿⣽⣻⣿⣿⣿⣧⠩⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⢰⢣⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⢀⢀⢿⣞⣷⢿⡇
⣿⣽⣆⠹⣧⠘⣿⣿⡷⣌⠙⢷⣯⡷⣟⣿⣿⣿⣷⡀⡹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣈⠃⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⢀⣴⡧⢀⠸⣿⡽⣿⢀
⢻⣽⣿⡄⢻⣷⡈⢿⣿⣿⢧⢀⠙⢿⣻⡾⣽⣻⣿⣿⣄⠌⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⢁⣰⣾⣟⡿⢀⡄⢿⣟⣿⢀
⡄⢿⣿⣷⢀⠹⣟⣆⠻⣿⣿⣆⢀⣀⠉⠻⣿⡽⣯⣿⣿⣷⣈⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⢀⣠⠘⣯⣷⣿⡟⢀⢆⠸⣿⡟⢸
⣷⡈⢿⣿⣇⢱⡘⢿⣷⣬⣙⠿⣧⠘⣆⢀⠈⠻⣷⣟⣾⢿⣿⣆⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⣠⡞⢡⣿⢀⣿⣿⣿⠇⡄⢸⡄⢻⡇⣼
⣿⣷⡈⢿⣿⡆⢣⡀⠙⢾⣟⣿⣿⣷⡈⠂⠘⣦⡈⠿⣯⣿⢾⣿⣆⠙⠻⠿⠿⠿⠿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⢋⣠⣾⡟⢠⣿⣿⢀⣿⣿⡟⢠⣿⢈⣧⠘⢠⣿
⣿⣿⣿⣄⠻⣿⡄⢳⡄⢆⡙⠾⣽⣿⣿⣆⡀⢹⡷⣄⠙⢿⣿⡾⣿⣆⢀⡀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⣀⣠⣴⡿⣯⠏⣠⣿⣿⡏⢸⣿⡿⢁⣿⣿⢀⣿⠆⢸⣿
⣿⣿⣿⣿⣦⡙⣿⣆⢻⡌⢿⣶⢤⣉⣙⣿⣷⡀⠙⠽⠷⠄⠹⣿⣟⣿⣆⢙⣋⣤⣤⣤⣄⣀⢀⢀⢀⢀⣾⣿⣟⡷⣯⡿⢃⣼⣿⣿⣿⠇⣼⡟⣡⣿⣿⣿⢀⡿⢠⠈⣿
⣿⣿⣿⣿⣿⣷⣮⣿⣿⣿⡌⠁⢤⣤⣤⣤⣬⣭⣴⣶⣶⣶⣆⠈⢻⣿⣿⣆⢻⣿⣿⣿⣿⣿⣿⣷⣶⣤⣌⣉⡘⠛⠻⠶⣿⣿⣿⣿⡟⣰⣫⣴⣿⣿⣿⣿⠄⣷⣿⣿⣿
*/

#include <bits/stdc++.h>

using namespace std;

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

  int n,s;
  string a;
  cin >> n >> s >> a;

  a[s-1] = tolower(a[s-1]);

  cout << a << endl;

  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define mod 1000000007

int f[110][101000];
int l[101000], r[101000];

int main()
{
	int n, m; scanf("%d%d", &n, &m);
	int tot = 0;
	int R;
	for(int L = 1; L <= n; L = R + 1)
	{
		R = n / (n / L);
		l[++tot] = L; r[tot] = R; 
	}
	f[0][1] = 1;
	int Ans = 0;
	for(int i = 1; i <= m; i++)
	{
		int k = 0, sum = 0;
		for(int j = tot; j >= 1; j--)
		{
			if(k + 1 <= tot && l[k + 1] * l[j] <= n) k++, sum = (sum + f[i - 1][k]) % mod;
			f[i][j] = 1ll * (r[j] - l[j] + 1) * sum % mod;
			if(i == m) Ans = (Ans + f[m][j]) % mod;
		}
	}
	printf("%d\n", Ans);
}

Measured memory_bytes: 40192
#include <cstdio>
using namespace std;
const int N=200005;
int n,pre[N],cnex[N];
int h[N],tot;
struct Edge{
	int v,next;
}e[N*2];
int a[N],len,mex[N][2];
inline void addEdge(int u,int v){
	e[++tot]=(Edge){v,h[u]}; h[u]=tot;
}
void readData(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&pre[i]);
		addEdge(pre[i],i); 
	}
}
void findCircle(int u){
	static int stk[N],top=0;
	static bool vis[N];
	stk[++top]=u;
	vis[u]=true;
	if(vis[pre[u]]){
		int v=pre[u];
		cnex[v]=u;
		for(;stk[top]!=v;top--){
			cnex[stk[top]]=stk[top-1];
			a[++len]=stk[top];
		}
		a[++len]=v;
		return;
	}
	findCircle(pre[u]);
}
void dfs(int u,int dep){
	for(int i=h[u],v;i;i=e[i].next)
		if((v=e[i].v)!=cnex[u])
			dfs(v,dep+1);
	static int cnt[N];
	for(int i=h[u],v;i;i=e[i].next)
		if((v=e[i].v)!=cnex[u])
			cnt[mex[v][0]]++;
	for(mex[u][0]=0;cnt[mex[u][0]];mex[u][0]++);
	if(dep==0)
		for(mex[u][1]=mex[u][0]+1;cnt[mex[u][1]];mex[u][1]++);
	for(int i=h[u],v;i;i=e[i].next)
		if((v=e[i].v)!=cnex[u])
			cnt[mex[v][0]]--;
}
bool run(int x){
	int last=x;
	for(int i=len-1;i>=1;i--){
		int u=a[i];
		last=(mex[u][0]==last)?mex[u][1]:mex[u][0];
	}
	last=(mex[a[len]][0]==last)?mex[a[len]][1]:mex[a[len]][0];
	return x==last;
}
bool judge(){
	for(int i=1;i<=len;i++)
		dfs(a[i],0);
	return run(mex[a[len]][0])||run(mex[a[len]][1]);
}
int main(){
	readData();
	findCircle(1);
	puts(judge()?"POSSIBLE":"IMPOSSIBLE");
	return 0;
}

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

int main(){
    char a[1003];
    cin >> a;

    int l;
    l = strlen(a);
    if(strncmp(&a[l-1], "s", 1) == 0){
        a[l] = 'e';
        a[l+1] = 's';
        a[l+2] = '\0';
    }else{
        a[l] = 's';
        a[l+1] = '\0';
    }
    cout << a;
}


Measured memory_bytes: 3608
n, k = map(int, input().split())
p = list(map(int,input().split()))
val = 0
atai = 0
val2 = 0
for i in range(k):
    val2 += p[i]
#print(val2)
val = val2
for i in range(k,n):
    if val < val2:
        val = val2
        atai = i-k+1
    #print(i,p[i],p[i-k])
    val2 += p[i]
    
    val2 -= p[i-k]
    #print(val2)
    if val < val2:
        val = val2

        atai = i-k+1
#print(atai)

#print(atai)
ans = 0
for i in range(k):
    ans += (p[atai]+1)/2
    atai += 1
    #print(atai)
    #print(kitai)
print(ans)

Measured memory_bytes: 71792
def dynamicprogramming():
  N, W = map(int, input().split())
  dp = [-1] * (W + 1)
  dp[0] = 0
  for _ in range(N):
    w, v = map(int, input().split())
    for i in range(W - w, -1, -1):
        dpi = dp[i]
        if dpi != -1:
          if dp[i + w] < dpi + v:
            dp[i + w] = dpi + v
  print(max(dp))

dynamicprogramming()

Measured memory_bytes: 7724
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int, int> P;
int main()
{
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++)
    cin >> A[i] >> B[i];
  vector<P> vc;
  for (int i = 0; i < N; i++)
    vc.push_back(P(A[i] + B[i], i));
  sort(vc.rbegin(), vc.rend());
  long ans = 0;
  for (int i = 0; i < N; i++)
  {
    if (i % 2 == 0)
      ans += A[vc.at(i).second];
    else
      ans -= B[vc.at(i).second];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2168
#include <iostream>
#include <limits>

using namespace std;

int make_sum(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n = n / 10;
    }

    return sum;
}

int main() {
    int n;
    cin >> n;
    int min_sum = numeric_limits<int>::max();
    for (int i = 1; i < n; ++i) {
        int sum_a = make_sum(i);
        int sum_b = make_sum(n - i);
        int sum = sum_a + sum_b;
        if (sum < min_sum) min_sum = sum;
    }
    cout << min_sum << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  int cnt = 0;
  for (int i = 0; i < N - 1; i++){
    if (S[i] == S[i + 1]){
      cnt++;
    }
  }
  cout << min(cnt + K * 2, N - 1) << endl;
}

Measured memory_bytes: 3748
n = int(input())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
count = 0
for i in range(n):
    c = min(a_list[i], b_list[i])
    a_list[i] -= c
    b_list[i] -= c
    count += c
    if b_list[i] > 0:
        c2 = min(a_list[i + 1], b_list[i])
        a_list[i + 1] -= c2
        count += c2
print(count)


Measured memory_bytes: 19156
#include <bits/stdc++.h>
#define ll long long
#define pet pair<int,int>
#define one first
#define two second

#ifdef debug
#define cin fin 
#define fileopen fin.open("test.txt");
#else
#define fileopen
#endif

#define int long long
#define big 1000000007
#define all(x) x.begin(),x.end()

using namespace std;

ifstream fin;

vector<vector<int>> primes;

int power(int a,int b,int m=big)
{
	if(b==0)
	return 1;

	int ans=power(a,b/2,m);
	if(b%2==0)
	return ans*ans%m;

	return ((a*ans)%m*ans)%m;
}

int inverse(int a,int m=big)
{
	return power(a,m-2,m);
}

int ceil(int a,int b)
{
	return (a-1)/b+1;
}

void init_prime()
{
	int size=1e6+1;
	primes.resize(1e6);

	for(int i=2;i<size;i++)
	{
		if(primes[i].size()==0)
		{
			for(int j=i;j<size;j+=i)
			primes[j].push_back(i);
		}
	}
}

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


/*_______________________________

			START
			FROM
			BELOW

		  #pragyanc2#
________________________________
*/

bool palin(string s)
{
    int l=0;
    int r = s.length()-1;

    while(l<r)
    {
        if(s[l]!=s[r])
        return false;

        l++;
        r--;
    }

    return true;
}

void solve()
{
    string s;
    cin >> s;

    string s1 = s.substr(0,(s.length()-1)/2);
    if(palin(s) && palin(s1))
    {
        cout << "Yes\n";
    }
    else 
    cout  << "No\n";
}

signed main()
{
	fileopen
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	//init_prime();

	int t=1;
	//cin >> t;

	for(int i=1;i<=1;i++)
	solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

int main(){
	int r,g,b;
	cin>>r>>g>>b;
	if((r*100+g*10+b)%4==0){
		cout<<"YES"<<endl;
	}
	else
		cout<<"NO"<<endl;
	
	return 0;
}

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

int main(){
  int N;
  //int x[365],y[365],b[365],p[365];
  int x,y,b,p;
  
  cin >> N;
  
  for(int i = 0;i<N;++i){
    cin >> x >> y >> b >> p;

    
    if(b >= 5 && p >= 2){
      cout << (x*b + y*p)*0.8 << endl;
    }else{
      if(b<= 5 && p <= 2){
	if(b*x + p*y >= (x*5 + y*2)*0.8){
	  cout << (x*5 + y*2)*0.8 << endl;
	}else{
	  cout << b*x + y*p << endl;
	}
      }else if(b> 5){
	if(b*x + p*y >= (b*x + y*2)*0.8){
	  cout << (b*x + y*2)*0.8 << endl;
	}else{
	  cout << b*x + p*y << endl;
	}
      }else{
	if(b*x + p*y >= (x*5 + p*y)*0.8){
	  cout << (x*5 + p*y)*0.8 << endl;
	}else{
	  cout << b*x + p*y << endl;
	}
      }
    }
  }
  return 0;
}



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

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int ball[10];
		for(int i = 0; i < 10; i++)cin >> ball[i];
		int b = 0,c = 0;
		for(int i = 0; i < 10; i++){
			if(b > ball[i] && c > ball[i]){
				cout << "NO" << endl;
				goto no;
			}else if(b < ball[i] && c > ball[i])b = ball[i];
			else if(b > ball[i] && c < ball[i])c = ball[i];
			else if(b > c)b = ball[i];
			else c = ball[i];
		}
		cout << "YES" << endl;
		no:;
	}
}


Measured memory_bytes: 3076
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define ll long long
#define INF 1000000000
#define clr(x) memset(x,0,sizeof(x))
using namespace std;

inline int read()
{
	register int ret=0,c=getchar();
	while(!isdigit(c))c=getchar();
	while(isdigit(c))ret=ret*10+c-'0',c=getchar();
	return ret;
}

#define M 100005

int n,fa[M],sg[M];
int first[M],lext[M<<1],to[M<<1],t;

void addedge(int s,int v)
{
	lext[++t]=first[s];
	first[s]=t;
	to[t]=v;
}

void dfs(int x)
{
	for(int i=first[x];i;i=lext[i])
	{
		int v=to[i];
		if(v==fa[x])continue;
		fa[v]=x;
		dfs(v);
		sg[x]^=sg[v]+1;
	}
}

int main()
{
	n=read();
	for(int i=1;i<n;i++)
	{
		int x=read(),y=read();
		addedge(x,y);
		addedge(y,x);
	}
	dfs(1);
	if(sg[1]==0)puts("Bob");
	else puts("Alice");
	return 0;
}

Measured memory_bytes: 7552
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <string>
using u8t = std::uint64_t;
using i8t = std::int64_t;
#define F(I,N) for(i8t I=0,I##_N=N;I<I##_N;I++)
#define FR(I,N) for(i8t I=N;I--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;

i8t div_ceil(i8t a, i8t b) {
  return (a + b -1)/ b;
}

int main() {
  R(A)R(B)R(N);
  i8t mx=0;
  if(N>=B)N=B;
  for(i8t x=1;x<=N;){
    mx=std::max(mx,A*x/B - A*(x/B));
    auto next_floor1_num=(A*x/B+1)*B;
    auto next_floor2_num=(x/B+1)*B;
    auto x1 = div_ceil(next_floor1_num, A);
    x=std::min(x1,next_floor2_num);
  }
  P(mx);
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }



signed main(){

    int N; cin >> N;
    string S; cin >> S;
    int Q; cin >> Q;
    vec k(Q); readv(k);

    vec D(0), C(0);
    REP(i, N){
        if(S[i] == 'D') D.push_back(i);
        //else if(S[i] == 'M') M.push_back(i);
        else if(S[i] == 'C') C.push_back(i);
    }
    vec nuM(N + 1);
    nuM[0] = 0;
    REP(i, N){
        if(S[i] == 'M') nuM[i + 1] = nuM[i] + 1;
        else nuM[i + 1] = nuM[i];
    }
    vec nuC(N + 1);
    nuC[0] = 0;
    REP(i, N){
        if(S[i] == 'C') nuC[i + 1] = nuC[i] + 1;
        else nuC[i + 1] = nuC[i];
    }

    vec hito(C.size() + 1);
    hito[0] = 0;
    REP(i, C.size()) hito[i + 1] = hito[i] + nuM[C[i] + 1]; 

    REP(q, Q){
        int ans = 0;
        REP(i, D.size()){
            int j = Lower_bound(C, D[i] + k[q]) - 1;
            int l = Lower_bound(C, D[i]);
            if(j >= 0 && l < N && D[i] <= C[j]){
                //cout << D[i] << "," << C[j] << endl;
                //ans += nuM[C[j] + 1] - nuM[D[i]];
                ans += hito[j + 1] - hito[l] - nuM[D[i] + 1] * (nuC[C[j] + 1] - nuC[D[i]]);
            }
        }
        cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 33012
import bisect 

n = int(input())
l = list(map(int, input().split()))
l.sort()
cnt = 0
for i in range(n-1):
    for j in range(i+1,n):
        a = l[i]
        b = l[j]
        k1 = bisect.bisect_left(l,a+b)
        ab = abs(a-b)
        k0 = bisect.bisect_right(l,ab)
        cnti = k1 - k0 
        if k0 <= i and i <= k1:
            cnti -= 1
        if k0 <= j and j <= k1:
            cnti -= 1       
        #print(a,b,cnti)
        cnt += cnti
print(cnt//3)

Measured memory_bytes: 50392
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
 
using namespace std;

signed main()
{
    fast;
    int n;
    cin>>n;

    vector<int> a(n);
    map<int,int> mp;
    for ( int i = 0 ; i < a.size() ; i++ )
    {
        cin>>a[i];
        mp[a[i]]++;
    }

    for ( map<int,int>::iterator it = mp.begin() ; it != mp.end() ; it++ )
    {
        if ( it->second <= 1 )
        {
            mp.erase(it);
        }
    }

    int psum = 0;
    int s[n+1];
    memset(s,0,sizeof(s));
    for ( map<int,int>::iterator it = mp.begin() ; it != mp.end() ; it++ )
    {
        psum += it->second*(it->second-1)/2;
        s[it->first] = it->second*(it->second-1)/2;
    }
    for ( int i = 0 ; i < a.size() ; i++ )
    {
        int sum = 0;
            // for ( map<int,int>::iterator it = mp.begin() ; it != mp.end() ; it++ )
            // {
            //     if ( it->first == a[i] )
            //     {
            //         sum += (it->second-1)*(it->second-2)/2;
            //     }
            //     else
            //     {
            //         sum += (it->second)*(it->second-1)/2;
            //     }
            // }

            if ( mp[a[i]] != 0 )
            {
                sum += psum - s[a[i]] + (mp[a[i]]-1)*(mp[a[i]]-2)/2;
            }
            else
            {
                sum += psum;
            }

        cout<<sum<<endl;
    }
    return 0;
}

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


int main() {
int N;
cin>>N;
vector<int> a(100005);
for(int i=0;i<N;i++){
  int x;
  cin>>x;
  a[x]++;
}
int Q;
cin>>Q;

vector<int> b(Q);
vector<int> c(Q);
for(int i=0;i<Q;i++) cin>>b[i]>>c[i];

long ans=0;
for(int i=0;i<100005;i++) ans+=a[i]*i;
//cout<<ans<<endl;
for(int i=0;i<Q;i++){
long s=b[i],t=c[i];

ans=ans-s*a[s]-t*a[t];
long u=a[s];
a[s]=0;
a[t]+=u;
ans+=t*a[t];

cout<<ans<<endl;
}

}


Measured memory_bytes: 4544
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	var count, max int
	for _, v := range s {
		if v == 'A' || v == 'C' || v == 'G' || v == 'T' {
			count ++
		} else {
			count = 0
		}
		if count > max {
			max = count
		}
	}

	fmt.Println(max)
}


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

#define TRUE	1
#define FALSE	0

int isPrime(int n)
{
	int i, lim, flag;

	if (n == 2)     return TRUE;
	if (n < 2)      return FALSE;
	if (n % 2 == 0) return FALSE;
	lim = sqrt(n) + 1;
	flag = 0;
	for (i = 3; i < lim; i += 2) {
		if (n % i == 0) {
			flag = 1;
			break;
		}
	}
	if (flag == 1)
		return FALSE;
	else
		return TRUE;
}

int main(void)
{
	int n, num, i, c = 0;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &num);
		if (isPrime(num)) {
			c++;
		}
	}
	printf("%d\n", c);

	return 0;
}



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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    string S; cin >> S;
    int ans = INF;
    REP(i,S.size()-2){
        int x = 100*(S[i]-'0') + 10*(S[i+1]-'0') + (S[i+2]-'0');
        ans = min(ans, abs(753-x));
    }

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

Measured memory_bytes: 3628
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int posC = str.length() + 5;
        for(int i = 0;i < str.length();i++){
            if(str.charAt(i) == 'C'){
                posC = i;
                break;
            }
        }
        for(int i = str.length() - 1;i >= 0;i--){
            if(str.charAt(i) == 'F'){
               if(posC < i){
                   System.out.print("Yes");
               }
                else System.out.print("No");
                return;
            }
        }
         System.out.print("No");
    }
}

Measured memory_bytes: 8148
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out
ll gcd(ll x, ll y){
    ll t;
    while(y != 0){
        t = x%y; x = y; y = t;
    }
    return x;
}
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}
int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll divc,divd,divcd,cd;
    cd=lcm(c,d);
    divc=b/c-(a-1)/c;
    divd=b/d-(a-1)/d;
    divcd=b/(cd)-(a-1)/(cd);
    cout<<(b-a+1)-divc-divd+divcd<<endl;
    // cout<<" "<<divc<<" "<<divd<<" "<<divcd<<endl;
//////////////////////////////////////////////////////
return 0;}

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

using namespace std;
typedef long long ll;

const int N = int(1e8) + 7;

void init(){

}

void solve(){
    int n;
    int A[24];
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
        scanf("%d", &A[i]);
    int ans = 0;
    for(int i = 0; i < n; i++){
        int b;
        scanf("%d", &b);
        if(b < A[i]) ans += A[i]-b;
    }
    printf("%d\n", ans);

}

const bool mtc = false;

int main(){
    int t;
    if(mtc){
        scanf("%d", &t);
        while(t--) solve();
    }
    else solve();
}


Measured memory_bytes: 256
S=input()[::-1]

preS=''
while len(S)!=0 and S!=preS:
    preS = S;
    pre = S[:7]
    if pre[:7][::-1] == 'dreamer':
        S=S[7:]
    elif pre[:6][::-1] == 'eraser':
        S=S[6:]
    elif pre[:5][::-1] == 'dream':
        S=S[5:]
    elif pre[:5][::-1] == 'erase':
        S=S[5:]

if len(S)==0:
    print('YES')
else:
    print('NO')


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

int N, K;


bool flag[10] = {false};

bool check(int n){
    while(n > 0){
        if(flag[n % 10] == true){
            return false;
        }else{
            n /= 10;
        }
    }
    return true;
}

int main(){
    cin >> N >> K;
    int num = 0,n;
    
    for(int d = 0; d < K; d++) {
        cin >> num;
        flag[num] = true;
    }

    for(n = N; n < 100000; n++){
        if(check(n) == true){
            break;
        }
    }
    
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
R,G,B,N = map(int,input().split())

ans = 0
balls = N
for r in range(0,(balls//R)+1):
  balls_r = balls - R*r
  for g in range(0,(balls_r//G)+1):
    balls_g = balls_r - G*g
    if (balls_g >= 0) and (balls_g % B == 0):
      ans += 1

print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    int N,a[100],i,k,j,t;
    scanf("%d",&N);
    for(i=0;i<N;i++)
        scanf("%d",&a[i]);
    for(t=0;t<N-1;t++)
            printf("%d ",a[t]);
        printf("%d\n",a[t]);
    for(i=1;i<N;i++)
    {
        k=a[i];
        j=i-1;
        while(j>=0&&a[j]>k)
        {
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=k;
        for(t=0;t<N-1;t++)
            printf("%d ",a[t]);
        printf("%d\n",a[t]);
    }
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;
const int mod = 1e9 + 7;

int main(){
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

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

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> h(n);
    vector<ll> near(n);
    rep(i,n) cin >> h[i];
    rep(i,m){
        ll a, b;
        cin >> a >> b;
        --a; --b;
        near[a] = max(near[a],h[b]);
        near[b] = max(near[b],h[a]);
    }
    ll cnt = 0;
    rep(i,n){
        if(h[i] > near[i]) cnt++;
    }
    cout << cnt << endl;

}

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


int main(){         //回答見た

    int K, N;
    scanf("%d %d", &K, &N);

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

    int tmp = 0;
    for(i = 0; i<N-1; i++){
        if((A[i+1]-A[i]) > tmp){
            tmp = A[i+1]-A[i];
        }
    }
    if(A[0] + (K-A[i]) > tmp){
        tmp = A[0] + (K-A[i]);
    }

    printf("%d",K-tmp);

   return 0;
}

Measured memory_bytes: 1024
#include <iostream>
int main()
{
    int a,b,c,k;
    std::cin >> a >> b >> c >>k;
    if(k<=a) std::cout << k << std::endl;
    else if(k<=a+b) std::cout << a << std::endl;
    else std::cout << a-(k-a-b) << std::endl;
    return 0;
}

Measured memory_bytes: 3508
package main

import "fmt"

func main() {
	var h1, h2, m1, m2, k int
	fmt.Scan(&h1, &m1, &h2, &m2, &k)

	s := h1*60 + m1
	e := h2*60 + m2
	r := e - k - s

	fmt.Println(r)
}


Measured memory_bytes: 1752
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

N,M = map(int,input().split())
A = [int(i) for i in input().split()]
change = [0 for i in range(M)]
for i in range(M):
    change[i] = [int(i) for i in input().split()]

D = []
change = sorted(change,key=lambda x:x[1],reverse=True)
for i in range(M):
    b,c = change[i]
    # for j in range(b):
    #     D += [c]
    D += [c]*b
    if len(D) > N:
        break

A += D
A.sort(reverse=True)
print(sum(A[:N]))


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

int main()
{
    int a , b , c ;
    cin >> a >> b >> c ;
    cout << a <<" "<< b <<" "<< 3*c-a-b <<" "<< endl ;
    cout << 4*c-2*a-b <<" "<< c <<" "<< 2*a+b-2*c <<" "<< endl ;
    cout << a+b-c <<" "<< 2*c-b <<" "<< 2*c-a <<" "<< endl ;
    return 0 ;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
    	try(Scanner sc = new Scanner(System.in)) {
    		int N = sc.nextInt();
    		int W = sc.nextInt();
    		//dp[重さ] = max 価値
    		long[] dp = new long[W+1];
    		int[] v = new int[N];
    		int[] w = new int[N];
    		for(int i=0; i<N; i++) {
    			v[i] = sc.nextInt();
    			w[i] = sc.nextInt();
    		}
    		for(int i=0; i<W+1; i++) {
    			dp[i] = 0;
    		}
    		for(int i=0; i<N; i++) {
    			for(int j=W; j>0; j--) {
    				if(j-w[i] >= 0)
    					dp[j] = Math.max(dp[j], dp[j-w[i]]+v[i]);
    			}
    		}
    		System.out.println(dp[W]);

    	}
    }

}




Measured memory_bytes: 27096
'use strict'
function main(input) {
    const tmp = input.split('\n');
    const N = parseInt(tmp[0], 10);
    const L = tmp[1].split(' ').map((elem) => parseInt(elem, 10));

    const longestSide = L.reduce((max, elem) => Math.max(max, elem));
    L.splice(L.indexOf(longestSide), 1);
    const sumOfRest = L.reduce((sum, elem) => sum + elem);
    if (longestSide < sumOfRest) {
        console.log('Yes');
    } else {
        console.log('No');
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7496
from itertools import permutations
import math
n = int(input())
x,y = [],[]
for _ in range(n):
    x_, y_ =map(int,input().split())
    x.append(x_)
    y.append(y_)
c = list(permutations([i for i in range(1,n+1)],n))
sum = 0
for ci in (c):
    tmp = 0
    for i in range(len(ci)-1):
            tmp += math.sqrt((x[ci[i]-1]-x[ci[i+1]-1])**2 
                             + (y[ci[i]-1]-y[ci[i+1]-1])**2)
    sum += tmp
print(sum/len(c))

Measured memory_bytes: 13780
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S; cin >> S;
  vector<char> az(26);
  for(int i = 0; i < 26; i++) {
    int x = (int)'a' + i;
    az.at(i) = (char)x;
  }
  for(int i = 0; i < az.size(); i++) {
    if(S.find(az.at(i)) == string::npos) {
      cout << az.at(i) << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>

int main(){
    int n;
    std :: cin >> n;
    std :: string str;
    std :: cin >> str;
    for(auto i : str)
        std :: cout << (char)((((i - 'A') + n) % 26) + 'A');
    std :: cout << '\n';
}


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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int pre = -999;
    rep(i,n){
        if(pre <= a[i] - 1){
            pre = a[i] - 1;
        } else if(pre <= a[i]){
            pre = a[i];
        } else {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(){
  int n,i;
  int a[1000];

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

    printf("\n");
}
return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VI a,b;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  a.resize(n);
  b.resize(n);
  forn(i,n)
    b[n-1-i]=a[i]=2+i*(n+5);
  in p;
  forn(i,n){
    cin>>p;
    --p;
    a[p]+=i;
    b[p]+=i;
  }
  forn(i,n)
    cout<<a[i]<<" ";
  cout<<"\n";
  forn(i,n)
    cout<<b[i]<<" ";
  cout<<"\n";
  return 0;
}


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

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

    int count = 0;
    double sum = 0;
    for(int i=0;i<n;++i){
        if(a[i] < 0){
            ++count;
            a[i] = -a[i];
        }
        sum += a[i];
        //cout<<sum<<" ";
    }
    sort(a, a + n); 
    if(count%2 == 1)sum -= a[0]*2;

    //cout<<endl;
    cout<<fixed<<setprecision(0)<<sum;
}

Measured memory_bytes: 1024
var n,k,i,j,s,t,p:longint;
    r:array[0..200000]of longint;
procedure quickly_sort(var a:array of longint;l,r:longint);inline;
var i,j,x,y:longint;
begin
  while true do
  begin
    if r<l+74 then
      exit;
    i:=l;j:=r;
    x:=a[(l+r)>>1];
    repeat
      while a[i]<x do inc(i);
      while x<a[j] do dec(j);
      if not(i>j) then
      begin
        y:=a[i];a[i]:=a[j];
        a[j]:=y;inc(i);dec(j);
      end;
    until i>j;
    if l<j then quickly_sort(a,l,j);
    if not(i<r) then
      exit;
    l:=i;
  end;
end;
procedure sort(var a:array of longint;l,r:longint);inline;
var i,j,t:longint;
begin
  if r>l then
  begin
    quickly_sort(a,l,r);
    i:=l;
    for i:=l to r do
    begin
      j:=i; 
      while j>pred(l) do
        if a[j]<a[pred(j)] then
        begin
          t:=a[pred(j)];a[pred(j)]:=a[j];a[j]:=t;
          dec(j);
        end
        else
          break;
    end;
  end;
end;
begin
  readln(n,k);
  for i:=1 to n do
  begin
    read(t);
    inc(r[t]);
  end;
  sort(r,0,n);
  for i:=n downto n-k+1 do
    dec(n,r[i]);
  writeln(n);
end.

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

using ll = long long int;

int main(){
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k-1] << endl;
    return 0;
}


Measured memory_bytes: 256
for i in range(int(input())):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())

    if x2 == x1 and x4 == x3:
        print('YES')
        continue

    if x2 == x1 or x4 == x3:
        print('NO')
        continue

    if abs((y2-y1)/(x2-x1) - (y4-y3)/(x4-x3)) < 1e-10:
        print('YES')
    else:
        print('NO')



Measured memory_bytes: 5604
n = int(input())
a = 0
b = 0
ba = 0
ans = 0
for i in range(n):
    s = input()
    ans += s.count('AB')
    if s[0] == "B" and s[-1] == "A":
        ba += 1
    elif s[0] == "B":
        b += 1
    elif s[-1] == "A":
        a += 1
        
if ba == 0:
    ans += min(a,b)
elif ba != 0:
    if a == 0 and b == 0:
        ans += ba-1
    else:
        ans += ba + min(a,b)
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
  
int main()
{
  string s;
  cin >> s;
  int N = s.size();

  int MIN = INF;
  FOR(i,'a','z'+1){
    int MAX = 0;
    int p = -1;
    REP(j,s.size()){
      if(i==s.at(j)){
        MAX = max(MAX,j-p-1);
        p=j;
      }
    }
    MAX = max(MAX,N-1-p);
    MIN = min(MAX,MIN);
  }


  cout << MIN << endl;
}

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

int main() {
  string a,b;
  cin >> a >> b;
  if(a=="H"){
    if(b=="H"){
      cout << "H" << endl;
    }
    else{
      cout << "D" << endl;
    }
  }
  else{
    if(b=="H"){
      cout << "D" << endl;
    }
    else{
      cout << "H" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int asc(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}

int main()
{	
	int n, p[25], ans = 0;
	cin >> n;
	rep(i, n) cin >> p[i];
	for (int i = 1; i < n-1; i++) {
		if (p[i - 1] < p[i] && p[i] < p[i + 1]) ans++;
		else if (p[i + 1] < p[i] && p[i] < p[i - 1]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def Some_Sums(n , a , b):

    ans = 0

    for i in range(1 , n + 1):
        s = str(i)
        array = list(map(int , s))
        if a <= sum(array) and sum(array) <= b:
            ans += i

    return ans

def main():
    n , a , b = map(int , input().split())
    print(Some_Sums(n , a , b))

if __name__ == '__main__':
    main()


Measured memory_bytes: 41580
<?php
fscanf(STDIN, '%d', $d);

if ($d === 25) {
    $ans = 'Christmas';
} elseif ($d === 24) {
    $ans = 'Christmas Eve';
} elseif ($d === 23) {
    $ans = 'Christmas Eve Eve';
} else {
    $ans = 'Christmas Eve Eve Eve';
}
echo $ans;

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N; cin>>N;
    vector<int> A(N); rep(n,0,N) cin>>A.at(n);

    bool cnt=true;
    int ans=0;
    while(1){
        rep(n,0,N){
            if(A.at(n)%2) cnt=false;
            else A.at(n)/=2;
        }
        if(cnt) ans++;
        else break;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize(3)
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
	/*
	int n,m;
	cin>>n>>m;
	cout<<(n+m-1)/m;*/
	ll n,m,a=0;
	cin>>n>>m;
	rep(i,m){
		int x;
		cin>>x;
		a+=x;
	}
	//cout<<a<<endl;
	if(a>=n)cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io();
    ll n, d; cin >> n >> d;
    d += d;
    ++d;
    if(n % d == 0){
        cout << n/d << '\n';
    }else{
        cout << n/d  + 1 << '\n';
    }
    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
vector<Int> gen(Int v0,Int vd,Int len,Int mod){
  vector<Int> vs(len);
  vs[0]=v0;
  for(Int i=0;i+1<len;i++)
    vs[i+1]=(vs[i]*58+vd)%(mod+1);
  return vs;
}

signed main(){
  Int m,n,m0,md,n0,nd;
  cin>>m>>n>>m0>>md>>n0>>nd;
  vector<Int> ms=gen(m0,md,m,n);
  vector<Int> ns=gen(n0,nd,n,m);
  if(0){
    for(Int i=0;i<m;i++) cout<<ms[i]<<" ";  
    cout<<endl;
    for(Int i=0;i<n;i++) cout<<ns[i]<<" ";
    cout<<endl;
  }

  Int ans=0;
  sort(ms.rbegin(),ms.rend());
  
  vector<Int> cnt(m+1,0);
  for(Int v:ns) cnt[v]++;
  cnt.erase(cnt.begin());

  Int sum=0;
  vector<Int> rev;

  for(Int x:ms){
    if(x==0) break;
    if(rev.empty()&&cnt.empty()) break;
    
    while(!cnt.empty()&&sum<x){
      rev.emplace_back(cnt.back());
      sum+=cnt.back();
      cnt.pop_back();      
    }
    while(!rev.empty()&&sum-rev.back()>=x){
      cnt.emplace_back(rev.back());
      sum-=rev.back();
      rev.pop_back();
    }
    
    Int res=min(sum,x);
    ans+=res;
    if(sum>=x){
      Int dif=sum-x;
      assert(!rev.empty());
      assert(rev.back()>=dif);

      if(rev.size()>=2u){
        rev[rev.size()-1]-=dif;
        rev[rev.size()-2]+=dif;
      }else{
        Int nxt=rev[0]-dif;
        rev[0]=dif;
        rev.emplace_back(nxt);
      }
      
      if(cnt.empty()){
        sum-=rev.back();
        rev.pop_back();
      }else{
        rev.back()+=cnt.back();
        sum+=cnt.back();
        cnt.pop_back();
      }
    }else{
      assert(cnt.empty());
      sum-=rev.back();
      rev.pop_back();
    }
  }
  
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 94500
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

const int maxn = 110;
const int INF = 0x3f3f3f3f;
const int mod = 1e9; 

char MAP[maxn][maxn];
bool use[maxn][maxn];
int N,M;
const int way[4][2] = {1,0,-1,0,0,1,0,-1};
bool check(int x,int y)
{
	return x >= 1 && x <= N && y >= 1 && y <= M ;
}
void dfs(int x,int y)
{
	use[x][y] = 1;
	for(int i = 0; i < 4 ; i ++)
	{
		int X = x + way[i][0];
		int Y = y + way[i][1];
		if(check(X,Y) && !use[X][Y] && MAP[X][Y] == MAP[x][y])
		{
			dfs(X,Y);
		}
	}
}
int main()
{
	while(~scanf("%d%d",&N,&M) && (N || M))
	{
		for(int i = 1; i <= N ; i ++)
		{
			for(int j = 1; j <= M ; j ++)
			{
				cin >> MAP[i][j];
			}
		}
		memset(use,0,sizeof(use));
		int sum = 0;
		for(int i = 1; i <= N ; i ++)
		{
			for(int j = 1; j <= M ; j ++)
			{
				if(!use[i][j])
				{
					dfs(i,j);
					sum++;
				}
			}
		}
		printf("%d\n",sum);
	}
	return 0;
}


Measured memory_bytes: 3620
import sys
d={}
f=0
for s in sys.stdin:
    if f==0:
        a,b=map(int,s.split(","))
        if a!=0 or b!=0:d[a]=b
        else:
            x=sorted(set(d.values()))[::-1]
            f=1
    else:print x.index(d[int(s)])+1

Measured memory_bytes: 4208
import java.util.TreeSet;

public class Main {

  private static void solve() {
    int n = ni();
    int[] a = na(n);

    TreeSet<int[]> set = new TreeSet<>((o1, o2) -> {
      if (o1[1] == o2[1])
        return o2[0] - o1[0];
      return o1[1] - o2[1];
    });

    int[][] b = new int[n][];
    for (int i = 0; i < n; i++) {
      b[i] = new int[] {i, a[i]};
    }

    for (int[] v : b) {
      int[] u = set.lower(v);
      if (u == null) {
        set.add(v);
      } else {
        set.remove(u);
        set.add(v);
      }
    }
    System.out.println(set.size());
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 49012
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

x=123
ans=0
for i in range(n):
  ans+=b[a[i]-1]
  if x+1==a[i]:
    ans+=c[x-1]
  x=a[i]
print(ans)

Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))
 
res = True
cnt = 0
 
while res:
    for i in range(n):
        if a[i]%2 != 0:
            res = False
            break
 
        a[i] = a[i]/2
 
    if res:
        cnt += 1
 
print(cnt)

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define PI 3.1415926535898

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

int main() {
    string n;
    cin >> n;
    int f = 0;
    rep(i, n.length()) f += (int) (n[i] - '0');
    Yes(stoi(n) % f == 0);

    return 0;
}



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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    long long n;
    cin >> n;
    
    long long ans = LLONG_MAX;
    for (long long i = 1; i <= sqrt(n); i++){
        if (n % i == 0){
            long long x = n / i;
            ans = min(ans, x + i - 2);
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int N;
vector<vector<P>> v;

bool judge(int bit) {
  rep(i, N) {
    if(!(bit & (1<<i))) continue;

    for(P xy: v[i]) {
      int x = xy.first;
      int y = xy.second;
      if(y == 1 && !(bit & (1<<x))) return false;
      if(y == 0 && (bit & (1<<x))) return false;
    }
  }
  return true;
}

int main() {
  cin >> N;
  v.resize(N);
  rep(i, N) {
    int A; cin >> A;
    v[i].resize(A);
    rep(j, A) {
      cin >> v[i][j].first >> v[i][j].second;
      v[i][j].first--;
    }
  }

  int res =0;
  rep(bit, (1<<20)) {
    if(judge(bit)) {
      int count = 0;
      for(int i = 0; i < N; i++) {
        if(bit & (1<<i)) count++;
      }
      res = max(res, count);
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256