akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize,
        x: usize,
    };
    let mut ans = 0;
    for i in 0..a+1{
        for j in 0..b+1{
            for k in 0..c+1{
                if i*500 + j*100 + k*50 == x{
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#! /usr/bin/env python3

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

A, B, C, K = map(int, read().split())

for _ in range(K):
    if A >= B:
        B *= 2
        continue
    if B >= C:
        C *= 2
        continue

if (A < B) & (B < C):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 27144
from bisect import bisect, insort

N = int(input())
P = list(map(int, input().split()))

ind = [-1] * (N + 1)
for i in range(N):
	ind[P[i]] = i

doneind = [-2, -1, ind[N], N, N + 1]
ans = 0
for i in range(N - 1, 0, -1):
	j = bisect(doneind, ind[i])
	if doneind[j] != N:
		ans += i * (doneind[j + 1] - doneind[j]) * (ind[i] - doneind[j - 1])
	if doneind[j - 1] != -1:
		ans += i * (doneind[j] - ind[i]) * (doneind[j - 1] - doneind[j - 2])
	insort(doneind, ind[i])
print(ans)

Measured memory_bytes: 85560
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    string s;
    int k;
    cin >> s >> k;

    set<string> S;

    for (int i = 0; i < s.size(); i++) {
        for (int j = 1; j <= k+1; j++) {
            if (i+j > s.size()) continue;
            S.insert(s.substr(i, j));
        }
    }

    // for (auto itr = S.begin(); itr != S.end(); ++itr) {
    //     cout << *itr;
    // }
    auto itr = S.begin();

    for (int i = 0; i < k-1; i++) {
        itr++;
    }
    

    cout << *itr << endl;
    

    return 0;
}

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

int main(int argc, char **argv)
{
	int w,h,x,y,r;
	cin >> w >> h >> x >> y >> r;
	
	if ( x-r >= 0 && x+r <= w ) {		
		if ( y-r >= 0 && y+r <= h ) {
			cout << "Yes\n";
		}else{
			cout << "No\n";
		}
	}else{
		cout << "No\n";
	}
	return 0;
}

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

int main() {
  int n; cin >> n;
  vector<int>p(n), q(n);
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];
  vector<int>ele(n); 
  rep(i,n) ele[i] = i+1;
  map<vector<int>, int> mp;
  
  do{
    mp[ele] = mp.size();
  } while(next_permutation(ele.begin(), ele.end()));
  
  int ans = abs(mp[p]-mp[q]);
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 5248
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
int h,w;
string st;
int main()
{
	cin>>h>>w;
	for(int i=1;i<=h;i++)
	{
		cin>>st;
		cout<<st;
		cout<<endl;
		cout<<st;
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
def solve(s, t):
    start = -1
    for i in range(len(s) - len(t) + 1):
        if all(s[len(s) - len(t) - i + j] in (t[j], '?') for j in range(len(t))):
            start = len(s) - len(t) - i
            break
    if start >= 0:
        return s[:start].replace('?', 'a') + t + s[start + len(t):].replace('?', 'a')
    else:
        return 'UNRESTORABLE'

_s = input()
_t = input()
print(solve(_s, _t))


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

int main(void){
  int N;
  cin >> N;
  int A[N];
  for(int i = 0; i < N; i++)
    cin >> A[i];
  vector<int> ans;
  bool ans_bool = true;
  for(int i = 0; i < N; i++){
    if(A[i] % 2 == 0){
      ans.push_back(A[i]);
    }
  }
  int len = ans.size();
  for(int i = 0; i < len; i++){
    if(ans[i] % 3 != 0 && ans[i] % 5 != 0){
      ans_bool = false;
    }
  }
  if(ans_bool) cout << "APPROVED" << "\n";
  else cout << "DENIED" << "\n";
  return 0;
}


Measured memory_bytes: 3628
import math
 
datas = input().split(" ")
 
a = int(datas[0])
b = int(datas[1])
c = int(datas[2])
 
if( c <= a or c <= b ):
  print( "No")
  
elif(4*a*b < (c-a-b)**2):
  print( "Yes" )
else:
  print( "No" )

Measured memory_bytes: 3060
import java.math.*

fun main(args: Array<String>) {
    val (N, K) = readInputLine().split(" ").map{it.toInt()}
    
    val hs = IntArray(N)
    
    for (i in 0 until N) {
        hs[i] = readInputLine().toInt()
    }
    
    hs.sort()
    
    var ans = Int.MAX_VALUE
    
    for (i in K - 1 until N) {
        ans = Math.min(ans, hs[i] - hs[i - K + 1])
    }
    
    println(ans)
}

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


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

using namespace std;

int main() {
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    int cost = min(n,k)*x + (n-k > 0 ? (n-k)*y : 0);
    cout<<cost<<endl;
    return 0;
}

Measured memory_bytes: 3584
import sys
input = sys.stdin.readline
from collections import deque
import math


n, d, a = map(int, input().split())

XH = []
for _ in range(n):
    x, h = map(int, input().split())
    XH.append((x, h))
XH.sort()

answer = 0
damage = 0
QUEUE = deque()
for x, h in XH:
    if QUEUE:
        while x > QUEUE[0][0]:
            damage -= QUEUE[0][1]
            QUEUE.popleft()
            if not QUEUE:
                break
    h -= damage
    if h <= 0:
        continue
    bomb = math.ceil(h / a)
    QUEUE.append((x + 2 * d, a * bomb))
    damage += a * bomb
    answer += bomb

print(answer)


Measured memory_bytes: 72156
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=MOD;
const int INF = 1e16;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

const int N=200005;

void solve()
{
    string s;
    cin>>s;
    int n=s.length();
    int rev=0;
    deque<char>fr,bk;int z,t;vector<pair<int,pair<int,char> > > ve;char ch;
    int q;
    cin>>q;
    while(q--)
    {
        cin>>t;
        if(t==1)
        {
            ve.pb(m1(1,m1(-1,'0')));
        }
        else
        {
            cin>>z>>ch;
            ve.pb(m1(2,m1(z,ch)));
        }
    }
    for(int i=ve.size()-1;i>=0;i--)
    {
        if(ve[i].first==1)
            rev^=1;
        else
        {
            int z=ve[i].second.first;ch=ve[i].second.second;
            if(rev)
            {
                if(z==1)
                {
                    bk.push_front(ch);
                }
                else
                {
                    fr.push_back(ch);
                }
                    
            }
            else
            {
                if(z==1)
                {
                    fr.push_back(ch);
                }
                else
                {
                    bk.push_front(ch);
                }
            }
        }
    }
    while(!fr.empty())
    {
        cout<<fr.front();
        fr.pop_front();
    }
    if(rev)
    {
        for(int i=n-1;i>=0;i--)
            cout<<s[i];
    }
    else
        for(int i=0;i<n;i++)
            cout<<s[i];
    while(!bk.empty())
    {
        cout<<bk.front();
        bk.pop_front();
    }
    cout<<endl;
}

int32_t main()
{
    
    IOS;
    //FILE *fin = freopen("in","r",stdin);
    //FILE *fout = freopen("out","w",stdout);
    
    int t;
    t=1;
     //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 8384
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
int main() {
	int n; std::cin >> n;
	std::vector<int> sticks(n); for (auto& s : sticks) std::cin >> s;
	std::sort(sticks.begin(), sticks.end());
	int count = 0;
	for (auto i = 0; i < n; ++i) for (auto j = i + 1; j < n; ++j) for (auto k = j + 1; k < n; ++k) {
		if (i < j && sticks[i] + sticks[j] > sticks[k]) {
			++count;
		}
	}
	std::cout << count << std::endl;
}

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

using namespace std;

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

	vector<vector<int>> a(26);
	for (int i = 0; i < s.length(); i++) {
		a[s[i] - 'a'].emplace_back(i + 1);
	}

	for (int i = 0; i < t.length(); i++) {
		if (a[t[i] - 'a'].empty()) {
			cout << -1 << endl;
			return 0;
		}
	}

	int now = 0;
	long long ans = 0;
	for (int i = 0; i < t.length(); i++) {
		int spot = lower_bound(a[t[i] - 'a'].begin(), a[t[i] - 'a'].end(), now + 1) - a[t[i] - 'a'].begin();
		if (spot == a[t[i] - 'a'].size()) {
			ans += s.length() - now;
			ans += a[t[i] - 'a'][0];
			now = a[t[i] - 'a'][0];
		} else {
			ans += a[t[i] - 'a'][spot] - now;
			now = a[t[i] - 'a'][spot];
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL)
#define REP(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b,_a=a;i>=_a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<endl
using namespace std;


int main() {
	SPEED;
	//freopen("in.txt", "r", stdin);
	
	int n;
	cin >> n;
	if(n <= 999) print("ABC");
	else print("ABD");
	
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func main() {
	L := nextInt()
	l := float64(L)
	fmt.Printf("%f\n", l*l*l/27)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int GCD(int a,int b);
signed main(){
    int x,y;
    cin>>x>>y;
    cout<<GCD(x,y)<<'\n';
    return(0);
}
    int GCD(int a,int b){
    while(b != 0){
        int r =a%b;
        a=b;
        b=r;
    }
    return(a);
}


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

const int mod = 1000000007;

struct mint {
    ll x;

    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 {
      mint res(*this);
      return res += a;
    }

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

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

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

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

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

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

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

  mint ans = 1;
  for (int i = 0; i < n; i++) {
    ans *= 10;
  }

  mint sub = 1;
  for (int i = 0; i < n; i++) {
    sub *= 9;
  }

  mint add = 1;
  for (int i = 0; i < n; i++) {
    add *= 8;
  }

  ans = ans - sub * 2 + add;
  cout << ans.x << '\n';
}


Measured memory_bytes: 3628
// AGC023
// A - Zero-Sum Ranges

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 200000;
const ll INF = 1e18;

int N;
int a[MAX_N];

ll comb2(int n) { return 1LL * n * (n - 1LL) / 2LL; }

ll solve() {
    ll s[MAX_N + 2];

    s[0] = 0;
    for (int i = 0; i < N; i++) {
        s[i + 1] = s[i] + a[i];
    }
    s[N + 1] = INF;
    sort(s, s + N + 2);

    ll ans = 0;
    int prev_i = 0;
    ll prev_s = s[0];
    for (int i = 1; i <= N + 1; i++) {
        if (s[i] != prev_s) {
            ans += comb2(i - prev_i);
            prev_i = i;
            prev_s = s[i];
        }
    }
    return ans;
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define DEBUG(x) cerr << #x << " = " << x << endl
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)

char isono[100];
char nakajima[100];

signed main() {
  ios::sync_with_stdio(false);
  int N; cin >> N;
  REP(i,N) {
    string s; cin >> s;
    isono[i] = s[0];
  }
  REP(i,N) {
    string s; cin >> s;
    nakajima[i] = s[0];
  }
  int p0 = 0, p1 = 0;
  const string isonoWin = "Isono-kun";
  const string nakajimaWin = "Nakajima-kun";
  REP(t,N) {
    // DEBUG(t+1);
    if(isono[t] == 'k' && nakajima[t] == 'k') {
      if(p0 == p1) {
        p0 = 0;
        p1 = 0;
      }
      else {
        cout << (p0 > p1 ? isonoWin : nakajimaWin) << endl;
        exit(0);
      }
    }
    if(isono[t] == 'k' && nakajima[t] == 'm') {
      if(p0 == 0) {
        cout << nakajimaWin << endl;
        exit(0);
      }
      else if(p0 == 5) {
        cout << isonoWin << endl;
        exit(0);
      }
      else {
        p0 = 0;
      }
    }
    if(isono[t] == 'k' && nakajima[t] == 't') {
      if(p0 == 0) {
        cout << nakajimaWin << endl;
        exit(0);
      }
      else {
        cout << isonoWin << endl;
        exit(0);
      }
    }
    if(isono[t] == 'm' && nakajima[t] == 'k') {
      if(p1 == 0) {
        cout << isonoWin << endl;
        exit(0);
      }
      else if(p1 == 5) {
        cout << nakajimaWin << endl;
        exit(0);
      }
      else {
        p1 = 0;
      }
    }
    if(isono[t] == 'm' && nakajima[t] == 'm') {
    }
    if(isono[t] == 'm' && nakajima[t] == 't') {
      if(p1 < 5) p1++;
    }
    if(isono[t] == 't' && nakajima[t] == 'k') {
      if(p1 == 0) {
        cout << isonoWin << endl;
        exit(0);
      }
      else {
        cout << nakajimaWin << endl;
        exit(0);
      }
    }
    if(isono[t] == 't' && nakajima[t] == 'm') {
      if(p0 < 5) p0++;
    }
    if(isono[t] == 't' && nakajima[t] == 't') {
      if(p0 < 5) p0++;
      if(p1 < 5) p1++;
    }
  }
  cout << "Hikiwake-kun" << endl;
}

Measured memory_bytes: 3244
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
template<typename T> inline void debug(const vector<T> &xs){
#ifdef DEBUG
	pr(xs);
#endif
}

int main(){
	int N;
	cin >> N;
	int n2 = 1<<N;
	vector<ll> S(n2);
	for(int i=0; i<n2; i++) cin >> S[i];
	sort(S.begin(), S.end());
	reverse(S.begin(), S.end());

	vector<ll> a(1, S[0]);
	S[0] = -1;
	for(int k=0; k<N; k++){
		int j=0;
		int na = a.size();
		for(int i=na-1; i>=0; i--){
			while(j<n2&&(S[j]<0||S[j]>=a[i])) j++;
			if(j==n2){
				cout << "No" << endl;
				return 0;
			}
			a.push_back(S[j]);
			S[j++] = -1;
		}
		sort(a.begin(), a.end());
	}
	cout << "Yes" << endl;

	return 0;
}


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

using namespace std;

//#define _FILES
const int maxn = 100005;
int a[maxn];

int main()
{
    ios_base::sync_with_stdio(false);

    #ifdef _FILES
        freopen("","r",stdin);
        freopen("","w",stdout);
    #endif // _FILES
    int n;
    cin >> n;
    for (int i=1;i<=n;i++)
    {
        int x;
        cin >> x;
        if (x == i) a[i] = 1;
    }
    int ans = 0;
    int counter = 0;

    for (int i=1;i<=n;i++)
    {
        if (!a[i])
        {
            ans += counter/2 + (counter & 1);
            counter = 0;
        }
        else
        {
            counter++;
        }
    }
    ans += counter/2 + (counter & 1);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 62;

int main() {
  //
  ll n;
  cin >> n;
  vl l(n);
  vl cnt(2002, 0), scnt(2002, 0);
  rep(i, n) {
    cin >> l[i];
    cnt[l[i]]++;
  }
  scnt[0] = cnt[0];
  REP(i, 1, 2002) {
    if (cnt[i] > 0) {
      scnt[i] = scnt[i - 1] + cnt[i];
    } else {
      scnt[i] = scnt[i-1];
    }
  }

  set<string> s;
  ll ans = 0;
  sort(ALL(l));
  rep(i, n - 2) {
    REP(j, i + 1, n - 1) {
      ll a = l[i];
      ll b = l[j];
      ll c1 = a + b - 1;
      // cerr << a << ":" << b << endl;
      // cerr << c1 << ","<<b -1 << "," << scnt[c1] << "," << scnt[b-1] << endl;
      ans += scnt[c1] - scnt[b];
      int b0 = upper_bound(ALL(l), b) - l.begin();
      ans += b0 - j - 1;
      // cerr << a << "," << b << "," << ans << endl;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
# ABC 070: B – Two Switches
a, b, c, d = [int(s) for s in input().split()]

if b <= c or d <= a:
    print(0)
elif a <= c and b >= d:
    print(d - c)
elif c <= a and d >= b:
    print(b - a)
elif a <= c:
    print(b - c)
else:
    print(d - a)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  int h, n;cin>>h>>n;
  vector<int> a(n), b(n);
  rep(i, n){
    cin>>a[i]>>b[i];
  }
  int MAX_A=20000;
  vector<vector<int>> dp(n+1, vector<int>(MAX_A+1, INF));
  dp[0][0]=0;
  rep(i, n){
    rep(j, MAX_A+1){
      if(j-a[i]>=0)dp[i+1][j]=min(dp[i][j], dp[i+1][j-a[i]]+b[i]);
      else dp[i+1][j]=dp[i][j];
    }
  }
  // rep(i, n+1){
  //   rep(j, h+1)cout<<dp[i][j]<<" ";cout<<endl;
  // }
  int ans=INF;
  for(int i=h;i<=MAX_A;i++){
    if(dp[n][i]!=INF)ans=min(ans, dp[n][i]);
  }
  cout<<ans<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
  return 0;
}


Measured memory_bytes: 80640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

ll dp[3010][3010][4];

int main(){
    int r,c,k;
    cin>>r>>c>>k;
    int mp[r][c]={};
    rep(i,k){
        int a,b,v;
        cin>>a>>b>>v;
        --a,--b;
        mp[a][b]=v;
    }

    rep(i,r){
        rep(j,c){
            rep(k,4){
                dp[i][j][k]=0;
            }
        }
    }
    dp[0][0][1]=mp[0][0];
    rep(i,r){
        rep(j,c){
            ll v=mp[i][j];
            if(0<i){
                dp[i][j][0]=max(dp[i][j][0],max({dp[i-1][j][0],dp[i-1][j][1],dp[i-1][j][2],dp[i-1][j][3]}));
                dp[i][j][1]=max(dp[i][j][1],v+max({dp[i-1][j][0],dp[i-1][j][1],dp[i-1][j][2],dp[i-1][j][3]}));
            }
            if(0<j){
                for(int l=0;l<4;++l){
                    if(l>0)dp[i][j][l]=max(dp[i][j][l],v+dp[i][j-1][l-1]);
                    dp[i][j][l]=max(dp[i][j][l],dp[i][j-1][l]);
                }
            }
        }
    }
    cout<<max({dp[r-1][c-1][0],dp[r-1][c-1][1],dp[r-1][c-1][2],dp[r-1][c-1][3]})<<endl;
}


Measured memory_bytes: 320552
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> Q;

ll mod = 1000000007;
int n, k;
string s;

int main()
{
	cin >> n >> k >> s;
	for (int i = 0; i < s.length(); i++)
	{
		if (i == k - 1)
		{
			if (s[i] == 'A') cout << 'a';
			if (s[i] == 'B') cout << 'b';
			if (s[i] == 'C') cout << 'c';
		}
		else
		{
			cout << s[i];
		}
	}
	cout << endl;
	cin >> n;
}

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

const ll mod = 1e9 + 7;

int main() {
  string L;
  cin >> L;

  ll n = L.size();

  vector<ll> dp1(n + 1); // A + B is less than L
  vector<ll> dp2(n + 1); // A + B can be L
  dp2[0] = 1;

  for (ll i = 0; i < n; i++) {
    if (L[i] == '0') {
      dp1[i + 1] = dp1[i] * 3 % mod;  // 00, 01, 10
      dp2[i + 1] = dp2[i] * 1 % mod;  // 00
    } else {
      dp1[i + 1] = dp1[i] * 3 % mod + // 00, 01, 10
                   dp2[i] * 1 % mod;  // 00
      dp2[i + 1] = dp2[i] * 2 % mod;  // 01, 10
    }
    dp1[i + 1] %= mod;
    dp2[i + 1] %= mod;
  }

  cout << (dp1[n] + dp2[n]) % mod << endl;
}


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

int H, W, K;

int  A[310][310];
char S[310][310];
int num = 1;  // 区画に入れる数字


// begin から end 行までの中に # の入った行が1行ある．
// その1行を見つけだして，縦に区切って行列 A に区画ごとの数字を代入していく. 
void solve(int begin, int end) {
  
  // どこに # があるかを１行ずつ探って見つける．
  // 基本的には先頭にあるはずなのだが，最初の行だけ先頭でない可能性があるあため
  // 細かく場合わけするより一律に求めてしまうことにする
  int strawberry_col;
  for (int i = begin; i <= end; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '#') strawberry_col = i;
    }
  }
  
  // strawberry_col を順に見ていって何列目に # があるかを vector<int> P に入れる
  vector<int> P;
  for (int i = 0; i < W; i++) {
    if (S[strawberry_col][i] == '#') {
      P.push_back(i);
    }
  }
 
  // P を用いて， begin から end 行までの A[i][j]に数字をあてはめていく
  for (int i = 0; i < P.size(); i++) {
    for (int j = begin; j <= end; j++) {   
      int row_begin = 0, row_end = W-1;
    // 最初のときの row_begin, 最後の row_end がそれぞれ例外になりうる
      if (i >= 1) row_begin = P[i];
      if (i < P.size() -1) row_end = P[i+1] - 1;
      
      for (int k = row_begin; k <= row_end; k++) {
        A[j][k] = num;
      }
      
    }
    num++;
  }
  
  
  
}

int main() {
  cin >> H >> W >> K;
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> S[i][j];
    }
  }
  
  
  vector<int> COL;
  
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '#') {
        COL.push_back(i);
        break;
      }
    }
  }
  
  
  for (int i = 0; i < COL.size(); i++) {
    int cl_begin = 0, cl_end = H-1;
    
    if (i >= 1) cl_begin = COL[i];
    if (i < COL.size() -1) cl_end = COL[i+1] -1;
    
    
    solve(cl_begin, cl_end);
    
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cout << A[i][j] << " ";
    }
    cout << endl;
  }
}

Measured memory_bytes: 1280
import java.util.*;
import java.io.*;
public class Main {
	public static boolean[] b;
	static int[] FF;
	static int[] A;
	public static void main(String[] ard)  throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(System.out);
		String[] s=br.readLine().trim().split("\\s++");
		int a=Integer.valueOf(s[0]);
		int b=Integer.valueOf(s[1]);
		int c=Integer.valueOf(s[2]);
		int d=Integer.valueOf(s[3]);
		int upper=Math.min(b,d);
                int lower=Math.max(a,c);
                 pw.println(Math.max(0,upper-lower));
		
	pw.close();
		
	}
	 static long solve(int[] A, int k){
	       //int[] sum=new int[A.length+k+1];
	     ///  for(int i=1;i<=A.length;i++)
		 int n=A.length-1;
	       long ans=0;
	      /// Arrays.sort(A);
	       for(int i=1;i<=n-k+1;i++)
	       {
	           ans=Math.max(ans,Math.abs(A[i]-A[i+k-1]));
	       }
	       
	       return ans;
	    }
	public static boolean palin(String s)
	{
	   int i=0;
	   int j=s.length()-1;
	   while(i<j)
	   {
		   if(s.charAt(i)==s.charAt(j))
		   {
			   i++;
			   j--;
		   }
		   else return false;     
	   }
	   return true;
	}
	
}

Measured memory_bytes: 20948
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <tuple>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

using T = tuple<ll,ll>;
using Graph = vector<vector<T>>;

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

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

    ll ans(0);

    if (a-k>= 0)
        ans += k, a -= k, k=0;
    else
        ans += a, k = k-a, a = 0;

    if (b-k>=0)
        b -= k, k=0;
    else
        k = k-b, b = 0;

    if (c-k>=0)
        ans -=k, c -= k;
    else
        ans -= c, k = k-c, c = 0;

    //cout << a << ' ' << b << ' ' << c << ' ' << k << endl;

    cout << ans << endl;

    return 0;
}


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

int N, K;
vector<int> h;
const int inf = 1 << 30;

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

int main() {
    scanf("%d %d", &N, &K);
    h.resize(N);
    for (int i = 0; i < N; i++) scanf("%d", & h[i]);
    sort(h.begin(), h.end(), greater<int>());
    int ans = inf;
    for (int i = 0; i <= N-K; i++) chmin(ans, h[i] - h[K+i-1]);
    cout << ans << endl;
}

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

int main() {
  int N;
  cin>>N;
  int x=0;
  for(int i=0;i<N;i++){
      string s;
      cin>>s;
      if(s=="Y")
      x=x+1;
  }

  if(x==0)
  cout<<"Three"<<endl;
  else if(x!=0)
  cout<<"Four"<<endl;
}


Measured memory_bytes: 256
while True:
	H, W = map(int, input().split())
	if H == 0 and W == 0:
		break
	for i in range(H):
		for j in range(W):
			if (i + j) % 2 == 0:
				print("#", end = '')
			else:
				print(".", end = '')
		print()
	print()


Measured memory_bytes: 7004
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main()
{
    int s,n = 2;
    cin >> s;
    int temp = s,i;
    vector<int> array(1,s);
    while(true){
        if(temp %2 == 0){
            temp /= 2;
        }else{
            temp = temp*3+1;
        }
        for(i = 0;i < array.size();++i){
            if(array.at(i) == temp){
                cout << n << endl;
                return 0;
            }
        }
        array.push_back(temp);
        ++n;
    }
    return 0;
}

Measured memory_bytes: 256
sx,sy,tx,ty = list(map(int, input().split()))

# (x,y)のケースで場合分けすればできそう
x = tx-sx
y = ty-sy
str = ""

if(x > 0) and (y > 0):
    #1
    str += "R"*x
    str += "U"*y
    #2
    str += "L"*x
    str += "D"*y
    #3
    str += "L"
    str += "U"*(y+1)
    str += "R"*(x+1)
    str += "D"
    #4
    str += "R"
    str += "D"*(y+1)
    str += "L"*(x+1)
    str += "U"

print(str)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    char c;
    cin >> c;
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
        cout << "vowel" << endl;
    }
    else{
        cout << "consonant" << endl;
    }
}


Measured memory_bytes: 256
"""
def factorization(n):
    if (n == 1 ):
        return [1]
    arr = []
    temp = n

    
    for i in range(2, int(-(-n**0.5//1))+1) :
        if ( temp % i == 0):
            cnt = 0
            while (temp % i == 0):
                cnt +=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return [arr[1]+1 for arr in arr ]

#print(factorization(N))

sum_ans = 0
def cal(list):
    ans = 1
    for i in list:
        ans *= i

    return ans


for i in range(1,N+1):
    #print(factorization(i),i)
    sum_ans += i * cal(factorization(i))
    #lenが掛け算

print(sum_ans)
"""
n=int(input())
ans=0
for i in range(1,n+1):
    d=n//i
    ans+=i*d*(d+1)//2
print(ans)



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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vll>;
df data(n, vll(m));
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/range/algorithm.hpp> // boost::sort(arr)
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
using boost::algorithm::join; // string s = join(arr, "");
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}

int main() {
  int d;
  cin >> d;
  vector<string> arr{"Christmas"};
  rep(i, 25 - d) arr.push_back("Eve");
  print(arr);
}


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

const ll inf = 1LL << 60;

int main(){ 
  
  ll N,M; cin >> N >> M;
  
  vector<ll> A(N);
  vector<ll> B(N+1);
  
  for(ll i = 0; i < N; i++){ cin >> A[i];}
  
  sort(A.begin(),A.end());
  
  B[N] = 0;
  B[N-1] = A[N-1];
  
  for(ll i = N-2; i >= 0; i--){ 
    B[i] = B[i+1]+A[i];
  }
 
  
  //ソート
  
  ll l = 0; ll r = inf;
  
  while( r - l > 1 ){ 
    
    ll d = l+(r-l)/2;
    
    ll cnt = 0;
    
    for(ll i = 0; i < N; i++){ 
      
      // d-A[i]以上となるような人数を求める
      
      auto itr = lower_bound(A.begin(),A.end(),d-A[i])-A.begin();
      
      cnt += N-itr;
     
      
      
    }
    
   if(cnt >= M){ //　もっと下限を上げていい
      l = d;
    }
    else{
      r = d;
    }
  }
  // 最大の下限l発見
  
  r = l;
  
  ll ans = 0;
  ll howmany = 0;
  
 
  for(ll i = 0; i < N; i++){
    //値がr-A[i](=x)以上となるような要素の和をansにたす
    
    ll x = r-A[i];
    
    auto itr = lower_bound(A.begin(),A.end(),x)-A.begin();
    
    // A[itr],,A[N-1]までの和
    
    if( itr == N ){ continue;}
    
    howmany += N-itr;
    
    ans += B[itr]+A[i]*(N-itr);
      
  }
  
  //howmany-r個分はもっとも小さい要素を除いて調整
  
  
  if( howmany > M){ ans -= r*(howmany-M);}

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

Measured memory_bytes: 1792
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
K = I()
x = IL()

num = 0
for i in range(N):
    num += min(x[i],K-x[i])
print(num*2)

Measured memory_bytes: 12484
#include<bits/stdc++.h>
using namespace std;
map<char,int>mp;
map<char,int>::iterator it;
int main()
{
  string s,s1;
  int l,l1,j=0,k=0;
  cin>>s>>s1;
  l=s.length();
  l1=s1.length();
  l+=l1;
  for(int i=0;i<l;i++)
  {
      if(i%2==0&&k<s.length()){cout<<s[k];k++;}
      else if(j<s1.length()){cout<<s1[j];j++;}
  }
  cout<<endl;

}


Measured memory_bytes: 256
K,N = map(int,input().split())
A = list(map(int,input().split())) #0toN-1
distance_btwn = [A[i]-A[i-1] for i in range(1,N)]
distance_btwn.append(A[0]+K-A[N-1])
most_far = max(distance_btwn)
print(K - most_far)

Measured memory_bytes: 26420
#include <bits/stdc++.h>
#define ll long long
#define arena ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

ll mod=1e9+7;

int main()
{
    arena
    ll n;
    cin>>n;
    ll arr[n];
    for(ll i=0;i<n;i++)
    cin>>arr[i];
    
    pair<ll,ll> cnt[60];
    for(ll i=0;i<60;i++)
    {
        cnt[i].first=0;
        cnt[i].second=0;
    }
    
    for(ll i=0;i<60;i++)
    {
        for(ll j=0;j<n;j++)
        {
            ll temp=arr[j]>>i;
            if(temp&1)
            cnt[i].first++;
            else
            cnt[i].second++;
        }
    }
    
    ll sum=0;
   for(ll i=0;i<60;i++)
   {
       ll x=((1ll<<i)%mod*(cnt[i].first)%mod*(cnt[i].second)%mod)%mod;
       sum=(sum%mod+x%mod)%mod;
   }
   cout<<sum;
}

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

typedef long long ll;

const int maxn = 110, maxk = 1e5 + 5;
int N, K, a[maxn];
int dp[maxk];

int rec(int k) {
    if (dp[k] != -1) {
        return dp[k];
    }
    dp[k] = 0;
    for (int i = 0; i < N; i++) {
        if (a[i] > k) {
            break;
        }
        if (rec(k - a[i]) == 0) {
            dp[k] |= 1;
        }
    }
    return dp[k];
}

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

    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    memset(dp, -1, sizeof(dp));
    int answer = rec(K);
    (answer == 1) ? cout << "First" : cout << "Second";

    return 0;
}

Measured memory_bytes: 8700
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        String x;
        if ( a < b ) {
            x = "<";
        } else if ( a > b ) {
            x = ">";
        } else {
            x = "==";
        }
        
        System.out.printf("%s %s %s\n","a",x,"b");
    }
}


Measured memory_bytes: 26356
from collections import defaultdict
N, K, L = map(int, input().split())


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

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

        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
            self.size[x] = 0
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            self.size[y] = 0
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    # すべての頂点に対して親を検索する
    def all_find(self):
        for n in range(len(self.par)):
            self.find(n)


UF1 = UnionFind(N)
UF2 = UnionFind(N)
for k in range(K):
    p, q = map(int, input().split())
    UF1.union(p-1, q-1)

for l in range(L):
    l, s = map(int, input().split())
    UF2.union(l-1, s-1)

UF1.all_find()
UF2.all_find()

D = defaultdict(int)
for i in range(N):
    D[UF1.par[i], UF2.par[i]] += 1

ans = [D[UF1.par[i], UF2.par[i]] for i in range(N)]
print(" ".join(map(str, ans)))


Measured memory_bytes: 62968
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;

bool solve() {
    ll N, M;
    cin >> N >> M;
    string S;
    cin >> S;
    vector<int> s(N);
    for ( int i = 0; i < N; i++ ) {
        s[i] = (S[i] == 'B' ? 1 : 0);
    }
    int a, b;
    vector<vector<int>> G(N);
    vector<vector<int>> nc(N, vector<int>(2));
    for ( int i = 0; i < M; i++ ) {
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        if ( a != b ) G[b].push_back(a);
        nc[a][s[b]]++;
        if ( a != b ) nc[b][s[a]]++;
    }
    auto get_m = [&](int i) {
        return min(nc[i][0],nc[i][1]);
    };
    queue<int> q;
    for ( int i = 0; i < N; i++ ) {
        if ( get_m(i) == 0 ) q.push(i);
    }
    vector<int> ng(N);

    while ( !q.empty() ) {
        int i = q.front();
        q.pop();
        if ( ng[i] > 0 ) continue;
        for ( int u : G[i] ) {
            if ( ng[u] > 0 ) continue;
            if ( u != i ) {
                nc[u][s[i]]--;
                if ( get_m(u) == 0 ) q.push(u);
            }
        }
        ng[i] = 1;
    }
    bool ans = false;
    for ( int i = 0; i < N; i++ ) {
        if ( ng[i] == 0 ) ans = true;
    }
    return ans;
}

int main() {
    string ans = solve() ? "Yes" : "No";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 22532
#include<iostream>
#include<cmath>
using namespace std;
 
int main(){
  int n;
  cin>>n;
  int h[n];
  for(int i=0; i<n; i++)
    cin>>h[i];
  int c, c1, c2;
  c = abs(h[1] - h[0]);
  c1 = c;
  c2 = 0;
  for(int i=2; i<n; i++){
      int x = abs(h[i] - h[i-1]) + c1;
      int y = abs(h[i] - h[i-2]) + c2;
      if(x <= y)
        c = x;
      else
        c = y;
      c2 = c1;
      c1 = c;
  }
  cout<<c;
}

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

    #define ll long long
    #define ff first
    #define ss second
    #define pb push_back
    #define vll vector<ll>
    #define mll map<ll,ll>
    #define MOD 1000000007
    #define pll pair<ll,ll>
constexpr ll INF = 1999999999999999997; 
    #define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
    int main() {
        fastio;

        int n;
        cin>>n;
        int a[n];
        map<int,int>m;
        for(int i=0;i<n;i++)
        {cin>>a[i]; m[a[i]]++;}
        bool visited[1000005]={0};
        int ans=0;
        sort(a,a+n);
        for(int i=0;i<n;i++)
        {
            if(!visited[a[i]])
            { //cout<<a[i]<<' ';

                visited[a[i]]=1;
                if(m[a[i]]==1)
                ans++;
                for(int j=a[i]*2;j<=1000000;j+=a[i])
                {
                    visited[j]=1;
                }
            }
        }
        cout<<ans<<endl;

    }

Measured memory_bytes: 14684
n = int(input())
s = list(input())
c = 0

for i in range(1000) :
    num_1 = i // 100
    num_2 = (i - num_1*100) // 10
    num_3 = (i - num_1*100 - num_2*10) % 100
    if str(num_1) not in s :
        continue
    if str(num_2) not in s :
        continue
    if str(num_3) not in s :
        continue
    for j in range(n-2) :
        if int(s[j]) == num_1 :
            for k in range(j+1,n-1) :
                if int(s[k]) == num_2 :
                    for l in range(k+1,n) :
                        if int(s[l]) == num_3 :
                            c += 1
                            break
                    break
            break

print(c)


Measured memory_bytes: 75596
#include<bits/stdc++.h>
using namespace std;
int x,y;
const int N=1e6+9;
const int mod=1e9+7;
int inv[N],frac[N];
void init(){
  frac[0]=frac[1]=inv[0]=inv[1]=1;
  for(int i=2;i<N;i++)frac[i]=1ll*i*frac[i-1]%mod,
  inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
  for(int i=2;i<N;i++)inv[i]=1ll*inv[i]*inv[i-1]%mod;
}
int C(int x,int y){
  return 1ll*frac[x]*inv[x-y]%mod*inv[y]%mod;
}
int main(){
  init();
  cin>>x>>y;
  int t=(x+y)/3;
  int ans=0;
  if(x>=t&&x<=2*t&&((x+y)%3==0))ans=C(t,x-t);
  cout<<ans<<endl;
}


Measured memory_bytes: 8064
s=j=0
a=[];b=[];d=[]
for i,x in enumerate(input()):
    if x=='\\':a+=[i]
    elif x=='/' and a:
        j=a.pop()
        c=i-j;s+=c
        while b and b[-1]>j:c+=d.pop();b.pop()
        b+=[j];d+=[c]
print(s)
print(len(b),*(d))


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

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

  if ((N/1000 == N%1000/100 && N%1000/100 == N%100/10) || (N%1000/100 == N%100/10 && N%100/10 == N%10)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

int arr[10];
bool flag;

void dfs(int num, int l, int r) {
  if(num==10) {
    flag = true;
    return;
  }

  if(arr[num] > l) dfs(num+1, arr[num], r);
  if(arr[num] > r) dfs(num+1, l, arr[num]);
  return;
}

int main() {
  int n;
  scanf("%d",&n);
  for(int i=0; i<n; ++i) {
    for(int j=0; j<10; ++j)
      scanf("%d", &arr[j]);

    flag = false;
    dfs(0,0,0);
    if(flag)
      printf("YES\n");
    else
      printf("NO\n");
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <string.h>
#include <string>
#include <cmath>
#include <cstdio>
#include <functional>
#include <map>
#include <typeinfo>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<double, double> pd;

string str(int a, int b)
{
  int res = a;
  for(int i = 1; i < b; i++)
  {
    res *= 10;
    res += a;
  }
  
  return to_string(res);
}

int main()
{
  int n, m;
  scanf("%d %d", &n, &m);
  
  printf("%s\n", min(str(n, m), str(m, n)).c_str());
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 
 
ll dp[8005],po[3005];
 
int main() 
{
    FAST;
    po[0]=1;
    for(int i=1;i<3005;i++)
        po[i]=(po[i-1]*2ll)%B;
    ll n,s;
    cin>>n>>s;
    ll a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
    {
        for(int j=3005;j>=0;j--)
            dp[j+a[i]]=(dp[j+a[i]]+(dp[j]*499122177ll)%B)%B;
        dp[a[i]]=(dp[a[i]]+po[n-1])%B;
    }
    cout<<dp[s];
    subt;
    return 0;
}

Measured memory_bytes: 3872
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
using namespace std;

int kakuketanosum(int n) {
	int s = 0;
	while (n > 0) {
		s += n % 10;
		n = n / 10;
	}
	/*if (s >= 10)
		s = kakuketanosum(s);
	else*/
		return s;
}
int main(void) {
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200)
		cout << s << endl;
	else
		cout << "red" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pci pair<char, int>
#define pic pair<int, char>
#define plvl pair<long long, vector<long long> >
#define pcvc pair<char, vector<char> >


using namespace std;

const int mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	if(b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

template <typename T>
void show1(vector<T> dp) {
	for(auto d : dp) {
		cout << d << " ";
	}
	cout << endl;
}

template <typename T>
void show2(vector<vector<T> > dp) {
	for(auto d : dp) {
		for(auto dd : d) {
			cout << dd << " ";
		}
		cout << endl;
	}
}

void executeCode() {
	string str;
	cin >> str;
	if(str == "ARC") {
		cout << "ABC" << endl;
	}else {
		cout << "ARC" << endl;
	}
}

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int tt = 1;
	// cin >> tt;
	while(tt--) {
		executeCode();	
	}
	return 0;
}

Measured memory_bytes: 3640