akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    vector<int> v(N);
    int m = 0;
    LL res = 0;
    for(int i = 0; i < N; ++i) {
        cin >> v[i];
        if(v[i] < 0) ++m;
        res += abs(v[i]);

    }

    if(m % 2 == 0) {
        cout << res << endl;

    } else {
        m = INF;
        for(int i = 0; i < N; ++i) {
            v[i] = abs(v[i]);

        }
        sort(all(v));
        res = 0;
        for(int i = 1; i < N; ++i) res += v[i];
        cout << res - v[0] << endl;

    }

    return 0;
}



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

void fnTrace(const vector<int> &argviSort)
{
  for (int i = 0; i < argviSort.size(); i++)
  {
    if (i) cout << " ";
    cout << argviSort[i];
  }
  cout << endl;
}

void fnInsertionSort(vector<int> &argviSort)
{
  for (int ixSorting = 1; ixSorting < argviSort.size(); ixSorting++)
  {
    int iTarget = argviSort[ixSorting];
    int ixSorted = ixSorting - 1;

    while (ixSorted >= 0               &&
           iTarget  < argviSort[ixSorted])
    {
      argviSort[ixSorted + 1] = argviSort[ixSorted];
      ixSorted--;
    }
    argviSort[ixSorted + 1] = iTarget;
    fnTrace(argviSort);
  }
}

int main()
{
  vector<int> viSort;
  int iMaxSize;
  
  cin >> iMaxSize;
  for (int i = 0; i < iMaxSize; i++)
  {
    int iNum;
    cin >> iNum;
    viSort.push_back(iNum);
  }

  fnTrace(viSort);
  fnInsertionSort(viSort);

  return 0;
}

Measured memory_bytes: 1220
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
	string w[7] = { "SUN","MON","TUE","WED","THU","FRI","SAT" };
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 1; i <= 7; ++i) {
		if (w[i % 7] == s) {
			for (int j = 1; j <= 7; ++j) {
				++ans;
				if (((i + j) % 7) == 0) {
					break;
				}
			}
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
A, B, M = map(int, input().split())
As = [int(s) for s in input().split()]
Bs = [int(s) for s in input().split()]
Ms = []
for i in range(M):
    Ms.append([int(s) for s in input().split()])

#print(As)
#print(Bs)
#print(Ms)

minPrice = min(As) + min(Bs) #without coupon

for m in Ms:
    a, b, d = m
    price = As[a-1] + Bs[b-1] - d 
    #print(a, b, d, price)
    minPrice = min(minPrice, price)

print(minPrice)


Measured memory_bytes: 32224
#include<bits/stdc++.h>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007





int lcm(int a,int b){
	return a/__gcd(a,b) * b;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}


map< int, int > prime_factor(int n) {
  map< int, int > ret;
  for(int i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){
        }

        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for (int i = 0; i < size;i++){
                makeSet(i);
            }
        }
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x,int y){
            return findSet(x) == findSet(y);
        }
        void unite(int x,int y){
            link(findSet(x), findSet(y));
        }
        void link(int x,int y){
            if(rank[x]>rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x]==rank[y]){
                    rank[y]++;
                }
            }
        }
        int findSet(int x){
            if(x!=p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};



signed main()
{
  int N,K;
  cin>>N>>K;
  if(K==1){
    cout<<0<<endl;
  }else if(N==K){
    cout<<0<<endl;
  }
  else{
  cout<<N-K<<endl;
  }

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
class Node{
public:
  Node* prev;
  Node* next;
  int data;
  Node(){
    prev=0;
    next=0;
    data=0;
  }
};
 
class List{
private:
  Node head;
public:
  List(){
    head.next=&head;
    head.prev=&head;
  }
  int insert(int a){
    Node* p = new Node();
 
    if(p==0){
      return -1;
    }
 
    Node* q = &head;
    Node* r = head.next;
 
    p->prev = q;
    p->next = r;
    p->data = a;
 
    q->next = p;
    r->prev = p;
 
    return 0;
  }
 
  int del(int a){
    Node* p;
 
    for(p=head.next;p!=&head;p=p->next){
      if(p->data==a){
        break;
      }
    }
 
    if(p==&head){
      return -2;
    }
 
    Node* q = p->prev;
    Node* r = p->next;
 
    q->next = r;
    r->prev = q;
 
    delete p;
 
    return 0;
  }
 
  int deleteFirst(){
    Node* p = head.next;
 
    if(p==&head){
      return -2;
    }
 
    Node* q = p->prev;
    Node* r = p->next;
 
    q->next = r;
    r->prev = q;
 
    delete p;
 
    return 0;
  }
 
  int deleteLast(){
    Node* p = head.prev;
 
    if(p==&head){
      return -2;
    }
 
    Node* q = p->prev;
    Node* r = p->next;
 
    q->next = r;
    r->prev = q;
 
    delete p;
 
    return 0;
  }
 
  void print(){
    for(Node* p=head.next;p!=&head;p=p->next){
      cout << p->data;
 
      if(p->next!=&head){
        cout << ' ';
      }else{
        cout << endl;
      }
    }
  }
};
 
int main(){
  List L;
 
  int n;
  cin >> n;
 
  for(int i=0;i<n;i++){
    char com[20];
    cin >> com;;
 
    if(com[0]=='i'){
      int x;
      cin >> x;
 
      L.insert(x);
    }else if(com[6]=='F'){
      L.deleteFirst();
    }else if(com[6]=='L'){
      L.deleteLast();
    }else{
      int x;
      cin >> x;
 
      L.del(x);
    }
  }
 
  L.print();
 
  return 0;
}


Measured memory_bytes: 34224
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)
#define repd(i,x,y) for(int i=x; i>=y; --i)

using namespace std;
const int N=100005,mod=1000000007;
typedef long long LL;
const LL INF=2000000000000000000ll;
int n,A[N],B[N];
LL x,y,a[N],s[N],f[N][2];

int getint()
{
	char ch;
	while(!isdigit(ch=getchar()));
	int x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

LL getLL()
{
	char ch;
	while(!isdigit(ch=getchar()));
	LL x=ch-48;
	while(isdigit(ch=getchar())) x=x*10+ch-48;
	return x;
}

void prepare()
{
	int p=1;
	rep(i,1,n)
	{
		while(p+1<=n && a[p+1]-a[i]<x) ++p;
		A[i]=p;
	}
	p=1;
	rep(i,1,n)
	{
		while(p+1<=n && a[p+1]-a[i]<y) ++p;
		B[i]=p;
	}
}

void inc(LL &x,int y)
{
	x=(x+y)%mod;
}

void inc(int l,int r,int x,int tp)
{
	if(l>r) return;
	inc(f[l][tp],x),inc(f[r+1][tp],-x);
}

void dp()
{
	int p1=0,p2=0;
	f[0][0]=f[0][1]=1;
	rep(i,0,n-1)
	{
		p1=max(p1,i+1);
		while(p1+1<=n && s[p1+1]>=x) ++p1;
		inc(max(i+1,B[i]),p1,f[i][1],0);
	
		p2=max(p2,i+1);
		while(p2+1<=n && s[p2+1]>=y) ++p2;
		inc(max(i+1,A[i]),p2,f[i][0],1);
		if(i)
		{
			inc(f[i+1][0],f[i][0]);
			inc(f[i+1][1],f[i][1]);
		}
	}
}

int main()
{
	n=getint(),x=getLL(),y=getLL();
	rep(i,1,n) a[i]=getLL();
	repd(i,n,2) s[i]=a[i]-a[i-1];
	s[1]=INF;
	prepare();
	dp();
	printf("%lld\n",(f[n][0]+f[n][1]+mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 4096
//fold
#ifndef KHALIL
#include <bits/stdc++.h>
#else
#include "header.h"
#endif
#define endl '\n'
#define mp make_pair
#define tostr(x) static_cast<ostringstream&>((ostringstream()<<dec<<x)).str()
#define rep(i,begin,end) for(auto i = begin;i < end;i++)
#define repr(i,begin,end) for(auto i = begin-1;i >= end;i--)
#define pb push_back
#define sz(a) ((int)(a).size())
#define fi first
#define se second
#define abs(a) ((a) < (0) ? (-1)*(a) : (a))
#define SQ(a) ((a)*(a))
#define eqd(a,b) (abs(a-b)<1e-9)
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename t> t in(t q){cin >> q;return q;}
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v){os << "[";for (int i = 0; i < sz(v); ++i) { os << v[i]; if (i != sz(v) - 1) os << ",";}os << "]";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const map<T, S>& v){for (auto it : v)os << "(" << it.first << ":" << it.second << ")";return os;}
template <typename T, typename S>ostream& operator<<(ostream& os, const pair<T, S>& v){os << "(" << v.first << "," << v.second << ")";return os;}
const long double PI = acosl(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);}
inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);}
//endfold
#define  N  (200005)
#define MOD (1000000000l + 7l)
#define OO (1050000000)
#define OOL (1100000000000000000)

//global
int a[N];
bool pos[N];

int main(){
	//fold
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cout << setprecision(10);
	//endfold
	int n,m;
	cin >> n >> m;
	rep(i,0,n){
		a[i+1] = 1;
	}
	pos[1] = 1;
	rep(i,0,m){
		int x,y;
		cin >> x >> y;
		if(!pos[x]){
			a[x]--;
			a[y]++;
		}else{
			if(a[x] == 1){
				pos[x] = 0;
				pos[y] = 1;
				a[x]--;
				a[y]++;
			}else{
				pos[y] = 1;
				a[x]--;
				a[y]++;
			}
		}
	}
	int re = 0;
	rep(i,0,n){
		if(pos[i+1] == 1) re++;
	}
	cout << re << endl;
	return 0;
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    string S;
    cin >> S;
    REP(i, S.length() - 1)
    {
        int l = S.length() - i - 1;
        if (l % 2 == 1)
            continue;
        bool e = true;
        REP(j, l / 2)
        {
            if (S[j] != S[l / 2 + j])
                e = false;
        }

        if (e)
        {
            cout << l << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String args[]){
	int[][] graph = new int[150][150];
	Scanner in = new Scanner(System.in);
	int n, u, k;

	n=in.nextInt();
	for(int i=0; i<n; i++){
	    u=in.nextInt();
	    k=in.nextInt();
	    //read vartex informetion
	    for(int j=0; j<k; j++){
		graph[u-1][in.nextInt()-1]=1;
	    }
	}

	//print
	for(int i=0; i<n; i++){
	    for(int j=0; j<n; j++){
		System.out.print(graph[i][j]);
		if(j<n-1)System.out.print(" ");
	    }
	    System.out.println("");
	}
    }
}

Measured memory_bytes: 13000
fun main(args: Array<String>) {
    val (a, b) = readInputLine().split(" ").map { it.toInt() }
    val s = readInputLine().toCharArray()

    for (i in 0 until a) {
        if (s[i] == '-') {
            println("No")
            return
        }
    }
    
    if (s[a] != '-') {
        println("No")
        return
    }
    
    for (i in a + 1..a + b) {
        if (s[i] == '-') {
            println("No")
            return
        }
    }
    
    println("Yes")
}
 
fun readInputLine(): String {
    return readLine()!!
}

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

const int N = 10005;

int ans[N];

int main() {
	for (int x = 1; x <= 100; x ++)
	for (int y = 1; y <= 100; y ++)
	for (int z = 1; z <= 100; z ++) {
		int val = x * x + y * y + z * z + x * y + y * z + x * z;
		if (val < N) ans[val] ++;
	}
	int n; cin >> n;
	for (int i = 1; i <= n; i ++) cout << ans[i] << endl;
	return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, m;
  cin >> n >> m;

  vector<pair<int, int>> vab(m);
  for (auto &p : vab) {
    cin >> p.first >> p.second;
  }

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

  int r = vab[0].second, ans = 1;
  for (auto &p : vab) {
    r = min(r, p.second);
    if (r - p.first < 1) {
      ans++;
      r = p.second;
    }
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
//2018.11.10

#include <iostream>
using namespace std;

int main() {

    int n;
    cin >> n;

    int a[n];
    int maxv = 0;

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

    int p_nums[maxv+3];
    for(int i=0;i<maxv+3;i++){
        p_nums[i]=0;
    }

    for(int i=0;i<n;i++){
        p_nums[a[i]]++;
        p_nums[a[i]+1]++;
        p_nums[a[i]+2]++;
    }

    int ans=0;
    for(int i=0;i<maxv+3;i++){
        ans = max(ans, p_nums[i]);
    }

    cout << ans << endl;

}


Measured memory_bytes: 1024
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
template<typename T>using pqg=priority_queue<T,vector<T>,greater<T>>;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline vector<vector<T>>vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    ll n=in();vector<ll>h(n);for(ll i=0;i<n;++i)h[i]=in();
    vector<ll>ans(n);
    for(ll i=n-2;i>=0;--i){
        if(h[i]>=h[i+1])ans[i]=ans[i+1]+1;
        else ans[i]=0;
    }
    cout<<*max_element(ans.begin(),ans.end())<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;

void solve(){
		int a,b,c;
		cin>>a>>b>>c;
		if(b-a==c-b)cout<<"YES";
		else cout<<"NO";

}

int main(){
	Red;
	int t=1;
	// cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner


object Main {

  def read() = {
    val sc = new Scanner(System.in)
    val r, d, x = sc.nextInt()
    (r, d, x)
  }

  def solve(r: Int, d: Int, x: Long): IndexedSeq[Long] = {
    (0 until 10).scanLeft(x)((acc, i) => r * acc - d).tail
  }

  def main(args: Array[String]): Unit = {
    val (r, d, x) = read()
    solve(r, d, x).foreach(println)
  }
}

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

int n, k;
vector <int> a;
set <int> st;

void rec(int c = 0, int s = 0, int v = 0, string num = "") {
    if (c == k) {
        st.insert(stoi(num.c_str()));
        return;
    }

    rep (i, n) {
        if ((s >> i) & 1) continue;
        rec(c + 1, s | (1 << i), i, num + to_string(a[i]));
    }

}

int main() {
    while(cin >> n, n) {
        cin >> k;
        a = vector <int> (n);
        rep (i, n) cin >> a[i];
        st.clear();
        rec();
        cout << st.size() << endl;
    }
    return 0;
}


Measured memory_bytes: 3392
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define ll long long int
#define INF 2000000000 
#define fill(space,a) memset(space,a,sizeof(space))

#define optimize() ios_base::sync_with_stdio(0);
#define MAXN 100005
int n, k;
vector <int> h;
int dp[MAXN];

int main()
{
	optimize();
	//freopen("input.txt", "r", stdin);

	cin >> n >> k;
	h.resize(n+1);
	h[0] = 0;
	for (int i = 1; i <= n; i++) cin >> h[i];
	
	for (int i = 0; i < MAXN; i++) dp[i] = INF;
	dp[1] = 0;
	for (int i = 2; i <= n; i++) 
		for (int j = i - 1; j > 0 && j >= (i-k); j--)
			dp[i] = min(dp[i],dp[j] + abs(h[j] - h[i]));
	
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define rep_eq(i,l,r) for(int i=l; i<=(int)(r); i++)
#define all(vec) vec.begin(),vec.end()
#define allr(vec) vec.rbegin(),vec.rend()
using namespace std;

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

using ll=int64_t;

using vb=vector<bool>;
using vc=vector<char>;
using vs=vector<string>;
using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;

vector<pair<ll,ll>> prime_factorize(ll n) {
  vector<pair<ll,ll>> res;
  for (ll p=2;p*p<=n;p++) {
    if (n%p!=0) {continue;}
    int num=0;
    while (n%p==0) {
      num++;
      n/=p;
    }
    res.push_back(make_pair(p,num));
  }
  if (n!=1) {res.push_back(make_pair(n,1));}
  return res;
}

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

  int N; cin >>N;
  ll P; cin >>P;

  auto fac=prime_factorize(P);
  ll ans=1;
  for (auto p:fac) {
    rep(j,0,p.second/N) {ans*=p.first;}
  }

  cout <<ans <<'\n';
  return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

#define FST first
#define SND second

// const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 100000;                  // 10^5
// const int MAX_N = 1000000000;              // 10^9
// const ll  MAX_N = 1000000000000000000;     // 10^18
// const int BASE  = 1000000000 + 7;          // 10^9 + 7
// const int INFI  = 1000000000 + 7;          // 10^9 + 7
// const ll INFL  = 1000000000000000000 + 7; // 10^18 + 7

int N, M, K;

bool check() {
  for (int x = 0; x <= N; x++) {
    for (int y = 0; y <= M; y++) {
      int z = M * x + y * (N - 2 * x);
      if (z == K) return true;
    }
  }
  return false;
}

void solve() {
  if (check()) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int k,n,i;
  char s[105];
  scanf("%d",&k);
  scanf("%s",&s);
  for(n=0;s[n]!=0;n++);
  if(k<n){
    for(i=0;i<3;i++){
      s[k+i]='.';
    }
    s[k+3]=0;
  }else{
    s[n]=0;
  }
  printf("%s",s);
  return(0);
}

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

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

    int i,j,k;
    vector<int>  ans(N+1);
    int A;
    for( i = 1; i <= 100; i++ ){
        if( i*i + i + 4 > N ) break;
        for( j = i; j <= 100; j++ ){
            if( i*i + j*j + i*j + i + j + 1 > N ) break;
            for( k = j; k <= 100; k++ ){
                A = i*i + j*j + k*k + i*j + j*k + k*i;
                if( A <= N ){
                    if( i == j && j == k && k == i ) ans[A] += 1;
                    else if( i != j && j != k && k != i ) ans[A] += 6;
                    else ans[A] += 3;
                }
            }
        }
    }

    for( i = 1; i <= N; i++ ){
        cout << ans[i] << endl;
    }

}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define INF 1.0e9
using namespace std;
typedef long long ll;

int N;

int main() {
    cin >> N;
    int ans = 0;
    for (int i = 9; i >= 1; i--) {
        if (N <= 111*i) ans = 111*i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007LL
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  150
#define tmod             998244353LL
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<pair< ll ,ll > > &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
//bool P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n,ll m);

vector<vector<int> > G(200005);
vector<ll> A(200005),ans(200005,1);

void DFS(ll s,ll p,ll &l,vector<ll> &V)
{
    ll ol = l,ov;
    auto it = lower_bound(V.begin(),(V.begin()+l),A[s]);
    if(it==V.begin()+l) V[l++] = A[s];
    else {ov = (*it); *it = A[s];}
    ans[s] = l;
    for(auto it:G[s]) if(it!=p) DFS(it,s,l,V);
    if(ol==l) *it = ov;
    else l--;
}

int main()
{
fast;
ll q=1,t;
//cin >> q;
while(q--)
{
    ll i,j,n,m,k,l,r,a,b,c=0,d=0,e,g,p,q,u,v,w,x,y,flag=1;
    //n=m=k=i=j=l=r=a=b=c=d=u=v=w=p=x=y=0;
    cin >> n;
    c = 100;
    for(i=1;;i++)
    {
        c = ((dl)c*1.01);
        if(c>=n) {cout << i;break;}
        //cout << c << " ";
    }

}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n,ll m)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2,m);
    if(n%2==0){return (temp*temp)%m;}
    else{return (b*((temp*temp)%m))%m;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<pair<ll,ll> > &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid].F==ser)
    {
        return mid;
    }
    else if(PS[mid].F > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}
/*
void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                P[j]=false;
            }
        }
    }

}

*/


Measured memory_bytes: 10944
class UnionFind:

    def __init__(self, n):
        self.roots = [i for i in range(n)]
        self.ranks = [0 for _ in range(n)]
        self.sizes = [1 for _ in range(n)]

    def find_root(self, node):
        parent = self.roots[node]
        if node == parent:
            return node
        else:
            root = self.find_root(parent)
            self.roots[node] = root
            return root

    def union(self, one, other):
        one_root = self.find_root(one)
        other_root = self.find_root(other)
        if one_root == other_root:
            return
        if self.ranks[one_root] < self.ranks[other_root]:
            self.roots[one_root] = other_root
            self.sizes[other_root] += self.sizes[one_root]
        else:
            self.roots[other_root] = one_root
            self.sizes[one_root] += self.sizes[other_root]
            if self.ranks[one_root] == self.ranks[other_root]:
                self.ranks[one_root] += 1

    def is_same_group(self, one, other):
        one_root = self.find_root(one)
        other_root = self.find_root(other)
        return one_root == other_root

    def size(self, node):
        root = self.find_root(node)
        return self.sizes[root]


def main():
    N, M = list(map(int, input().split(' ')))
    bridges = list()
    for _ in range(M):
        A, B = list(map(int, input().split(' ')))
        A -= 1
        B -= 1
        bridges.append((A, B))
    bridges.reverse()
    tree = UnionFind(N)
    convenience = [0]
    for b in bridges[:-1]:
        one, other = b
        c = convenience[-1]
        if not tree.is_same_group(one, other):
            one_size = tree.size(one)
            other_size = tree.size(other)
            c += one_size * other_size
        convenience.append(c)
        tree.union(one, other)
    convenience.reverse()
    max_c = N * (N - 1) // 2
    for c in convenience:
        print(max_c - c)


if __name__ == '__main__':
    main()

Measured memory_bytes: 26248
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
ll mod=pow(10,9)+7;
struct Combination{
    vec n,n_rev;

    Combination(int N){
        n.resize(N+1);
        n_rev.resize(N+1);
        n[0]=1;n_rev[1]=1;
        for(int i=1;i<=N;i++){
            n[i]=((ll)i*n[i-1])%mod;
        }
        for(int i=2;i<=N;i++){
            n_rev[i]=matpow(n[i],mod-2);
        }
    }

    //累乗(aのk乗)
    ll matpow(ll a,int k){
        ll dp=1,mt=a;
        while(k>0){
            if(k & 1)dp=(dp*mt)%mod;
            mt=(mt*mt)%mod;
            k/=2;
        }
        return dp;
    }

    ll comb(int N,int r){  
        if(r==0 || N==r)return 1;
        return (((n[N]*n_rev[r])%mod)*n_rev[N-r])%mod;
    }
};

int main(){
    ll N,M,K;cin>>N>>M>>K;
    Combination Comb(N*M);
    ll ans=0;
    for(int y=1;y<N;y++){
        ans=(ans+(ll)y*(N-y)*M*M)%mod;
    }
    for(int x=1;x<M;x++){
        ans=(ans+(ll)x*(M-x)*N*N)%mod;
    }
    ans=(ans*Comb.comb(N*M-2,K-2))%mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3328
A, B, C = map(int, input().split())
K = int(input())

ans = "No"
def f(a, b, c, cnt, k):
    global ans
    if cnt > k:
        return
    if b > a and c > b:
        ans = "Yes"
        return
    
    f(2*a, b, c, cnt+1, k)
    f(a, 2*b, c, cnt+1, k)
    f(a, b, 2*c, cnt+1, k)


f(A, B, C, 0, K)
print(ans)

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
	llong N, M;
	string S;

	cin >> N >> M;
	cin >> S;

	reverse(ALL(S));
	vector<int> ok;
	for (int i = 0; i < N+1; ++i) {
		if (S[i] == '0')
			ok.push_back(i);
	}

	int now = 0;
	vector<llong> ans;
	while (now < N) {
		llong next = *(--upper_bound(ALL(ok), now + M));
		if (next == now) break;
		else {
			ans.push_back(next - now);
			now = next;
		}
	}

	if (now != N) {
		cout << -1 << endl;
	} else {
		reverse(ALL(ans));
		for (int i = 0; i < ans.size(); ++i) {
			cout << ans[i] << " ";
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1976
import itertools
n,k=map(int,input().split())
l=[]
for i in range(n):
    l.append(list(map(int,input().split())))
c=itertools.combinations(range(n),2)
d=itertools.combinations(range(n),2)
ans=10**25
for i0 in range(n):
    for i1 in range(i0,n):
        for j0 in range(n):
            for j1 in range(j0,n):
                i=[i0,i1]
                j=[j0,j1]
                #print(i,j)
                lx=min(l[i[0]][0],l[i[1]][0])
                rx=max(l[i[0]][0],l[i[1]][0])
                dy=min(l[j[0]][1],l[j[1]][1])
                uy=max(l[j[0]][1],l[j[1]][1])
                tk=0
                for p in l:
                    if lx<=p[0]<=rx and dy<=p[1]<=uy:
                        tk+=1
                if tk>=k:
                    ans=min(ans,(uy-dy)*(rx-lx))
print(ans)


Measured memory_bytes: 61916
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val p = (1..n).map { sc.nextInt() }
    val sorted = p.sorted()
    var count = 0
    for (i in p.indices) {
        if (p[i] != sorted[i]) {
            count++
        }
    }
    println(if (count == 0 || count == 2) "YES" else "NO")
}

Measured memory_bytes: 34244
#include <iostream>
using namespace std;
int main(void)
{
	int A, B, C; cin >> A >> B >> C;
	bool flag = false;
	if (A == B && B != C)flag = true;
	else if (B == C && C != A)flag = true;
	else if (C == A && A != B)flag = true;
	cout << (flag ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;
#define nl endl

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
bool mark[100005];vi prime;
void seive(ll N){for(int i=2;i<=N;i++){if(mark[i]==false){prime.pb(i);for(int j=i+i;j<N;j+=i)mark[j]=true;}}}
//freopen("input.txt", "r", stdin);

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    cin>>s;
    int y,m,d;
    y=(s[2]-'0')*10+s[3]-'0';
    m=(s[5]-'0')*10+s[6]-'0';
    d=(s[8]-'0')*10+s[9]-'0';
   // cout<<m<<" "<<d<<endl;
    if(m>4){
        cout<<"TBD"<<endl;
    }
    else  cout<<"Heisei"<<endl;

    End;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
	int k, n;
	cin >> k >> n;
	vector<int> v(n+1);
	rep(i, n) cin >> v[i];
	v[n] = v[0] + k;
	int d = 0;
	rep(i, n)
	{
		int a = abs(v[i] - v[i + 1]);
		d = max(d, a);
	}
	cout << k - d << endl;
}


Measured memory_bytes: 1024
while 1:
    a, op, b = input().split()
    if op == "+":
        print(int(a) + int(b))
    elif op == "-":
        print(int(a) - int(b))
    elif op == "*":
        print(int(a) * int(b))
    elif op == "/":
        print(int(int(a) / int(b)))
    elif op == "?":
        break

Measured memory_bytes: 7648
#include <stdio.h>

using namespace std;

void outPut(int Array[],char mark){
	for(int i = 1; i <= 13; i++){
		if(Array[i] == 0) printf("%c %d\n",mark,i);
	}
}

int main(){
	char mark[2];
	int n,S[14],H[14],C[14],D[14],tmp;
	for(int i = 0; i < 14; i++) S[i] = H[i] = C[i] = D[i] = 0;
	scanf("%d",&n);

	for(int i = 0; i < n; i++){
		scanf("%s %d",mark,&tmp);
		switch(mark[0]){
		case 'S':
			S[tmp] = 1;
			break;
		case 'H':
			H[tmp] = 1;
			break;
		case 'C':
			C[tmp] = 1;
			break;
		case 'D':
			D[tmp] = 1;
			break;
		}
	}
	outPut(S,'S');
	outPut(H,'H');
	outPut(C,'C');
	outPut(D,'D');
}


Measured memory_bytes: 2688
#include<stdio.h>

int main(){

    int i, x;

    i = 1;

    while (1) {
    	scanf("%d", &x);
    	if (x == 0){
    		break;
    	} else {
    		printf("Case %d: %d\n", i, x);
    	}
    	i = i + 1;
    }
    
    return 0;
}

Measured memory_bytes: 600
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

int N;
int d[100000];

void solve()
{
    sort(d, d+N);
    int ans = d[N/2] - d[N/2-1];
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) cin >> d[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 640
import sys

def warshall_floyd(v_count, matrix):
    for i in range(v_count):
        for j in range(v_count):
            c2 = matrix[j][i]
            for k, (c1, c3) in enumerate(zip(matrix[j], matrix[i])):
                if c1 > c2+c3:
                    matrix[j][k] = c2+c3
    return matrix


def has_negative_cycle(a) -> bool:
    return any(row[i] < 0 for i, row in enumerate(a))


V, E = map(int, input().split())
inf = float("inf")
matrix = [[inf]*V for _ in [0]*V]
for i in range(V):
    matrix[i][i] = 0
for s, t, d in (map(int, l.split()) for l in sys.stdin):
    matrix[s][t] = d
warshall_floyd(V, matrix)
if has_negative_cycle(matrix):
    print("NEGATIVE CYCLE")
else:
    for row in matrix:
        print(" ".join(map(lambda n: str(n) if n!=inf else "INF", row)))


Measured memory_bytes: 6224
k = int(input())
ans = [i for i in range(50)]
# print(ans)
def inv_process(arr,i):
    arr[i] += 50
    for j in range(50):
        if j == i:
            continue
        else:
            arr[j]-=1
loop = k//50
sup = k-loop*50

for i in range(50):
    ans[i] += loop


for i in range(sup):
    inv_process(ans,i)

print(50)
for i in range(49):
    print(ans[i],end=" ")
print(ans[-1])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int MOD = 1e9+7;
const long long INF = 1LL << 60;
const int INF_int = 1e9;
typedef long long ll;
int main(){
    string s; cin >> s;
    for(int i=2; i < s.size(); i+=2){
        if(s.substr(0, (s.size()-i)/2)==s.substr((s.size()-i)/2, (s.size()-i)/2)){
            cout<<s.size()-i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 384
def main():
  N = int(input())
  S = list(input())
  answer = []
  for i in range(N - 1):
    if S[i] != S[i + 1]:
      answer.append(S[i])
  if len(answer) == 0 or answer[-1] != S[-1]:
    answer.append(S[-1])
  print(len(answer))

main()


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, W, w1;
vector<LL> vec[4];
vector<LL> sum[4];

int main() {
	cin >> n >> W;
	inc(i, n) {
		LL w, v;
		cin >> w >> v;
		
		if(i == 0) { w1 = w; }
		vec[w - w1].PB(v);
	}
	
	inc(k, 4) {
		sort(ALL(vec[k]), greater<LL>());
		inc(i, vec[k].size() + 1) {
			if(i == 0) { sum[k].PB(0); }
			else { sum[k].PB(sum[k][i - 1] + vec[k][i - 1]); }
		}
	}
	
	LL ans = 0;
	inc(i, sum[0].size()) {
	inc(j, sum[1].size()) {
	inc(k, sum[2].size()) {
	inc(l, sum[3].size()) {
		LL ws = i * w1 + j * (w1 + 1) + k * (w1 + 2) + l * (w1 + 3);
		if(ws <= W) { setmax(ans, sum[0][i] + sum[1][j] + sum[2][k] + sum[3][l]); }
	}
	}
	}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())
ans = 10 ** 10

for i in range(0, max(x, y) * 2 + 1, 2):
    total = i * c + (max(0, y - i // 2)) * b + (max(0, x - i // 2)) * a
    ans = min(total, ans)
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

string s;

ll cal(ll l, ll r) {
	vector<ll> h;
	ll foo = 0;
	ll bar = 0;
	FOR(i, l, r) {
		if(s[i] == '[') {
			foo = 0;
			bar = 0;
			ll hoge = i + 1;
			FOR(j, i + 1, r) {
				i = j;
				if(s[j] == '[') {
					++foo;
					++bar;
				}
				if(s[j] == ']') {
					if(foo > 0) --foo;
					else {
						if(bar == 0) {
							h.pb(stoi(s.substr(hoge, j - hoge)) / 2 + 1);
						} else {
							h.pb(cal(hoge, j));
						}
						break;
					}
				}
			}
		}
	}
	sort(ALL(h));
	ll ans = 0;
	REP(i, min(h.size(), h.size() / 2 + 1)) {
		ans += h[i];
	}
	return ans;
}

int main(void) {
	ll n;
	cin>>n;
	REP(i, n) {
		cin>>s;
		cout<<cal(1, s.size() - 1)<<endl;
	}
}

Measured memory_bytes: 3220
n = int(input())
s = [input() for _ in range(2)]
ans = 1
pre_vertical = False
start = 1
flag = False
if s[0][0] == s[1][0]:
    pre_vertical = True
    ans *= 3
else:
    start = 2
    ans *= 6
for i in range(start, n):
    if flag:
        flag = False
        continue
    if s[0][i] == s[1][i]:
        if pre_vertical:
            ans *= 2
        else:
            ans *= 1
        pre_vertical = True
    else:
        if pre_vertical:
            ans *= 2
        else:
            ans *= 3
        pre_vertical = False
        flag = True
    ans %= 1000000007
print(ans)

Measured memory_bytes: 3064
N = int(input())
a = list(map(int, input().split()))
a0 = sum(i % 2 != 0 for i in a)
if sum(i % 4 == 2 for i in a) > 0:
    a0 += 1
a2 = sum(i % 4 == 0 for i in a)
print('Yes' if a0 <= a2 + 1 else 'No')


Measured memory_bytes: 84892
lst=list(str(input()))
temp=[]
for i in range(4):
  if lst[i] not in temp:
    temp.append(lst[i])
if len(temp)!=2:
  print("No")
else:
  if lst.count(temp[0])==2 and lst.count(lst[1])==2:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 3060
A, B, C = map(int,input().split())
ans = 0

while A != B or A != C or B != C:
    num = [A, B, C]
    num = sorted(num)
    if num[0] == num[1]:
        num[0] += 1
        num[1] += 1
    
    else:
        num[0] += 2
    
    ans += 1
    A = num[0]
    B = num[1]
    C = num[2]

print(ans)

Measured memory_bytes: 9200
#include<stdio.h>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<utility>
#include<stack>
#include<algorithm>
#include<string>
#include<string.h>
#include<assert.h>
#include<iomanip>
#include<unordered_map>
#define F first
#define S second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;

const int N = 2e5 + 5;

struct node{
  int val;
  node *left, *right;
  node(int val = 0, node *left = NULL, node *right = NULL){
    this->val = val;
    this->left = left;
    this->right = right;
  }
};

int ar[N];
int cnt = 0;
map<int, int> codex;
vector<int> lst[N];

node *root[N];

node *upd(node *bef, int target, int val, int l, int r){
  if(l == r)return new node(val, NULL, NULL);
  int m = (l + r) / 2;
  if(target <= m){
    node *left = upd(bef->left, target, val, l, m);
    return new node(max(bef->val, val), left, bef->right);
  }
  node *right = upd(bef->right, target, val, m + 1, r);
  return new node(max(bef->val, val), bef->left, right);
}

int get(node *cur, int x, int l, int r){
  if(l >= x)return 0;
  if(r < x)return cur->val;
  int m = (l + r) / 2;
  return max(get(cur->left, x, l, m), get(cur->right, x, m + 1, r));
}

int ans[N];

void dfs(int idx, int par){
  int cur_lis = get(root[par], ar[idx], 0, cnt - 1) + 1;
  root[idx] = upd(root[par], ar[idx], cur_lis, 0, cnt - 1);
  ans[idx] = root[idx]->val;
  for(auto nx : lst[idx]){
    if(nx == par)continue;
    dfs(nx, idx);
  }
}

int main(){
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  for(int i = 1; i <= n; ++i){
    cin >> ar[i];
    codex[ar[i]];
  }

  for(int i = 1; i < n; ++i){
    int a, b; cin >> a >> b;
    lst[a].pb(b);
    lst[b].pb(a);
  }

  for(auto &x: codex){
    x.S = cnt++;
  }

  for(int i = 1; i <= n; ++i) ar[i] = codex[ar[i]];

  root[0] = new node(0, NULL, NULL);
  root[0]->left = root[0]->right = root[0];
  dfs(1, 0);

  for(int i = 1; i <= n; ++i){
    cout << ans[i] << endl;
  }

}


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

vector< int > heap;

int left(int node) {
  return node*2;
}

int right(int node) {
  return node*2+1;
}

int parent(int node) {
  return node/2;
}

void upHeap(int node) {
  int nParent = parent(node);
  if ((nParent >= 1) && (heap[node-1] > heap[nParent-1])) {
    int holder = heap[node-1];
    heap[node-1] = heap[nParent-1];
    heap[nParent-1] = holder;
    upHeap(nParent);
  }
  return;
}

void insert(int value) {
  heap.push_back(value);
  upHeap(heap.size());
  return;
}

void downHeap(int node) {
  int l = left(node), r = right(node);
  int largest = node;
  if ((l <= heap.size()) && (heap[l-1] > heap[node-1]))
    largest = l;
  if ((r <= heap.size()) && (heap[r-1] > heap[largest-1]))
    largest = r;
  if (largest != node) {
    int holder = heap[node-1];
    heap[node-1] = heap[largest-1];
    heap[largest-1] = holder;
    downHeap(largest);
  }
}

int extract(void) {
  int output = heap[0];
  if (heap.size())
    heap[0] = heap[heap.size()-1];
  heap.pop_back();
  downHeap(1);
  return output;
}

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  while (true) {
    string command;
    cin >> command;
    if (command == "end")
      break;
    if (command == "insert") {
      int input;
      cin >> input;
      insert(input);
    } else {
      cout << extract() << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 7024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstdlib>
using namespace std;
//#define M_PI 3.141592

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    double d = M_PI / 180.0;
    double s, l, h;

    double tmp;
    tmp = sqrt(a*a + b*b - 2*a*b*cos(c*d));

    l = tmp + a + b;
    s = a * b * sin(c*d) / 2;
    h = sin(c*d) * b;
    
    printf("%lf\n%lf\n%lf\n", s, l, h);

}


Measured memory_bytes: 3476
S = sorted(list(str(input())))
T = sorted(list(str(input())),reverse=True)

for i in range(min(len(S),len(T))):
    if S[i] < T[i]:
        print('Yes')
        break
    elif S[i] == T[i]:
        if i+1 == len(S) < len(T):
            print('Yes')
            break
        elif i+1 == len(T):
            print('No')
            break
        else:
            continue
    else:
        print('No')
        break

Measured memory_bytes: 3064