akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        double[] p = new double[n];
        for (int i=0; i<n; i++) p[i] = sc.nextDouble();

        double[][] dp = new double[n+1][n+1];

        dp[0][0] = 1;

        for (int i=1; i<=n; i++) {
            for (int j=0; j<=n; j++) {
                if (j == 0) {
                    dp[i][j] = dp[i-1][j] * (1 - p[i-1]);
                    continue;
                }
                dp[i][j] = dp[i-1][j] * (1 - p[i-1]) + dp[i-1][j-1] * p[i-1];
            }
        }

        double res = 0;

        for (int i=n/2+1; i<=n; i++) {
            res += dp[n][i];
        }

//        System.out.println(dp[1][1]);
//        System.out.println(dp[1][0]);

        System.out.println(res);

    }

}



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

int main()
{
	while (true){
		int n;
		cin >> n;
		if (!n) break;
		int pipe = 0;
		for (int i = 0; i < n; i++){
			int in;
			cin >> in;
			pipe += in;
		}
		int j[65000], jsum = 0;
		j[0] = 0;
		for (int i = 1; i < n; i++){
			cin >> j[i];
			jsum += j[i];
		}
		sort(j, j + n);
		for (int i = 1; i < n; i++)	j[i] += j[i - 1];
		for (int i = 0; i < n; i++)	j[i] = jsum - j[i];

		unsigned int ans = 0;
		for (int i = 0; i < n; i++){
			ans = max(ans, (unsigned int)(pipe + j[i]) * (i + 1));
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1424
import sys
import heapq
if sys.version[0] == '2':
    range, input = xrange, raw_input
MAX_SPEED = 30
while True:
    N, M = map(int, input().split())
    if not (N | M):
        break
    S, G = map(lambda x: int(x) - 1, input().split())
    edge = [[] for _ in range(N)]
    for _ in range(M):
        x, y, d, c = map(int, input().split())
        edge[x - 1].append((y - 1, d, c))
        edge[y - 1].append((x - 1, d, c))
    INF = float('inf')
    dist = [[[INF for _ in range(N)] for _ in range(MAX_SPEED + 1)] for _ in range(N)]
    que = [(0.0, S, 0, S)]
    while que:
        cost, now, v, prev = heapq.heappop(que)
        if cost > dist[now][v][prev]:
            continue
        if now == G and v == 1:
            print("{:.20f}".format(cost))
            break
        dist[now][v][prev] = cost
        for x, d, c in edge[now]:
            if x == prev:
                continue
            for dv in (-1, 0, 1):
                nv = v + dv
                if 0 < nv <= c and dist[x][nv][now] > dist[now][v][prev] + d / nv:
                    dist[x][nv][now] = dist[now][v][prev] + d / nv
                    heapq.heappush(que, (dist[x][nv][now], x, nv, now))
    else:
        print("unreachable")

Measured memory_bytes: 9824
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

ll N,M;
vector<vector<ll>> G,L,R;
ll dp[100000], ans[100000];
ll dfs1(int v, int pv = -1) {
    dp[v] = 1;
    for (int i = 0; i < G[v].size(); ++i) {
        if (G[v][i] == pv) continue;
        L[v][i+1] = R[v][i] = dfs1(G[v][i],v)+1;
        dp[v] = dp[v]*R[v][i]%M;        
    }
    return dp[v];
}

void dfs2(int v, ll val = 0, int pv = -1) {
    ans[v] = dp[v]*(val+1);
    ans[v] %= M;
    rep(i,G[v].size()) {
        if (G[v][i] == pv) continue;
        ll K = L[v][i]*R[v][i+1]%M;
        K = K*(val+1)%M;
        dfs2(G[v][i], K, v);
    }
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> N >> M;
    G.resize(N); L.resize(N); R.resize(N);
    rep(i,N) L[i].emplace_back(1);
    rep(i,N) R[i].emplace_back(1);
    rep(i,N-1) {
        int x,y; cin >> x >> y;
        --x; --y;
        G[x].emplace_back(y);
        G[y].emplace_back(x);
        L[x].emplace_back(1);
        R[x].emplace_back(1);
        L[y].emplace_back(1);
        R[y].emplace_back(1);
    }
    dfs1(0);
    rep(i,N) {
        int k = G[i].size();
        rep(j,k) {
            L[i][j+1] = L[i][j+1]*L[i][j]%M;
            R[i][k-j-1] = R[i][k-j-1]*R[i][k-j]%M;
        }
    }
    dfs2(0);

    rep(i,N) cout << ans[i] << ln;
}


Measured memory_bytes: 30336
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

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

	int cnt = 0;
	while(true) {
		bool odd = false;
		rep(i, N) {
			if(A[i]%2!=0) odd = true; 
		}

		if(!odd) {
			cnt++;
			rep(i, N) A[i] /= 2;
			//cout << "cnt:" << cnt << endl;
		} else {
			break;
		}
	}

	cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<cassert>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<bitset>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const int INF = (1 << 30);
const long double EPS = 10e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int calc_min_pair(int a) {
    int b = 1;
    while(b < a) b <<= 1;
    return b-a;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n), used(n, 0);
    map<int, int> mp;
    for(int i=0;i<n;++i) {
        cin >> a[i];
        ++mp[a[i]];
    }
    sort(all(a));

    int ans = 0;
    for(int i=n-1;i>=0;--i) {
        if(mp[a[i]] <= 0) continue;
        int b = calc_min_pair(a[i]);
        // cerr << a[i] << " " << b << endl;
        --mp[a[i]];
        if(b == 0) b = a[i];
        if(mp[b] > 0) {
            ++ans;
            --mp[b];
        }
    }

    cout << ans << endl;
}


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

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

struct Piece {
    Piece(pii ul_, int h_, int w_) : ul{ul_}, h{h_}, w{w_} {}
    pii ul;
    int h;
    int w;
    pair<Piece, Piece> cut(int s)
    {
        s = s % (2 * h + 2 * w);
        if (s < w) {
            Piece pieces[2] = {Piece{ul, h, s}, Piece{make_pair(ul.first, ul.second + s), h, w - s}};
            sort(pieces, pieces + 2);
            return make_pair(pieces[0], pieces[1]);
        }
        s -= w;
        if (s < h) {
            Piece pieces[2] = {Piece{ul, s, w}, Piece{make_pair(ul.first + s, ul.second), h - s, w}};
            sort(pieces, pieces + 2);
            return make_pair(pieces[0], pieces[1]);
        }
        s -= h;
        if (s < w) {
            const int s_ = w - s;
            Piece pieces[2] = {Piece{ul, h, s_}, Piece{make_pair(ul.first, ul.second + s_), h, w - s_}};
            sort(pieces, pieces + 2);
            return make_pair(pieces[0], pieces[1]);
        }
        s -= w;
        if (s < h) {
            const int s_ = h - s;
            Piece pieces[2] = {Piece{ul, s_, w}, Piece{make_pair(ul.first + s_, ul.second), h - s_, w}};
            sort(pieces, pieces + 2);
            return make_pair(pieces[0], pieces[1]);
        }
    }
    bool operator<(const Piece& p)
    {
        return h * w < p.h * p.w;
    }
};

int main()
{
    while (true) {
        int n, w, d;
        cin >> n >> w >> d;
        if (n == 0 and w == 0 and d == 0) {
            break;
        }
        vector<Piece> piece;
        piece.push_back(Piece{make_pair(0, 0), d, w});
        for (int i = 0; i < n; i++) {
            int p, s;
            cin >> p >> s;
            p--;
            const auto pieces = piece[p].cut(s);
            piece.erase(piece.begin() + p);
            piece.push_back(pieces.first);
            piece.push_back(pieces.second);
        }
        sort(piece.begin(), piece.end());
        for (int i = 0; i < piece.size(); i++) {
            const auto& p = piece[i];
            if (i > 0) {
                cout << " ";
            }
            cout << p.w * p.h;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3000
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 12; i++) {
            sb.append(s.charAt(i));
            if (i == 3) {
                sb.append(" ");
            }
        }
        System.out.println(sb);
        // output
    }
}


Measured memory_bytes: 10188
#include <iostream>
#include <climits>
#include <vector>
#include <queue>
using namespace std;
#define ll long long
void solve(){
	ll n,m;
	cin >> n >> m;
	ll x[m],y[m],in[n]={0};
	vector<ll> adj[n];
	for(ll i=0;i<m;i++){
		cin >> x[i] >> y[i];
		x[i]--;
		y[i]--;
		adj[x[i]].push_back(y[i]);
		in[y[i]]++;
	}
	queue<ll> q;
	for(ll i=0;i<n;i++){
		if(!in[i]){
			q.push(i);
		}
	}
	ll dp[n]={0},vis[n]={0};
	while(!q.empty()){
		ll t=q.front();
		q.pop();
		for(auto k:adj[t]){
			if(!vis[k]){
				dp[k]=max(dp[t]+1,dp[k]);
				if(--in[k]==0)
					q.push(k);
			}
		}
		vis[t]=1;
	}
	ll ans=0;
	for(ll i=0;i<n;i++){
		ans=max(ans,dp[i]);
	}
	cout << ans << "\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll t=1;
	// cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 13024
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, BinaryHeap, VecDeque, BTreeSet, BTreeMap};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::io::stdin;

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
                   ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
                   ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let abcd: Vec<isize> = util::line()
        .chars()
        .map(|c| c as isize - '0' as isize)
        .collect();

    for f in 0..1 << 3 {
        let mut x = abcd[0];

        for i in 0..3 {
            if f & 1 << i == 0 {
                x -= abcd[i + 1];
            } else {
                x += abcd[i + 1];
            }
        }

        if x == 7 {
            println!(
                "{}{}=7",
                abcd[0],
                abcd[1..]
                    .iter()
                    .zip(0..3)
                    .flat_map(|(n, i)| {
                        vec![
                            if f & 1 << i == 0 {
                                "-".to_owned()
                            } else {
                                "+".to_owned()
                            },
                            n.to_string(),
                        ].into_iter()
                    })
                    .collect::<String>()
            );
            return;
        }
    }
}


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

struct Trunmp {
    char suit;
    int nmber;
};

void bubble_sort(vector<Trunmp>& trumps) {
    for (int i = 0; i < trumps.size(); i++) {
        for (int j = (int)trumps.size() - 1; j > i; j--) {
            if (trumps[j].nmber < trumps[j - 1].nmber)
                swap(trumps[j], trumps[j -1]);
        }
    }
}

void selection_sort(vector<Trunmp>& trumps) {
    for (int i = 0; i < trumps.size(); i++) {
        int mini = i;
        for (int j = i; j < trumps.size(); j++) {
            if (trumps[j].nmber < trumps[mini].nmber)
                mini = j;
        }
        swap(trumps[i], trumps[mini]);
    }
}

bool is_stable(vector<Trunmp>& t1, vector<Trunmp>& t2) {
    for (int i = 0; i < t1.size(); i++) {
        if (t1[i].suit != t2[i].suit)
            return false;
    }
    return true;
}

void print_trumps(vector<Trunmp>& trumps) {
    for (int i = 0; i < trumps.size(); i++) {
        if (i > 0)
            cout << " ";
        cout << trumps[i].suit << trumps[i].nmber;
    }
    cout << endl;
}

int main() {
    int N;
    cin >> N;
    vector<Trunmp> trumps1(N), trumps2(N);
    for (int i = 0; i < N; i++)
        cin >> trumps1[i].suit >> trumps1[i].nmber;
    copy(trumps1.begin(), trumps1.end(), trumps2.begin());

    bubble_sort(trumps1);
    selection_sort(trumps2);

    print_trumps(trumps1);
    cout << "Stable" << endl;
    print_trumps(trumps2);
    if (is_stable(trumps1, trumps2))
        cout << "Stable" << endl;
    else
        cout << "Not stable" << endl;
    return 0;
}


Measured memory_bytes: 3152
using System;

namespace AtCoder.ABC090
{
    public class A
    {
        public static void Solve()
        {
            string s1 = Console.ReadLine();
            string s2 = Console.ReadLine();
            string s3 = Console.ReadLine();

            Console.WriteLine(s1[0].ToString()+s2[1].ToString()+s3[2].ToString());
        }    
    }
}

namespace AtCoder {
    class Program
    {
        static void Main(string[] args)
        {
            ABC090.A.Solve();
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstring>
#include <map>
#include <cctype>
#define Pf p.first
#define Ps p.second
#define PP mas[Ps][Pf]
using namespace std;

typedef pair<int,int> P;
int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
char mas[101][101];
bool used[50][50][4][16];
int w,h,muki = 0 ,memo = 0;

P move(P p,int i){
    Pf += dx[i];
    Ps += dy[i];
    if(Pf < 0) Pf = w-1;
    else if(Pf >= w) Pf = 0;
    if(Ps < 0) Ps = h-1;
    else if(Ps >= h) Ps = 0;
    return p;
}

bool solve(P p,int muki){
    while(1){
        if(!used[Ps][Pf][muki][memo]) return false;
        else if(PP == '@') return true;
        used[Ps][Pf][muki][memo] = false;
        if(PP == '>') muki = 0;
        else if(PP == 'v') muki = 1;
        else if(PP == '<') muki = 2;
        else if(PP == '^') muki = 3;
        else if(PP == '_') muki = (memo == 0)? 0 : 2;
        else if(PP == '|') muki = (memo == 0)? 1 : 3;
        else if(PP == '.'){}
        else if(isdigit(PP)) memo = PP - '0';
        else if(PP == '+') memo = (memo == 15)? 0 : memo + 1;
        else if(PP == '-') memo = (memo == 0)? 15 : memo - 1;
        else if(PP == '?'){
            for(int i=0;i<4;i++){
                if(solve(move(p,i),i)) return true;
            }
            return false;
        }
        p = move(p,muki);
    }
}

int main(){
    cin >> h >> w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++) cin >> mas[i][j];
    }
    memset(used,true,sizeof(used));
    if(solve(P(0,0),0)) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 1924
#include<iostream>
using namespace std;
int  main()
{
	int a, b;
	cin >> a >> b;
	bool flag = false;
	for (int c = 0; c <= 3; c++) {
		if ((a*b*c) % 2 == 1)flag = true;
	}
	if (flag)cout << "Yes" << endl;
	else cout<< "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import math
from collections import deque
from collections import defaultdict

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

h1,m1,h2,m2,k = readInts()

ans = (h2*60+m2)-(h1*60+m1) - k

print(ans)

Measured memory_bytes: 9600
#include<cstdio>

void max_swap(int&a, int &b)
{
	if(a>b) return;
	int c=a;
	a=b;
	b=c;
}

int main(void)
{
	int a, b, c, k;

	while(scanf("%d%d%d%d", &a, &b, &c, &k)==4)
	{
		max_swap(a, b);
		max_swap(a, c);
		int ans=(a<<k)+b+c;
		printf("%d\n", ans);
	}
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    rep(i,N){
        cin >> A[i];
    }
    rep(i,N){
        cin >> B[i];
    }
    map<int,int> mpa;
    map<int,int> mpb;
    rep(i,N){
        mpa[A[i]]++;
        mpb[B[i]]++;
    }
    vector<int> a(N + 1, 0);
    vector<int> b(N + 1, 0);
    rep(i,N){
        a[A[i]] = i + 1;
    }
    rep(i,N){
        b[B[i]] = i + 1;
    }
    rep(i,N){
        a[i + 1] = max(a[i + 1], a[i]);
        b[i + 1] = max(b[i + 1], b[i]);
    }
    cout << endl;
    int max_sum = 0;
    int max_pointer = 1;
    for (int i = 1; i <= N; i++){
        if (max_sum < mpa[i] + mpb[i]){
            max_sum = mpa[i] + mpb[i];
            max_pointer = i;
        }
    }
    bool possible = true;
    vector<int> C(N);
    if (max_sum > N){
        possible = false;
    }
    else{
        int zurashi = -1 * N;
        rep(i,N){
            zurashi = max(zurashi, a[i + 1] - b[i]);
        }
        rep(i,N){
            C[(i + zurashi) % N] = B[i];
        }
    }
    if (!possible) cout << "No" << endl;
    else{
        cout << "Yes" << endl;
        rep(i,N){
            cout << C[i] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 25940
#include <iostream>
using namespace std;
#define ll long long
#include <string>
#include <algorithm>
int main()
{
	ll w,h,x,y,n,a;
	ll t1,t2;

	cin>>w>>h>>n;
	ll x1=0,y1=0,x2=w,y2=h;
	t1=w;t2=h;
	for(int i=0;i<n;i++)
	{
		cin>>x>>y>>a;
		if(a==1)
		{
			if(x>x1)
			x1=x;
		}
		if(a==2)
		{
			if(x2>x)
			x2=x;
		}
		if(a==3)
		{
			if(y>y1)
			y1=y;
		}
		if(a==4)
		{
			if(y2>y)
			y2=y;
		}
		//	cout<<w<<"  "<<h<<endl;
	}
	ll ww=x2-x1;ll hh=y2-y1;
	if(ww<=0||hh<=0)
	{
		cout<<0;
	}
	else
	{
		cout<<ww*hh<<endl;
	}
	return 0;
} 


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

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  int N;
  cin >> N;
  string s, t;
  cin >> s >> t;

  vec<string> ss(N);
  string tmp;
  for (int i = N - 1; i >= 0; i--) {
    tmp = s[i] + tmp;
    ss[N - 1 - i] = tmp;
  }

  tmp.clear();
  vec<string> ts(N);
  for (int i = 0; i < N; i++) {
    tmp = tmp + t[i];
    ts[i] = tmp;
  }

  ll com = 0;
  for (int i = 0; i < N; i++) {
    if (ss[i] == ts[i]) {
      com = i + 1;
    }
  }
  const auto ans = s.length() + t.length() - com;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >> n;
  int sum = 0;
  vi w(n);
  rep(i,n) {
    cin >> w[i];
    sum+=w[i];
  }
  int ans = INF;
  int now = 0;
  rep(i,n-1) {
    now += w[i];
    ans = min(ans, abs(now - sum+now)) ;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n, max_w = map(int, input().split())
dp = [[0 for _ in range(max_w+1)] for _ in range(n+1)]
for i in range(n):
    w, v = map(int, input().split())
    for j in range(max_w+1):
        if j-w >= 0:
            dp[i+1][j] = max(dp[i][j-w] + v,dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]
print(dp[n][max_w])

Measured memory_bytes: 171400
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
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; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i, h) {
		cin >> s[i];
	}
	VV cx(h, V(w, -1));
	VV cy(h, V(w, -1));
	rep(i, h) {
		int cnt = 0;
		int pos = 0;
		rep(j, w) {
			if (s[i][j] == '.') cnt++;
			if (s[i][j] == '#' || j == w - 1) {
				if (j == w - 1) j++;
				REP(k, pos, j) {
					if (s[i][k] == '#') continue;
					cx[i][k] = cnt;
				}
				cnt = 0;
				pos = j;
			}
		}
	}
	rep(i, w) {
		int cnt = 0;
		int pos = 0;
		rep(j, h) {
			if (s[j][i] == '.') cnt++;
			if (s[j][i] == '#' || j == h - 1) {
				if (j == h - 1) j++;
				REP(k, pos, j) {
					if (s[k][i] == '#') continue;
					cy[k][i] = cnt;
				}
				cnt = 0;
				pos = j;
			}
		}
	}
	int ans = -1;
	rep(i, h) rep(j, w) {
		chmax(ans, cx[i][j] + cy[i][j] - 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 35712
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll N = 3e3 + 5;

int R,C,K,a[N][N];
ll f[N][N][4],p[N][N][4];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>R>>C>>K;
    for(int i=1;i<=K;i++){
    	int u,v,w;cin>>u>>v>>w;
    	a[u][v]=w;
    }
    for(int i=1;i<=R;i++){
    	for(int j=1;j<=C;j++){
    		// if(a[i][j]==0 && (i+j!=0) && (i!=R && j!=C)) continue;
    		// cout<<"i="<<i<<" j="<<j<<'\n';
    		for(int k=0;k<=3;k++){
    			for(int l=0;l<=3 && k<=1;l++){
    				// if(a[i][j-1]==0 && (i+j-1!=0))break;
    				if(k==0) f[i][j][k]=max(f[i][j][k],f[i-1][j][l]);
    				else     f[i][j][k]=max(f[i][j][k],f[i-1][j][l-1]+a[i][j]);
    			}
    // 			cout<<"111111:\n";
    // 			cout<<"f["<<i<<"]["<<j<<"]["<<k<<"]="<<f[i][j][k]<<'\n';
    // 			cout<<"p["<<i<<"]["<<j<<"]["<<k<<"]="<<p[i][j][k]<<'\n';
				f[i][j][k]=max(f[i][j][k],p[i][j-1][k]);
				if(k==1) f[i][j][k]=max(f[i][j][k],f[i][j][k-1]+a[i][j]);
				if(k>0){
					if(p[i][j-1][k-1]>0 || k==1) f[i][j][k]=max(f[i][j][k],p[i][j-1][k-1]+a[i][j]);
				}
				p[i][j][k]=max(p[i][j-1][k],f[i][j][k]);
				// cout<<"222222:\n";
    			// cout<<"f["<<i<<"]["<<j<<"]["<<k<<"]="<<f[i][j][k]<<'\n';
    			// cout<<"p["<<i<<"]["<<j<<"]["<<k<<"]="<<p[i][j][k]<<'\n';
    // 			// for(int l=0;l<=k;l++){
    			// }
    		}
    	}
    }
    ll ans=0;
    for(int i=0;i<=3;i++) ans=max(ans,f[R][C][i]);
	cout<<ans;
    return 0;
}

Measured memory_bytes: 602024
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define SIZE 100005

using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
int aa[SIZE];
int pos[SIZE];
bool used[SIZE];
int anspos[SIZE];
int cyc[SIZE];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&aa[i]);
	for(int i=0;i<n-1;i++)pos[i]=i;
	int M;ll K;
	scanf("%d %lld",&M,&K);
	for(int i=0;i<M;i++){
		int hoge;
		scanf("%d",&hoge);hoge--;
		swap(pos[hoge],pos[hoge-1]);
	}
	
	for(int i=0;i<n-1;i++){//posの移動
		if(!used[i]){//同じサイクルに属するものをすべてチェック
			int wh=i;
			int len=0;
			bool flag=true;
			while(flag){
				used[wh]=true;
				cyc[len]=wh;
				wh=pos[wh];
				len++;
				if(wh==i)flag=false;
			}
			//cout<<len<<endl;
			for(int j=0;j<len;j++){
				int nex=(int)(K%len);
				anspos[cyc[j]]=cyc[(nex+j)%(len)];
			}
		}
	}
	ll sum=aa[0];
	//for(int i=0;i<n-1;i++)printf("%d ",anspos[i]);
	//cout<<endl;
	for(int i=0;i<n;i++){
		printf("%lld\n",sum);
		int now=anspos[i];
		sum=sum+aa[now+1]-aa[now];
	}
}

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

int main() {
  int n;
  cin >> n;
  vector<bool> button_pushed(n, false);
  vector<int> button_next(n);
  int push_button = 1;
  //ボタンの番号とindexは1ずれているのに注意
  
  for (int i = 0; i < n; i++)
    cin >> button_next[i];
  
  int count = 0;  
  while (1) {
    if(push_button == 2)
      break;
    else if (button_pushed[push_button - 1]) {
      count = -1;
      break;
    }
    else {
      count++;
      button_pushed[push_button - 1] = true;
      push_button = button_next[push_button - 1];
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 640
from bisect import bisect_left, bisect
from itertools import accumulate
from math import ceil


def solve(h, aa, bb):
    max_a = max(aa)
    bs = sorted(bb)
    i = bisect(bs, max_a)
    if i == n:
        return ceil(h / max_a)
    bba = list(accumulate(reversed(bs[i:])))
    remain = h - bba[-1]
    if remain <= 0:
        return bisect_left(bba, h) + 1
    return ceil(remain / max_a) + len(bba)


n, h = map(int, input().split())
aa, bb = zip(*(map(int, input().split()) for _ in range(n)))

print(solve(h, aa, bb))


Measured memory_bytes: 59224
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), m = sc.nextInt();
        int[] a = new int[n], b = new int[n], c = new int[m], d = new int[m];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        for(int i = 0; i < m; i++){
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }
        for(int i = 0; i < n; i++){
            int index = m;
            int tmp = Integer.MAX_VALUE;
            for(int j = m-1; j >= 0; j--){
                int x = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
                if(x <= tmp){
                    index = j;
                    tmp = x;
                }
            }
            System.out.println(index+1);
        }
    }
}

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

using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const { return mint(*this) += a; }

    mint operator-(const mint a) const { return mint(*this) -= a; }

    mint operator*(const mint a) const { return mint(*this) *= a; }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }

    mint &operator/=(const mint a) { return *this *= a.inv(); }

    mint operator/(const mint a) const { return mint(*this) /= a; }
};

istream &operator>>(istream &is, const mint &a) { return is >> a.x; }

ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

struct UnionFind {
    vector<int> d;

    UnionFind(int n = 0) : d(n, -1) {}

    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }

    bool same(int x, int y) { return find(x) == find(y); }

    int size(int x) { return -d[find(x)]; }
};

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;
    string s;
    cin >> n >> s;
    vector<vector<int>> A(3, vector<int>(n + 10));
    string x = "RGB";
    for (int k = 0; k < 3; ++k) {
        for (int i = 0; i < s.size(); ++i) {
            if (s[i] == x[k])A[k][i + 1] += A[k][i] + 1;
            else A[k][i + 1] += A[k][i];
        }
    }
    ll ans = 0;
    for (int i = 0; i < s.size() - 2; ++i) {
        char c1 = s[i];
        for (int j = i + 1; j < s.size() - 1; ++j) {
            char c2 = s[j];
            for (int k = 0; k < 3; ++k) {
                if (c1 != c2 && c1 != x[k] && c2 != x[k]) {
                    ans += A[k][n] - A[k][j + 1];
                    if (s[j + (j - i)] == x[k])ans--;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define N 10
vector<int>v[N];
int n,m,x,y;
bool vis[N];

int solve(int a,int b){
//	cout<<a<<endl;
	if(b==n)return 1;
	int ans=0;
	for(int i=0,j=v[a].size();i<j;i++){
		if(!vis[v[a][i]]){
			vis[v[a][i]]=1;
			ans+=solve(v[a][i],b+1);
			vis[v[a][i]]=0;
		}
	}
	return ans;
}

int main(){
	memset(vis,0,sizeof(0));
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	vis[1]=1;
	cout<<solve(1,1)<<endl;
}

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

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;
static long long INF = (1LL<<62);
using LLPair = pair<LL, LL>;

void bfs_grid(LL H, LL W, vector<string> &s, vector<vector<LL>> &D, char start, char wall = '#'){
	const int dh[4] = {1, 0, -1, 0};
	const int dw[4] = {0, 1, 0, -1};

	D.assign(H, vector<LL>(W, -1));
	queue<LLPair> Q;
	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			if(s[i][j] == start){
				Q.push(make_pair(i, j));
				D[i][j] = 0;
			}
		}
	}
	while(!Q.empty()){
		auto p = Q.front(); Q.pop();
		LL ch = p.first;
		LL cw = p.second;
		for(int i=0; i<4; i++){
			LL nh = ch + dh[i];
			LL nw = cw + dw[i];
			if(nh < 0 || nw < 0 || nh >= H || nw >= W){
				continue;
			}
			if(D[nh][nw] != -1 || s[nh][nw] == wall){
				continue;
			}
			Q.push(make_pair(nh, nw));
			D[nh][nw] = D[ch][cw] + 1;
		}
	}
}

int main(int argc, char* argv[]){
	LL H, W;
	cin >> H >> W;
	vector<string> S;
	int wall = 0;
	for(int i=0; i<H; i++){
		string s;
		for(int j=0; j<W; j++){
			char c; cin >> c;
			s.push_back(c);
			if(c == '#'){
				wall++;
			}
		}
		S.push_back(s);
	}
	S[0][0] = 's';

	vector<vector<LL>> D;
	bfs_grid(H, W, S, D, 's');

	LL d = D[H-1][W-1];
	if(d == -1){
		printf("-1\n");
		return 0;
	}
	else{
		LL ans = H*W - wall - (d+1);
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3728
#!/usr/bin/ruby
n,*a=`dd`.split.map(&:to_i)
#raise if n<=2
if n<=2
	p n
	exit
end
c=0
r=1
a[0]=1
(1...n).each{|i|
	d=2 # i==n-1 ? 1 : 2
	if a[i]>=a[i-1]+d
		a[i]=a[i-1]+d
	else
		a[i]=a[i-1]
		r=r*(i+1-c)%(10**9+7)
		c+=1
	end
}
p (1..n-c).reduce(r){|s,i|s*i%(10**9+7)}

Measured memory_bytes: 11012
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#define MN 100000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n,m,num[MN+5],b[MN+5];
int main()
{
    n=read();m=read();
    for(int i=1;i<=n;++i) num[i]=1,b[i]=i==1;
    for(int i=1;i<=m;++i)
    {
        int x=read(),y=read();
        if(num[x]==1) b[y]|=b[x],b[x]=0,++num[y],--num[x];
        else b[y]|=b[x],++num[y],--num[x];
    }
    int ans=0;
    for(int i=1;i<=n;++i) ans+=b[i];
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1024
/***********************
*  Author: xuziyuan    * 
***********************/
 
#include <bits/stdc++.h>
 
#define rt0 return 0
#define rep(i,n) for(LL i=0;i<n;i++)
#define repn(i,n) for(LL i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))
 
using namespace std;
 
const LL MOD=1e9+7;
 
LL n,a[200010],ans;
bool vis[200010];
vector <LL> pw;
map <LL,LL> mp;

int main()
{
	pw.pb(1);
	repn(i,40) pw.pb(pw[i-1]*2LL);//,cout<<pw[i]<<endl;
	cin>>n;
	rep(i,n) cin>>a[i];
	sort(a,a+n);
	for(LL i=n-1;i>=0;i--)
	{
		if(vis[i]) continue;
		vis[i]=true;
		LL sum=pw[lower_bound(pw.begin(),pw.end(),a[i])-pw.begin()];
		if(sum==a[i]) sum=pw[lower_bound(pw.begin(),pw.end(),a[i]*2)-pw.begin()];
		LL targ=sum-a[i];
		LL pos=upper_bound(a,a+n,targ)-a-1;
		if(pos==n||a[pos]!=targ) continue;
		LL npos=pos-mp[targ]-(a[i]==targ);
		if(npos>=0&&a[npos]==targ&& !vis[npos])
		{
			ans++;
			mp[targ]+=1+(a[i]==targ);
			vis[npos]=true;
		}
		else vis[i]=false;
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <map>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdio>

using namespace std;

typedef pair<int, int> P;

int main(){
    int n, m;
    P data[5000];
    P data2[5000];
    bool ans[5000];
    while(cin >> n >> m){
        for(int i=0;i<n;i++){
            int a, b;
            scanf("%d%d", &a, &b);
            data[i] = P(a, i);
            data2[i] = P(b, i);
        }
        sort(data, data+n);
        sort(data2, data2+n);
        for(int i=0;i<m;i++){
            P a, b;
            scanf("%d%d%d%d", &a.first, &a.second, &b.first, &b.second);
            fill(ans,ans+5000,false);
            int l = lower_bound(data, data+n, P(a.first,-1)) - data;
            int r = lower_bound(data, data+n, P(b.first+1,-1)) - data;
            for(int j=l;j<r;j++){
                ans[data[j].second] = true;
            }

            int l2 = lower_bound(data2, data2+n, P(a.second,-1)) - data2;
            int r2 = lower_bound(data2, data2+n, P(b.second+1,-1)) - data2;
            int cnt = 0;
            for(int j=l2;j<r2;j++){
                if(ans[data2[j].second]) cnt++;
            }
            printf("%d\n", cnt);

        }
    }
}

Measured memory_bytes: 1316
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	double T, X;
	cin >> T >> X;
	cout << fixed << setprecision(10) << T / X << endl;
}

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

int main()
{ 
  int n, t, min_c = 1001;
  vector<vector<int>> ct(100, vector<int>(2));

  cin >> n >> t;
  for (int i = 0; i < n; i++)
  {
    cin >> ct[i][0] >> ct[i][1];
    if (ct[i][1] <= t && ct[i][0] < min_c)
      min_c = ct[i][0];
  }
  if (min_c == 1001)
    cout << "TLE" << endl;
  else
    cout << min_c << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define INF 100000000
using namespace std;
int n;
int t[20][20];
int cost[1<<20]; // 1が立つとこを使った組み合わせ

int minT(int state,int k){ // stateの状態でkを攻略するのにかかる最小値
  int rtn = cost[1<<k];
  for( int i=0;i<n;i++ )
    if( state & (1<<i) ) // i番目は既に攻略した
      rtn = min( rtn,t[k][i] );
  return rtn;
}
int solve(int state){
  if( cost[state]!=INF ) return cost[state];
  for( int i=0,s;i<n;i++ ){
    s = 1<<i;
    if( state & s ){ // stateのiビット目が1である時
      s = state - s;
      cost[state]=min( cost[state],solve(s)+minT(s,i) );
    }
  }
  return cost[state];
}

int main(){
  while( cin>>n && n ){
    cost[0] = 0;
    for( int i=1,len=1<<n;i<len;i++ ) cost[i] = INF;
    for( int i=0;i<n;i++ ){  cin >> cost[1<<i];
      for( int j=0;j<n;j++ ) cin >> t[i][j];
    }
    cout << solve( (1<<n)-1 ) << endl;
  }
  return 0;
}

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

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    map<string,int> mp;
    string s;
    int n;
    cin>>n;
    while(n--){
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<'\n';
    cout<<"WA x "<<mp["WA"]<<'\n';
    cout<<"TLE x "<<mp["TLE"]<<'\n';
    cout<<"RE x "<<mp["RE"]<<'\n';

    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <string.h>
int main()
{
 int x;
 scanf("%d", &x);
 int a = x / 100, b = x % 100;
 if((a >= 1 && a <= 12) && (b >= 1 && b <= 12))
  printf("AMBIGUOUS");
 else if(b >= 1 && b <= 12)
  printf("YYMM");
 else if(a >= 1 && a <= 12)
  printf("MMYY");
 else
  printf("NA");
 putchar(10);
}

Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T*)array, (T*)(array+N), val);
}
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class BComparingStrings {
public:
	void solve(std::istream& in, std::ostream& out) {
        int a, b;
        in >> a >> b;
        string aa = "", bb = "";
        rep(i, b){
            aa += to_string(a);
        }
        rep(i, a){
            bb += to_string(b);
        }

        if(aa < bb){
            out << aa << endl;
        }else{
            out << bb << endl;
        }
	}
};


int main() {
	BComparingStrings solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
// ~/Remember,remember the 6th of March

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-8;
const ll MOD = 1000000007;
const int N = 100000 + 7;

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


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

int main()
{
	int n;
	long long tmp;
	vector<long long> vec;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> tmp;
		vec.push_back(tmp - i - 1);
	}

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

	double center;
	if (n % 2)
	{
		center = vec[n / 2];
	}
	else
	{
		center = (vec[n / 2] + vec[n / 2 - 1]) / 2.0;
	}

	long long ceilNum = ceil(center);
	long long floorNum = floor(center);
	long long ansCeil = 0;
	long long ansFloor = 0;

	for (int i = 0; i < n; i++)
	{
		ansCeil += abs(vec[i] - ceilNum);
		ansFloor += abs(vec[i] - floorNum);
	}

	cout << min(ansCeil, ansFloor) << endl;

	return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
vector<bool> vis;
vector<int> dp;
vector<vector<int> > g;
int dfs(int node){
  vis[node] = true;
  for (int i = 0; i < (int)g[node].size(); i++){
    int vertex = g[node][i];
    if (!vis[vertex]){
      dfs(vertex);
    }
    dp[node] = max(dp[node], dp[vertex] + 1);
  }
  return dp[node];
}
int main(){
  int V, E;
  cin >> V >> E;
  g = vector<vector<int> > (V);
  dp = vector<int> (V);
  vis = vector<bool> (V, false);
  for (int i = 0; i < E; i++){
    int start, end;
    cin >> start >> end;
    start--; end--;
    g[start].push_back(end);
  }
  int ans = 0;
  for (int i = 0; i < V; i++){
    if (!vis[i]){
      ans = max(ans, dfs(i));
    }
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 8192
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000000000
using namespace std;


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

  vector<vector<pair<ll,ll> > > list(n+1);
  
  rep(i,m){
	ll a,b,c;
	cin >> a >> b >> c;
	list[a].emplace_back(b,c-p);
  }
  
  vector<ll> cur(n+1,-MAX),tmp(n+1,0);
  vector<bool> reach(n+1,false);
  cur[1] = 0;
  reach[1] = true;
  ll ans;
  bool flag;
  rep(i,3*n){
	rep(j,n){
	  if(!reach[j+1]) continue;
	  rep(k,list[j+1].size()){
	    reach[list[j+1][k].first] = true;
		if(cur[list[j+1][k].first] < cur[j+1]+list[j+1][k].second){
		  cur[list[j+1][k].first] = cur[j+1]+list[j+1][k].second;
		}
	  }
	}
	//rep(j,n) cout << cur[j+1] << " ";
	//cout << endl;
	if(i == n-2){
	  ans = cur[n];
	  tmp = cur;
	}
	if(i == n-1){
	  rep(j,n){
		if(tmp[j+1] < cur[j+1] ) cur[j+1] = MAX;
	  }
	}
  }

  if(ans < cur[n]) cout << -1 << endl;
  else cout << max(ans,0LL) << endl;

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

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

#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)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int n; 
    cin >> n;
    string s, t, ans = "";
    cin >> s >> t;
    rep(i, n){
        ans += s[i];
        ans += t[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256