akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

int cnt_yakusu(int n){
    int cnt = 0;
    for(int i=1;i<=n;i++){
        if(n%i==0) cnt++;
    }
    return cnt;
}

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(i%2==0) continue;
        int yakusu = cnt_yakusu(i);
        if(yakusu==8) ans++;
    }

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

Measured memory_bytes: 3624
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string.h>
using namespace std;
#define lson rt << 1
#define rson rt << 1 | 1
const int N = 100000 + 10;
struct node
{
    int l, r;
    int w; //  w维护值  lazy懒标记
} tree[(N << 2) + 10];
inline int read()
{
    int num = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch))
    {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch))
    {
        num = (num << 3) + (num << 1) + (ch ^ 48);
        ch = getchar();
    }
    return w ? -num : num;
}

//快速写
inline void write(int x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
void build(int rt, int l, int r) //建树初始化
{
    tree[rt].l = l;
    tree[rt].r = r;
    if (l == r)
    {
        tree[rt].w = 0;
        return;
    }
    int mid = (l + r) >> 1;
    build(lson, l, mid);
    build(rson, mid + 1, r);
    tree[rt].w = tree[lson].w + tree[rson].w; //合并父节点
}
int query(int rt, int ql, int qr) //区间查询 单点查询时ql==qr
{
    int l = tree[rt].l;
    int r = tree[rt].r;
    if (l >= ql && r <= qr)
    {
        return tree[rt].w; //查询维护值w
    }
    int mid = (l + r) >> 1;
    int ans = 0;
    if (ql <= mid)
        ans += query(lson, ql, qr);
    if (qr > mid)
        ans += query(rson, ql, qr);
    return ans;
}

void updata(int rt, int x, int val) //单点更新  x更新点 val更新值
{
    int l = tree[rt].l;
    int r = tree[rt].r;
    if (l == r)
    {
        tree[rt].w += val;
        return;
    }
    int mid = (l + r) >> 1;

    if (x <= mid)
        updata(lson, x, val);
    else if (x > mid)
        updata(rson, x, val);
    tree[rt].w = tree[lson].w + tree[rson].w; //合并父节点
}

int x[100000 + 10];
int lsh[100000 + 10];
int n;
int fin(int k, int size, int pos)
{
    int l = 1;
    int r = pos - 1;
    int sum = query(1, l, r);
    if (sum == 0)
        return -1;
    else
    {
        int ans = r;
        while (l <r)
        {
            if (l + 1 == r)
                break;
            int mid = (l + r) >> 1;
            if (query(1, mid, r) >= 1)
            {
                l = mid;
            }
            else
            {
                r = mid;
            }
        }
        if (query(1, r, r))
            return r;
        return l;
    }
}
int main()
{
    n = read();
    for (int i = 1; i <= n; i++)
    {
        x[i] = read();
        lsh[i] = x[i];
    }
    sort(lsh + 1, lsh + 1 + n);
    int size = unique(lsh + 1, lsh + 1 + n) - (lsh + 1);
    build(1, 1, size);
    for (int i = 1; i <= n; i++)
    {
        int pos = lower_bound(lsh + 1, lsh + 1 + size, x[i]) - lsh;
        int res = fin(x[i], size, pos);
        if (res != -1)
            updata(1, res, -1);
        updata(1, pos, 1);
    }
    write(query(1, 1, size));
    return 0;
}

Measured memory_bytes: 4352
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args) {
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))){
      Integer N = Integer.parseInt(in.readLine());
      String s = in.readLine();
      int left=0, right=0, com=0;
      for(int i=0;i<N;i++){
        if(s.charAt(i)=='('){
          com = Math.max(com, 0);
          com++;
        }else{
          com--;
        }
        if(com<0){
          left++;
        }
      }
      com = 0;
      for(int i=N-1;i>=0;i--){
        if(s.charAt(i)=='('){
          com++;
        }else{
          com = Math.min(com, 0);
          com--;
        }
        if(com>0){
          right++;
        }
      }
      com = 0;
      StringBuffer sb = new StringBuffer(s);
      for(int i=0;i<left;i++){
        sb.insert(0, "(");
      }
      for(int i=0;i<right;i++){
        sb.append(")");
      }
      System.out.println(sb.toString());
    }catch(IOException e){
      e.printStackTrace();
    }
  }
}


Measured memory_bytes: 22996
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
#include <unordered_set>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

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

  int32_t N, K;
  cin >> N >> K;
  vector<int32_t> A(N,0);
  for (auto& a : A) {
    cin >> a;
  }
  for (int k = 0; k < K; k++) {
    vector<int> begin(N,0);
    vector<int> end(N,0);
    for (int i = 0; i < N; i++) {
      int b = max(0, i - A[i]);
      int e = min(N-1, i + A[i]);
      begin[b]++;
      end[e]++;
    }
    int cum_beg = begin[0];
    int cum_end = 0;
    A[0] = cum_beg;
    for (int i = 1; i < N; i++) {
      cum_beg += begin[i];
      cum_end += end[i-1];
      A[i] = cum_beg - cum_end;
    }
    if (begin[0] == N && end[N-1] == N)
      break;
  }
  for (int i = 0; i< N; i++) {
    cout << A[i] << " ";
  }
  cout  << endl;
  return 0;
}


Measured memory_bytes: 5592
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
#define inf 1000000001
using namespace std;
ll read(){
	char ch=getchar();ll x=0;int op=1;
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') op=-1;
	for (;isdigit(ch);ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
#define N 2005
int n,ans,a[N],b[N],f[N][N],w1[N][N],w2[N][N];char ch[5];
int main(){
	n=read();
	rep (i,1,2*n){
		scanf("%s",ch);int x=read();
		if (ch[0]=='B') a[x]=i;else b[x]=i;
	}
	rep (i,1,n) rep (j,1,i-1) ans+=(a[i]<a[j])+(b[i]<b[j]);
	rep (i,1,n) rep (j,1,n) w1[i][j]=w1[i][j-1]+(b[j]>a[i]);
	rep (i,1,n) rep (j,1,n) w2[i][j]=w2[i][j-1]+(a[j]>b[i]);
	memset(f,0x3f,sizeof(f));
	rep (i,0,n) f[0][i]=f[i][0]=0;
	rep (i,1,n) rep (j,1,n) f[i][j]=min(f[i-1][j]+w1[i][j],f[i][j-1]+w2[j][i]);
	cout<<ans+f[n][n]<<'\n';
	return 0;
}

Measured memory_bytes: 47360
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var n = next();
  var ans = 0;
  for(var i = 1; i <= n; i++){
    var a = next();
    if(i % 2 && a % 2)ans++;
  }
  return ans;
}

Measured memory_bytes: 29692
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

bool input(vector<int>& row, vector<int>& col, int& N, int& M) {
    scanf("%d %d ", &N, &M);

    for (int i = 0; i < N; i++) {
        int t;
        scanf("%d ", &t);
        row.push_back(t);
    }
    for (int i = 0; i < M; i++) {
        int t;
        scanf("%d ", &t);
        col.push_back(t);
    }
    return true;
}

void create2(vector<int> a, vector<int>& res) {
    for (int i = 0; i < a.size(); i++) {
        int t = 0;
        for (int j = i; j < a.size(); j++) {
            t += a[j];
            res.push_back(t);
        }
    }
    sort(res.begin(), res.end());
}

void solve(vector<int> r, vector<int> c) {
    int res = 0;
    for (int i = 0; i < r.size(); i++) {
        res += distance(
            lower_bound(c.begin(), c.end(), r[i]),
            upper_bound(c.begin(), c.end(), r[i]));
    }
    printf("%d\n", res);
}

int main() {
    int N, M;
    while (true) {
        vector<int> row, col;
        input(row, col, N, M);
        if (N == 0 && M == 0) {return 0;}
        vector<int> row2;
        vector<int> col2;

        create2(row, row2);
        create2(col, col2);

        solve(row2, col2);
    }
}

Measured memory_bytes: 24228
import copy

def print_list(A):
    print(*A, sep=" ")

def swap(a, b):
    return b, a

def val(str):
    return int(str[1])

def is_stable(_in, _out, n):
    for i in range(0, n):
        for j in range(i+1, n):
            for a in range(0, n):
                for b in range(a+1, n):
                    if val(_in[i]) == val(_in[j]) and _in[i] == _out[b] and _in[j] == _out[a]:
                        return False
    return True

def print_stable(_in, _out, n):
    if is_stable(_in, _out, n):
        print("Stable")
    else:
        print("Not stable")    

def find_minj(A, i, n):
    minj = i
    for j in range(i, n):
        if val(A[j]) < val(A[minj]):
            minj = j
    return minj        

def bubble_sort(A, n):
    A0 = copy.copy(A)
    flg = 1 #逆の隣接要素が存在する
    i = 0
    while flg:
        flg = 0
        for j in range(n-1, i, -1):
            if val(A[j-1]) > val(A[j]):
                A[j-1], A[j] = swap(A[j-1], A[j])
                flg = 1
        i += 1
    print_list(A)
    print_stable(A0, A, n)

def selection_sort(A, n):
    A0 = copy.copy(A)
    for i in range(0, n):
        minj = find_minj(A, i, n)
        if val(A[i]) > val(A[minj]):
            A[i], A[minj] = swap(A[i], A[minj])
    print_list(A)
    print_stable(A0, A, n)

n = int(input())
A = list(map(str,input().split()))
B = copy.copy(A)

bubble_sort(A, n)
selection_sort(B, n)


Measured memory_bytes: 6348
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int x = in.nextInt();
		int y = in.nextInt();
		int z = in.nextInt();
		
		if(x<y && y<z){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17176
#include<stdio.h>
int main(){
  int n,m,i;
  scanf("%d%d",&n,&m);
  int l=1,r=n,lnum,rnum;
  for(i=0;i<m;i++){
    scanf("%d%d",&lnum,&rnum);
    if(l<lnum)
      l=lnum;
    if(rnum<r)
      r=rnum;
  }
  if(l<=r)
    printf("%d\n",r-l+1);
  else
    printf("0\n");
  return 0;
}


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

int date_to_days(int y, int m, int d)
{
  int days = 0;
  for (int i = 1; i < y; ++i) {
    if (i % 3 == 0) days += 20 * 10;
    else days += (20 + 19) * 5;
  }
  for (int i = 1; i < m; ++i) {
    if (i % 2 == 0 && y % 3 != 0) days += 19;
    else days += 20;
  }

  days += d - 1;
  return days;
}

int main()
{
  int n;
  cin >> n;
  int premium = date_to_days(1000, 1, 1);
  for (int i = 0; i < n; ++i) {
    int y, m, d;
    cin >> y >> m >> d;
    cout << premium - date_to_days(y, m, d) << endl;
  }
}

Measured memory_bytes: 1160
import java.util.*;

public class Main {
	Scanner sc;
	final int MOD = 998244353;
	int N;
	int[][] p;
	int[] pow2;
	
	int[] st;
	int M;
	
	public Main() {
		sc = new Scanner(System.in);
	}
	
	private void calc() {
		N = sc.nextInt();
		p = new int[N][2];
		for (int i = 0; i < N; i++) {
			p[i][0] = sc.nextInt();
			p[i][1] = sc.nextInt();
		}
		pow2 = new int[N+1];
		pow2[0] = 1;
		for (int i = 1; i < N+1; i++)
			pow2[i] = (pow2[i-1]*2)%MOD;
		M = 1 << (Integer.toBinaryString(N-1).length());
		st = new int[2*M-1];
		
		Arrays.sort(p, (a,b) -> Integer.compare(a[1], b[1]));
		for (int i = 0; i < N; i++) p[i][1] = i;
		Arrays.sort(p, (a,b) -> Integer.compare(a[0], b[0]));
		for (int i = 0; i < N; i++) p[i][0] = i;
		
		int sum = (int) (((long)N-4)*(pow2[N]-1)%MOD);
		
		for (int j = 0; j < N; j++) {
			int a1 = insertYPos(p[j][1]);
			int a2 = p[j][1] - a1;
			int a3 = p[j][0] - a1;
			int a4 = N-1-p[j][1] - a3;
			
			int s = (pow2[a1] + pow2[a2])%MOD;
			s = (s + pow2[a3])%MOD;
			s = (s + pow2[a4])%MOD;
			sum = (sum + s)%MOD;
		}
		
		out(sum);
	}
	
	private int insertYPos(int y) {
		int r = getSegmentSum(0, y, 0, 0, M);
		updateYPos(y);
		return r;
	}
	
	private void updateYPos(int y) {
		int i = M-1+y;
		while (true) {
			st[i]++;
			if (i == 0) break;
			i = (i-1) >>> 1;
		}
	}
	
	private int getSegmentSum(int s, int e, int n, int l, int r) {
		if (r <= s || e <= l) return 0;
		if (s <= l && r <= e) return st[n];
		int vl = getSegmentSum(s, e, 2*n + 1, l, (l+r)/2);
		int vr = getSegmentSum(s, e, 2*n + 2, (l+r)/2, r);
		return vl+vr;
	}
	
	private void out(Object o) {
		System.out.println(o);
		System.out.flush();
	}
	
	public static void main(String[] args) {
		Main m = new Main();
		m.calc();
	}

}

Measured memory_bytes: 121868
from math import pi, sin, cos, sqrt

A, B, H, M = map(int, input().split())

x1 = A * cos(2 * pi * (H + M / 60) / 12)
y1 = A * sin(2 * pi * (H + M / 60) / 12)
x2 = B * cos(2 * pi * M / 60)
y2 = B * sin(2 * pi * M / 60)

print(sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)))


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

const int N_MAX =1000001;
struct edge{int to,length;};
int N;
vector<edge> G[N_MAX];
int d[N_MAX] ={};
int color[N_MAX]={};
int used[N_MAX];

void dfs(int v,int dis);


int main(void){
    cin >> N;
    int u,v,w;
    fill(used,used+N,false);

    rep(i,N-1){
        cin >> u >> v >> w;
        G[u-1].push_back((edge){v-1,w%2});       
        G[v-1].push_back((edge){u-1,w%2});       
    }
    dfs(0,0);
    rep(i,N){
        cout << color[i] << endl;
    }
}


void dfs(int v,int dis){
    if(used[v]) return ;
    d[v] =dis;
    used[v] = true;
    color[v] = dis%2;
    rep(i,G[v].size()){
        edge e = G[v][i];
        if(!used[e.to])dfs(e.to,dis+e.length);
    }
    return ;
}


Measured memory_bytes: 37632
#include<iostream>
using namespace std;
int main() {
	double l[10];
	double v[2];
	char c;
	while (cin >> l[0] >> c >> l[1] >> c >> l[2] >> c >> l[3] >> c >> l[4] >> c >> l[5] >> c >> l[6] >> c >> l[7] >> c >> l[8] >> c >> l[9] >> c >> v[0] >> c >> v[1]) {
		double a = 0;
		for (int i = 0; i < 10; i++){
			a += l[i];
		}
		a = a * v[0] / (v[0] + v[1]);
		for (int i = 0; i < 10; i++){
			a -= l[i];
			if (a == 0){
				cout << i + 1 << endl;
				goto c;
			}else if (a < 0){
				cout << i + 1 << endl;
				goto c;
			}
		}
	c:
		a = 0;
	}
}

Measured memory_bytes: 3156
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    ll n;
    cin >>n;
    vll a(n);
    ll money = 1000;
    ll kabu = 0;
    
    rep(i, n) {
        cin >>a[i];
        if (i > 0) {
            if (a[i] > a[i-1]) {
                kabu = money / a[i-1];
                money %= a[i-1];
            }
            if (a[i] > a[i-1]) {
                
                money += kabu * a[i];
                kabu = 0;
            }
        }
    }
    money += kabu * a[n-1];
    mes (money);
    
    
    
    
    
    
    


}


Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;

int abs(int x){
    if(x<0){
	x*=-1;
    }
    return x;
}

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

    int n,m,a[55],b[55],c[55],d[55];
    long long minv=LINF,point;

    cin>>n>>m;
    reps(i,n){
	cin>>a[i]>>b[i];
    }

    reps(i,m){
	cin>>c[i]>>d[i];
    }

    reps(i,n){
	reps(j,m){
	    long long sum=abs(a[i]-c[j])+abs(b[i]-d[j]);
	    if(minv>sum){
		minv=sum;
		point=j;
	    }
	}
	cout<<point<<'\n';
	minv=LINF;
    }
    return 0;
}


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

int main(){
    double ans = 9999999999;
    int aa=0;
    int N;
    double A, T;
    double h =0;
    cin >> N;
    cin >> T >> A;
    rep(i, N){
        cin >> h;
        double temp = T - h * 0.006;
        if(temp > A) temp = temp -A;
        else temp = A-temp;
        //cout << temp << endl;
        ans = min(ans , temp);
        if(ans == temp) aa = i+1;
    }
    cout << aa << endl;
    return 0;
}

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

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

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

const int N = 200005;

int A[N], B[N];

int main() {
  int n;
  S(n);
  rep(i,0,n) {
    S(B[i]);
    A[i] = B[i];
  }
  sort(B, B + n);
  rep(i,0,n) {
    if(A[i] <= B[n / 2 - 1]) {
      P(B[n / 2]);
    } else {
      P(B[n / 2 - 1]);
    }
  }
  return 0;
}


Measured memory_bytes: 3712
/*

Author: @karngyan
Team: BlundersPride

*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<ll,ll> pll;
typedef std::vector<vll> vvll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair
const ll N = 305;
ld n ;
ld dp[N][N][N];
// e(a , b , c) = (n-(a+b+c))/n * e(a,b,c) + (a/n)*e(a-1 , b, c) + (b/n)*e(a+1 , b -1 , c) + (c/n)*e(a , b+1, c-1) + 1
// prob id we chose a plate with 0 sushi , 1 sushi , 2 sushi or 3 sushi .. add all

// now rewrite the above formula to get e(a , b, c)

ld e(ld a , ld b , ld c)
{
	if( a < 0 or b < 0 or c < 0)
		return 0.0;
	if(a+b+c == 0)
		return 0.0;

	ld &ans = dp[(ll)a][(ll)b][(ll)c];
	if((ll)ans != -1)
		return ans;

	ans = (n/(a+b+c))*( ((a/n)*e(a-1 , b, c)) + ((b/n)*e(a+1 , b-1 , c)) + ((c/n)*e(a , b+1, c-1)) + 1.0);
	return ans;

}


signed main()
{

	fast;
	cout<<fixed<<setprecision(10);
	rep(i,0,N)
	rep(j,0,N)
	rep(k,0,N)
	dp[i][j][k] = -1;
////////////////////////////////////////////////////////////////////////////////////////////
	cin >> n;
	ll a = 0 , b = 0 , c = 0;
	rep(i,0,(ll)n)
	{
		ll e;
		cin >> e;
		if(e == 1)
			a++;
		if(e == 2)
			b++;
		if(e == 3)
			c++;
	}
	
	cout<<e(a , b , c)<<endl;







////////////////////////////////////////////////////////////////////////////////////////////
	
	return 0;
}


Measured memory_bytes: 443776
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0
    for c in '753':
        ret += dfs(s+c)
    return ret


def main():
    print(dfs('0'))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
s = dict()

for i in range(n):
  si = input()
  if si in s:
    s[si]+=1
  else:
    s[si]=1

ss = sorted([(_[1], _[0]) for _ in s.items()])[::-1]

mx = ss[0][0]

ssr = []
for ssi in ss:
  if ssi[0] == mx:
    ssr.append(ssi[1])
sss = sorted(ssr)

for sssi in sss:
  print(sssi)

Measured memory_bytes: 46932
#include<bits/stdc++.h>
using namespace std ;
int main ()
{
	int A=0,B=0,C=0;
	while(cin>>A>>B>>C)
	{
			if(A==7) 
		{
			if(B==5&&C==5)
			{
				 cout<<"YES"<<endl;
			}
			else cout<<"NO"<<endl;
		}
		else if(A==5)
		{
			if((B==7&&C==5)||(B==5&&C==7))
			{
				 cout<<"YES"<<endl;
			}
			else cout<<"NO"<<endl;
		}
	}
	return 	0;
}

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	


using namespace std;


typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 2e6+100;
const ll inf = 1e15;


int main(){
	fastio;
	ll a,b,c;
	string s;
	cin >> s;
	ll ans = 0;
	f(i,0,s.size())	 ans+=s[i]-'0';
	if(ans%9 == 0) cout << "Yes\n";
	else cout << "No\n";
}

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

using namespace std;

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

	ll n, x, t;
	cin >> n >> x >> t;
	ll ans=(n+x-1)/x;
	ans=(ll)ans*t;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <numeric>
using namespace std;
 
#define LOCAL  1
#define UPLOAD 2
 
#define ll long long
const long long INF = 1LL << 60;
 
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
#define REP(i,M) for(int i=0;i<M;i++)
 
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
 
  ll S = input();
  ll W = input();
  
  output(S <= W ? "unsafe" : "safe");

  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
template<class V> struct BIT { BIT() {}  // [L, R)
    int NV;vector<V> bit;BIT(int n){init(n);}void init(int n){NV=1;while(NV<n)NV*=2;bit.resize(NV);}
    V operator[](int e) { V s = 0; e++; while (e) s += bit[e - 1], e -= e&-e; return s; }
    void add(int e, V v) { e++; while (e <= NV) bit[e - 1] += v, e += e&-e; }
    int lower_bound(V val) { V tv = 0; int i, ent = 0; for (i = NV - 1; i >= 0; i--)
        if(tv+bit[ent+(1<<i)-1]<=val)tv+=bit[ent+(1<<i)-1],ent += (1 << i);return ent;}
    V get(int L, int R) {assert(0 <= L); assert(R <= NV); assert(L <= R);
        V res = 0; if(R) res += operator[](R - 1); if (L) res -= operator[](L - 1);return res;}
    void clear() { bit.clear(); }};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



string S;
//---------------------------------------------------------------------------------------------------
typedef long long ll;
ll BubbleSortCount(vector<int> &v) {
    int n = v.size();

    vector<int> dic;
    fore(i, v) dic.push_back(i);
    sort(dic.begin(), dic.end());
    dic.erase(unique(dic.begin(), dic.end()), dic.end());

    vector<int> w;
    fore(i, v) w.push_back(lower_bound(dic.begin(), dic.end(), i) - dic.begin());

    ll res = 0;
    BIT<ll> bit(n + 10);
    fore(i, w) bit.add(i, 1);
    fore(i, w) {
        res += bit.get(0, i);
        bit.add(i, -1);
    }
    return res;
}
//---------------------------------------------------------------------------------------------------
ll solve() {
    int N = S.length();
    deque<int> idx[26];
    rep(i, 0, N) idx[S[i] - 'a'].push_back(i);

    vector<int> vis(N);
    vector<int> to(N, -1);
    int l = 0;
    rep(i, 0, N) if (!vis[i]) {
        int c = S[i] - 'a';

        if (idx[c].size() == 1) continue;
        int j = idx[c].back();
        idx[c].pop_front();
        idx[c].pop_back();

        to[i] = l; vis[i] = 1;
        to[j] = N - 1 - l; vis[j] = 1;
        l++;
    }

    vector<int> v;
    rep(c, 0, 26) while (!idx[c].empty()) {
        int x = idx[c].front();
        idx[c].pop_front();
        v.push_back(x);
    }

    ll res = -1;
    if (v.size() == 0) res = BubbleSortCount(to);
    else if (v.size() == 1) {
        to[v[0]] = N / 2;
        res = BubbleSortCount(to);
    } else res = -1;
    return res;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> S;
    cout << solve() << endl;
}

Measured memory_bytes: 7056
import math
n=int(input())
a=list(map(int,input().split()))
A=max(a)
l=[i for i in range(A+1)]
for i in range(2,A+1):
  if l[i]==i:
    for j in range(1,A//i+1):
      if i*j<=A:
        l[i*j]=i

L=set()
f=0
for i in range(n):
  x=a[i]
  L2=set()
  while x!=1:
    L2.add(l[x])
    x//=l[x]
  L2=list(L2)
  for j in range(len(L2)):
    if L2[j] in L:
      f=1
    else:
      L.add(L2[j])
  if f==1:
    break
if f==0:
  print('pairwise coprime')
  exit()

y=a[0]
for i in range(1,n):
  y=math.gcd(y,a[i])
if y==1:
  print('setwise coprime')
else:
  print('not coprime')

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

namespace AtCoder_Beginner_Contest_126
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = NK[0];
            var K = NK[1];
            int max = (int)Math.Ceiling(Math.Log(K, 2));
            var li = new double[max + 1];
            li[0] = 1;
            for (int i = 1; i <= max; ++i)
            { li[i] = li[i - 1] * 0.5; }
            double p = 0;

            var nd = N;
            if (K <= N)
                nd = K-1;

            for (int i = 1; i <= nd; ++i)
            {
                int jyo = (int)Math.Ceiling(Math.Log((double)K / i, 2));
                p += li[jyo];
            }
            double hosei = 0;
            if (K <= N)
                hosei = (double)(N + 1 - K) / N;
            double ans = p / NK[0] + hosei;
            Console.WriteLine(ans);                        
        }
    }
}

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

int main () {
  int N;
  cin >> N;
  vector <double> x(N);
  vector <string> u(N);
  for (int i = 0; i < N; i++) cin >> x.at(i) >> u.at(i);
  double ans = 0;
  for (int i = 0; i < N; i++){
    if (u.at(i) == "JPY") ans += x.at(i);
    else ans += 380000*x.at(i);
  }
  cout << fixed << setprecision(10);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <memory.h>
#include <queue>
#include <string.h>
#include <set>
#include <bitset>
using namespace std;

#define N 301
#define inf 1000000000000000000L
vector<pair<int,int> > adj[N];

pair<long long,int> need[N][N];
//first = 충전 cost, 남은 리터
//충전 코스트가 낮으면 낮을 수록 , 남은 리터가 높으면 높을 수록 좋다
void dijkstra(int st,int L,int n) {
  for(int i=1;i<=n;++i) {
    need[st][i] = make_pair(inf,0);
  }

  need[st][st] = make_pair(0LL,-L);
  priority_queue<pair<pair<long long,int>,int>,vector<pair<pair<long long,int>,int> >,
  greater<pair<pair<long long,int>,int> > >pq;
  pq.push(make_pair(make_pair(0LL,-L),st));
  int numComplte = 0;
  while(!pq.empty() && numComplte<n) {
    pair<long long,int> dist = pq.top().first;
    int curNode = pq.top().second;
    pq.pop();
    if(need[st][curNode]!=dist) continue;
    ++numComplte;
    for(int i=0;i<adj[curNode].size();++i) {
      int w = adj[curNode][i].first;
      pair<long long,int> ndist = dist;
      if(ndist.second + w>0) {
        ++ndist.first;
        ndist.second  = -L;
      }
      ndist.second += w;
      int nextNode = adj[curNode][i].second;
      if(need[st][nextNode]>ndist) {
        need[st][nextNode] = ndist;
        pq.push(make_pair(ndist,nextNode));
      }
    }
  }
}
void solve() {
  int n,m,l;scanf("%d %d %d",&n,&m,&l);
  for(int i=0;i<m;++i) {
    int a,b,c;scanf("%d %d %d ", &a,&b,&c);
    if(c>l)continue;
    adj[a].push_back(make_pair(c,b));
    adj[b].push_back(make_pair(c,a));
  }
  for(int i=1;i<=n;++i) {
    dijkstra(i,l,n);
  }
  int q;scanf("%d ",&q);
  while(q--) {
    int a,b;scanf("%d %d ", &a,&b);
    pair<long long,int> x = need[a][b];
    if(x.first==inf) {
      printf("-1\n" );
      continue;
    }
    printf("%lld\n", x.first);
  }
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


Measured memory_bytes: 4428
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define ft first
#define sd second
#define flag bool fl=true

#define mod 1000000007
#define N 10000001
#define MX 1000000001
#define MXX 1000000000000000001

#define pb push_back
#define fa(n) for(int i=0;i<n;i++)
#define fa1(n) for(int i=1;i<=n;i++)
#define fab(i, a, b) for(int i=a;i<=b;i++)
#define cs cout<<"Case "<<qq<<": "
#define csl cout<<"Case "<<qq<<":"<<endl;
#define T int tt, qq=0; cin>>tt; while(qq++<tt)
#define fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define ina(array, size) for(int i=0;i<size;i++) cin>>array[i];
#define outa(array, size) for(int i=0;i<size;i++) cout<<array[i]<<" ";
#define outla(array, size) for(int i=0;i<size;i++) cout<<array[i]<<endl;

#define deg(rad) (rad*180.0)/pi
#define pi acos(-1)
#define log(n) (int)log2(n)
#define logg(a)(b) log(b)/log(a)

int main()
{
    ll d, t, s;
    cin>>d>>t>>s;

    if(t*s>=d) cout<<"Yes";
    else cout<<"No";
}


/*

//----------useful_functions----------

long long extended_euclid(ll a, ll b, ll &x, ll &y) //ax+by=c
{
    if(b==0)
    {
        x=1, y=0;
        return a;
    }

    ll x1, y1;
    ll d=extended_euclid(b, a%b, x1, y1);
    x=y1;
    y=x1-y1*(a/b);
    return d;
}

long long bigMod(ll a, ll b) //(a^b)%mod
{
    ll ans=1;
    while(b)
    {
        if(b%2==1) ans=(ans*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return ans%mod;
}

long long modInverse(ll a, ll b) //a*x=1 mod b
{
    ll x, y;
    ll gcd=extended_euclid(a, b, x, y);

    if(gcd==1) return ((x%b)+b)%b;
    else return 1;
}

long long nCr(ll n, ll r) //n<=1e6
{
    //declare globally-> ll fact[1000001];
    fact[1]=1;
    for(ll i=2; i<1000001; i++)
        fact[i]=(i*fact[i-1])%mod;

    return (fact[n]*modInverse(fact[r], mod)*modInverse(fact[n-r], mod))%mod;
}

long long josephus(ll n, ll k) //k'th person is killed out of n in the circle
{
    if(n==1) return 1;
    else return (josephus(n-1, k)+k-1)%n+1;
}

bool fl[N+1];
vector<ll> sieve(ll n)
{
    vector<ll> primes;
    for(ll i=3; i*i<=n; i+=2)
        for(ll j=i*i; j<=n; j+=i+i)
            fl[j]=true;

    primes.pb(2);
    for(ll i=3; i<=n; i+=2) if(!fl[i]) primes.pb(i);
    return primes;
}
vector<ll> p=(sieve(N));

ll eulerTotient(ll x)
{
    db ans=x;
    for(int i=0; i<p.size() && p[i]*p[i]<=x; i++)
    {
        if(x%p[i]==0)
        {
            ans*=(1.0-(1/(db)p[i]));
            while(x%p[i]==0) x/=p[i];
        }
    }
    if(x>1) ans*=(1.0-(1/(db)x));

    return ans;
}

*/


Measured memory_bytes: 3628
n = int(input())
A = list(map(int, input().split()))

ans = 0
count = 1
y = 0

if A.count(1) == 0:
    ans = -1
else:
    for i in range(n):
        if A[i] != count:
            ans += 1
            pass
        else: 
            count += 1

print(ans)





Measured memory_bytes: 24744
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
#include <tgmath.h>
#include <time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007
int n, k;
ll nyan[222222] = {}, sum = 0;

main()
{
    scanf("%d%d", &n, &k);
    for (int i = 1; i < 222222; i++)
    {
        nyan[i] = nyan[i - 1] + i;
    }
    for (int i = k; i <= n + 1; i++)
    {
        sum += nyan[n] - nyan[max(0, n - i)] - nyan[i - 1] + 1;
        sum %= mod;
        //printf("%lld\n", sum);
    }
    printf("%lld\n", sum);
}

Measured memory_bytes: 3468
#include <stdio.h>
#include <string.h>
#include <stdlib.h> //この問題は隣接しないとなので、qsortだめです～

int main(void)
{
    int N;
    int K;
    int a[200000];
    double max = 0.0;
    double sum = 0.0;
    for (int i = 0; i < 200000; i++)
    {
        a[i] = -1;
    }
    scanf("%d %d", &N, &K);
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &a[i]);
    }
    // for (int i = 0; i < N - K + 1; i++)
    // {
    //     for (int j = 0; j < K; j++)
    //     {
    //         sum += ((double)a[i + j] + 1) / 2;
    //     }
    //     if (sum > max)
    //     {
    //         max = sum;
    //     }
    //     sum = 0;
    //}
    for (int j = 0; j < K; j++)
    {
        max += ((double)a[j] + 1) / 2;
    }
    sum = max;
    for (int i = 0; i < N - K; i++)
    {
        sum += ((double)a[i + K] - (double)a[i]) / 2;
        if (max < sum)
        {
            max = sum;
        }
    }

    printf("%lf", max);
    return 0;
}

Measured memory_bytes: 896
#include <iostream>

using namespace std;

int main(void){
  int a, b;
  
  cin >> a >> b;
  
  if(a + b == 15) cout << '+' << endl;
  else if(a * b == 15) cout << '*' << endl;
  else cout << 'x' << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7;
int sqr(int x){return x*x%mod;}
int pow(int a,int n){return n?sqr(pow(a,n/2))*(n&1?a:1)%mod:1;}
int n,x,h[200001],ans=0,r=1;
main()
{
	cin>>n;
	for(int i=1;i<=n;i++)h[i]=(h[i-1]+pow(i,mod-2))%mod;
	for(int i=1;i<=n;i++)cin>>x,ans+=x*(h[i]+h[n-i+1]-1+mod)%mod,r=r*i%mod;
	cout<<ans%mod*r%mod<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cstring>
int main()
{
	int N, K;
	std::cin >> N >> K;
	std::vector<int> P(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> P[i];
	}
	std::vector<int> C(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> C[i];
	}
	int64_t max_score_all = 0;
	for (int i = 0; i < N; ++i) {
		int64_t max_score = 0;
		int64_t score = 0;
		int pos = i;
		for (int64_t count = 0; count < K; ++count) {
			pos = P[pos]-1;
			score += C[pos];
			if (count==0||score > max_score) {
				max_score = score;
			}
			if (pos == i) {
				const int64_t loop = count + 1;
				count = K / loop * loop - 1;
				const int64_t diff = max_score - score;
				score *= K / loop;
				if (score + diff > max_score) {
					max_score = score + diff;
				}
			}
		}
		if (i==0||max_score > max_score_all) {
			max_score_all = max_score;
		}
	}
	std::cout << max_score_all << std::endl;
	return 0;
}

Measured memory_bytes: 3664
using namespace std;

#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <numeric>
#include <map>
using namespace std;


int main(void){
	int N,M;

	cin >> N;

  multiset<long long int> A, plu, minu;
  for (int i = 0;i<N;i++)
  {
    long long int tmp;
    cin >> tmp;
    A.insert(tmp);
    if (tmp <= 0)
      minu.insert(tmp);
    else
      plu.insert(tmp);
  }
  
  auto sum = 0LL, neuv = 0LL;
  vector<pair<long long int,long long int>> r;
  
  while (plu.size() + minu.size() > 1) {
    if (plu.empty()){
      if (minu.size() == 2){
      	neuv = *minu.rbegin() - *(minu.rbegin()++);
     	r.emplace_back(*minu.rbegin(), *(minu.rbegin()++));
      }
      else{
      	neuv = *(minu.rbegin()++) - *minu.rbegin();
     	r.emplace_back(*(minu.rbegin()++), *minu.rbegin());
      }
      sum = neuv;
      minu.erase(--minu.end());
      minu.erase(--minu.end());
      if (neuv < 0)
        minu.insert(neuv);
      else
        plu.insert(neuv);
    }
    else if (minu.empty()) {
      if (plu.size() == 2){
        neuv = *(plu.begin()++) - *plu.begin();
      r.emplace_back(*(plu.begin()++), *plu.begin());
      }
      else{
        neuv = *plu.begin() - *(plu.begin()++);
      r.emplace_back(*plu.begin(), *(plu.begin()++));
      }
      sum = neuv;
      plu.erase(plu.begin());
      plu.erase(plu.begin());
      if (neuv <= 0)
        minu.insert(neuv);
      else
        plu.insert(neuv);
    }
    else if (plu.size() <= minu.size()) {
      neuv = *plu.begin() - *minu.rbegin();
      sum = neuv;
      r.emplace_back(*plu.begin(), *minu.rbegin());
      plu.erase(plu.begin());
      minu.erase(--minu.end());
      if (neuv < 0)
        minu.insert(neuv);
      else
        plu.insert(neuv);
      
    }
    else {
      neuv = *minu.rbegin() - *plu.begin();
      sum = neuv;
       r.emplace_back(*minu.rbegin(), *plu.begin());
      plu.erase(plu.begin());
      minu.erase(--minu.end());
      if (neuv <= 0)
        minu.insert(neuv);
      else
        plu.insert(neuv);
      
    }
  }
	cout << sum << endl;
  for (auto&& i : r)
    cout << i.first << " " << i.second << endl;

	return 0;
}


Measured memory_bytes: 12916
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define debug(x) cout << #x << " = " << (x) << endl;
#define pb push_back
//#define MOD 1000000007
//#define MOD 998244353
#define MOD 1000000007000000
#define INF 1000000000000
#define EPS 0.00000000001
typedef long long ll;

ll power(ll x, ll y) // x^y
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
        {
            res = res * x % MOD;
        }
        x = x * x % MOD;
        y >>= 1;
    }
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    ll n,p;
    cin>>n>>p;
    vector<int> a(n);
    ll guu=0,ki=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]%2==0){
            a[i]=0;
            guu++;
        }
        else{
            a[i]=1;
            ki++;
        }
    }
    if(ki==0){
        if(p==0){
            cout<<power(2,n)<<endl;
        }
        else{
            cout<<0<<endl;
        }

    }
    else{
        cout<<power(2,n-1)<<endl;
    }

    

}


Measured memory_bytes: 256
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

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

template< typename T > using Vec = vector< T >;

template< typename T > bool inRange(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool inRange(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//



int main() {
	int A, B, T;
	cin >> A >> B >> T;
	cout << (T / A) * B << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    string w;
    cin >> w;
    map<char, int> m;
    for (int i = 0; i < w.size(); i++)
        m[w[i]]++;
    for (auto it = m.begin(); it != m.end(); it++) {
        if (it->second % 2) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

#define MAX 2000000000
#define INFTY -1

int H;
int A[MAX+1];

void maxHeapify(int);
int extract(void);
void IncreaseKey(int ,int );
void insert(int);

int main(){
	int key;
	char com[10];

	while(1){
		scanf("%s",com);

		if(strcmp(com,"end") == 0) break;
		if(strcmp(com,"insert") == 0){
			scanf("%d",&key);
			insert(key);
		}
		else{
			printf("%d\n",extract());
		}
	}
	return 0;
}

void maxHeapify(int z){
  int right, left, largest;
  int tmp;
  left = 2 * z;
  right = 2 * z + 1;

	//keyが最大のノードを選ぶ
  if(left <= H && A[left] > A [z]) largest = left;
  else largest = z;
  if(right <= H && A[right] > A[largest]) largest = right;

  if(largest != z){
    tmp = A[z];
    A[z] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}


int extract(){
	int maxv;
	if(H < 1) return INFTY;
	maxv = A[1];
	A[1] = A[H--];
	maxHeapify(1);
	return maxv;
}

void IncreaseKey(int i,int key){
int tmp;

	if(key < A[i]) return;
	A[i] = key;
	while(i > 1 && A[i / 2] < A[i]){
	 //A[i]とA[i / 2]を交換
	 	tmp = A[i];
		A[i] = A[i / 2];
		A[i / 2] = tmp;
		i = i / 2;
	}
}

void insert(int key){
	H++;
	A[H] = INFTY;
	IncreaseKey(H,key);
}



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

#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second

typedef pair<int, int> PII;
typedef long long ll;

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

	int n;
	cin >> n;
	double coin[3000];
	for (int i = 1; i <= n; i++) cin >> coin[i];
	vector<vector<double> > dp(n+2,vector<double>(n+2, 0));
	dp[0][0]=1.0;
	for (int i = 1; i <= n; i++) {
		dp[i][0]=(1.0-coin[i])*dp[i-1][0];
		for (int j = 1; j <= i; j++) {
			dp[i][j]=dp[i-1][j-1]*(coin[i]);
			dp[i][j]+=dp[i-1][j]*(1.0-coin[i]);
		}
	}
	double ans = 0;
	for (int i = (n+1)/2; i <= n; i++) ans+=dp[n][i];
	cout << setprecision(9) << ans << "\n";

}

Measured memory_bytes: 73656
#include<iostream>
#include<stack>
#include<stdlib.h>
using namespace std;
int main(){

  int x,y;
  stack<int> S;
  char s[100];
  
  while(cin >> s){
    
    if(s[0] == '+'){
      x=S.top();
      S.pop();
      y=S.top();
      S.pop();
      S.push(x+y);
    }else if(s[0] == '-'){
      x=S.top();
      S.pop();
      y=S.top();
      S.pop();
      S.push(y-x);
    }else if(s[0] == '*'){
      x=S.top();
      S.pop();
      y=S.top();
      S.pop();
      S.push(x*y);
    }else{
      x = atoi(s);
      S.push(x);
    }
    
  }
  
  cout <<S.top()<<endl;
  
  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <cstring>
#include <stdio.h>

using namespace std;

int main(){
	long long n, x;
	cin>>n;
	x = n/11;
	int y = n%11;
	if(y == 0)
		cout<<2*x<<endl;
	else if(y <= 6)
		cout<<2*x + 1<<endl;
	else cout<<2*x + 2<<endl;
	return 0;
}

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

#define endl '\n'

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

    int n; cin >> n;
    map<string, int> freq;
    int maior = 0;
    for (int i=0; i<n; i++){
        string x; cin >> x;
        freq[x]++;
        maior = max(maior, freq[x]);
    }
    for (pair<string, int> x : freq){
        if (x.second == maior) cout << x.first << endl;
    }
}

Measured memory_bytes: 23808