akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  int D;
  cin >> D;
  if(D == 25) print("Christmas");
  else if(D == 24)print("Christmas Eve");
  else if(D == 23) print("Christmas Eve Eve");
  else if(D == 22) print("Christmas Eve Eve Eve");

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main(){    
    int N;
    cin >> N;
    double x[N], y[N];
    double dist[N][N]; 

    for(int i = 0; i < N; i++){
        cin >> x[i] >> y[i];
    }

    double sum = 0;

    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(i != j){
                sum += sqrt((x[j] - x[i])*(x[j] - x[i]) + (y[j] - y[i])*(y[j] - y[i]));
            }
        }
    }

    cout << fixed << setprecision(10) << sum/N << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
//https://atcoder.jp/contests/abc135/tasks/abc135_c
//city savers
class Main
{
	public static void main(String args[])throws IOException
	{
		double n,max=0,i;
		Scanner sc=new Scanner(System.in);
		n=sc.nextDouble();
		double a[]=new double[(int)n+1];
		double b[]=new double[(int)n];
		for( i=0;i<n+1;i++)
		{
			a[(int)i]=sc.nextDouble();
		}

		for( i=0;i<n;i++)
			b[(int)i]=sc.nextDouble();
		for( i=n-1;i>=0;i--)
		{
			if(b[(int)i]<=a[(int)i+1])
			{
				max+=b[(int)i];
				a[(int)i+1]-=b[(int)i];
				b[(int)i]=0;

				
			}
			else if(b[(int)i]>a[(int)i+1])
			{
				max+=a[(int)i+1];
				b[(int)i]-=a[(int)i+1];
				a[(int)i+1]=0;
				if(b[(int)i]<=a[(int)i])
				{
					max+=b[(int)i];
					a[(int)i]-=b[(int)i];
					b[(int)i]=0;
				}
				else if(b[(int)i]>a[(int)i])
				{
					max+=a[(int)i];
					b[(int)i]-=a[(int)i];
					a[(int)i]=0;

				} 	
			}
			
		}
		
		System.out.println((long)max);
	}
}

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

typedef long long ll;

ll gcd( ll x, ll y );
ll lcm( ll x, ll y );

int main()
{
    int x, y;

    for ( int i = 0;i < 7; ++i ) {
        cin >> x >> y;
        cout << x - y << endl;
    }

    return 0;
}

ll gcd( ll x, ll y )
{
    if ( y == 0 ) return x;
    return gcd( y, x % y );
}

ll lcm( ll x, ll y )
{
    return x / gcd( x, y ) * y;
}




Measured memory_bytes: 3072
"use strict";

main(require("fs").readFileSync("/dev/stdin", "utf8"));

function main(input) {
  const [n, a, b] = input.trim().split(" ").map(Number);

  let ans = 0;
  for (let i = 1; i <= n; i++) {
    const sumOfEachDigit = String(i).split("").map(Number).reduce((p, c) => p + c);
    if (sumOfEachDigit >= a && sumOfEachDigit <= b) {
      ans += i;
    }
  }

  console.log(ans);
}


Measured memory_bytes: 10708
#include <stdio.h>
int main (void){
    int a,b,i,m,d,day,y[13]={31,29,31,30,31,30,31,31,30,31,30,31};
    for(;;){
        scanf("%d%d",&m,&d);
        if(m==0)break;
        day=0;
        a=y[m-1]-d;
        for(i=0;i<m;i++){
            day=day+y[i];
        }
        day=day-a;
        b=day%7;
        switch(b){
            case 0:printf("Wednesday\n");
            break;
            case 1:printf("Thursday\n");
            break;
            case 2:printf("Friday\n");
            break;
            case 3:printf("Saturday\n");
            break;
            case 4:printf("Sunday\n");
            break;
            case 5:printf("Monday\n");
            break;
            case 6:printf("Tuesday\n");
            break;
        }
    }
return 0;
}

Measured memory_bytes: 584
#include "bits/stdc++.h"
#define lpa(i,a,b) for(int i=a; i<b; ++i)
#define lp(i,n) lpa(i,0,n)
using namespace std;
int main()
{
	long long n,a,b,c,d,flag=0;
	cin>>n>>a>>b>>c>>d;
	lp(i,n) if(i*c-d*(n-1-i)<=(b-a) && (b-a)<=i*d-(n-1-i)*c) flag=1;
	if(flag==1) cout<<"YES";
	else cout<<"NO";
}

Measured memory_bytes: 256
#ifndef UNION_FIND_HPP
#define UNION_FIND_HPP

#include <vector>
#include <utility>

//===
struct UnionFind {
    std::vector<int> parent;

    UnionFind() = default;
    UnionFind(int nmemb) {
        init(nmemb);
    };

    void init(int nmemb) {
        parent.clear();
        parent.resize(nmemb, -1);
    };

    int root(int x) {
        if (parent[x] < 0) return x;
        return parent[x] = root(parent[x]);
    };

    void unite(int x, int y) {
        x = root(x);
        y = root(y);

        if (x == y) return;

        if (parent[y] < parent[x]) std::swap(x, y);

        parent[x] += parent[y];
        parent[y] = x;
        
        return;
    };
    
    bool same(int x, int y) {
        return root(x) == root(y);
    };
    int size(int x) {
        return -(parent[root(x)]);
    };
};
//===

#endif
#define _overload(_1, _2, _3, _4, name, ...) name
#define _rep1(Itr, N) _rep3(Itr, 0, N, 1)
#define _rep2(Itr, a, b) _rep3(Itr, a, b, 1)
#define _rep3(Itr, a, b, step) for (llong (Itr) = a; (Itr) < b; (Itr) += step)
#define repeat(...) _overload(__VA_ARGS__, _rep3, _rep2, _rep1)(__VA_ARGS__)

#include <iostream>

using namespace std;
using llong = long long;

llong n, m;
llong a, b;
UnionFind uf(200005);

int main() {
    cin >> n >> m;
    repeat(i, m) {
        llong a, b;
        cin >> a >> b;
        uf.unite(a, b);
    }

    llong ans = 0;
    repeat(i, 1, n + 1) {
        ans = max<llong>(ans, uf.size(i));
    }
    cout << ans << endl;

    return 0;
};


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

using namespace std;
using LL = long long;
using VI = vector<int>;
using PI = pair<int, int>;

int main() {
	string s;
	cin >> s;
	string p = "print";
	string rev = "reverse";
	string rep = "replace";
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string q;
		int a, b;
		cin >> q;
		if (q == p) {
			cin >> a >> b;
			cout << s.substr(a, b - a + 1) << endl;;
		}
		else if (q == rev) {
			cin >> a >> b;
			for (int j = 0; j < (b - a + 1) / 2; j++) {
				swap(s[a + j], s[b - j]);
			}
		}
		else if (q == rep) {
			string t;
			cin >> a >> b >> t;
			for (int j = 0; j < b - a + 1; j++) {
				s[a + j] = t[j];
			}
		}
	}
	return 0;
}



Measured memory_bytes: 3216
S = list(input())
flag = 1
if "S" in S:
  if not("N" in S):
    flag = 0
if "N" in S:
  if not("S" in S):
    flag = 0
if "E" in S:
  if not("W" in S):
    flag = 0
if "W" in S:
  if not("E" in S):
    flag = 0
if flag:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 38256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;

#define MAX 25
#define NIL -1
struct Node { int p, l, r; };
Node T[MAX];
int n;

void preorder(int u) {
	if (u == NIL) return;
	cout << " " << u;
	preorder(T[u].l);
	preorder(T[u].r);
}

void inorder(int u) {
	if (u == NIL) return;
	inorder(T[u].l);
	cout << " " << u;
	inorder(T[u].r);
}

void postorder(int u) {
	if (u == NIL) return;
	postorder(T[u].l);
	postorder(T[u].r);
	cout << " " << u;
}


int main() {
	int root=0;
	int id = 0;
	int lft, rght;
	cin >> n;
	for (int i = 0; i < n; i++) T[i].p = NIL;
	for (int i = 0; i < n; i++) {
		cin >> id >> lft >> rght;
		T[id].l = lft;
		T[id].r = rght;
		if(lft !=NIL) T[lft].p = id;
		if(rght!=NIL) T[rght].p = id;
	}
	for (int i = 0; i < n; i++) if (T[i].p == NIL) root = i;
	cout << "Preorder" << endl;
	preorder(root);
	cout << endl;
	cout << "Inorder" << endl;
	inorder(root);
	cout << endl;
	cout << "Postorder" << endl;
	postorder(root);
	cout << endl;

}

Measured memory_bytes: 3072
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
from collections import defaultdict
d = defaultdict(int)
ans, t = 0, 0
for i in range(n):
  d[a[i]] += 1
  if d[a[i]]==2:
    d[a[i]] = 0
    ans = max(ans, t*a[i])
    t = a[i]
print(ans)

Measured memory_bytes: 18216
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.List
import           Data.Maybe

readInts :: IO [Int]
readInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

main = do
  _ <- BS.readInt <$> BS.getLine
  nums <- readInts
  putStrLn $ solve nums

solve :: [Int] -> String
solve nums
  | ans < 3 = "YES"
  | otherwise = "NO"
  where
    nums' = sort nums
    zipped = zip nums nums'
    ans = sum $ map f zipped
    f (x, y)
      | x == y = 0
      | otherwise = 1


Measured memory_bytes: 508
#ifndef TEMPLATE_HPP
#define TEMPLATE_HPP
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())
using namespace std;
using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void chmax(T &x, T y) { x = max(x, y); }
template <typename T> void chmin(T &x, T y) { x = min(x, y); }
template <typename T> T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename U> vector<U> make_vector(T&& n, U&& val) { return vector<U>(forward<T>(n), forward<U>(val)); }
template <typename T, typename... Args> decltype(auto) make_vector(T&& n, Args&&... args) { return vector<decltype(make_vector(forward<Args>(args)...))>(forward<T>(n), make_vector(forward<Args>(args)...)); }
const int INF = 1001001001;
const i64 LINF = 1001001001001001001ll;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
#endif

void solve() {
  int n;
  cin >> n;
  vi32 a(n), b(n);
  cin >> a >> b;
  i64 asum = accumulate(all(a), 0ll);
  i64 bsum = accumulate(all(b), 0ll);
  if (asum > bsum) {
    cout << "No" << endl;
  } else {
    i64 cnt = 0;
    rep(i, n) {
      cnt += max(0, b[i] - a[i] + 1) / 2;
    }
    if (cnt > bsum - asum) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#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 FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll N, K, T, W, H, M, C;

const int MAX = 510000;
const int MOD = 1e9;

const double PI=3.14159265358979323846;

/*
long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e12;

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}*/

int length(vector<int> v, int u, int HW){
    if(v.size() == 0) return HW;
    if(v[0] > u) return v[0];
    if(v[v.size() - 1] < u) return HW - v[v.size()- 1] -1;
    else{
        int i = lower_bound(ALL(v), u)- v.begin();
        return v[i] - v[i-1] -1;
    }
}

int st[200001], t[10000];

int main(){
    cin >>N;
    vector<pair<ll, ll>> v;
    REP(i,N){
        ll a,b; cin >> a>>b;
        v.push_back(make_pair(b,a));
    }
    sort(ALL(v));
    bool flag = true;
    ll t = 0;
    for(int i = 0; i < N; ++i){
        t += v[i].second;
        if(t > v[i].first) flag = false;
    }
    if(flag) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 6384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;



int main()
{
	ll n; cin>>n;
	ll N=n;
	ll x=n,y=1;
	for(ll i=2;i*i<=N;++i)
	{
		if(n%i!=0)continue;
		x=n/i;
		y=i;
		//cout<<x<<","<<y<<endl;
	}
	cout<<x+y-2<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>    
#include<cstdio>  
#include<stdio.h>  
#include<cstring>    
#include<cstdio>    
#include<climits>    
#include<cmath>   
#include<vector>  
#include <bitset>  
#include<algorithm>    
#include <queue>  
#include<map>  
using namespace std;


int main()
{
	int a[5], i,n;
	n = 3;
	for (i = 1; i <= 3; i++)
	{
		cin >> a[i];
	}
	if (a[2] - a[1] == a[3] - a[2])
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 888
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, Q = map(int, readline().split())
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, readline().split())
        G[a - 1].append(b - 1)
        G[b - 1].append(a - 1)

    P = [0] * N
    (*PX,) = map(int, read().split())
    for p, x in zip(*[iter(PX)] * 2):
        P[p - 1] += x

    def dfs(v, p):
        for nv in G[v]:
            if nv == p:
                continue
            P[nv] += P[v]
            dfs(nv, v)

    dfs(0, -1)

    print(' '.join(map(str, P)))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 296968
N = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(N-1):
    if a[i] > a[i+1] >= 0:
        a[i+1] += a[i]
        ans.append((i+1, i+2))
    if a[i] >= 0 > a[i+1] and a[i] + a[i+1] >= 0:
        a[i+1] += a[i] * 2
        ans.append((i+1, i+2))
        ans.append((i+1, i+2))
for i in range(N-1)[::-1]:
    if 0 >= a[i] > a[i+1]:
        a[i] += a[i+1]
        ans.append((i+2, i+1))
    if a[i] >= 0 > a[i+1]:
        a[i] += a[i+1] * 2
        ans.append((i+2, i+1))
        ans.append((i+2, i+1))
print(len(ans))
for x, y in ans:
    print(x, y)


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

struct TNode
{
	int Id;
	TNode* Parent;
	TNode* LChild;
	TNode* RChild;
};

//???????????????????????????TNode*???????????????(vector??????????????¢?????????????????????)
class TTable
{
private:
	vector<TNode*> FNodes;
	void Create(int Id)
	{
		if(FNodes[Id] == NULL){
			TNode* Node;
			Node = new TNode;
			*Node = {Id, NULL, NULL, NULL};
			FNodes[Id] = Node;
		}
	}
public:
	//TNode*?????????&?????????????????????????????????
	//????????????????????§delete????????????????????????????????????????????????????????¨?????????????????????????????????????????????
	//???????????????????????????Id??¨TNode*???????????????????????¨??§????????????????????????????????¨????????????????????????????????????
	TNode* operator[](int n)
	{
		Create(n);
		return FNodes[n];
	}
	TNode* operator[](int n)const
	{
		return FNodes[n];
	}
	TTable(int n)
	{
		//????´??????°???????????????
		FNodes.resize(n, NULL);
	}
	~TTable()
	{
		int n = FNodes.size();
		for(int i = 0; i < n; i++){
			delete FNodes[i];
		}
	}
	int size()const
	{
		return FNodes.size();
	}
};

enum TNodeType {Root, InternalNode, Leaf};

void CreateLeftRelation(TNode* ParentNode, TNode* LChildNode)
{
	ParentNode->LChild = LChildNode;
	LChildNode->Parent = ParentNode;
}

void CreateRightRelation(TNode* ParentNode, TNode* RChildNode)
{
	ParentNode->RChild = RChildNode;
	RChildNode->Parent = ParentNode;
}

void Input(TTable& Table)
{
	for(int i = 0; i < Table.size(); i++){
		int Id;
		cin >> Id;
		TNode* Node = Table[Id];
		int left;
		cin >> left;
		if(left != -1){
			CreateLeftRelation(Node, Table[left]);
		}
		int right;
		cin >> right;
		if(right != -1){
			CreateRightRelation(Node, Table[right]);
		}
	}
}

void PreorderOutput(const TNode* Node)
{
	if(Node == NULL) return;
	cout << ' ' << Node->Id;
	PreorderOutput(Node->LChild);
	PreorderOutput(Node->RChild);
}

void InorderOutput(const TNode* Node)
{
	if(Node == NULL) return;
	InorderOutput(Node->LChild);
	cout << ' ' << Node->Id;
	InorderOutput(Node->RChild);
}

void PostorderOutput(const TNode* Node)
{
	if(Node == NULL) return;
	PostorderOutput(Node->LChild);
	PostorderOutput(Node->RChild);
	cout << ' ' << Node->Id;
}

TNode* GetRootNode(TNode* Node)
{
	while(Node->Parent){
		Node = Node->Parent;
	}
	return Node;
}

void Output(const TTable& Table)
{
	TNode* Node = GetRootNode(Table[0]);
	cout << "Preorder"  << endl;
	PreorderOutput(Node);
	cout << endl;
	cout << "Inorder"   << endl;
	InorderOutput(Node);
	cout << endl;
	cout << "Postorder" << endl;
	PostorderOutput(Node);
	cout << endl;
}

int main()
{
	int n;
	cin >> n;
	TTable Table(n);
	Input(Table);
	Output(Table);
    return 0;
}

Measured memory_bytes: 3116
N=int(input())
slimes=input()
slime_list=[]
for s in slimes:
 slime_list.append(s)

slime=slime_list[0]
count=1
for s in slime_list:
 if (s!=slime):
  count+=1
  slime=s
 else:
  continue

print(count)

Measured memory_bytes: 4212
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;



int main() {
	int n, k;
	cin >> n >>k;
	string s;
	cin >> s;
	int cnt = 0;
	char lastChar = '1';
	vector<int> hs;
	for (int i = 0;i < n; i++) {
		
		if (s[i] != lastChar) {
			hs.emplace_back(cnt);
			cnt = 1;
			lastChar = s[i];
		}
		else {
			cnt++;
		}
	}
	hs.emplace_back(cnt);
	if (lastChar == '0') {
		hs.emplace_back(0);
	}
	


	int ans = 0;
	if (hs.size() <=2* k +1) {
		for (int i = 0; i < hs.size(); i++) {
			ans += hs[i];
		}
	}
	else {
		int sum = 0;
		for (int i = 0; i < 2*k+1; i++) {
			sum += hs[i];
		}
		
		ans = sum;
		for (int i = 0; i < hs.size() - 2 * (k + 1);i+=2) {
			sum += hs[i + 2 * (k + 1)] + hs[i + 2 * k + 1] - hs[i] - hs[i + 1];
			if (sum > ans) {
				ans = sum;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1020
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = LIST()

dp0 = list2d(N+1, 4, -INF)
dp1 = list2d(N+1, 4, -INF)
dp0[0][2] = 0
for i, a in enumerate(A):
    for j in range(4):
        if j != 0:
            dp0[i+1][j-1] = max(dp0[i+1][j-1], dp0[i][j])
            dp0[i+1][j-1] = max(dp0[i+1][j-1], dp1[i][j])
        if j != 3:
            dp1[i+1][j+1] = max(dp1[i+1][j+1], dp0[i][j] + a)
if N % 2 == 0:
    ans = max(dp0[N][2], dp1[N][2])
else:
    ans = max(dp0[N][1], dp1[N][1])
print(ans)


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

typedef long long int lli;

const lli MOD = 1e9 + 7;
int n, x, y, z;

lli dp[41][1 << 17];
lli ans[41];

bool valid(lli n) {
	return ((n&(1 << (x+y+z-1))) && (n&(1 << (y+z-1))) && (n&(1 << (z-1))));
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> x >> y >> z;

	const lli CAP = (1 << (x + y + z));

	for(int i = 0; i < 41; i++) {
		for(int j = 0; j < CAP; j++) {
			dp[i][j] = 0;
		}
		ans[i] = 0;
	}
	dp[0][0] = 1;

	for(lli i = 1; i <= n; i++) {
		for(lli j = 0; j < CAP; j++) {
			for(lli k = 1; k <= 10; k++) {
				lli newSig = ((j << k) | ((lli)1 << (k-1)));
				newSig %= CAP;
				dp[i][newSig] += dp[i-1][j];
				dp[i][newSig] %= MOD;
			}
		}
		ans[i] += 10*ans[i-1];
		ans[i] %= MOD;
		for(lli j = 0; j < CAP; j++) {
			if(valid(j)) {
				ans[i] += dp[i][j];
				ans[i] %= MOD;
				dp[i][j] = 0;
			}
		}
	}

	cout << ans[n] << endl;

	return 0;
}

Measured memory_bytes: 42240
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2){
        cout<<min(a-1,n-b)+1+(b-a-1)/2<<endl;
    }
    else{
        cout<<(b-a)/2<<endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int r,c,i,j;
  scanf("%d %d",&r,&c);
  int rc[r+1][c+1];
  rc[r][c]=0;
  for(j=0;j<c;j++){
    rc[r][j]=0;
  }
  for(i=0;i<r;i++){
    rc[i][c]=0;
    for(j=0;j<c;j++){
      scanf("%d",&rc[i][j]);
      rc[i][c]+=rc[i][j]; 
      rc[r][j]+=rc[i][j];
    }
    rc[r][c]+=rc[i][c];
  }
  for(i=0;i<=r;i++){
    for(j=0;j<=c;j++){
      printf("%d",rc[i][j]);
      if(j!=c)printf(" ");
    }
    printf("\n");
  }
  return(0);
}

Measured memory_bytes: 644
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll  a[500000];
ll sum=0;
int main()
{
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        ll k;
        cin>>k;
        sum+=k;
        a[k]++;
    }
    ll q;
    cin>>q;
    for(ll i=0;i<q;i++)
    {
        ll b,c;
        cin>>b>>c;
        ll x=a[b];
        sum=sum-x*b+x*c;
        a[b]=0;
        a[c]=a[c]+x;
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 4372
#include<iostream>
#include<algorithm>
#define MAX 128
#define MOD 100000
using namespace std;
int main()
{
  while(true){
    int W,H;
    cin >> W >> H;
    if( W == 0 && H == 0 ) break;
    int M[MAX][MAX][2][2]= {{{{0,},},},};

    M[2][3][0][0] = 1;
    M[2][3][0][1] = 0;
    M[2][3][1][0] = 0;
    M[2][3][1][1] = 0;
    M[3][2][0][0] = 0;
    M[3][2][0][1] = 0;
    M[3][2][1][0] = 1;
    M[3][2][1][1] = 0;
    for(int i = 4; i < H+2; ++i){ M[i][2][0][0] = 0; M[i][2][0][1] = 0; M[i][2][1][0] = 0; M[i][2][1][1] = 1; }
    for(int i = 4; i < W+2; ++i){ M[2][i][0][0] = 0; M[2][i][0][1] = 1; M[2][i][1][0] = 0; M[2][i][1][1] = 0; }
    for(int i = 2; i < H+2; ++i){
      for(int j = 2; j < W+2; ++j){
	//M[i][j][0][0] += M[i][j-1][1][1];
	//M[i][j][1][0] += M[i-1][j][0][1];
	for(int k = j-2; k >= 2; --k){ M[i][j][0][1] += (M[i][k][1][0] + M[i][k][1][1]) % MOD; }
	for(int k = i-2; k >= 2; --k){ M[i][j][1][1] += (M[k][j][0][0] + M[k][j][0][1]) % MOD; }
	//cout << M[i][j][0][0] << ',' << M[i][j][0][1] << ',' << M[i][j][1][0] << ',' << M[i][j][1][1] << ' ';
      }
      //cout << endl;
    }
    int ans = 0;
    for(int i = 2; i < H+1; ++i){
      ans += M[i][W+1][0][0] + M[i][W+1][0][1];
    }
    for(int j = 2; j < W+1; ++j){
      ans += M[H+1][j][1][0] + M[H+1][j][1][1];
    }
    cout << ans % MOD << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    string s; cin >> s;
    string res = "##############";
    int l = 0;
    for(int i = 0; i < s.length();i++){
        if(s[i] == 'B'){
            l = max(0,l - 1);
        }else{
            res[l] = s[i];
            l++;
        }
    }
    cout << res.substr(0,l) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (a > 0 && c > 0) {
		c -= b;
		if (c <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
		a -= d;
		if (a <= 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    for(int i = 0; i < n; ++i){
        int k, p;
        cin >> k >> p;
        while(k > p){
            k -= p;
        }
        cout << k << endl;
    }
}

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

int main()
{
    int n;
    cin >> n;
    char s[303][303];
    int ans = 0;
    for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin >> s[i][j];
    for(int l = 0; l < n; l++){
        bool yes = true;
        for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) if(s[(i + l) % n][j] != s[(j + l) % n][i]) yes = false;
        if(yes) ans += n;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
from bisect import bisect_right
from collections import defaultdict

s = input()
t = input()
idx = defaultdict(list)
for i in range(len(s)):
    idx[s[i]].append(i)
num = 0
prev = -1
for c in t:
    l = len(idx[c])
    if l == 0:
        print(-1)
        exit()
    j = bisect_right(idx[c], prev)
    if j == l:
        prev = idx[c][0]
        num += 1
    else:
        prev = idx[c][j]
print(len(s) * num + prev + 1)


Measured memory_bytes: 7924
#include<bits/stdc++.h>
using namespace std;
int m,k;
int main()
{
	scanf("%d%d",&m,&k);
	
	if(m==1){
		if(!k) printf("0 0 1 1\n");
		else printf("-1");
		return 0;
	}
	m=1<<m;
	if(k>m-1){
		printf("-1");
		return 0;
	}
	int i;
	printf("%d ",k);
	for(i=0;i<m;i++)
	if(i!=k) 
	printf("%d ",i);
	
	printf("%d ",k);
	for(i=m-1;i>=0;i--){
	if(i!=k) 
	printf("%d ",i);
	}
	return 0;
}

Measured memory_bytes: 1792
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-09-23 06:07:24
*/

#include <iostream>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF 1000000000

int main()
{
    int X, Y;
    cin >> X >> Y;

    for (int c = 0; c <= X; c++) {
        int t = X - c;
        int sum = 2*c + 4*t;
        
        if (sum == Y) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


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

bool isprime(int a) {
  if (a == 2) return true;
  if (a % 2 == 0) return false;
  int m = sqrt(a);
  for (int i=3; i<=m; i+=2) {
    if (a%i == 0) {
      return false;
    }
  }
  return true;
}

int main () {
  int N; cin >> N;
  int cnt = 0;
  for (int i=0; i<N; i++) {
    int x; cin >> x;
    if (isprime(x)) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3068
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#define INF 1000000000
using namespace std;

int main() {

	int a, b; cin >> a >> b;
	int sum = -INF;
	sum = max(sum, a + b);
	sum = max(sum, a - b);
	sum = max(sum, a * b);

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
import Control.Monad ( replicateM )
import Data.List ( sort, group )
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [n,m] <- readInts
  abs   <- replicateM m readInts
  mapM_ print $ honsu n abs

honsu
  :: Int -> [[Int]] -> [Int]
honsu n as = map l' . group . sort . concat $ ([1..n] : as)
  where
    l' :: [a] -> Int
    l' =  (+ (-1)) . length

Measured memory_bytes: 636
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <limits.h>
using namespace std;

int main() {
    unsigned long N;
    unsigned long Counts[5];
    unsigned long Town[6];
    unsigned long MinCount = ULONG_MAX;
    unsigned long GroupCount = 0;

    cin >> N;

    for (int i = 0; i < 5; i++)
    {
        unsigned long num;
        cin >> num;
        Counts[i] = num;
    }

    for (int i = 0; i < 5; i++)
    {
        if (MinCount > Counts[i])
        {
            MinCount = Counts[i];
        }
    }

    GroupCount = N / MinCount;

    if (N % MinCount != 0)
    {
        GroupCount++;
    }

    cout << 5 + (GroupCount - 1) << endl;


    return 0;

}



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

using namespace std;

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

#ifndef ONLINE_JUDGE
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define dbg(x)
#endif

#define X first
#define Y second

ll f(ll base, ll num){
    ll res = 0;
    while (num){
        res += num % base;
        num /= base;
    }
    return res;
}


int main(){
    std::ios_base::sync_with_stdio(false);
    ll n, s; cin >> n >> s;
    if (n == s) {
        cout << n + 1 << endl;
        return 0;
    }
    for (ll i = 2; i * i <= n; i++){
        if (f(i, n) == s){
            cout << i << endl;
            return 0;
        }
    }
    ll rt = sqrt(n);
    while (rt * rt < n) rt++;
    ll ans = LLONG_MAX;
    for (ll q = min(s, rt); q >= 1; q--){
        ll r = s - q;
        if ((n - r) % q == 0){
            ll b = (n - r) / q;
            if (r < b && f(b, n) == s){
                ans = min(ans, b);
            }
        }
    }
    if (ans == LLONG_MAX) cout << -1 << endl;
    else cout << ans << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define re register
int q[1001000],miu[1001000];
const int mod=998244353;
int main()
{
	re int n,a;
	re int ans=0;
	scanf("%d",&n);
	miu[1]=1;
	for(re int i=1;i<=1e6;i++)
	{
		for(re int j=i*2;j<=1e6;j+=i)miu[j]=(miu[j]+1ll*mod-miu[i])%mod;
	}
	for(re int i=1;i<=n;i++)
	{
		scanf("%d",&a);
		q[a]++;
		ans=(ans+mod-a)%mod;
	}
	for(re int i=1;i<=1e6;i++)
	{
		for(re int j=2;i*j<=1e6;j++)
		q[i]=(q[i]+(long long)q[i*j]*j)%mod;
	}
	for(re int i=1;i<=1e6;i++)
	{
		re int num=(long long)q[i]*q[i]%mod;
		for(re int j=2;i*j<=1e6;j++)
		num=(num+(long long)q[i*j]*miu[j]%mod*q[i*j]%mod*j%mod*j)%mod;
		ans=(ans+(long long)num*i)%mod;
	}printf("%lld\n",(long long)ans*((mod+1)/2)%mod);
}

Measured memory_bytes: 8064
import java.util.*;

class Main{
    public static void main(String argv[]) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        int first = Integer.parseInt(str.substring(0,2));
        int second = Integer.parseInt(str.substring(2, 4));

        if(first==0 || first >12){
            if(second==0 || second > 12){
                System.out.println("NA");
            }
            else{
                System.out.println("YYMM");
            }
        }
        else{
            if(second==0 || second > 12){
                System.out.println("MMYY");
            }
            else{
                System.out.println("AMBIGUOUS");
            }
        }
    }
}

Measured memory_bytes: 21332
#include<stdio.h>

#define INF 1000000
#define W 1
#define B 3

int n,M[101][101],d[101],colar[101];

void prim(void){
  int min,i,u,v;

  d[1]=0;

  while(1){
    min=INF;
    for(i=1;i<=n;i++){
      if((colar[i]!=B)&&(d[i]<min)){
        min=d[i];
        u=i;
      }
    }

    if(min==INF)
    break;

    colar[u]=B;

    for(v=1;v<=n;v++){
      if((colar[v]!=B)&&(M[u][v]!=INF)){
        if(M[u][v]<d[v])
        d[v]=M[u][v];
      }
    }

  }
}

int main(){
  int i,j,min_t=0,x;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    colar[i]=W;
    d[i]=INF;
    for(j=1;j<=n;j++){
      scanf("%d",&x);
      if(x==-1)
      M[i][j]=INF;
      else
      M[i][j]=x;
    }
  }

  prim();

  for(i=1;i<=n;i++){
    min_t+=d[i];
  }

  printf("%d\n",min_t);

  return 0;
}



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

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int a, b;
  while (cin >> a >> b, a) {
    int cnt[5] = {};
    cnt[0] = a + b;
    for (int i = 1; i < 5; i++) {
      cin >> a >> b;
      cnt[i] = a + b;
    }
    auto p = max_element(cnt, cnt + 5);
    cout << char('A' + (p - cnt)) << " " << *p << endl;
  }

  return 0;
}


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

int main(void){
    long long int a = 0;
    double b = 0; 
    long long int ans = 0;

    scanf("%lld%lf", &a, &b);
//    printf("%lld\n", a);
//    printf("%lf\n", b);
    long long int c = b * 100 + 0.5;

    ans = a * c;

    ans /= 100;

//    ans = floor(a * b);

    printf("%lld\n", ans);

    return 0;

} 


Measured memory_bytes: 3836
//26/04/2020
#include<bits/stdc++.h>
#include<cmath>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define debug printf("Debug\n");
#define en '\n'


#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 2019

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};

//Algos
template<typename T> using Pbds=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

//Number Theory
template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

//Geometry
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan2( double(y1-y2) , double(x1-x2));}


/*Containers*/
vector<ll>v;
deque<ll>dq;
stack<ll>stk;
map<ll,ll>mp;
unordered_map<ll,ll>ump;
set<ll>st;
multiset<ll>mst;
unordered_set<ll>ust;
unordered_multiset<ll>umst;
priority_queue<ll,deque<ll>,greater<ll>>pq;
Pbds<ll>ost;

string s;
ll c[200005];
ll len;
ll vis[2020];

int main(){
    _fastio
    cin>>s;
    len=s.length();
    reverse(s.begin(),s.end());

    ll ans=0;
    ll su=0;
    ll p=1;
    vis[0]=1;
    for(ll i=0;i<len;i++){
        ll d=s[i]-'0';
        ll x=(d%mod*p%mod)%mod;
        su=(su%mod+x%mod)%mod;
        p*=10;
        p%=mod;
        ans+=vis[su]++;
    }
    cout<<ans<<en;

    return 0;
}


Measured memory_bytes: 3772
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
int n;
std::vector<std::pair<std::string,int>> cards;

void regcards(std::string str,int x){
	cards.push_back(std::make_pair(str,x));
}
int main(){
	for(int i=0;i<4;++i){
		for(int j=1;j<=13;++j){
			switch(i){
				case 0:
					regcards("S",j);
				break;
				case 1:
					regcards("H",j);
				break;
				case 2:
					regcards("C",j);
				break;
				case 3:
					regcards("D",j);
				break;
			}
		}
	}
	std::cin>>n;
	for(int i=0;i<n;++i){
		std::string str;
		int x;
		std::cin>>str>>x;
		for(auto it=cards.begin();it<cards.end();++it){
			if(*it==std::make_pair(str,x))cards.erase(it);
		}
	}
	if(cards.empty()){
		return 0;
	}
	for(auto v:cards){
		std::cout<<v.first<<" "<<v.second<<std::endl;
	}
	return 0;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  int p=0;
  for (int i=0;i<3;i++) {
    if (s.at(i) == t.at(i)) {
      p++;
    }
  }
  cout << p << endl;
}

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

ll solve() {
    ll N;
    cin >> N;
    
    auto get_res = []() {
        string s;
        cin >> s;
        if ( s == "Red" ) return 0;
        else if ( s == "Blue" ) return 1;
        else return -1;
    };

    auto check = [&](int k) {
        cout << "?";
        for ( int i = 0; i < N; i++ ) {
            cout << " " << k + i + 1;
        }
        cout << std::endl;
        return get_res();
    };

    int f = check(0);
    int l = 0, r = N+1;
    while ( r - l > 1 ) {
        int m = (l + r) / 2;
        int c = check(m);
        if ( c == -1 ) {
            cout << "! " << std::endl;
            return 0;
        }
        if ( c == f ) l = m;
        else r = m;
    }

    vector<int> cl(2*N);
    for ( int j = 0; j < 2*N; j++ ) {
        if ( j < r  || j >= r+N ) {
            cout << "?";
            for ( int i = r; i < r+N-1; i++ ) {
                cout << " " << i + 1;
            }
            cout << " " << j + 1 << std::endl;
            cl[j] = get_res();
        } else {
            cout << "?";
            for ( int i = 0; i < r-1; i++ ) {
                cout << " " << i + 1;
            }
            for ( int i = r+N; i < 2*N; i++ ) {
                cout << " " << i + 1;
            }
            cout << " " << j + 1 << std::endl;
            cl[j] = get_res();
        }
    }

    cout << "! ";
    for ( int i = 0; i < 2*N; i++ ) {
        char x = cl[i] == 0 ? 'R' : 'B';
        cout << x;
    }
    cout << std::endl;
    return 0;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 724
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int h,w,x;
char s[1000][1000];
bool visited [1000][1000];
pair<int,int> start,goal;
queue<pair<int,pair<int,int>>> q;
vector<pair<int,int>> ino;

int main(){
  int n;string s;cin>>n>>s;
  int ans = 0;;
  repd(sep,1,n){
    int cnt=0;
    for(char c='a';c<='z';c++){
      bool left = false,right = false;
      rep(i,sep){
        if(s[i]==c){left=true;break;}
      }
      repd(i,sep,n){
        if(s[i]==c){right=true;break;}
      }
      if(left&&right)cnt++;
    }
    ans = max(ans,cnt);
  }
  cout << ans << endl;
}


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

using namespace std;

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

    int k;
    long long int sum=0;
    cin>>k;

    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int l=1;l<=k;l++){
                sum+=__gcd(__gcd(i,j),l);
            }
        }
    }
    cout<<sum<<"\n";

    return 0;
}


Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;

class Program
{
    static int f(int x) {
        if (x % 2 == 0) return x / 2;
        return 3 * x + 1;
    }

    static void Main(string[] args) {
        var list = new List<string>(Console.ReadLine().Split(' ')).Select(ele => Int32.Parse(ele)).ToList();

        Console.WriteLine(list[0] * list[1] / 2.0);


        Console.ReadLine();
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<double, double>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int n;
  cin >> n;
  vd x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];
  double sum = 0;
  rep(i, n - 1) rep2(j, i, n) sum += hypot(x[i] - x[j], y[i] - y[j]);
  printf("%.10f\n", sum * 2 / n);
}

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

int main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;

    int cnt = 0;
    for (int i = 0; i <= a; i++) {
        for (int j = 0; j <= b; j++) {
            for (int k = 0; k <= c; k++) {
                if (500 * i + 100 * j + 50 * k == x) cnt++;
            }
        }
    }

    cout << cnt << endl;
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// // descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

    int N;
    cin >> N;
    int a[N], pos[N + 2];
    rep(i, 0, N) {
        cin >> a[i];
        pos[a[i]] = i;
    }
    pos[0] = -1;
    pos[N + 1] = N;

    set<ll> s;
    s.insert(-1);
    s.insert(N);

    ll rsl = 0;
    rep(i, 1, N + 1) {
        auto itr = s.lower_bound(pos[i]);
        ll r_value = *itr;
        itr--;
        ll l_value = *itr;
        rsl += i * (pos[i] - l_value) * (r_value - pos[i]);
        s.insert(pos[i]);
    }

    cout << rsl << endl;
}



Measured memory_bytes: 11264
#include<stdio.h>
#define MAX_V 1000000
int prime[MAX_V+1];
int main(){
	int i,k,v;
	for(i=2;i<=MAX_V;i++){
		prime[i]=1;
	}
	for(i=2;i*i<=MAX_V;i++){
		if(prime[i]){
			for(k=2*i;k<=MAX_V;k+=i){
				prime[k]=0;
			}
		}
	}
	for(i=2;i<=MAX_V;i++){
		prime[i]+=prime[i-1];
	}
	while(scanf("%d",&v)!=EOF){
		printf("%d\n",prime[v]);
	}	
	return 0;
}

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

typedef struct data {
    int solved, penalty, id;
    int ac[11], wa[11];
} Data;

int comp(const void* a, const void* b)
{
    Data x=*((Data*)a);
    Data y=*((Data*)b);
    if (x.solved > y.solved) return -1;
    if (x.solved < y.solved) return 1;
    if (x.penalty < y.penalty) return -1;
    if (x.penalty > y.penalty) return 1;
    if (x.id == y.id) return 0;
    return x.id < y.id ? -1 : 1;
}

int main(void)
{
    Data a[100];
    int t, p, r;
    while (scanf("%d%d%d", &t, &p, &r), t) {
        int i, j;
        for(i=1;i<=t;++i) {
            for(j=1;j<=p;++j) a[i].ac[j]=a[i].wa[j]=0;
            a[i].id=i;
            a[i].solved=a[i].penalty=0;
        }

        while (r--) {
            int tid, pid, etime;
            char msg[20];
            scanf("%d%d%d%s", &tid, &pid, &etime, msg);
            if (a[tid].ac[pid]) continue;
            if (*msg=='C') {
                a[tid].ac[pid]++;
                a[tid].solved++;
                a[tid].penalty+=a[tid].wa[pid]*1200+etime;
            }
            else {
                a[tid].wa[pid]++;
            }
        }
        qsort(a+1, t, sizeof(Data), comp);
        for(i=1;i<=t;++i)
            printf("%d %d %d\n", a[i].id, a[i].solved, a[i].penalty);
    }
    return 0;
}

Measured memory_bytes: 616
#include <iostream>
#include <string>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <climits>
#include <numeric>
#include <algorithm>
#include <cassert>

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k,n;
    cin >> k >> n;
    vector<int> as(n);
    for(int& a : as) cin >> a;
    
    int max_d = as[0] + k - as[n-1];
    for(int i = 1; i < n; ++i)
    {
        max_d = max(max_d, as[i] - as[i-1]);
    }
    cout << k - max_d << '\n';

    return 0;
}


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

int main() {
  int Xmax, Ymax, N, x, y, z, Xmin=0, Ymin=0;
  cin >> Xmax >> Ymax >> N;
  for (int i=0; i<N; i++){
    cin >> x >> y >> z;
    if (z==1 && Xmin<x) Xmin=x;
    else if (z==2 && Xmax>x) Xmax=x;
    else if (z==3 && Ymin<y) Ymin=y;
    else if (z==4 && Ymax>y) Ymax=y;
  }
  if (Xmax-Xmin<0 || Ymax-Ymin<0) cout << 0 << endl;
  else cout << (Xmax-Xmin)*(Ymax-Ymin) << endl;
}

Measured memory_bytes: 256