akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long


ll funct(ll t){
    if(!t){
        return 0LL;
    }
    ll res;
    if(t%2 == 0){
        ll halft = t/2;
        if(halft%2 == 0){
            res = t;
        }else{
            res = 1 ^ t;
        }
    }else{
        ll halft = (t+1)/2;
        if(halft % 2 == 0){
            res = 0;
        }else{
            res = 1;
        }
    }
    return res;
}

int main(){
    ll a, b;
    cin >> a >> b;
    ll ans = funct(a-1)^funct(b);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
const int dy[]={0,-1,0,1,1,-1,-1,1};
const int dx[]={1,0,-1,0,1,1,-1,-1};

int dp[1010][1010];
int main() {
	int h, w; cin >> h >> w;
	rep(i,h)rep(j,w) dp[i][j] = INF;
	int sy, sx; cin >> sy >> sx;
	--sy, --sx;
	int gy, gx; cin >> gy >> gx;
	--gy, --gx;
	char c[h][w];
	rep(i,h)rep(j,w) cin >> c[i][j];
	deque<tuple<int, int, int>> que;
	que.emplace_back(sy, sx, 0);
	dp[sy][sx] = 0;
	while(not que.empty()) {
		auto[y, x, co] = que.front();
		que.pop_front();
		for(int i = 0; i < 4; ++i) {
			int ny = y + dy[i];
			int nx = x + dx[i];
			if(ny < 0 or h <= ny) continue;
			if(nx < 0 or w <= nx) continue;
			if(c[ny][nx] == '#') continue;
			if(co < dp[ny][nx]) {
				dp[ny][nx] = co;
				que.emplace_front(ny, nx, co);
			}
		}
		for(int dy = -2; dy <= 2; ++dy) {
			for(int dx = -2; dx <= 2; ++dx) {
				int ny = y + dy;
				int nx = x + dx;
				if(ny < 0 or h <= ny) continue;
				if(nx < 0 or w <= nx) continue;
				if(c[ny][nx] == '#') continue;
				if(co + 1 < dp[ny][nx]) {
					dp[ny][nx] = co + 1;
					que.emplace_back(ny, nx, co + 1);
				}
			}
		}
	}
	cout << (dp[gy][gx] == INF ? -1 : dp[gy][gx]) << '\n';
	return 0;
}

Measured memory_bytes: 8524
from itertools import accumulate
 
n, k = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
 
P = [p-1 for p in P]
 
check = [False] * n
loops = []
 
for i in range(n):
    if check[i]:
        continue
    check[i] = True
    next = P[i]
    tmp = [i]
    while next != i:
        check[next] = True
        tmp.append(next)
        next = P[next]
    loops.append(tmp)
 
 
ans = 0
 
for loop in loops:
 
    num = len(loop)
    div = k // num
    r = k % num
    if r == 0:
        r = num
        div -= 1
    L = [C[p] for p in loop]
    ans_tmp = 0  
    sumL = sum(L)
    by_loop = max(sumL, 0) * div
    if k>num and sumL <= 0:
      r = num
    L += L[:r]
    ACC = [0] + list(accumulate(L))
 
    for i in range(num):
            for j in range(i+1, i+r+1):
                ans_tmp = max(ans_tmp, ACC[j] - ACC[i] + by_loop)
 
    ans = max(ans, ans_tmp)
if ans == 0:
    ans = max(C)
print(ans)

Measured memory_bytes: 74576
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    println!("{}", (n + 1) / 2);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <numeric>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)

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

int main(void)
{
	int n, m;
	while (cin >> n >> m, n|m) {
		vector<int> taro, hanako;
		taro = vector<int>(n);
		hanako = vector<int>(m);
		rep(i, n) cin >> taro[i];
		rep(i, m) cin >> hanako[i];

		int taros, hanakos;
		taros = accumulate(ALL(taro), 0);
		hanakos = accumulate(ALL(hanako), 0);

		vector<pair<int, pii> > pairs;
		rep(i, n)
			rep(j, m)
				if (taros-taro[i]+hanako[j] == hanakos-hanako[j]+taro[i])
					pairs.push_back(make_pair(taro[i]+hanako[j], pii(taro[i], hanako[j])));

		if (pairs.size() == 0)
			printf("%d\n", -1);
		else {
			sort(ALL(pairs));
			printf("%d %d\n", pairs[0].second.first, pairs[0].second.second);
		}
	}
	return 0;
}

Measured memory_bytes: 1420
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct _Node {
  int key;
  struct _Node *next, *prev;
} Node;

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while(cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void init(void) {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(void) {
  Node *cur = nil->next;
  int isf = 0;
  while(1) {
    if(cur == nil) break;
    if(isf++>0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if(t==nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(void) {
  deleteNode(nil->next);
}

void deleteLast(void) {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(void) {
  int key, n, i;
  int size = 0;
  int np = 0, nd = 0;
  char com[20];
  scanf("%d", &n);
  init();
  for(i=0;i<n;i++) {
    scanf("%s%d",com, &key);
    if (com[0] == 'i') {
      insert(key);
      np++;
      size++;
    } else if(com[0] == 'd') {
      if(strlen(com) > 6) {
        if(com[6] == 'F')
          deleteFirst();
        else if(com[6] == 'L')
          deleteLast();
      } else {
        deleteKey(key);
        nd++;
      }
      size--;
    }
  }
  printList();
  return 0;
}



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

int main()
{
    int N,a;
    cin >> N;
    if(N==1) { cout << 0 << endl; }
    else {
        int min=1000, max=0;
    
        for(int i=0; i<N; i++) {
            cin >> a;
            if(a<min) { min = a; }
            else if(a>max) { max = a; }
            else {}
        }
        cout << max-min << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define AB_BHI_NI_DEGI                \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define int long long
#define pb push_back
#define N 100009
#define inf 1e18
const double PI = 3.141592653589793238462643383279;
int mod = 1e9 + 7;
//int mod = 998244353;
#define P pair<int, int>
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define ld long double

const int MAX = 1000001;

// structure to store queries
struct Query
{
    int l, r, idx;
};

// cmp function to sort queries according to r
bool cmp(Query x, Query y)
{
    return x.r < y.r;
}

// updating the bit array
void update(int idx, int val, int bit[], int n)
{
    for (; idx <= n; idx += idx & -idx)
        bit[idx] += val;
}

// querying the bit array
int query(int idx, int bit[], int n)
{
    int sum = 0;
    for (; idx > 0; idx -= idx & -idx)
        sum += bit[idx];
    return sum;
}

void answeringQueries(int arr[], int n, Query queries[], int q)
{
    // initialising bit array
    int bit[n + 1];
    memset(bit, 0, sizeof(bit));

    // holds the rightmost index of any number
    // as numbers of a[i] are less than or equal to 10^6
    int last_visit[MAX];
    memset(last_visit, -1, sizeof(last_visit));

    // answer for each query
    int ans[q];
    int query_counter = 0;
    for (int i = 0; i < n; i++)
    {
        // If last visit is not -1 update -1 at the
        // idx equal to last_visit[arr[i]]
        if (last_visit[arr[i]] != -1)
            update(last_visit[arr[i]] + 1, -1, bit, n);

        // Setting last_visit[arr[i]] as i and updating
        // the bit array accordingly
        last_visit[arr[i]] = i;
        update(i + 1, 1, bit, n);

        // If i is equal to r of any query  store answer
        // for that query in ans[]
        while (query_counter < q && queries[query_counter].r == i)
        {
            ans[queries[query_counter].idx] =
                query(queries[query_counter].r + 1, bit, n) -
                query(queries[query_counter].l, bit, n);
            query_counter++;
        }
    }

    // print answer for each query
    for (int i = 0; i < q; i++)
        cout << ans[i] << endl;
}
void solve()
{
    int n, q;
    cin >> n >> q;
    int arr[n];
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    Query queries[q];
    for (int i = 0; i < q; i++)
    {
        int ll, rr;
        cin >> ll >> rr;
        ll--;
        rr--;
        queries[i].l = ll;
        queries[i].r = rr;
        queries[i].idx = i;
    }
    sort(queries, queries + q, cmp);
    answeringQueries(arr, n, queries, q);
}
int32_t main()
{
    AB_BHI_NI_DEGI
    int Test = 1;
    //cin >> Test;
    while (Test--)
        solve();
    return 0;
}

Measured memory_bytes: 35028
N = gets.to_i
A = gets.split(' ').map(&:to_i)


min = nil
N.times do |i|
  a = 0
  b = 0
  N.times do |j|
    if i <= j
      a += A[j]
    else
      b += A[j]
    end
  end
  break if b.nil?
  c = (a - b).abs
  if min.nil?
    min = c
  else
    min = c if min > c
  end
end

puts min


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


def main():
    from itertools import accumulate

    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    plus = list()
    minus = list()

    for ai, bi in zip(a, b):
        diff = ai - bi

        if diff > 0:
            plus.append(diff)
        elif diff < 0:
            minus.append(diff)

    sorted_plus = list(accumulate([0] + sorted(plus, reverse=True)))
    summed_plus = sorted_plus[-1]
    summed_minus = sum(minus)
    ans = len(minus)

    if summed_plus < abs(summed_minus):
        print(-1)
        exit()

    for i in range(len(sorted_plus)):
        summed = sorted_plus[i] - sorted_plus[0]

        if summed + summed_minus >= 0:
            print(ans)
            exit()

        ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19068
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }


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

    ll res = 0, sum = 0, right = 0;
    for(int left = 0; left < n; left++){
        while(right < n){
            int XOR = sum ^ A[right];
            if(sum + A[right] != XOR)break;
            sum += A[right];
            right++;
        }
        res += right - left;

        sum -= A[left];
    }
    cout << res << ln;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, m;
priority_queue<int> pq;
ll sum = 0;
int main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> m;
	for(int i=0; i<n; i++){
		int x; cin >> x; 
		sum += x;
		pq.push(x);
	}
	while(m--){
		int mx = pq.top(); pq.pop();
		int buy = mx/2;
		sum -= mx-buy;
		pq.push(buy);
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 892
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

int main(){
    init();
    ll N,K;cin>>N>>K;
    vector<ll>h(N);
    for (int  i = 0; i < N; i++)
    {
        cin>>h[i];
    }

    sort(h.begin(),h.end());
    ll ans=INF;
    for(int i=0;i+K-1<N;i++){
        ans=min(h[i+K-1]-h[i],ans);
    }
    cout<<ans<<endl;   
}

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

//方針：K回の修行でかかる時間X以下にできるかの判定を考える
//ある時間を境にできるとできないが決まるので2分探索行う
int main(void){
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> A(N);
  vector<ll> F(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  for(int i = 0; i < N; ++i) cin >> F[i];

  //貪欲に割り当てるため
  //Aは降順，Fは昇順にソートする
  sort(A.begin(),A.end(),greater<ll>());
  sort(F.begin(),F.end());

  //X以下でできるかの判定
  auto f = [&](ll X){
    ll k = K;
    for(int i = 0; i<N; ++i){
      //A[i]*F[i]がX以下であるためにA[i]をQ以下にする必要がある
      ll Q = X/F[i];
      //Qになるまで修行．既にQ以下なら必要なし
      k -= max(0ll, A[i]-Q);
    }
    //修行回数がK以下ならtrue
    return k>=0;
  };
  // lは必ずできない，rは必ずできる状態にする
  ll l = -1, r = 1e12;
  //lとrが隣り合うまで続ける
  while(r-l>1){
    ll X = (l+r)/2;
    if(f(X)) r = X;
    else l = X;
  }

  //出力
  cout << r << endl;
}


Measured memory_bytes: 3328
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# import numpy as np


mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

try:
    # sys.setrecursionlimit(int(pow(10,6)))
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("../output.txt", "w")
except:
    pass


# @lru_cache(None)

X=L()[0]
if X>=30:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 10556
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;
}
 
using namespace std;

//ここから

void solve(){
  int n;
  cin>>n;
  vector<ll>t(n),a(n);
  rep(i,n)cin>>t[i]>>a[i];
  ll anst=t[0],ansa=a[0];
  rep(i,n-1){
    ll x=(anst+t[i+1]-1)/t[i+1];
    ll y=(ansa+a[i+1]-1)/a[i+1];
    ll z=max(x,y);
    anst=z*t[i+1],ansa=z*a[i+1];
  }
  cout<<anst+ansa;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


Measured memory_bytes: 256
a,p,q,o,x,b;
main(){
  for(scanf("%d",&p),q=p;q&&~scanf("%s",&a);o=o==3?q--,b=x=!printf("%d\n",x):o){
    //printf("%d\n",a%9);
    ///*
    //printf("bef x:%d b:%d o:%d\n",x,b,o);
    if(a%9==7)b=b*2+1,x+=b>>3&1;
    if(a%9==8)o++;
    if(a%9==6)for(x++,b&=7;b;b/=2)x+=b&1;
    //printf("x:%d b:%d o:%d\n",x,b,o);
     //*/
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const double PI = 3.14159265358979;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

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

	ll b = 0;
	ll sum = 0;
	rep(i, 0, s.size()) {
		if (s[i] == 'B')b++;
		else {
			sum += b;
		}
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

pair<double, double> solve(int a, int b, vector<int>& w, vector<int>& x)
{
    if(a == b)
        return make_pair(0.0, 0.0);

    int c = min_element(x.begin()+a, x.begin()+b) - x.begin();
    int left = accumulate(w.begin()+a, w.begin()+c+1, 0);
    int right = accumulate(w.begin()+c+1, w.begin()+b+1, 0);

    pair<double, double> p = solve(a, c, w, x);
    pair<double, double> q = solve(c+1, b, w, x);
    p.first  -= right / (double)(left + right);
    p.second -= right / (double)(left + right);
    q.first  += left  / (double)(left + right);
    q.second += left  / (double)(left + right);

    return make_pair(min(p.first, q.first), max(p.second, q.second));
}

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

    while(--d >= 0){
        double r;
        int s;
        cin >> r >> s;
        vector<int> w(s);
        for(int i=0; i<s; ++i)
            cin >> w[i];

        sort(w.begin(), w.end());
        
        double ret = -1.0;
        do{
            vector<int> x(s-1);
            for(int i=0; i<s-1; ++i)
                x[i] = i;

            do{
                pair<double, double> p = solve(0, s-1, w, x);
                double len = p.second - p.first;
                if(len < r)
                    ret = max(ret, len);
            }while(next_permutation(x.begin(), x.end()));
        }while(next_permutation(w.begin(), w.end()));

        if(ret < -0.5)
            cout << -1 << endl;
        else
            printf("%.10f\n", ret);
    }

    return 0;
}

Measured memory_bytes: 1012
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>
#include <cstdint>
#include <set>

using namespace std;
using ull = unsigned long long;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

#define EPS (1e-7)
#define ALL(x) begin(x), end(x)


template<class T>
T gcd(T a, T b) {
	return (b == 0) ? a : gcd(b, a % b);
}


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

	vector<ll> L(M), R(M);
	for (size_t i = 0; i < M; i++) {
		cin >> L[i] >> R[i];
	}

	const auto lmax = *max_element(ALL(L));
	const auto rmin = *min_element(ALL(R));

	ll ans = 0;
	if (lmax > rmin) {
		ans = 0;
	} else {
		ans = rmin - lmax + 1;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a=0,b=0,c=0,d,n=0,x=0;
    VI m(5);
    string s,s1,s2;
    cin >> x >> a;
    if(x < a)
        cout << 0 << endl;
    else 
        cout << 10 << endl;
    return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F(i,L,R) for(int i=L;i<R;i++)
#define FE(i,L,R) for(int i=L;i<=R;i++)
#define RF(i,l,r) for(int i=r;i>l;i--)
#define RFE(i,l,r) for(int i=r;i>=l;i--)
#define getI(i) scanf("%d",&i)
#define getII(i,j) scanf("%d%d",&i,&j)
#define getIII(i,j,k) scanf("%d%d%d",&i,&j,&k)
#define VgetI(i) int (i);scanf("%d",&(i));
#define VgetII(i,j) int (i),(j);scanf("%d%d",&(i),&(j));
#define VgetIII(i,j,k) int (i),(j),(k);scanf("%d",&(i),&(j),&(k));
#define EoF(n) int(n);while(~getI(n))
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define abs(n) (n>0?n:(-n))
#define INF 2147483647
#define nINF -2147483648
int main(){
	int n,ans=0,flag=1;
	scanf("%d",&n);
	int arr[n];
	F(i,0,n) scanf("%d",&arr[i]);
	while(flag){
		F(i,0,n) if(arr[i]%2){
			flag=0;
			break;
		}
		F(i,0,n) arr[i]/=2;
		if(flag) ans++;
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  long long int n, k;
  
  scanf("%lld%lld", &n, &k);
  
  n = n % k;
  if(n < k - n){
    printf("%lld\n", n);
  }else{
    printf("%lld\n", k - n);
  }
  
  return 0;
}

Measured memory_bytes: 128
A, B, C = map(int, input().split())
k = A % B
if k == 0:
    ans = 'YES' if C == 0 else 'NO'
else:
    for i in range(1, 101):
        if (i * k) % B == C:
            ans = 'YES'
            break
    else:
        ans = 'NO'
print(ans)


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

int main() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  double rad, tanshin;
  
  tanshin = 5*H+M/12;
  
  if(tanshin>=M){
    rad = 3.14159265358979*(tanshin-M)/30;
  }
  else{
    rad = 3.14159265358979*(M-tanshin)/30;
  }
  
  double ans = sqrt(A*A+B*B-2*A*B*cos(rad));
  
  printf("%.10lf", ans);
  
}



Measured memory_bytes: 4216
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

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

  if (S[2] == S[3] && S[4] == S[5]){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import sys
n,m = map(int,input().split())

a = [list(map(int,input().split()))for i in range(m)]

a.sort()

k = [0 for i in range(n)]

for i in range(m):
    if a[i][0] != 1:
        break
    else:
        k[a[i][1]-1] = 1

for i in range(m):
    if k[a[i][0]-1] == 1:
        if a[i][1] == n:
            print("POSSIBLE")
            sys.exit()
print("IMPOSSIBLE")

Measured memory_bytes: 54140
#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};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B&lang=jp

#define NMAX 100005
struct PS {
    string name;
    int time;
};

PS ps[NMAX];
int head, tail;

static void enq(PS p) {
    ps[tail] = p;
    tail = (tail + 1) % NMAX;
}

static PS deq() {
    PS y = ps[head];
    head = (head + 1) % NMAX;
    return y;
}

int main() {
    int n; cin >> n;
    int q; cin >> q;
    REP(i, n) {
        string na; cin >> na;
        int ti; cin >> ti;
        enq({na, ti});
    }

    int el = 0;
    while(head != tail) {
        PS p = deq();
        int c = min(p.time, q);
        el += c;
        p.time -= c;
        if (p.time > 0) {
            enq(p);
        } else {
            printf("%s %d\n", p.name.c_str(), el);
        }
    }

    return 0;
}


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

int main() {
	long double a, b, h, m;
	static const double pi = 3.14159265358979323846;

	cin >> a;
	cin >> b;
	cin >> h;
	cin >> m;

	long double c;
	long double theta_a, theta_b;
	long double theta;
	theta_a = (h * 2 * pi / 12) + (m * pi / 360);
	theta_b = m * 2 * pi / 60;

	// ok

	theta = abs(theta_a - theta_b);

	c = (a * a) + (b * b) - (2 * a * b * cos(theta));
	c = sqrt(c);

	printf("%.20Lf\n", c);

	return 0;
}

Measured memory_bytes: 4168
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
##############################

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

ans_min = 0
ans_max = 0
colors = [0] * 8

def get_colors(num):
    if num <= 399:
        return 0
    elif num <= 799:
        return 1
    elif num <= 1199:
        return 2
    elif num <= 1599:
        return 3
    elif num <= 1999:
        return 4
    elif num <= 2399:
        return 5
    elif num <= 2799:
        return 6
    elif num <= 3199:
        return 7
    else:
        return -1

all = 0
for i in range(N):
    color = get_colors(A[i])
    if color == -1:
        all += 1
    else:
        colors[color] += 1

# all は「好きな色」に変えることができる！（レートの色以外でもいい）

x = colors.count(0)
# 自由選択できない
if all == 0:
    ans_min = 8-x
    ans_max = 8-x
else:
    if x == 8:
        # all しかない
        ans_min = 1
        ans_max = all
    else:
        # 混合
        ans_min = 8-x
        ans_max = ans_min+all

print(ans_min, ans_max)


Measured memory_bytes: 3064
import Data.Bits (xor)
import Data.Bool (bool)

main :: IO ()
main = do
    s <- getLine
    answer $ solve s

type Answer = Bool
answer :: Answer -> IO ()
answer = putStrLn . bool "First" "Second"

solve :: String -> Answer
solve = last' . flip (zipWith . ((.) xor . (==)) . head <*> id) (iterate not False)
  where
    last' = foldl (flip const) undefined


Measured memory_bytes: 12796
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, K; cin >> N >> K ;
    vector<pair<ll,ll> >p;
    vector<ll>x,y;
    rep(i,N){
        ll a,b; cin >> a >> b ;
        x.pb(a);
        y.pb(b);
        p.pb(mp(a,b));
    }
    sort(all(x));
    sort(all(y));
    ll ans = (1000000000*2);
    ans = ans * ans;
    FOR(i,0,x.size())FOR(j,i+1,x.size())FOR(k,0,y.size())FOR(l,k+1,y.size()){
        ll cnt = 0;
        rep(n,p.size()){
            if(p[n].first >= x[i] && p[n].first <= x[j] && p[n].second >= y[k] && p[n].second <= y[l])cnt++;
        }
        if(cnt >= K) ans = min(ans, (x[j]-x[i])*(y[l]-y[k]));
        
    }
    cout << ans << endl;
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
int mod = 1000000000 + 7;
int dp[101][4][4][4];
int main()
{
        //input->compute->output//

        string S;
        cin >> S;
        string T = "ACGT";

        int now = 0;
        int ans = 0;
        for (int i = 0; i < S.size(); i++)
        {
                bool ok = false;
                for (int j = 0; j < T.size(); j++)
                {
                        if (S[i] == T[j])
                        {
                                ok = true;
                        }
                }
                if (!ok)
                {
                        now = 0;
                }
                else
                {
                        now++;
                        ans = max(now, ans);
                }
        }

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
int main(){
        long long N,M,X[100000],def[100000],result=0;
        std::cin>>N>>M;
        for(int i=0; i<M; i++) {
                std::cin>>X[i];
        }
        std::sort(X,X+M);
        for(int i=0; i<M-1; i++)
                def[i]=X[i+1]-X[i];
        std::sort(def,def+M-1);
        for(int i=0; i<M-N; i++)
                result+=def[i];
        std::cout<<result;
        return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;

int main(void){
    string str;
    int alphabet[26] ={};
    while(getline(cin,str)){
        for (int i = 0; i < 26; i++){
            for (int j = 0; j < str.size(); j++){
                if ((str[j] == 65 + i) || (str[j] == 97 + i)){
                    alphabet[i] += 1;
                }
            }
        }
    }
    for (int i = 0; i < 26; i++){
        printf("%c : %d\n", i + 97, alphabet[i]);
    }
    return 0;
}


Measured memory_bytes: 3268
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize,
        t: [i64; n],
        a: [i64; n]
    }
    const M: i64 = 1000000007;

    let mut th = Vec::new();
    let mut tmax = t[0];
    th.push((tmax, tmax));
    for i in 1..n {
        if t[i] > tmax {
            tmax = t[i];
            th.push((tmax, tmax));
        } else {
            th.push((1, tmax));
        }
    }
    let mut ah = Vec::new();
    let mut amax = a[n-1];
    ah.push((amax, amax));
    for i in (0..n-1).rev() {
        if a[i] > amax {
            amax = a[i];
            ah.push((amax, amax));
        } else {
            ah.push((1, amax));
        }
    }
    ah.reverse();

    let mut ans = 1i64;
    for i in 0..n {
        if let Some((h1, h2)) = inner(th[i], ah[i]) {
            ans *= h2 + 1 - h1;
            ans %= M;
        } else {
            println!("0");
            return;
        }
    }
    println!("{}", ans);

}

fn inner(r1: (i64, i64), r2: (i64, i64)) -> Option<(i64, i64)> {
    if r1.0 <= r2.0 && r2.1 <= r1.1 {
        Some(r2)
    } else if r2.0 <= r1.0 && r1.1 <= r2.1 {
        Some(r1)
    } else {
        None
    }
}


Measured memory_bytes: 8896
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
const int MOD = 1e9 + 7;
const int INF = 1e18;


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k;
    cin>>k;
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<a[k-1]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int p,q,a,n;
ll res;

P compute(int nume,int deno,int nw)
{
    P p;
    p.first = nume*nw + deno;
    p.second = deno * nw;
    return p;
}

void dfs(int mn,int nume,int deno,int cnt)
{
    if(deno*p == nume*q){
        res++;
        return;
    }
    if(cnt == n){
        return;
    }
    if(deno*p < nume*q){
        return;
    }
    for(int i=mn;i<=a/deno;i++){
        P p = compute(nume,deno,i);
        dfs(i,p.first,p.second,cnt+1);
    }
    return;
}

int main()
{
    while(1){
        scanf("%d%d%d%d",&p,&q,&a,&n);
        if(p == 0 && q == 0 && a == 0 && n == 0){
            break;
        }
        res = 0;
        rep(i,12000){
            dfs(i+1,1,i+1,1);
        }
        printf("%lld\n",res);
    }
	return 0;
}

Measured memory_bytes: 3168
s = list(input())
n = len(s)
ans = [0] * n

r = 0
l = 0
s.append("R")

for i in range(n):
    if s[i] == "R":
        r += 1
        
        if s[i+1] == "L":
            if r % 2 == 1:
                ans[i] += r//2 + 1
                ans[i+1] += r//2
                
            else:
                ans [i] += r//2
                ans[i+1] += r//2
                
            r = 0
        
    else:
        l += 1
        
        if s[i+1] == "R":
            if l % 2 == 1:
                ans[i-l] += l//2
                ans[i-l+1] += l//2 + 1
                
            else:
                ans[i-l] += l//2
                ans[i-l+1] += l//2
                
            l = 0
            
print(*ans)

Measured memory_bytes: 82972
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    int ans=0;
    for(int i = 0;i<s.length();i++)
    {
        if(s[i]!=t[i])
        ans++;
    }
    
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

void solve() {
	int n, k, q;
	cin >> n >> k >> q;
	vi v(n);
	rep(i, 0, n-1) v[i] = k-q;
	while(q--){
		int x;
		cin >> x;
		v[x-1]++;
	}
	rep(i, 0, n-1){
		if(v[i]<=0){
			cout << "No\n";
		}else{
			cout << "Yes\n";
		}
	}
}

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

	// test
	solve();

	return 0;
}

Measured memory_bytes: 3932
#include<iostream>
using namespace std;
int main()
{
  int n,i,c=0;
  cin>>n;
  for(i=1;i<10;i++)
  {
    if(n%i==0)
    {
      if((n/i)<=9)
      {
        c++;
      }
    }
  }
    if(c!=0)
      cout<<"Yes";
    else
      cout<<"No";
    
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define taskname "A"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const int maxn = 5e3 + 5;
const int logn = log2(maxn) + 1;
const int inf = 1e9 + 1;
int n,a[maxn];
vector<int> adj[maxn];
ll dp[maxn][maxn];
bool dp1[maxn][maxn];
ll tmp[maxn];
bool tmp1[maxn];
int sub[maxn];

void dfs(int u , int par){
    dp1[u][0] = (a[u] > 0);
    dp[u][0] = a[u];
    sub[u] = 1;
    for(auto c : adj[u]){
        if(c == par)continue;
        dfs(c , u);
        fill_n(tmp,maxn,1e18);
        fill_n(tmp1,maxn,0);
        for(int i = 0 ; i <= sub[u] ; ++i){
            for(int j = 0 ; j <= sub[c] ; ++j){
                if(dp[c][j] < 0 || dp1[c][j])tmp[i + j + 1] = min(tmp[i + j + 1] , dp[u][i]);
                tmp[i + j] = min(tmp[i + j] , dp[u][i] + dp[c][j]);
                if(dp1[c][j] && dp1[u][i])tmp1[i + j] = 1;
                if(dp1[u][i] && (dp[c][j] < 0 || dp1[c][j]))tmp1[i + j + 1] = 1;
            }
        }
        sub[u] += sub[c];
        for(int i = 0 ; i <= sub[u] ; ++i){
            dp[u][i] = tmp[i];
            dp1[u][i] = tmp1[i];
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP" , "r")){
        freopen(taskname".INP","r",stdin);
        freopen(taskname".OUT","w",stdout);
    }
    fill_n(&dp[0][0],maxn*maxn,1e18);
    memset(dp1,0,sizeof dp1);
    cin >> n;
    for(int i = 1 ; i <= n ; ++i)cin >> a[i];
    for(int i = 1 ; i < n ; ++i){
        int u , v;cin >> u >> v;
        adj[u].pb(v);adj[v].pb(u);
    }
    dfs(1,0);
//    cout << dp[1][2] << " " << dp1[1][2] << endl;
    for(int i = 0 ; i <= n ; ++i){
        if(dp[1][i] < 0 || dp1[1][i])return cout << i , 0;
    }
}

Measured memory_bytes: 221440
#include <iostream>

using namespace std;

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

  if( a <= c && b <= c ){
    cout << a + b << endl;
  }else if( b <= a && c <= a ){
    cout << b + c << endl;
  }else if( a <= b && c <= b ){
    cout << a + c << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#ifndef min
#define min(a, b)            (((a) < (b)) ? (a) : (b))
#endif

void swap(int *x, int *y)
{
	int a = *x;
	int b = *y;
	int tmp;
	tmp = *x;
	*x = *y;
	*y = tmp;
	return;
}
int gcd(int x, int y)
{
	int r;

	if ( x < y ) {
        swap(&x, &y);
	}
	while (y > 0) {
        r = x % y;
        x = y;
        y = r;
	}

    return x;
}

int main(void)
{
	int A;
	int B;

	int ans;
	
	scanf("%d %d", &A, &B);

	ans = gcd(A, B);

	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
const int INF = 10000000;

string replaceAll(string s, string from, string to){
    vector<int> all;
    string tmp = s, tmp_space = s;

    string::size_type pos = tmp.find(from);
    while(pos != string::npos){
        all.emplace_back(pos);
        pos = tmp.find(from, pos + from.size());
    }
    if(all.empty()) return "0";

    //string space(from.size(), ' ');
    rep(j,all.size()){
        tmp.replace(all[j] + (to.size() - from.size()) * j, from.size(), to);
        //tmp_space.replace(all[j] + (from.size() - to.size()) * j, from.size(), space);
    }
    //if(tmp_space.find(to) != string::npos) return "0";

    return tmp;
}

int bfs(int n, string s, string t, pair<string, string> p[11], int cnt){
    queue<pair<string,int>> q;
    q.push(make_pair(s,0));

    while(not q.empty()){
        pair<string, int> u = q.front(); q.pop();
        if(u.first == t) return u.second;
        if(u.first.size() > 10) continue;

        string tmp;
        rep(i,n){
            tmp = replaceAll(u.first, p[i].first, p[i].second);
            if(tmp == "0" || u.first == tmp) continue;
            q.push(make_pair(tmp, u.second + 1));
        }
    }
    return -1;
}

int main(){
    int n;
    while(cin >> n,n){
        pair<string, string> p[11];
        rep(i,n){
            string a, b;
            cin >> a >> b;
            p[i] = make_pair(a,b);
        }
        string s, t;
        cin >> s >> t;
        cout << bfs(n,s,t,p,0) << endl;
        //int tmp = dfs(n,s,t,p,0);
        //cout << (tmp == INF ? -1 : tmp) << endl;
    }
}

Measured memory_bytes: 4172
#include<iostream>
#include<vector>
#include<utility>
#include<deque>
#include<algorithm>
#include <iomanip>
#include<cmath>
#include<numeric>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;
constexpr ll MOD = ll(1e9 + 7);

int n, q;
ll k;
vector<ll> p;

int main(void) {
	cin >> n >> k >> q;
	p.resize(n + 1);
	for (int i = 0; i < q; i++) {
		int ai;
		cin >> ai;
		p[ai]++;
	}

	for (int i = 1; i <= n; i++) {
		if (k - q + p[i] > 0)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n, k;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    cin >> n >> k;
    if (k > (n + 1) / 2) {
        cout << "-1";
        return 0;
    }
    int mxk = (n + 1) / 2;
    if (n % 2 == 0) {
        int r = 2 * n - 1;
        int l = n / 2;
        while (r >= l) {
            cout << k + l << " " << k + r << " " << k + (l + r + mxk) << '\n';
            r -= 2;
            l += 1;
        }
        r = 2 * n - 2;
        l = 0;
        while (r >= n) {
            cout << k + l << " " << k + r << " " << k + (l + r + mxk + 1) << '\n';
            r -= 2;
            l += 1;
        }
    }
    else {
        int r = 2 * n - 1;
        int l = n / 2;
        while (r >= l) {
            cout << k + l << " " << k + r << " " << k + (l + r + mxk) << '\n';
            r -= 2;
            l += 1;
        }
        r = 2 * n - 2;
        l = 0;
        while (r >= n) {
            cout << k + l << " " << k + r << " " << k + (l + r + mxk) << '\n';
            r -= 2;
            l += 1;
        }
    }
    return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s, t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<char>());
  if(s<t){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void trace(int[] a,int n){
        for (int i = 0;i < n;i++){
            if(i > 0)
                System.out.print(" ");
            System.out.print(a[i]);
        }
        System.out.print("\n");
    }

    public static int selectionSort(int[] a,int n){
        int count = 0;
        for(int i = 0;i < n;i++){
            int minj = i;
            int j;
            for(j = i;j < n;j++){
                if(a[j] < a[minj]){
                    minj = j;
                }
            }
            int temp = a[i];
            a[i] = a[minj];
            a[minj] = temp;
            if(minj != i)
                count++;
        }
        return count;
    }

    public static void main(String[] args) {
        int n;
        int[] a = new int[100];
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        for (int i = 0; i < n; i++)
            a[i] = sc.nextInt();
        int count = selectionSort(a,n);
        trace(a, n);
        System.out.println(count);
    }
}


Measured memory_bytes: 26396
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <deque>
using namespace std;
typedef long long ll;
int n, m, k;
vector<int> a[100001];
vector<int> b[100001];
int c[100001];
int ans[100001];
vector<int> v;
void go(int x, int color) {
	c[x] = color;
	v.push_back(x);
	for (int next : a[x]) {
		if (!c[next]) {
			go(next, color);
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);	
	cin >> n >> m >> k;
	for (int i = 0; i < m; i++) {
		int x, y; cin >> x >> y; a[x].push_back(y); a[y].push_back(x);
	}
	for (int i = 0; i < k; i++) {
		int x, y; cin >> x >> y; b[x].push_back(y); b[y].push_back(x);
	}
	int color = 0;
	for (int i = 1; i <= n; i++) {
		if (c[i] == 0) {
			color += 1;
			v.clear();
			go(i, color);
			for (int j = 0; j < v.size(); j++) {
				int x = v[j];
				ans[x] = v.size() - a[x].size() - 1;
				for (int o = 0; o < b[x].size(); o++) {
					if (c[b[x][o]] == color)ans[x] -= 1;
				}
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << ans[i] << ' ';
	}cout << '\n';

}




Measured memory_bytes: 13436
#include <stdio.h>

int main(void) {
	int n,m,i,j,b,a[1024],v[1024] = {0},mv = 0,most = 0;
	scanf("%d%d",&n,&m);
	for(i = 1;i <= n;i++){
		scanf("%d",&a[i]);
	}
	for(i = 1;i <= m;i++){
		scanf("%d",&b);
		for(j = 1;j <= n;j++){
			if(a[j] <= b){v[j]++;break;}
		}
	}
	for(i = 1;i <= n;i++){
		if(v[i] > mv){mv = v[i];most = i;}
	}
	printf("%d\n",most);
	return 0;
}

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

int main(){

  int n, ans = 0, k;
  cin >> n >> k;

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

  sort(a, a+n);

  for (int i = n-1; i >= 0; i--) {
    if(k != 0){
      k -= 1;
      ans += a[i];
    }
  }

  cout << ans << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  map<string,int>m;
  for(int i=0;i<n;i++)
  {
    string s;
    cin>>s;
    m[s]++;
  }
  cout<<"AC x "<<m["AC"]<<endl;
  cout<<"WA x "<<m["WA"]<<endl;
  cout<<"TLE x "<<m["TLE"]<<endl;
  cout<<"RE x "<<m["RE"]<<endl;
}


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

int main() {
    string s;
    cin >> s;
    cin >> s;
    cout << 'A';
    for(int i = 0;i < s.size(); i++) {
        if(s[i] >= 'A' && s[i] <= 'Z')
            cout << s[i];
    }
    cout << 'C' <<endl;
}

Measured memory_bytes: 256
s=input()+'R'
t=[]
k=0
for i in range(1,len(s)):
  k+=1
  if s[i]!=s[i-1]:
    t+=[k]
    k=0
a=[0]*(len(s)-1)
k=-1
for i in range(len(t)//2):
  k+=t[2*i]
  a[k]=(t[2*i]+1)//2+t[2*i+1]//2
  a[k+1]=t[2*i]//2+(t[2*i+1]+1)//2
  k+=t[2*i+1]
print(*a)

Measured memory_bytes: 48012
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main()
{
	long long a,b,v,w,t;
	cin >> a >> v;
	cin >> b >> w;
	cin >> t;
	if(a<b){
		if(a+v*t>=b+w*t){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
	else{
		if(a-v*t<=b-w*t){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3624