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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int main() {
   ll n, p;
   cin >> n >> p;
   bool even = true;
   rep (i, n) {
      int x;
      cin >> x;
      if (x&1) {
         even = false;
      }
   }

   if (even) {
      if (p == 1) {
         cout << 0 << endl;
      } else {
         cout << (1LL << n) << endl;
      }
   } else {
      cout << (1LL << (n-1)) << endl;
   }

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	string s, t;
	cin >> s >> t;
	forn(i, sz(s)) {
		if(s[i] != t[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}



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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

struct Node{
	int parent = -1;
	int left_child = -1;
	int right_child = -1;
};

void preorder(vector<Node>& a, int x){
	cout << " "<< x ;
	if(a[x].left_child == -1 && a[x].right_child == -1) return;
	if(a[x].left_child != -1){
		preorder(a, a[x].left_child);
	}
	if(a[x].right_child != -1){
		preorder(a, a[x].right_child);
	}
}

void inorder(vector<Node>& a, int x){
	if(a[x].left_child == -1 && a[x].right_child == -1){
		cout << " "<< x ;
		return;
	}
	if(a[x].left_child != -1){
		inorder(a, a[x].left_child);
	}
	cout << " "<< x;
	if(a[x].right_child != -1){
		inorder(a, a[x].right_child);
	}
}

void postorder(vector<Node>& a, int x){
	if(a[x].left_child == -1 && a[x].right_child == -1){
		cout << " " << x;
		return;
	}
	if(a[x].left_child != -1){
		postorder(a, a[x].left_child);
	}
	if(a[x].right_child != -1){
		postorder(a, a[x].right_child);
	}
	cout << " " << x;
}

int main(){
	int n;
	cin >> n;
	vector<Node> a(n);
	rep(i, n){
		int x;
		cin >>x;
		int l,r;
		cin >> l >> r;
		if(l != -1) a[l].parent = x;
		if(r != -1) a[r].parent = x;
		a[x].left_child = l;
		a[x].right_child = r;
	}
	rep(i, n){
		if(a[i].parent == -1){
			cout << "Preorder" << endl;
			preorder(a, i);
			cout << endl << "Inorder" << endl;
			inorder(a, i);
			cout << endl << "Postorder" << endl;
			postorder(a, i);
			cout << endl;
			break;
		}
	}

}



Measured memory_bytes: 3120
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var yohou = Console.ReadLine();
            var jissai = Console.ReadLine();

            var count = 0;
            for (int i = 0; i < 3; i++) if (yohou[i] == jissai[i]) count++;
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13140
use std::cmp::min;
use std::io::stdin;

fn main() {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let mut itr = s.split_whitespace().map(|e| e.parse::<usize>().unwrap());
    let n = itr.next().unwrap();
    let k = itr.next().unwrap();
    let m = 998244353;
    let mut s = String::new();
    stdin().read_line(&mut s).ok();

    let v: Vec<usize> = s
        .split_whitespace()
        .map(|e| e.parse::<usize>().unwrap())
        .collect();

    let mut a = vec![0; k + 1];
    let mut ans = 0;
    for i in 0..n {
        a[0] += 1;
        let mut a2 = vec![0; k + 1];
        for j in 0..k + 1 {
            a2[j] = (a2[j] + a[j]) % m;
            if j + v[i] <= k {
                a2[j + v[i]] = (a2[j + v[i]] + a[j]) % m;
            }
        }

        a = a2;

        ans = (ans + a[k]) % m;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }



int main() {
	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	int ans = 0;
	rep(i, n) {
		if (i == 0) {
			ans = max(ans, a[0] + (k - a[n - 1]));
		}
		else {
			ans = max(ans, a[i] - a[i - 1]);
		}
	}
	cout << k - ans << endl;
	return 0;
}




Measured memory_bytes: 1024
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    X,Y=MI()
    if X%Y==0:
        print(-1)
        exit()
    print(X)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(long long i=0; i<(int)n; i++)
#define rep2(i,a,n) for(long long i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int N, M, K, H, W, L, R, X;
//string S, T;

signed main(){
  string dir = "UDLR";
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx>> ty;
  tx -= sx; ty -= sy;
  
  cout << string(tx, 'R') << string(ty, 'U');
  cout << string(tx, 'L') << string(ty, 'D');
  cout << 'L'<< string(ty+1, 'U') << string(tx+1, 'R')<<'D';
  cout << 'R'<< string(ty+1, 'D') << string(tx+1, 'L')<<'U';

  cout << endl;
  return 0;
}

Measured memory_bytes: 3644
def com(N,K,mod):
    n=N
    k=K
    X=1  #分子
    Y=1  #分母
    for _ in range(K):
        X*=n
        X%=mod
        n-=1
    for _ in range(K):
        Y*=k
        Y%=mod
        k-=1
    Y=pow(Y,mod-2,mod)  #Y**(mod-2) mod(mod)
    return X*Y%mod  #nCk mod(mod)

def main():
    N,a,b=map(int,input().split())
    mod=1000000007
    t=(pow(2,N,mod)-1-com(N,a,mod)-com(N,b,mod))%mod
    print(t)
    
if __name__=="__main__":
    main()

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val mod = 1000000007L

    val N = readInputLine().toInt()
    val xArr = readInputLine().split(" ").map { it.toLong() }.toLongArray()

    val factorial = LongArray(N + 1)
    val inverse = LongArray(N + 1)
    factorial[0] = 1L
    factorial[1] = 1L
    inverse[0] = 1L
    inverse[1] = 1L
    for (i in 2..N) {
        factorial[i] = (factorial[i - 1] * i.toLong() % mod)
        inverse[i] = (mod - inverse[mod.toInt() % i] * (mod / i.toLong()) % mod)
    }
    val dist = LongArray(N)

    for (i in 1 until N) {
        dist[i] = xArr[i] - xArr[i - 1]
    }

    var ans = 0L
    var inverseSum = 0L

    for (i in 1 until N) {
        inverseSum += inverse[i]
        inverseSum %= mod
        ans += dist[i] * inverseSum % mod
        ans %= mod
    }

    println(ans * factorial[N - 1] % mod)
}

fun readInputLine(): String {
    return readLine()!!
}


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

int main(){
  int N, M, K, a;
  cin >> N >> M;
  int A[M+1] = {0};
  for(int i = 0; i < N; i++){
    cin >> K;
    for(int j = 0; j < K; j++){
      cin >> a;
      A[a]++;
    }
  }
  int ans = 0;
  for(int i = 1; i <= M; i++){
    if(A[i] == N) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int a[50],b[50],c[59];
int main()
{
	int n;cin>>n;rep(i,n) cin>>a[i];rep(i,n) cin>>b[i];rep(i,n-1) cin>>c[i];
	int out=0;
	rep(i,n){
		out+=b[a[i]-1];
		if(i<n-1 && a[i]+1==a[i+1]) out+=c[a[i]-1];
	}
	cout<<out<<endl;
}


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

#define int ll

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}

int32_t main() {
	int x, n;
	cin >> x >> n;
	set<int> s;
	for(int i = 0; i < n; i++) {
		int p;
		cin >> p;
		s.insert(p);
	}
	for(int d = 0; d < 1000; d++) {
		if(!s.count(x - d)) {
			cout << x - d << '\n';
			return 0;
		}
		if(!s.count(x + d)) {
			cout << x + d << '\n';
			return 0;
		}
	}
	assert(false);
}


Measured memory_bytes: 3636
def f(n):
    if n in memo:
        return memo[n]
    c=list(str(bin(n)))[2:].count('1')
    r=n%c
    if r>0:
        memo[n]=f(r)+1
    else:
        memo[n]=1
    return memo[n]

memo={0:0}
N=int(input())
X=list(input())
XC=X.count('1')
XN=int('0b'+''.join(X),2)
for i in range(N):
    if X[i]=='1':
        if XC==1:
            print(0)
            continue
        tx=(XN%(XC-1)-pow(2,N-i-1,XC-1))
        if tx<0:
            tx+=XC-1
        tx%=XC-1
    else:
        tx=(XN%(XC+1)+pow(2,N-i-1,XC+1))%(XC+1)
    print(f(tx)+1)

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

int main() {
    const int lastMonth = 4280;
    while (true) {
        int w;
        cin >> w;
        if (w == -1) {
            break;
        }
        int fee = 1150;
        if (w > 10) {
            fee += (w - 10) * 125;
        }
        if (w > 20) {
            fee += (w - 20) * 15;
        }
        if (w > 30) {
            fee += (w - 30) * 20;
        }
        cout << lastMonth - fee << endl;
    }
}

Measured memory_bytes: 0
// A- Sum of Two Integers

#include <bits/stdc++.h>

using namespace std;

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


	int counter = 0;
	if(n % 2 == 1){
		for(int i = 1; i <= n / 2; ++i){
			if(n - i > 0) ++counter;
		}
	}
	else{
		for(int i = 1; i < n / 2; ++i){
			if(n - i) ++counter;
		}
	}

	cout << counter << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
class Main{
	public static void main(String[] args){
	int h =0;
	int w =0;
	int t =0;
	Scanner scan = new Scanner(System.in);
	ArrayList<Integer> listw = new ArrayList<Integer>();
	ArrayList<Integer> listh = new ArrayList<Integer>();
		while(scan.hasNextLine()){
			h = scan.nextInt();			
			w = scan.nextInt();
			
			if(h==0 && w==0){
				break;
			}
			else{
				listh.add(h);
				listw.add(w);
			}
		}
		
		
		
		for(int i=0;i<listh.size();i++){
			for(int ii=0;ii<listh.get(i);ii++){
				for(int iii=0;iii<listw.get(i);iii++){
					if(ii == 0 || ii ==listh.get(i)-1 || iii == 0 || iii == listw.get(i)-1){
					System.out.print("#");
					}
					else{
					System.out.print(".");
					}
					
				}
			System.out.println("");
			}
		System.out.println("");
		}
	}
}

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

int main() {
    int  N,K;
    cin >>N>>K;
    int  a[N];
    rep(i,N){
        cin>>a[i];
    }
     ll first=0;
    rep(i,K){
        first+=a[i];
    }
    ll mx =first;
    rep(i,N-K){
        first += a[K+i]-a[i];
        mx=max(mx,first);
    }
    cout<<(mx+K)/2<<'.';
    if((mx+K)%2==0)cout<<"00000000000"<<endl;
    else cout<<"50000000000"<<endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

ll solve()
{
    int K;

    std::cin >> K;

    if (K < 10) return K;

    queue<ll> q;

    for (int i = 1; i < 10; ++i)
        q.push(i);

    int index = 9;

    while (true) {

        ll curr = q.front();
        q.pop();

        ll next = curr;
        if ((curr % 10) - 1 >= 0) {
            next = next * 10 + (curr % 10) - 1;
            ++index;
            if (index == K) return next;
            q.push(next);
        }

        next = curr;
        next = next * 10 + (curr % 10);
        ++index;
        if (index == K) return next;
        q.push(next);

        next = curr;
        if ((curr % 10) + 1 <= 9) {
            next = next * 10 + (curr % 10) + 1;
            ++index;
            if (index == K) return next;
            q.push(next);
        }
    }

    return 0;
}

int main()
{
    std::cout << solve() << std::endl;
//    solve();

    return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
	public static long half(long hp) {
		if (hp == 0) {
			return 0;
		} else {
			return 2 * half(hp / 2) + 1;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		System.out.println(half(H));
	}

}


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

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

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

void solve(int tc) {
    int n;
    cin >> n;
    vt<int> a(n);
    for (int &i : a) cin >> i;

    vt<int> dp(n);
    dp[0] = 0, dp[1] = abs(a[0] - a[1]);
    for (int i = 2; i < n; i++) {
        dp[i] = min(dp[i - 2] + abs(a[i - 2] - a[i]),
                    dp[i - 1] + abs(a[i - 1] - a[i]));
    }
    cout << dp.back();
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) solve(tc);
}


Measured memory_bytes: 3972
#include<iostream>
using namespace std;
main()
{
	int n;cin>>n;
	int s=0,m,t[100],p,x;
	for(int i=0;i<n;i++)
	{
		cin>>t[i];
		s+=t[i];
	}
	cin>>m;
	for(int i=0;i<m;i++)
	{
		cin>>p>>x;
		cout<<s+x-t[p-1]<<endl;
	}
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main(void) {
    int N, b, i;
    char S[105];
    scanf("%s", S);
    N=strlen(S);
    b=1;
    for (i=0; i<(N-1)/2; i++) {
        // printf("(%d %d) ", i, (N-1)/2-i-1); continue;
        if (S[i]!=S[(N-1)/2-i-1]) {
            b=0;
            break;
        }
    }
    // printf("\n");
    for (i=0; i<(N-1)/2; i++) {
        // printf("(%d %d) ", (N+3)/2-1+i, N-i-1); continue;
        if (S[(N+3)/2-1+i]!=S[N-i-1]) {
            b=0;
            break;
        }
    }
    // printf("\n");
    for (i=0; i<N; i++) {
        // printf("(%d %d) ", i, N-i-1); continue;
        if (S[i]!=S[N-i-1]) {
            b=0;
            break;
        }
    }
    if (b==1) printf("Yes");
    else printf("No");
    return 0;
}

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

using  ll = long long;
using ull = unsigned long long;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
constexpr ll kINF = 1152921504606846976;//2^60
constexpr double kEPS = 1e-6;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define rep(i,n) REP(i,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep(i,n) RREP(i,n)
#define mp make_pair
#define fi first
#define sc second

ll N;
double p[3000];
double dp[3000][3000];

int main(void) {
  cin >> N;
  rep(i, N) cin >> p[i];

  rep(i,N) rep(j, N) dp[i][j] = 0.0;
  dp[0][0] = 1.0;

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

  double ans = 0.0;
  rep (i,N + 1) if (i >= N / 2 + 1) ans += dp[N][i]; 

  printf("%.15f\n", ans);
  return 0;
}

Measured memory_bytes: 70528
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,(n)-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,(n)-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    string s;
    cin >> s;
    int a = 0;
    rep(i,sz(s)){
        a += s[i] - '0';
        a %= 9;
    }
    if(a%9==0)puts("Yes");
    else puts("No");

    // cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

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

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

Measured memory_bytes: 256
import copy

N, M, X = map(int, input().split())

li = [[0 for i in range(M+1)] for j in range(N)]

for n in range(N):
  li[n]=list(map(int, input().split()))

sumLiA = [0 for i in range(M+1)]
sumLi = copy.deepcopy(sumLiA)
costLi = []
flag = 1

for pat in range(2**N):
  pat = format(pat, '012b')
  for bookNum in range(N):
    if pat[-bookNum-1] == '1':
      for i in range(M+1):
        sumLi[i] += li[-bookNum-1][i]
  for liN in range(1, M+1):
    if sumLi[liN] < X:
      flag = 0
      break
  if flag == 1:
    costLi.append(sumLi[0])
  flag = 1
  sumLi = copy.deepcopy(sumLiA) 

if costLi == []:
  print(-1)
else:
  print(min(costLi))


Measured memory_bytes: 9276
import java.awt.Frame;
import java.awt.image.SinglePixelPackedSampleModel;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

import javax.print.attribute.standard.Chromaticity;
import javax.sql.rowset.FilteredRowSet;
import javax.swing.BorderFactory;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.events.EndDocument;
import javax.xml.transform.Templates;

import java.math.BigInteger;
import java.time.chrono.MinguoChronology;
import java.util.Scanner;

public class Main {
  static InputReader in;
  static PrintWriter out;
  
  static class Solution {
    void solve() throws IOException {
      Scanner sc = new Scanner(System.in);
      while (sc.hasNext()) {
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        out.println(gcd(x, y) + " " + lcm(x, y));
      }
//      End solve()
    }
    
    int gcd(int x, int y) {
      if (x < y) {
        int tmp = x;
        x = y;
        y = tmp;
      }
   
      while (y > 0) {
        int r = x % y;
        x = y;
        y = r;
      }
      return x;
    }
    
    long lcm(int x, int y) {
      if (x == 0 || y == 0) {
        return 0;
      }
      long lcm = x *( y / gcd(x, y));
      
      return lcm;
    }
//  End solution
  } 
  

  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}

  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;
    
    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }
   
    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }
    
    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken()); 
    }
    
    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }
    
    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }
    
  }
  
}

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

namespace CsTest
{
    static class CsTest
    {
        static int customParse(string s)
        {
            int current = 0;
            for(int i = 0; i < s.Length; ++i)
            {
                int n = s[i] - '0';
                if (n >= 0 && n <= 9)
                {
                    current *= 10;
                    current += n;
                }
            }
            return current;
        }

        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');
            Console.WriteLine((long)(long.Parse(s[0]) * customParse(s[1]) / 100));
        }
    }
}

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

int main()
{
	int k;
	cin >> k;
	if(k % 2 == 0){
		cout << k * k / 4 << "\n";
	}else{
		cout << (k/2) * (k/2+1) << "\n";
	}

	return 0;
}


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

int main() {
	int N;
    int Alice=0;
    int Bob=0;
	cin >> N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
      cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    for(int i=0;i<N;i++){
      if(i%2 == 0){
        Alice += a.at(i);
      }
      else{
        Bob += a.at(i);
      }
    }
  cout << max(Alice,Bob)-min(Alice,Bob) << endl;        
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (true)
    {
        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: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    string ans="No";
    cin >> N;
    for (int i = 1; i <= 9; i++){
        int a = N/i;
        int b = N%i;
        if(a<=9 && b==0){
            ans = "Yes";
            break; 
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3568
#include <stdio.h>
#include <string.h>
int main(void) {
	// your code goes here
	char s[100];
	gets(s);
	printf("%c",s[0]-32);
	int i =0;
	while(s[i]!='\0')
	{
	
		if(s[i-1]==' '&& i!=0)
		printf("%c",s[i]-32);
		i++;
	}

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main() {
  int n; cin >> n;
  vector<pair<int,int>> p;
  FOR(i,0,n-1){
    int x,l; cin >> x >> l;
    p.PB(MP(x+l,x-l));
  }
  SORT(p);
  FOR(i,0,n-1){
    swap(p[i].first,p[i].second);
  }

  int now = -1000000100;
  int ans = 0;
  FOR(i,0,n-1){
    // cout << now << " " << p[i].first << " " << p[i].second << endl;
    if(now<=p[i].first){
      now = p[i].second;
      ++ans;
    }
  }

  cout << ans << endl;
}

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

int main(){
  int n, k;
  double ans=0;
  cin >> n >> k;
  for(int i=1;i<=n;i++){
    int x=i;
    double cnt=0., y=1., z=(double)n;
    while(x<k){
      x=x<<1;
      cnt=cnt+1;
      y=y*0.5;
    }
    if(cnt==0)y=1.;
    ans+=1/z*y;
  }
  printf("%.12lf\n",ans);
  return 0;
}


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

s = input()
for i in range(len(s)):
    if s[i] == 'A':
        s = s[i:]
        break

s = s[::-1]

for i in range(len(s)):
    if s[i] == 'Z':
        s = s[i:]
        print(len(s))
        break



Measured memory_bytes: 3512
#include <stdio.h> // C++???????????????
#include <string.h> // c++???????????????
#include <math.h> // c++???????????????
#include <iostream>
#include <string>
#include <stack>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;

typedef long long int lli;
#define PI 3.1415926535897932
#define MAX(a,b) ((a>b)?(a):(b)) // ?????§????????????
#define MIN(a,b) ((a<b)?(a):(b)) // ????°?????????????
#define INRANGE(a,b,c) ((a<=b&&b<=c)?(1):(0)) // a<=b<=c??????????????????????????????
#define N 4

void swap(int &a,int &b){ // c??????*
	int w=a;
	a=b;
	b=w;
}

int getdigit(int num){ // ??´??°????????°?????????
	int i,j;
	if(num<0) num*=-1; // ?????°???????????¢
	if(num==0)return 1;
	for(i=10,j=1;;i*=10,j++){
		if(INRANGE(i/10,num,i-1))return j;
	}
	return 0; // ????????¨??????
}

int getN(int num,int digit){ // ?????????????????°????????????
	int i=1,j;
	for(j=1;j<digit;i*=10,j++);
	return (num/i)%10;
}

int zeller(int y,int m,int d){ // ?????§??????
	if(m<3){y--; m+=12;}
	return (y+y/4-y/100+y/400+(13*m+8)/5+d)%7;
	// 0=sunday!
}

int gcd(int a,int b){	// ?????§??¬?´???°
	if(b==0) return a;
	return gcd(b,a%b);
}

int lcm(int a,int b){	// ????°???¬?????°
	return a*b/gcd(a,b);
}

int stoi(const string str){ // ?????????????????´??°
	int i=0,j;
	int len=str.length();
	int w=0;
	for(i=1,j=1;i<=len && INRANGE('0',str[len-i],'9');i++,j*=10){
		w+=(str[len-i]-'0')*j;
	}
	if(str[0]=='-')w*=-1; // ??????????????????
	return w;
}

string itos(int a){ // ??´??°???????????????
	int i;
	string str="";
	int keta;
	if(a<0){str+='-';a*=-1;} // ?????°??????????????????
	for(keta=10;a/keta!=0;keta*=10);
	for(i=keta/10;i!=0;i/=10){
		str+=((a/i)%10)+'0';
	}
	return str;
}

int main(void){
	string str;
	string str1,str2;
	int a,b; //a>b
	int c;
	while(cin>>str,str!="0000"){
		c=0;
		while(str!="6174"){
			for(int i=0;i<N;i++){
				for(int j=i+1;j<N;j++){
					if(str[i]<str[j])swap(str[i],str[j]);
				}
			}
			str1=str;
			for(int i=0;i<N/2;i++) swap(str[i],str[N-i-1]);
			str2=str;
			str=itos(stoi(str1)-stoi(str2));
			switch(getdigit(stoi(str))){
				case 1:
					str="000"+str;
					break;
				case 2:
					str="00"+str;
					break;
				case 3:
					str="0"+str;
					break;
			}
			if(str=="0000"){cout<<"NA"<<endl; goto LOOP;}
			c++;
		}
		cout<<c<<endl;
LOOP:;
	}
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}

int main(void) {
  ll N;
  cin >> N;
  pt(180*(N-2));
  
  
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef long long   ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9;
const double PI = acos(-1);
#define tam 300000
#define offset 
const ll MOD= 1e9+7;



#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {

template < class c > struct rge { c b, e; };
template < class c > rge<c> range(c i, c j) { return rge<c>{i, j}; }
template < class c > auto dud(c* x) -> decltype(cerr << *x, 0);
template < class c > char dud(...);

struct debug {
    ~debug() { cerr << endl; }
    
    //     Part 1
    
    template < class c > typename \
    enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) {
        cerr << boolalpha << i;
        return * this;
    }
    
    //     Part 2
    
    template < class c > typename \
    enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) {
        return * this << range(begin(i), end(i)); 
    }
    
    //   Part 3
    
    template < class c, class b > debug & operator << (pair < b, c > d) {
        return * this << "(" << d.first << ", " << d.second << ")";
    }
    
    //   Part 4
    
    template < class c > debug & operator <<(rge<c> d) {
        *this << "[";
        for (auto it = d.b; it != d.e; ++it)
            *this << ", " + 2 * (it == d.b) << *it;
        return * this << "]";
    }
    
};
#define qwer(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
    set<string> s;
    forr(i,0,n)
    {
        string tx;
        cin>>tx;
        s.insert(tx);
    }
    cout<<(int)s.size()<<endl;
    

}
// PLUS ULTRA!
    

Measured memory_bytes: 19204
DBG = !true
n = 3
conn = Array.new(4).map{[]}
for i in 0...n
  a,b = gets.split.map{|z| z.to_i}
  a -= 1
  b -= 1
  conn[a] << b
  conn[b] << a
end
if DBG
  print conn
  puts ""
end

narc = [0,0,0,0]
for i in 0..3
  narc[conn[i].size] += 1
end
print narc if DBG

if narc[1] == 2 && narc[2] == 2
  puts "YES"
else
  puts "NO"
end


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

int main()
{
    int n, s[100], ans = 1000000;
    cin >> n;
    for (int in = 0; in < n; in++)
    {
        cin >> s[in];
    }
    sort(s, s + n);

    for (int i = s[0]; i <= s[n - 1]; i++)
    {
        int cost = 0;

        for (int j = 0; j < n; j++)
        {
            cost += (abs(s[j] - i) * abs(s[j] - i));
        }

        ans = min(ans, cost);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3484
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

def solve():
    n = int(input())
    l = list(map(int,input().split()))
    l = sorted(l)
    m = n // 2 - 1
    if l[m] == l[m+1]:
        print(0)
    if l[m] < l[m+1]:
        print(l[m+1]-l[m])
        
    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
        def dump(*args):
            names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
            print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
    except:
        def dump(*args):
            pass

    solve()

# vim: set foldmethod=marker:}}}


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

int main(void) {
  string S;
  cin >> S;
  int ans = 10000;
  for (int i = 0, len = S.length(); i < len - 2; i++) {
    int num = 0;
    for (int j = 0; j < 3; j++) {
      int exp = 1;
      for (int k = 0; k < 2 - j; k++) {
        exp *= 10;
      }
      num += (S[i + j] - '0') * exp;
    }
    ans = min(ans, abs(753 - num));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll);
ll mod_fact(ll, ll);
ll mod_inv(ll, ll);
ll gcd(ll, ll);
//
int main(){
    int n, m;
    cin >> n >> m;
    priority_queue<double> pq;
    for(int i = 0; i < n; i++){
        double a;
        cin >> a;
        pq.push(a);
    }
    for(int i = 0; i < m; i++){
        double d = pq.top();
        pq.pop();
        pq.push(d / 2);
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += floor(pq.top());
        pq.pop();
    }
    cout << ans;
}

Measured memory_bytes: 1400
#include<iostream>
#include<string>
#include<utility>
#include<map>

using namespace std;

bool isAc(string result) {
    return result == "AC";
}

int main() {
    int N, M;
    cin >> N >> M;

    map<int, pair<bool, int> > probrems;

    for(int i = 0; i < M; i++) {
        int p;
        string S;
        cin >> p >> S;
        if (probrems.count(p) == 0) {
            if (isAc(S)) {
                probrems.insert(make_pair(p, make_pair(true, 0)));
            } else {
                probrems.insert(make_pair(p, make_pair(false, 1)));
            }
        } else {
            if (isAc(S)) {
                probrems[p] = make_pair(true, probrems[p].second);
            } else if(!probrems[p].first){
                probrems[p] = make_pair(false, probrems[p].second + 1);
            }
        }
    }

    int acNum = 0, waNum = 0;
    for(auto p : probrems) {
        pair<bool, int> probrem = p.second;
        if(probrem.first) {
            acNum++;
            waNum += probrem.second;
        }
    }

    acNum = acNum < N ? acNum : N;

    cout << acNum << " " << waNum << endl;

    return 0;
}

Measured memory_bytes: 6528
#include <stdio.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)
#define INF (long long int)(9223372036854775807)
#define IINF (int)(2147483647)
#include <stdlib.h>

typedef struct tree {
  lld value;
  struct tree *left;
  struct tree *right;
} tree_t;

int search_and_insert(tree_t *tree, lld value) {
  if (value == tree->value) {
    return 0;
  } else if (value < tree->value) {
    if (tree->left == NULL) {
      tree->left = malloc(sizeof(tree_t));
      tree->left->value = value;
      tree->left->left = NULL;
      tree->left->right = NULL;
      return 1;
    } else {
      return search_and_insert(tree->left, value);
    }
  } else {
    if (tree->right == NULL) {
      tree->right = malloc(sizeof(tree_t));
      tree->right->value = value;
      tree->right->left = NULL;
      tree->right->right = NULL;
      return 1;
    } else {
      return search_and_insert(tree->right, value);
    }
  }
}

void free_tree(tree_t *tree) {
  if (tree->left != NULL) {
    free_tree(tree->left);
  }
  if (tree->right != NULL) {
    free_tree(tree->right);
  }
  free(tree);
}

int main(void) {
  int n;
  lld q, r = 0;
  unsigned char c;
  tree_t *tree = NULL;
  scanf("%d\n", &n);
  for (int i = 0; i < n; i++) {
    q = 0;
    while (1) {
      c = getchar();
      if (c == '\n') {
        break;
      }
      q *= 27;
      q += c - 'a' + 1;
    }
    if (tree != NULL) {
      r += search_and_insert(tree, q);
    } else {
      tree = malloc(sizeof(tree_t));
      tree->value = q;
      tree->left = NULL;
      tree->right = NULL;
      r += 1;
    }
  }

  printf("%lld\n", r);
}

Measured memory_bytes: 7900
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxN = 2e3 + 13, maxK = 1e5 + 13;
int n, b[maxK], a[maxK], ans;
map<int, int> val;
map<int, bool> mark;
int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
	cin >> a[i];
	int x = a[i];
	a[i] = b[i] = 1;
	for (int j = 2; j < maxN; j++) {
	    if(x % j == 0){
		int cnt = 0;
		while (x % j == 0) {
		    x /= j;
		    cnt++;
		}
		if (cnt % 3 == 1) {
		    a[i] *= j;
		    b[i] *= j * j;
		}
		else if (cnt % 3 == 2){
		    a[i] *= j * j;
		    b[i] *= j;
		}
	    }
	}
	if(x != 1){
	    int y = ceil(sqrt(x));
	    a[i] *= x;
	    if (y * y == x)
		b[i] *= y;
	    else
		b[i] *= x * x;
	}
	val[a[i]]++;
    }
    for (int i = 0; i < n; i++)
	if (!mark[a[i]]) {
	    mark[a[i]] = mark[b[i]] = 1;
	    if (a[i] == 1)
		ans++;
	    else
		ans += max(val[a[i]], val[b[i]]);
	}

    cout << ans << endl;
}


Measured memory_bytes: 26880
import scala.annotation.tailrec
import scala.math._

object Main extends App {

  val YES = "YES"
  val Yes = "Yes"
  val NO = "NO"
  val No = "No"

  val input: Array[Array[Int]] = Array.ofDim(6, 6000000)
  ///////////////////////////////////////////

  val sc = new java.util.Scanner(System.in)
//  val a, b, k = sc.nextInt
  val n = sc.nextInt
  val p = List.fill(n)(sc.nextInt)
  val q = List.fill(n)(sc.nextInt)

  val permutations = (1 to n).permutations.map(_.mkString("")).toSeq.sorted
  val a = permutations.indexOf(p.mkString(""))
  val b = permutations.indexOf(q.mkString(""))

  println(abs(a - b))

  ///////////////////////////////////////////

  def bigIterator(start: BigInt, end: BigInt, step: BigInt = 1) =
    Iterator.iterate(start)(_ + step).takeWhile(_ <= end)

  def lcm(a :Int, b :Int): Int =
    a / gcd(a, b) * b

  def lcm(a :Long, b :Long): Long =
    a / gcd(a, b) * b

  def gcd(a: Int, b: Int): Int =
    if (b == 0) a else gcd(b, a % b)

  def gcd(a: Long, b: Long): Long =
    if (b == 0) a else gcd(b, a % b)

  def setOrUpdated[A, B](a: Map[A, B], key: A, value: B, f: (B, B) => B) =
    a.get(key) match {
      case Some(v) => a.updated(key, f(value, v))
      case _ => a + (key -> value)
    }

  // https://stackoverflow.com/questions/10199171/matcherror-when-match-receives-an-indexedseq-but-not-a-linearseq/10199441#10199441
  object +: {
    def unapply[T](s: Seq[T]) =
      s.headOption.map(head => (head, s.tail))
  }

  @tailrec
  def foldLeftWithNext[A, B](seq: Seq[A])(z: B)(op: (B, A, A) => B)(tailOp: (B, A) => B): B = {
    seq match {
      case Nil => z
      case a +: Nil => tailOp(z, a)
      case a +: next +: tail => foldLeftWithNext(next +: tail)(op(z, a, next))(op)(tailOp)
    }
  }
}

Measured memory_bytes: 190248
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

#define QuatientRU(a,r) (a+r-1)/r


int main() {
  int a, b, c, d;
  int x,y;

  cin >> a >> b >> c >> d;

  x = QuatientRU(c,b); y = QuatientRU(a,d); 

  if(y >= x){
    cout << "Yes" <<endl;
  }else{
    cout << "No" <<endl;
  }

  return 0;
}


Measured memory_bytes: 3620
def main():
    N, A, B = [int(v) for v in input().split()]
    S = input()

    c1 = 0
    c2 = 0

    for i in range(N):
        if c1 >= A + B:
            print('No')
            continue

        if S[i] == 'a':
            c1 += 1
            print('Yes')
        elif S[i] == 'b':
            if c2 < B:
                c1 += 1
                print('Yes')
            else:
                print('No')
            c2 += 1
        else:
            print('No')


main()


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

int main()
{
  int n, m, s[5], c[5], val[3] = {-1, -1, -1};
  cin >> n >> m;
  for (int i = 0; i < m; i++)
  {
    cin >> s[i] >> c[i];
    if (val[s[i] - 1] != -1 && val[s[i] - 1] != c[i])
    {
      val[s[i] - 1] = -2;
    }
    else
    {
      val[s[i] - 1] = c[i];
    }
  }
  if (val[0] == -2 || val[1] == -2 || val[2] == -2)
  {
    cout << -1 << endl;
    return 0;
  }
  switch (n)
  {
  case 1:
    cout << (val[0] == -1 ? 0 : val[0]) << endl;
    break;
  case 2:
    if (val[0] == 0)
    {
      cout << -1 << endl;
      return 0;
    }
    cout << (val[0] == -1 ? 1 : val[0]) << (val[1] == -1 ? 0 : val[1]) << endl;
    break;
  case 3:
    if (val[0] == 0)
    {
      cout << -1 << endl;
      return 0;
    }
    cout << (val[0] == -1 ? 1 : val[0]) << (val[1] == -1 ? 0 : val[1]) << (val[2] == -1 ? 0 : val[2]) << endl;
    break;
  }
}


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

ll mod = 1e9+7;

int main(){
    ll n,m;
    cin>>n>>m;

    if(n>1 && m>1){
        cout<<n*m-2*n-2*m+4<<endl;
    }else if(n==1 && m==1){
        cout<<1<<endl;
    }else if(n==1){
        cout<<m-2<<endl;
    }else{
        cout<<n-2<<endl;
    }
    return 0;
}

Measured memory_bytes: 3584