akhauriyash/Code-Regression huggingface dataset:
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N, K;
	std::vector<int> L;
	std::cin >> N >> K;
	L.resize(N);
	for (auto& l : L) {
		std::cin >> l;
	}
	std::sort(L.rbegin(), L.rend());
	int result = 0;
	for (int i =  0; i < K; ++i)
		result += L[i];
	std::cout << result << "\n";
}


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

vector<int> adj[100005];
int vals[100005];

void DFS(int i){
	for (int j: adj[i]){
		DFS(j);
	}
	vector<int> v;
	for (int j: adj[i]){
		v.push_back(vals[j]);
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	for (int i = 0; i < v.size(); i++){
		v[i] += (i + 1);
	}
	int mx = 0;
	for (int i = 0; i < v.size(); i++){
		if (mx < v[i]) mx = v[i];
	}
	vals[i] = mx;
}

int main(){
	int N; cin >> N;
	for (int i = 2; i <= N; i++){
		int k; cin >> k;
		adj[k].push_back(i);
	}
	DFS(1);
	cout << vals[1] << endl;
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	if(a==1)a=14;
	if(b==1)b=14;
	if(a==b)cout << "Draw" << endl;
	if(a>b)cout << "Alice" << endl;
	if(a<b)cout << "Bob" << endl;
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
    int num;
    char sign;
}Card;
void selctionSort( int n, Card *a);
void bubblesort(int number, Card card[number]);
void printArray(Card *card, int number);
int main(int argc, char** argv) {
    int number;
    int readScan = scanf("%d", &number);
    Card card[number];
    for(int i = 0; i< number; i++)
    {
        {
            int reaScan = scanf( " %c%d", &card[i].sign, &card[i].num);
        }
    }
    Card card2[number];
    for(int i=0; i< number; i++)
    {
        card2[i].num = card[i].num;
        card2[i].sign = card[i].sign;
    }
    
    
    bubblesort(number, card);
    printArray(card, number);
    printf("Stable\n");
    selctionSort( number, card2);  
    printArray(card2, number);
    int right=0;
    for(int i=0; i<number;i++)
    {
        if(card[i].sign != card2[i].sign)
        {
            right =1;
        }
    }
    if(right == 0)
    {
        printf("Stable\n");
    }
    
    if(right == 1)
    {
        printf("Not stable\n");
    }
    return (EXIT_SUCCESS);
}

void bubblesort(int number, Card *card)
{
    int c;
    char mark0;
    for (int i = 0; i < number; i++)
    {
	for (int j = 0; j < number-i-1; j++)
	{
        if (card[j].num>card[j+1].num)
	{
            c = card[j].num ;
            mark0 = card[j].sign;
            card[j].num = card[j+1].num;
            card[j].sign = card[j+1].sign;
            card[j+1].num =c;
            card[j+1].sign = mark0;			
        }
	}
    }
}

void selctionSort( int n, Card *a)
{
    int b;
    char mark;
    int min ;
    for (int i = 0; i < n-1; i++)
    {   
        min = i;
        for (int j = i+1; j < n; j++)
	{
            if (a[j].num < a[min].num)
            { 
                min = j;
            }   
        }  
        b= a[i].num;
        mark = a[i].sign;
        a[i].num=a[min].num;
        a[i].sign = a[min].sign;
        a[min].num=b;
        a[min].sign=mark;
       
    }
}

void printArray(Card *card, int number)
{
     for(int i= 0; i< number; i++)
    {    
        if(i<number-1)
        {
            printf("%c%d ", card[i].sign,card[i].num);
        }
        if(i==number-1)
        {
            printf("%c%d\n", card[i].sign,card[i].num);
        }
    }
}


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

int main() {
  ll n;
  cin >> n;
  map<P, ll> mp;
  rep2(i, 1, n + 1) {
    string s = to_string(i);
    ll a = s[0] - '0';
    ll b = s.back() - '0';
    mp[{a, b}]++;
  }
  ll ans = 0;
  for(auto v : mp) {
    ll a = v.first.first;
    ll b = v.first.second;
    ans += mp[{b, a}] * v.second;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
//constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
ll INF = 6001001001001001001;
long double EPS = 1e-6;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

bool F(string S){
    string T = S.substr((S.size() + 1) / 2,S.size() / 2);
    reverse(ALL(T));
    return S.substr(0,S.size()/2) == T;
}

int main(){
    string S;
    cin >> S;
    ll N = S.size();
    bool flag = 1;
    if(!F(S)) flag = 0;
    if(!F(S.substr(0,(N-1)/ 2))) flag = 0;
    if(!F(S.substr((N+1)/2,(N - 1)/ 2))) flag = 0;
    if(flag) cout << "Yes" << endl;
    else cout  << "No" << endl;
}
    


Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

const MOD: usize = 1_000_000_000 + 7;

fn main() {
    input! {
        n: usize,
        A: [usize; n],
    }
    let mut ans = 0;
    let mut sums: usize = A.iter().sum();
    for i in 0..n {
        ans += A[i] % MOD * ((sums - A[i]) % MOD);
        ans %= MOD;
        sums -= A[i];
    }
    println!("{}", ans);
}


Measured memory_bytes: 3588
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
ll A[100010];

int main()
{
  std::cin >> N;

  ll sum = 0;

  rep( i, N ) {
    std::cin >> A[i];
    sum ^= A[i];
  }
  
  ll ans = sum;

  rep( i, N )
    A[i] &= ~sum;

  ll r = 0;

  repd( i, 61 ) {
    ll j = r;
    for( ; j < N; ++j ) {
      if( A[j]>>i&1 ) {
        std::swap( A[r], A[j] );

        break;
      }
    }

    if( j == N )
      continue;
    
    rep( j, N ) {
      if( j == r )
        continue;

      if( A[j]>>i&1 )
        A[j] ^= A[r];
    }

    ++r;
  }

  ll x = 0;

  rep( i, r )
    x ^= A[i];

  ans += x*2;

  std::cout << ans << std::endl;

  return 0;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
#define PER(i,n) for(int i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



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

  int a, b, c;
  cin >> a >> b >> c;
  YesorNo(a <= c && c <= b);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int a,s,n;
std::bitset<1<<22>d;     
int main(){
    std::cin>>n;d[0]=1;
    for(;n;n--)std::cin>>a,s+=a,d|=(d<<a);
    while(!d[++s/2]){} std::cout<<s/2;
}

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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;

lli n,x;
vll d;
lli y;
vll q;

lli min_dist = 0;
vll safety_zone;
vll plan;

int main(){
  cin >> n >> x;
  d = vll(n+1);
  for(lli i = 1;i <= n;i++) cin >> d[i];
  cin >> y;
  q = vll(y);
  for(lli i = 0;i < y;i++) cin >> q[i];
  safety_zone = vll(n+1);
  plan = vll(n+1);
  plan[0] = x;
  for(lli i = n-1;i >= 0;i--){
    if(abs(min_dist+1-d[i+1]) <= min_dist) min_dist += d[i+1];
    safety_zone[i] = min_dist;
  }
  for(lli i = 1;i <= n;i++){
    plan[i] = min(plan[i-1],abs(plan[i-1]-d[i]));
  }
  for(lli i = 0;i < y;i++){
    if(plan[q[i]-1] > safety_zone[q[i]]) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}


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

using namespace std;

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

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int s = 0;
    if (k <= a) {
        cout << k;
    }
    else {
        s += a;
        k -= a;
        if (k <= b) {
            cout << s;
        }
        else {
            k -= b;
            s -= k;
            cout << s;
        }
    }

}



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

bool used[1001001];
int dist[1001001];
vector<int> adj[1001001];

void impossible() { cout << "-1\n"; exit(0); }

int dfs(int i) {
    used[i] = true;
    int ans = 0;
    for (int j : adj[i]) {
        if (used[j] && dist[j] == 0) impossible();
        else if (used[j]) ans = max(ans, dist[j]);
        else ans = max(ans, dfs(j));
    }
    return dist[i] = ans + 1;
}

int n;
int nd(int i, int j) { if (i < j) swap(i, j); return i * n + j; }
void addedge(int i1, int j1, int i2, int j2) {
    adj[nd(i1, j1)].push_back(nd(i2, j2));
}

int main() {
    cin >> n;
    int a[n][n-1];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n-1; j++) cin >> a[i][j], a[i][j]--;
    for (int i = 0; i < n; i++)
        for (int j = 1; j < n-1; j++) addedge(i, a[i][j-1], i, a[i][j]);

    int ans = -1;
    for (int i = 0; i < n; i++) {
        int v = nd(i, a[i][0]);
        if (!used[v]) dfs(v);
        ans = max(ans, dist[v]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 48128
#include <stdio.h>
int main(){
  int i,j,a,b,H[1000],W[1000];
  a=1;
  b=1;
while(1){
scanf("%d %d",&H[a],&W[a]);
 if(H[a]==0 || W[a]==0)break;
 a++;
  }while(1){
  for(i=0;i<H[b];i++){
    for(j=0;j<W[b];j++){
      printf("#");
    }printf("\n");
  }printf("\n");
  b++;
  if(b==a)break;
}return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    int n;
    scan(n);
    int a[n];
    rep(i, n){
        scan(a[i]);
    }
    double ave = 0;
    rep(i, n){
        ave += a[i];
    }
    ave /= (double) n;
    int ans = 0;
    double mindis = 101;
    rep(i, n -1){
        if(mindis > fabs(a[i] - ave)){
            mindis = fabs(a[i] - ave);
            ans = i;
        }
    }
    print(ans);
}

Measured memory_bytes: 256
n, m = map(int, raw_input().split())
l = [0]*n
cnt = [1]*n
l[0] = 1
for i in range(m):
	x, y = map(int, raw_input().split())
	x -= 1
	y -= 1
	if l[x] == 1:
		l[y] = 1
	cnt[x] -= 1
	cnt[y] += 1
	if cnt[x] == 0:
		l[x] = 0
print l.count(1)

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MN = 100010;

int N, K;
int a[MN];
ll sl[MN], sr[MN];
ll acc[MN];

int main() {
	cin >> N >> K;

	rep(i, N) {
		cin >> a[i];
		acc[i+1] = acc[i] + a[i];
	}

	rep(i, N) {
		sl[i+1] = sl[i] + max(0, a[i]);
	}

	for (int i = N-1; i >= 0; --i) {
		sr[i] = sr[i+1] + max(0, a[i]);
	}

	ll ret = LLONG_MIN;
	for (int i = 0; i <= N - K; ++i) {
		ll t = max(0LL, acc[i + K] - acc[i]) + sl[i] + sr[i + K];
		ret = max(ret, t);
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 2944
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

def err():
    print('No')
    quit()
n,m = inpl()
s = [input() for _ in range(n)]
dx = (0,1,0,-1)
dy = (1,0,-1,0)
for i in range(n):
    for j in range(m):
        if s[i][j] == '#':
            for d in range(4):
                nx = dx[d]+j
                ny = dy[d]+i
                if 0 <= nx < m and 0 <= ny < n:
                    if s[ny][nx] == '#':
                        break
            else:
                err()
print('Yes')

Measured memory_bytes: 77628
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

ll dfs(int now, int from, const vector<vector<int>> &G, int K) {
  // now以下の部分木を塗る場合の数を返す
  if (K < G[now].size()) {
    return 0;
  }
  int usable_color = from == -1 ? K - 1 : K - 2;
  ll res = 1;
  for (auto e : G[now]) {
    if (e == from)
      continue;
    res *= usable_color;
    usable_color--;
    res %= MOD;
    res *= dfs(e, now, G, K);
    res %= MOD;
  }
  return res;
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<vector<int>> G(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  ll ans = k * dfs(0, -1, G, k);
  ans %= MOD;
  cout << ans << endl;
}


Measured memory_bytes: 11520
while True:
    try:
        a, b, c, d, e, f = map(float, raw_input().split())
    except EOFError:
        break
    x = (e * c - b * f) / (a * e - b * d)
    y = (-d * c + a * f) / (a * e - b * d)
    print '%.3f %.3f' % (x + 0.00001, y + 0.00001)

Measured memory_bytes: 5268
#include<stdio.h>
void line(int n, char c){
    while(n--){
        printf("%c", c);
        c = (c== '#')? '.' : '#';
    }
}

int main(){
    int a, b, i, j;
    char c;
    while(1){
        scanf("%d %d", &a, &b);
        if(a == 0 && b == 0) break;
        c = '#';
        while(a--){
            line(b, c);
            printf("\n");
            c = (c== '#')? '.' : '#';
        }
        printf("\n");
    }
return 0;
}



Measured memory_bytes: 2040
#include <iostream>

using namespace std;

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

	if (a + b == 15) {
		cout << "+" << endl;
	}
	else if (a * b == 15) {
		cout << "*" << endl;
	}
	else {
		cout << "x" << endl;
	}

}

Measured memory_bytes: 256
<?php

$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));

$c = explode(' ', $a);
$h = explode(' ', $b);

$n = $c[0];
$k = $c[1];

$count =0;
foreach ($h as $tall) {
    if((int)$tall >= (int)$k){
        $count += 1;
    }
}

echo $count;

Measured memory_bytes: 12792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc103/tasks/abc103_d

int main() {
    int N, M; cin >> N >> M;
    P ab[M];
    REP(i, M) {
        int a, b; cin >> a >> b;
        ab[i] = {b, a};
    }
    sort(ab, ab+M);

    int now = 0;
    int cnt = 0;
    REP(i, M) {
        P p = ab[i];
        int l = p.second;
        int r = p.first;

        if (l >= now) {
            cnt++;
            now = r;
        }
    }

    cout << cnt << "\n";

    return 0;
}


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

int main() {
  int N,K; cin >>N>>K;
  vector<int> vec(N);
  for(int i=0;i<N;i++)
  {
    cin >>vec[i];
  }
  int sum=0, h=0;
  sort(vec.begin(),vec.end());
 for(int i=0;i+K<=N;i++)
 {
   sum=vec[i+K-1]-vec[i];
   if(i==0){h=sum;}
   else{ h=min(h,sum);}
   //cout <<sum <<" "; 
 }
  //cout <<endl;
  cout <<h <<endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <string>
#include <bitset>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10



int main() {
	int n, m, x; cin >> n >> m >> x;
	vector<int>A(m);
	REP(i, m) cin >> A[i];
	sort(A.begin(), A.end());
	int lcost = 0, rcost = 0;
	REP(i, m) {
		if (A[i] < x) lcost++;
		else rcost++;
	}
	print(min(lcost, rcost));

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

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

int main() {
  long long N;
  cin>>N;
  vector<long>A(N);
  long C=0;
  for(long i=0;i<N;i++){
    cin>>A[i];
    if(i>0){
      if(A[i]<A[i-1]){
        C+=A[i-1]-A[i];
        A[i]=A[i-1];
      }
    }
  }
  cout<<C<<endl;
}

Measured memory_bytes: 4672
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    
    int a = stdIn.nextInt();
    int b = stdIn.nextInt();
    int c = stdIn.nextInt();
    
    int a2 = a;
    int b2 = b;
    int c2 = c;
    
    a = b;
    b = a2;

    int a3 = a;
    int b3 = b;
    int c3 = c;
    a = c3;
    c = a3;
    
    System.out.println(a + " " + b + " " + c);
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;

int main(){
    int cnt[5] = {0};
    for(int i=0; i<3; ++i){
        int a, b;
        cin >> a >> b;
        cnt[a]++; cnt[b]++;
    }
    for(int i=1; i<=4; ++i){
        if(cnt[i]>=3){
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;
}

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

//resは最終的な答え、dp[みている要素][ここまでに何個選んだか][選んだ要素についてw[i](1番目の要素の重さを引いた後の重さ)の和]=最大価値
long long int W,N,res=0;
long long int dp[105][105][305]={},w[234],v[234];

int main()
{
  
  cin>>N>>W;
  //一番最初の品の重さをメモする変数
	long long int W1=0;
	for(long long int i = 1; i <= N; i++){
		cin>>w[i]>>v[i];
	}
  //w[1]をメモ
	W1=w[1];
  //w[i]からW1を引くことでw[i]を0~3の範囲に抑え込める。N=100のときでも和は300を超えない。
	for(long long int i = 1; i <= N; i++){
		w[i]-=W1;
	}
  //dpの遷移。iはどの品を今見ているかを表す
	for(long long int i = 1; i <= N; i++){
    //jは今までに何品選んだかどうかを表す。i番目より前をみた時最大でもi-1品しか選んでいないのでj<iの範囲でループ。
		for(long long int j = 0; j < i; j++){
      //kは今までに選んだ品のw[i]の和を表す。j品選んだ時最大でも重さは3*jなのでk<=3*jの範囲でループ。
			for(long long int k = 0; k <= 3*j; k++){
        //i番目の品を選んだ時
				dp[i][j+1][k+w[i]] = max(dp[i][j+1][k+w[i]],dp[i-1][j][k]+v[i]);
        //i番目の品を選ばなかった時
				dp[i][j][k]=max(dp[i][j][k],dp[i-1][j][k]);
			}
		}
	}
  //条件を満たす中で最も価値の大きいものを見つける。
	for(long long int j = 0; j <= N; j++){
		for(long long int k = 0; k <= 3*j; k++){
      //dp[N][j][k]について、ナップサック内の重さの和はj*W1+kでこれがW以下でないといけない。
			if((j*W1)+k<=W){res = max(res,dp[N][j][k]);}
		}
	}
	cout<<res<<endl;
	
	
}


Measured memory_bytes: 23552
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int K,S;
    cin >> K >> S;
    int count = 0;
    for(int x = 0; x <= K && x <= S; x++){
        for(int y = 0; y <= K && x + y <= S; y++){
            if((S - x - y) <= K) count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
mod = 10**9+7
mod2 = mod * 5

n, m = gets.to_s.split
n, m = n.to_i, m.to_i

stairs = [1] * (n+1)

m.times do
  stairs[gets.to_s.to_i] = 0
end

2.upto(n) do |i|
  next if stairs[i] == 0
  stairs[i] = stairs[i-1] + stairs[i-2]
  stairs[i] %= mod if stairs[i] > mod2
end

puts stairs[-1] % mod

Measured memory_bytes: 2812
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;

// vector<pair<int, int>>adj[105];
int adj[105][105];
int dis[105][105];
int32_t main(){
	ios::sync_with_stdio(false);
    int n, m;
    // memset(dis,0,sizeof(0));
    cin>>n>>m;
    for(int i=0;i<105;i++){
        for(int j=0;j<105;j++){
            if(i==j){
                dis[i][j]=0;
                continue;
            }
            dis[i][j]=1e18;
            adj[i][j]=1e18;
        }
    }
    REP(i,0,m){
        int A, B, C;
        cin>>A>>B>>C;
        adj[A][B]=C;
        adj[B][A]=C;
        dis[A][B]=C;
        dis[B][A]=C;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                dis[j][k]=min(dis[j][k],dis[j][i]+dis[i][k]);
            }
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(adj[i][j]!=1e18){
                if(adj[i][j]>dis[i][j]){
                    ans++;
                }
            }
        }
    }
    // for(int i=1;i<=n;i++){
    //     for(int j=i+1;j<=n;j++){
    //         if(adj[i][j]!=1e18){
    //             int f=0;
    //             for(int k=1;k<=n;k++){
    //                 for(int l=k+1;l<=n;l++){
    //                     if((dis[k][i]+dis[i][j]+dis[j][l])==dis[k][l]){
    //                         f=1;
    //                     }
    //                 }
    //             }
    //             if(f==0){
    //                 ans++;
    //             }
    //         }
    //     }
    // }
    cout<<ans<<"\n";




	return 0;
}

Measured memory_bytes: 384
from math import ceil
n,k=map(int,input().split())
lst=list(map(int,input().split()))
ng=0
ok=10**9+1
while ok-ng>1:
    mid=(ok+ng)//2
    tmp=0
    for i in range(n):
        tmp+=ceil(lst[i]/mid)-1
    if tmp>k:
        ng=mid
    else:
        ok=mid
print(ok)

Measured memory_bytes: 104396
#include<bits/stdc++.h>
using namespace std;
int f[200002]={},a,n;
int main()
{
	cin>>n;
	for(int i=1;i<n;i++)
	{
		cin>>a;
		f[a]++;
	}
	for(int i=1;i<=n;i++)
	cout<<f[i]<<endl;
}

Measured memory_bytes: 4416
#include <iostream>

using namespace std;

int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int x3, y3, x4, y4;

    int vx = x2 - x1;
    int vy = y2 - y1;

    x3 = x2 - vy; y3 = y2 + vx;
    x4 = x1 - vy; y4 = y1 + vx;

    cout <<  x3 << " " << y3 << " " << x4 << " " << y4;
    cout << "\n";
    return 0;
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define long long long
#define db double
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template <class T> inline void chmin(T &a, const T& val) { if (a > val) a = val; }
template <class T> inline void chmax(T &a, const T& val) { if (a < val) a = val; }
template <class T> long sqr(T a) { return 1ll * a * a; }
template <class T> void compress(T &a){
  sort(all(a)); a.resize(unique(all(a)) - a.begin());  
}

const db pi = acos(-1.00);
const db eps = 1e-6;
const int INF = 1e9;
const int MOD = 1e9+7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};

int main()
{
  fastio;
  int n, m; cin >> n >> m;
  vector <vector <long>> dp(n + 1, vector <long> (m + 1, 0));
  for (int i = 1; i <= n; i++){
    int w, val; cin >> w >> val;
    for (int j = 0; j <= m; j++){
      dp[i][j] = dp[i - 1][j];
      if (w <= j) chmax(dp[i][j], dp[i - 1][j - w] + val);
    }
  }
  long ans = 0;
  for (int i = 0; i <= m; i++) chmax(ans, dp[n][i]);
  cout << ans;
  return 0;
}

Measured memory_bytes: 83136
s = gets.chomp
gu = 0
pa = 0
ans = 0
s.each_char do |c|
  if c == "g" && pa < gu
    ans += 1
    pa += 1
  elsif c == "g"
    gu += 1
  elsif c == "p" && pa < gu
    pa += 1
  else
    ans -= 1
    gu += 1
  end
end
puts ans


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

typedef long long LL;

const double PI = acos(-1.0);

int n, m, q, a[60], b[60], c[60], d[60], v[30], ans;

void dfs(int p, int x) {
    //printf("dfs %d %d\n", p, x);
    v[p] = x;
    if (p == n) {
        int t = 0;
        for (int i = 0; i < q; ++i) {
            if (v[b[i]] - v[a[i]] == c[i]) t += d[i];
        }
        ans = max(ans, t);
        return ;
    }
    for (int i = x; i <= m; ++i) {
        dfs(p+1, i);
    }
}

int work() {
    scanf("%d%d%d", &n, &m, &q);

    for (int i = 0; i < q; ++i) {
        scanf("%d%d%d%d", &a[i], &b[i], &c[i], &d[i]);
    }

    dfs(1, 1);
    printf("%d\n", ans);

    return 0;
}

int main() {
    work();
    //while (~scanf("%d", &n)) work();
    //scanf("%d", &T); while (T--) work();

    return 0;
}


Measured memory_bytes: 3828
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//SOLVE
void solve(void)
{
  int N;cin>>N;
  vector<double> vec (N,0); 
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  vector<vector<double> > DP (N+1,vector<double>(N+1,0));
  DP[0][0] = 1;
  for (int i = 1; i < N+1; i++)
  {
    for (int j = 1; j < N+1; j++)
    {
      DP[i][j] +=  DP[i-1][j-1]*vec[i-1];//当たる；
      DP[i][j-1] +=  DP[i-1][j-1]*(1-vec[i-1]);//外れる；
    }
    
  }
  // DEBUG(DP);
  double ANS = 0;
  for (int i = (N+1)/2; i < N+1; i++)
  {
    ANS += DP[N][i];
  }
  cout<<ANS<<endl;
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
#define ll long long
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll k;
	cin >> k;
	ll seven = 7%k;
	int ans = -1;
		for(int i = 1;i<1e7;i++) {
			if(seven == 0) {
				ans = i;
				break;
			}
			seven = (seven*10+7)%k;	
		}
	cout << ans << '\n';
}



Measured memory_bytes: 3660
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long inf = 1ll << 62;
typedef pair<int, int> P;
string a[501];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> a[i];
	int cnt = 0;
	rep(i, n)rep(j, n)if (a[i][j] == '#')cnt++;
	if (!cnt) {
		cout << -1 << endl;
		return 0;
	}
	cnt = inf;
	int finc = 0;

	rep(j, n) {
		int c = 0;
		rep(i, n) {
			if (a[i][j] == '#')c++;
		}
		if (c == n)finc++;
	}

	rep(i, n) {
		int f = 0;
		rep(j, n) {
			if (a[i][j] == '.')f++;
		}
		int is = 0;
		rep(j, n) {
			if (a[j][i] == '#')is++;
		}
		if (is)cnt = min(cnt, f);
		else cnt = min(cnt, f + 1);
	}
	cout << cnt + n - finc << endl;

}

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

using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, v) for(auto& a : v)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll big = 1000000007ll;
ll big2 = 1000000009ll;
ll n,m,q,T,k;

ll W;

unordered_map<ll,ll> M;

vector<vector<ll> > C(4 , vector<ll>());

ll w1 = 0;

ll has(ll a1, ll a2, ll a3, ll a4){
    return 100*(100*(100*a4+a3)+a2)+a1;
}

ll TW(ll a1, ll a2, ll a3, ll a4){
    return w1*a1 + (w1+1)*a2 + (w1+2)*a3 + (w1+3)*a4;
}

ll dp(ll a1, ll a2, ll a3, ll a4){
    ll tw = TW(a1,a2,a3,a4);
    if(tw > W)return -big*big;

    ll h = has(a1,a2,a3,a4);

    if(M.find(h) != M.end())return M[h];

    ll ans = 0;

    if(a1 < C[0].size()){
        ans = max(ans , C[0][a1] + dp(a1+1,a2,a3,a4));
    }
    if(a2 < C[1].size()){
        ans = max(ans , C[1][a2] + dp(a1,a2+1,a3,a4));
    }
    if(a3 < C[2].size()){
        ans = max(ans , C[2][a3] + dp(a1,a2,a3+1,a4));
    }
    if(a4 < C[3].size()){
        ans = max(ans , C[3][a4] + dp(a1,a2,a3,a4+1));
    }

    M[h] = ans;
    return ans;
}

bool comp(ll i, ll j){
    return i > j;
}

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    ll a,b,c,d;

    cin >> n >> W;
    for(ll c1 = 0; c1 < n; c1++){
        cin >> a >> b;
        if(c1 == 0)w1 = a;
        ll dif = a-w1;
        C[dif].push_back(b);
    }

    for(ll c1 = 0; c1 < 4; c1++){
        sort(all(C[c1]) , comp);
    }

    cout << dp(0,0,0,0) << "\n";

    return 0;
}


Measured memory_bytes: 7496
from copy import deepcopy
h,w,n = (int(i) for i in input().split())
c1,ans = [[] for i in range(w)],0
for i in range(h):
	s = input()
	for j in range(w): c1[j].append(int(s[j]))
if n<4:
	if h==30: z = 25
	else: z = h//2
	for i in range(z,h):
		for j in range(w):
			c,m,a = deepcopy(c1),0,0
			del c[j][i]
			c[j].insert(0,0)
			while 1:
				d = []
				for k in range(i-h,-h,-1):
					k2 = 0
					while k2<w-n+1:
						if c[k2][k] and all(c[k2][k]==c[k2+k3][k] for k3 in range(1,n)):
							b = n
							for k3 in range(k2+n,w):
								if c[k2][k]==c[k3][k]: b+=1
								else: break
							d.append((h+k,k2,b))
							k2+=b
						else: k2+=1
				if d:
					for k,k2,k3 in d:
						a+=(2**m)*c[k2][k]*k3
						for k4 in range(k2,k2+k3): del c[k4][k]
					for k,k2,k3 in d:
						for k4 in range(k2,k2+k3): c[k4].insert(0,0)
				else: break
				m+=1
			ans = max(ans,a)
print(ans)

Measured memory_bytes: 3444
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 400020
using namespace std;
int read(){
	int nm=0,fh=1; int cw=getchar();
	for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return nm*fh;
}
struct num{
	int pos,id;num(){pos=0,id=0;}
	num(int _pos,int _id){pos=_pos,id=_id;}
}p[M],S[M];
int vis[M],H,W,n,top;
bool on(int x,int y){return x==0||y==0||x==H||y==W;}
int bas(int x,int y){if(!x)return y;if(y==W)return W+x;if(x==H)return W+H+W-y;return W+H+W+H-x;}
bool cmp(num x,num y){return x.pos<y.pos;}
int main(){
	H=read(),W=read(),n=read();
	for(int i=1;i<=n;i++){
		int x=read(),y=read(),xx=read(),yy=read();
		if(!on(x,y)||!on(xx,yy)){i--,n--;continue;}
		int L=bas(x,y),R=bas(xx,yy); if(L>R) swap(L,R);
		p[(i<<1)-1]=num(L,i),p[i<<1]=num(R,i);
	} n<<=1,sort(p+1,p+n+1,cmp);
	for(int i=1;i<=n;i++){if(S[top].id!=p[i].id||!top) top++,S[top]=p[i];else top--;}
	puts(top?"NO":"YES"); return 0;
}

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

#define ll long long
const int MOD = 1e9 + 7;
#define INF 2e9

#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

#define MATCH(_str, _ptn) regex_match(_str, regex(_ptn))
#define REPLACE(_str, _ptn, _replacement) regex_replace(_str, regex(_ptn), _replacement)

# define pb push_back

# define INIT() cin.tie(0); ios::sync_with_stdio(false); cout << fixed << std::setprecision(20)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll n,m,k;
string s;
int main() {
    INIT();

    char a;
    cin >> a;
    
    cout << fixed << std::setprecision(20) << ((a < 'a') ? 'A' : 'a');
}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main()
{
    int a, b, c, A[3];
    
    cin >> a >> b >> c;
    
    if(a < b)
    {
        if( a < c )
        {
            A[0] = a;
            A[1] = min(b, c);
            A[2] = max(b, c);
        }
        else
        {
            A[0] = c;
            A[1] = min(a, b);
            A[2] = max(a, b);
        }
    }
    else
    {
        if( b < c )
        {
            A[0] = b;
            A[1] = min(a, c);
            A[2] = max(a, c);
        }
        else
        {
            A[0] = c;
            A[1] = min(a, b);
            A[2] = max(a, b);
        }
    }
    
    cout << A[0] << " " << A[1] << " " << A[2] << endl;
    return 0;
}

Measured memory_bytes: 3084
#include<stdio.h>
#include<string.h>
 
int main(){
	char a[20] = "AC";
	char b[20] = "WA";
	char c[20] = "TLE";
	char d[20] = "RE";
	int tc;
	int ac = 0;
	int wa = 0;
	int tle = 0;
	int re = 0;
	char s[100];
	scanf("%d", &tc);
	for(int i=0; i<tc; i++){
		scanf("%s", s);
		if(strcmp(s,a) == 0){
			ac++;
		}
		else if(strcmp(s,b) == 0){
			wa++;
		}
		else if(strcmp(s,c) == 0){
			tle++;
		}
		else if(strcmp(s,d) == 0){
			re++;
		}
	}	
		printf("AC x %d\n", ac);
		printf("WA x %d\n", wa);
		printf("TLE x %d\n", tle);
		printf("RE x %d\n", re);
	return 0;
}

Measured memory_bytes: 1736
n=int(input(''))
a=list(map(int,input('').split(' ')))
b={}
for i in range(n):
    if str(a[i]) in b:
        b[str(a[i])]+=1
    else:
        b[str(a[i])]=1

ok=1
for i in b:
    if b[i]>=2:
        ok=0
        break

if ok==0:
    print('NO')
else:
    print('YES')

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int r0,w,c,r;
    cin >> r0 >> w >> c >> r;
    if(r==0) return 0;
    cout << max((c*w-r0+r-1)/r,0) << endl;
  }
  return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <cmath>
#include <set>
#define Rep(i, x, y) for (int i = x; i <= y; i ++)
#define Dwn(i, x, y) for (int i = x; i >= y; i --)
#define RepE(i, x) for (int i = pos[x]; i; i = g[i].nex)
#define v g[i].y
using namespace std;
typedef long long ll;
typedef double db;
int n, a[105], mn = 1000, mx;
int main()
{
	cin >> n;
	Rep(i, 1, n) scanf ("%d", &a[i]), mn = min(mn, a[i]), mx = max(mx, a[i]);
	cout << mx - mn<<endl;

	return 0;
}

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

int main(){
    int A, B;
    std::cin >> A >> B;
    int cnt = 0;
    for(int i = A; i <= B; i++){
        std::string S = std::to_string(i);
        std::size_t n = S.size();
        int j;
        for(j = 0; j < n / 2; j++){
            if(S[j] != S[n - 1 - j]) break;
        }
        if(j == n / 2) cnt++;
    }
    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  vector<string> v={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string s;cin>>s;
    rep(i,0,siz(v)){
        if(v[i]==s){
            cout<<(7-i)<<endl;
            return 0;
        }
    }
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;



signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll ans = 0;
	ll k = 0;
	ll n; cin >> n;
	string s; cin >> s;
	for (auto a : s) {
		if (a == 'D') {
			k--;
		}
		else {
			k++;
			ans = max(ans, k);
		}
	}
	cout << ans << endl;
}

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

using namespace std;

int f, s, o;

int main () {
	int n;
	cin >> n;   
	for (int i = 1;i <= n;i ++) {
		int x;
		cin >> x;
		if (x % 4 == 0) f ++;
		else if (x % 2 == 0) s ++;
		else o ++;
	}
	if (f == o - 1 && f + o == n) {
		cout << "Yes";
		return 0;
	}               
	if (f >= o) {
		cout << "Yes";
	}
	else cout << "No";
	return 0;
}

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

int main(){

    int N;
    string A, B, C;
    cin >> N;
    cin >> A;
    cin >> B;
    cin >> C;

    int ans = 0;
    for(int i = 0; i < N; i++){
        if(A[i] == B[i] && B[i] == C[i]) continue;
        else if(A[i] == B[i] && B[i] != C[i]) ans++;
        else if(B[i] == C[i] && C[i] != A[i]) ans++;
        else if(C[i] == A[i] && A[i] != B[i]) ans++;
        else if(A[i] != B[i] && B[i] != C[i]) ans += 2;
    }

    cout << ans << endl;

    return 0;
}

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

def k_cut(k, nums):
    return nums[k:] + nums[:k]

def riffle_shuffle(n, nums):
    return [nums[i//2 + n*(i%2)] for i in range(2*n)]

n = int(input())
nums = [i + 1 for i in range(2*n)]

m = int(input())
for i in range(m):
    k = int(input())
    if k == 0:
        nums = riffle_shuffle(n, nums)
    else:
        nums = k_cut(k, nums)

for num in nums:
    print(num)

Measured memory_bytes: 4260
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

void solve() {
  int N; cin >> N;
  string MARCH = "MARCH";
  vl initial(5, 0);
  rep(i,N) {
    string name; cin >> name;
    rep(j,5) {
      if (name[0] == MARCH[j]) {
        ++initial[j];
        break;
      }
    }
  }
  
  ll ans = 0;
  for (int i=0; i<3; ++i) {
    for (int j=i+1; j<4; ++j) {
      for (int k=j+1; k<5; ++k) {
        ans += initial[i] * initial[j] * initial[k];
      }
    }
  }

  cout << ans << endl;
  return;
}

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


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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int32_t main() {
    //ios::sync_with_stdio(false); cin.tie(nullptr);

    vector<int> a(4), b = {1,9,7,4};
    for (int i = 0; i < 4; i++) {
        cin >> a[i];
    }

    sort(all(a));
    sort(all(b));

    if (a == b) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }

    return 0;
}


Measured memory_bytes: 256