akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;
 
struct ATAD{
  int numb,did;
  char lac;
};
 
int Kat(ATAD VA[],int p,int r){
  ATAD axa = VA[r];
  int i=p-1;
  for(int j=p;j<r;j++){
    if(VA[j].numb<=axa.numb){
      i++;
      swap(VA[i],VA[j]);
    }
  }
  swap(VA[i+1],VA[r]);
  return i+1;
}
 
void qsot(ATAD A[],int p,int r){
  if(p<r){
    int qaa = Kat(A,p,r);
    qsot(A,p,qaa-1);
    qsot(A,qaa+1,r);
  }
}
 
void kakn(ATAD A[],int n){
  for(int i=1;i<n;i++){
    if(A[i-1].numb<A[i].numb)continue;
    if(A[i-1].did<A[i].did)continue;
    cout<<"Not stable"<<endl;
    return;
  }
  cout<<"Stable"<<endl;
}
 
int main(){
  int n;
  ATAD A[100000];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i].lac>>A[i].numb;
    A[i].did=i;
  }
   
  qsot(A,0,n-1);
  kakn(A,n); 
  for(int i=0;i<n;i++){
    cout<<A[i].lac<<' '<<A[i].numb<<endl;
  }
   
  return 0;
}

Measured memory_bytes: 2328
n = int(input())
lim = n
i = 1

a = 1
b = n
while lim > i:
    if n % i == 0:
        if a + b > n % i + i:
            a = i
            b = n / i
    lim = n // i
    i += 1
sub = a + b - 2
'''
if a == 1:
    print("こっちに")
    sub += 1
if b == 1:
    print("きてる")
    sub += 1
'''
print(int(sub))


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
int main() {
	ll a, b, c;
	scanf("%lld%lld%lld", &a, &b, &c);
	puts((c - a - b) > 0 && 4 * a * b < (c - a - b) * (c - a - b) ? "Yes" : "No");
	return 0;
}


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

int main() {
    int n, m;

    cin >> n;
    int t[n];
    int total = 0;
    for (int i = 0; i < n; i++) {
        cin >> t[i];
        total += t[i];
    }
    cin >> m;
    int p[m];
    int x[m];
    for (int i = 0; i < m; i++) {
        cin >> p[i] >> x[i];
    }

    for (int i = 0; i < m; i++) {
        int index = p[i] - 1;
        int diff = t[index] - x[i];
        cout << total - diff << endl;
    }
};


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

using ll =long long;

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

	vector<ll>v(n);
	for(ll i=0;i<n;i++){
		cin >> v[i];
	}	

	ll res = 9999999999;
	//cout << res << "\n";
	for(ll i=1;i<=100;i++){
		ll ans = 0;
		for(ll j=0;j<n;j++){
			ans = ans + (ll)(pow((i-v[j]),2));
		}
		//cout << ans << " ";
		res = min(res,ans);
	}

	cout << res << "\n";


	// ll dist=0;
	// for(ll j=0;j<n;j++){
	// 	dist = (ll)pow((1-v[j]),2);
	// }

	// cout << dist << "\n";

	return 0;
}

Measured memory_bytes: 256
N=int(input())
xlist=list(map(int,input().split()))

xmin=min(xlist)
xmax=max(xlist)

min_answer=10**9
for i in range(xmin,xmax+1):
  answer=0
  for x in xlist:
    answer+=(x-i)**2

  min_answer=min(answer,min_answer)

print(min_answer)

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

ll h,w;
string s[2020];
ll a[2020][2020];
ll pre[2020][2020];

int main(){
	cin>>h>>w;
  rep(i,h)cin>>s[i];
  rep(i,h-1)rep(j,w-1){
    map<char,int> cnt;
    cnt[s[i][j]]++; cnt[s[i+1][j]]++; cnt[s[i][j+1]]++; cnt[s[i+1][j+1]]++;
    if(cnt['#']%2==0) a[i][j]=0;
    else a[i][j]=1;
  }
  rep(i,h-1){
    rep(j,w-1){
      if(a[i][j]){
        pre[i][j]=0;
      }else{
        if(i==0)pre[i][j]=1;
        else pre[i][j]=pre[i-1][j]+1;
      }
    }
  }
  ll res=max(h,w);
  rep(i,h-1){
    stack<P> st;
    rep(j,w-1){
      ll lastidx=j;
      if(st.size()&&st.top().fi>pre[i][j]){
        while(st.size()&&st.top().fi>=pre[i][j]){
          maxch(res,(st.top().fi+1)*(j-st.top().se+1));
          lastidx=st.top().se;
          st.pop();
        }
      }
      if(st.size()==0||st.top().fi<pre[i][j])st.push(P(pre[i][j],lastidx));
    }
    while(st.size()){
      maxch(res,(st.top().fi+1)*(w-st.top().se));
      st.pop();
    }
  }
  cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 67840
#include <bits/stdc++.h>
#define ll long long
#define dbg(x) cout<<#x<<"="<<x
#define nl cout<<"\n"
#define frn(i,n) for(int i = 0;i < n;i++)
#define fr(i,a,b) for(int i = a;i < b;i++)
#define pb push_back
#define trav(x,c) for(auto &x:c)
using namespace std;
const int mod = 1e9+7;
int toint(string s) {
  int ans = 0;
  for(char x: s) ans = ans*10 + (x - '0');
  return ans;
}

int sum(int x) {
  int s = 0;
  while(x) {
    s += x%10;
    x /= 10;
  }
  return s;
} 

bool equal(string s) {
  for(int i = 0,j = s.size()/2;j < s.size();i++,j++) {
    if(s[i] != s[j]) return false;
  }
  return true;
}

ll fact(int n) {
  ll ans = 1;
  fr(i,2,n+1) ans = (ans*i)%mod;
  return ans;
}

int main() {
  int m,n;
  cin>>m>>n;
  string a[m], b[n];
  frn(i,m) cin>>a[i];
  frn(i,n) cin>>b[i];
  for(int i = 0;i+n-1 < m;i++) {
    for(int j = 0;j+n-1 < m;j++) {
      bool found = true;
      for(int k = 0;k < n;k++) {
        for(int l = 0;l < n;l++) {
          if(b[k][l] != a[i+k][j+l]) {
            found = false;
            break;
          }
        }
      }
      if(found) {cout<<"Yes"; return 0;}
    } 
  }
  cout<<"No";
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

const int N = 600;

class S{
public:
  int y, x, c;
};

int t, n, sy, sx;
bool mapData[N][N];
bool visited[N][N];
int dy[] = {1, 0, -1, -1, 0, 1};
int dx[] = {1, 1, 0, -1, -1, 0};

int bfs(){
  int res = 0;
  fill(visited[0], visited[N], false);
  S u, v;
  queue<S> q;
  u.y = sy;
  u.x = sx;
  u.c = 0;
  q.push(u);
  visited[sy][sx] = true;
  res++;
  while(!q.empty()){
    u = q.front(); q.pop();
    if(u.c >= t) continue;
    for(int i=0;i<6;i++){
      int ny = u.y + dy[i];
      int nx = u.x + dx[i];
      if(!mapData[ny][nx]) continue;
      if(visited[ny][nx]) continue;
      visited[ny][nx] = true;
      res++;
      v.y = ny;
      v.x = nx;
      v.c = u.c+1;
      q.push(v);
    }
  }
  return res;
}


main(){
  while(cin >> t >> n && (t|n)){
    fill(mapData[0], mapData[N], true);
    for(int i=0;i<n;i++){
      int y, x;
      cin >> x >> y; 
      mapData[y+N/2][x+N/2] = false;
    }
    cin >> sx >> sy;
    sx += N/2;
    sy += N/2;
    cout << bfs() << endl;
  }
  return 0;
}

Measured memory_bytes: 0
N, C, K = list(map(int, input().split()))
T = []
for i in range(N):
    t = int(input())
    T.append(t)

T.sort()

bus = 0  # 出発したバスの台数
wait = 0  # 待っている人
dep = None  # 次のバスの出発時刻

for ti in T:
    if dep is None:  # バスを準備
        dep = ti + K
        bus += 1
    elif ti > dep:  # 前のバスの発車時間を過ぎている
        dep = ti + K
        bus += 1
        wait = 0

    wait += 1

    if wait == C:  # 満員になった
        dep = None
        wait = 0

print(bus)

Measured memory_bytes: 7384
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll MOD = 1e9+7;

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
 	int n, m; cin >> n >> m;
 	int sum = 0;
 	FOR(i, m){
 		int x; cin >> x;
 		sum+=x;
 	}
 	cout << max(n-sum, -1) << '\n';
 
	return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    int Q,H,S,D;
    int N;
    cin >> Q >> H >> S >> D >> N;
    int L1 = min({Q*4,Q*2+H,H*2,S});
    cout << min(L1*N,N/2*D+N%2*L1) << endl;
}



Measured memory_bytes: 3600
n = int(input())
S = list(map(int,input().split()))
q = int(input())
T = list(map(int,input().split()))

ans = 0
for i in T:
    if S[0] == i or S[n-1] == i:
        ans += 1
        continue
        
    l, r = 0, n-1
    while r-l > 1:
        m = (l+r)//2
        if S[m] == i:
            ans += 1
            break
        if S[m] < i:
            l = m
        else:
            r = m

print(ans)



Measured memory_bytes: 16716
#include <algorithm>
#include<cfenv>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include<numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;
vector<llong> AllDivisors(llong N) {
	vector<llong> ANS;
	for (llong i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			ANS.push_back(i);
			if (N / i != i)ANS.push_back(N / i);
		}
	}
	sort(ANS.begin(), ANS.end());
	return ANS;
}
bool IsPrime(llong N) {
	for (llong i = 2; i * i <= N; i++) {
		if (N % i == 0) return false;
	}
	return true;
}
pair<llong, llong> Reduction(pair<llong, llong> A) {
	llong tmp = gcd(A.first, A.second);
	auto p = make_pair(A.first / tmp, A.second / tmp);
	return p;
}
//ここまで共通
string S, T;
int main() {
	cin >> S >> T;
	int count = 0;
	for (int i = 0; i <= S.length() - T.length(); i++) {
		int tmp = 0;
		for (int j = 0; j < T.length(); j++) {
			if (T[j] == S[i + j]) tmp++;
		}
		count = max(count, tmp);
	}

	cout << T.length() - count << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

#define sz(x) (int)(x).size()
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

struct int_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct pair_hash {
    size_t operator()(pii x) const {
        return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
    }
};

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<cd> vcd;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pii>> vvpii;
typedef vector<vector<pll>> vvpll;
typedef unordered_map<int, int, int_hash> umpii;
typedef unordered_map<ll, ll, int_hash> umpll;
typedef unordered_set<int, int_hash> usi;
typedef unordered_set<ll, int_hash> usll;
typedef unordered_set<pii, pair_hash> uspii;
typedef queue<int> qi;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = numeric_limits<int>::max();
const int MX = 100001; //check the limits, dummy

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

    string s; cin >> s;
    ll i = s.find_first_of('<'), n = sz(s);
    ll sum = i != string::npos ? i * (i + 1) / 2 : n * (n + 1) / 2;
    for(; i != string::npos && i < n; i++) {
        if(s[i] == '>' && s[i - 1] == '<') {
            ll r = i, l = i - 1;
            while(r < n && s[r] != '<') r++;
            while(l >= 0 && s[l] != '>') l--;
            ll a = r - i, b = i - 1 - l;
            sum += max(a, b) * (max(a, b) + 1) / 2
                + min(a, b) * (min(a, b) - 1) / 2;
        }
    }

    i = s.find_last_of('>');
    sum += i != string::npos ? (n - i - 1) * (n - i) / 2 : n * (n + 1) / 2;
    cout << sum << endl;
}

Measured memory_bytes: 1172
S = list(input())
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

if A+B+C+D == 7:
  print('{}+{}+{}+{}=7'.format(A,B,C,D))
elif A+B+C-D == 7:
  print('{}+{}+{}-{}=7'.format(A,B,C,D))
elif A+B-C+D == 7:
  print('{}+{}-{}+{}=7'.format(A,B,C,D))
elif A+B-C-D == 7:
  print('{}+{}-{}-{}=7'.format(A,B,C,D))
elif A-B+C+D == 7:
  print('{}-{}+{}+{}=7'.format(A,B,C,D))
elif A-B+C-D == 7:
  print('{}-{}+{}-{}=7'.format(A,B,C,D))
elif A-B-C+D == 7:
  print('{}-{}-{}+{}=7'.format(A,B,C,D))
elif A-B-C-D == 7:
  print('{}-{}-{}-{}=7'.format(A,B,C,D))
else:
  print('none')

Measured memory_bytes: 3064
#include <cassert>
#include <cstddef>
#include <tuple>
#include <utility>
#include <vector>

template <class Abelian> class PotentializedUnionFind {

public:
  using value_type = Abelian;
  using size_type = std::size_t;
  using container_type =
      std::vector<std::tuple<size_type, value_type, size_type>>;

protected:
  container_type c;

private:
  size_type &par(const size_type i) { return std::get<0>(c[i]); }
  size_type par(const size_type i) const { return std::get<0>(c[i]); }
  value_type &val(const size_type i) { return std::get<1>(c[i]); }
  const value_type &val(const size_type i) const { return std::get<1>(c[i]); }
  size_type &siz(const size_type i) { return std::get<2>(c[i]); }
  size_type siz(const size_type i) const { return std::get<2>(c[i]); }
  value_type potential(size_type x) {
    value_type ret = {};
    while (x != par(x)) {
      val(x) = val(x) + val(par(x));
      ret = ret + val(x);
      x = par(x) = par(par(x));
    }
    return std::move(ret);
  }

public:
  PotentializedUnionFind() : c() {}
  explicit PotentializedUnionFind(const size_type size)
      : c(size, std::forward_as_tuple(static_cast<size_type>(0), value_type(),
                                      static_cast<size_type>(1))) {
    for (size_type i = 0; i < size; ++i)
      par(i) = i;
  }

  size_type size() const { return c.size(); }
  bool empty() const { return c.empty(); }

  size_type find(size_type x) {
    assert(x < size());
    while (x != par(x)) {
      val(x) = val(x) + val(par(x));
      x = par(x) = par(par(x));
    }
    return x;
  }
  value_type diff(const size_type x, const size_type y) {
    assert(x < size());
    assert(y < size());
    assert(same(x, y));
    return potential(y) + (-potential(x));
  }
  bool same(const size_type x, const size_type y) {
    assert(x < size());
    assert(y < size());
    return find(x) == find(y);
  }
  size_type size(const size_type x) {
    assert(x < size());
    return siz(find(x));
  }

  bool unite(size_type x, size_type y, value_type d) {
    assert(x < size());
    assert(y < size());
    d = d + potential(x) + (-potential(y));
    x = find(x);
    y = find(y);
    if (x == y)
      return false;
    if (siz(x) < siz(y))
      std::swap(x, y), d = -d;
    siz(x) += siz(y);
    par(y) = x;
    val(y) = std::move(d);
    return true;
  }
};

#include<iostream>
 
int main() {
    int n, q;
    std::cin >> n >> q;
    PotentializedUnionFind<int> T(n);
    while (q--) {
        int t, x, y, z;
        std::cin >> t >> x >> y;
        if (t) {
            if (T.same(x, y))
                std::cout << T.diff(x, y) << std::endl;
            else
                std::cout << "?" << std::endl;
        }
        else {
            std::cin >> z;
            T.unite(x, y, z);
        }
    }
    return 0;
}


Measured memory_bytes: 5216
#include <stdio.h>
#include <ctype.h>

int stack[102]; int top;
char buf[2000];

int main()
{
	int  v1, v2;
	char *p;

	fgets(p=buf,500,stdin);
	top = 0;
	while (*p>=' ') {
		while (isspace(*p)) p++;
		if (isdigit(*p)) {
			v1 = 0;
	    	while(isdigit(*p)){
	    	    v1 = 10*v1 + (*p++ & 0xf);
			}
		stack[top++] = v1;
		}else{
			v1 = stack[--top];
			v2 = stack[--top];
			if(*p == '+') v2 += v1;
			else if(*p == '-') v2 -= v1;
			else if(*p == '*') v2 *= v1;
			stack[top++] = v2;
			p++;
		}
	}
	printf("%d\n",stack[--top]);
	return 0;
}


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

import sys


def parseRomanNumber(roman):
    roman_dict = {
      "I": 1,
      "V": 5,
      "X": 10,
      "L": 50,
      "C": 100,
      "D": 500,
      "M": 1000}
    numbers = [0]
    roman = roman.replace("\n", "")
    for i in [roman_dict[c] for c in roman[::-1]]:
        if i >= numbers[-1]:
            numbers.append(i)
        else:
            numbers.append(i * -1)
    return sum(numbers)


def main():
    romans = sys.stdin.readlines()
    for roman in romans:
        print parseRomanNumber(roman)


if __name__ == '__main__':
    main()

Measured memory_bytes: 5672
found = []
for s in range(4):
    suit = []
    for i in range (14):
            suit.append(False)
    found.append(suit)
    
num_card = int(input())
for i in range (num_card):
    suit, rank = input().split()
    suit = 'SHCD'.index(suit)
    rank = int(rank)
    found[suit][rank] = True
        
for s in range(4):
    for r in range(1,14):
        if found[s][r] == False:
            suit = 'SHCD'[s]
            print (suit, r)


Measured memory_bytes: 5596
N,M = map(int, raw_input().split())
E = [[] for _ in range(N)]
for _ in range(M):
  a,b = map(int, raw_input().split())
  E[a-1] += [b-1]
  E[b-1] += [a-1]

def BT(p, c, V):
  if c==N-1:
    return 1
  V[p] = True
  ans = 0
  for e in E[p]:
    if not V[e]:
      ans += BT(e, c+1, V)
  V[p] = False
  return ans

print BT(0, 0, [False]*N)


Measured memory_bytes: 2568
#include<iostream>
#include<bits/stdc++.h>
#include<vector>
#include<math.h>

using namespace std;

int main()
{
   int n, k, ans, total = 0;

   cin >> n >> k;

   vector<int> xv;

   for(int i = 0; i < n; i++)
   {
      int x;
      cin >> x;
      xv.push_back(x);
   }

   for(int i = 0; i < n; i++)
   {
      ans = min(xv[i],abs(xv[i] - k));
      //cout << ans << endl;
      total = total + ans*2;
   }

   cout << total;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> P;
map <int,int> mp;
vector<int> V;
#define INF (1<<29)
#define INFLL (1ll<<58)
#define EPS (1e-10)
static const int MAX=1e5;
static const int MOD=1e9+7;
static const int NMAX=50;
static const int MMAX=50;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
int k,T,a[MAX+3];
int main(){
    cin.tie(0);  ios::sync_with_stdio(false);
    
    cin>>k>>T;
    int max_a=0,sum=0;
    for(int i=0;i<T;i++){
        cin>>a[i];
        max_a=max(max_a,a[i]);
    }
    
    cout<<max(0,2*max_a-k-1)<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fore(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define PI 3.141592653589793
using namespace std;
using ll = long long;
using ld = long double;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    ll a, b, k;
    cin >> a >> b >> k;
    if(a >= k){
        cout << a-k << " " << b << endl;
    }else
    {
        ll l = 0;
        cout << 0 << " " << max(b-(k-a), l) << endl;
    }
    
}

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

using namespace std;

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

    int d[n] = {};
    for (int i = 0; i < n; ++i) {
        cin >> d[i];
    }
    sort(d, d + n, greater<int>());

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main()
{
    char str[10];
    scanf("%s",str);
    if(str[2]==str[3]&&str[4]==str[5])
    {
    	printf("Yes");
	}
	else
	{
		printf("No");
	}
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    int p[N];
    for(int i=0; i<N; i++){
        cin >> p[i];
    }
    sort(p,p+N);
    int ans=0;
    for(int i=0; i<K; i++){
        ans+=p[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>

using namespace std;

int main(void) {
	char S[11];
	int ans, len, t;
	scanf("%s", S);
	len = strlen(S);

	ans = 1000;
  for(int i=0; i<len-2; i++){
			t = (S[i] - '0')*100 + (S[i+1] - '0')*10 + (S[i+2] - '0');
			if(t > 753){
				ans = min(ans, t-753);
			}else{
				ans = min(ans, 753-t);
			}
	}
	printf("%d", ans);
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}

string board[1005];
ll dp[1005][1005];

const ll MAX = MOD;

struct obj{
  ll id,count;
};

bool func(obj x,obj y){
  return x.count>y.count;
}

obj a[300005],b[300005];
map<pll,int> mp;

void solve(){
  ll H,W,M; cin>>H>>W>>M;
  REP(i,H){
    a[i] = {i,0};
  }
  REP(i,W){
    b[i] = {i,0};
  }
  REP(count,M){
    ll h,w; cin>>h>>w;
    --h; --w;
    a[h].count++;
    b[w].count++;
    mp[MP(h,w)]++;
  }
  sort(a,a+H,func);
  sort(b,b+W,func);
  ll ans;
  obj tate = a[0];
  obj yoko = b[0];
  if(mp[MP(tate.id,yoko.id)]==0){
    ans = tate.count+yoko.count;
  }else{
    ans = tate.count+yoko.count-1;
    REP(i,H){
      if(a[i].count!=tate.count)break;
      REP(j,W){
        if(b[j].count!=yoko.count)break;
        if(mp[MP(a[i].id,b[j].id)]==0){
          ans = tate.count+yoko.count; break;
        }
      }
    }
    REP(j,W){
      if(b[j].count!=yoko.count)break;
      REP(i,H){
        if(a[i].count!=tate.count)break;
        if(mp[MP(a[i].id,b[j].id)]==0){
          ans = tate.count+yoko.count; break;
        }
      }
    }
  }
  cout << ans << "\n";
}

int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}
  solve();
  return 0;
}


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

using namespace std;

#define ll long long
#define pii pair<int, int>
#define MOD 1e9 + 7
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);

void solve()
{
    int n, w;
    cin >> n >> w;

    int values[n][2];

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

    ll dp[n + 1][w + 1];
    for(int i = 0; i <= n; i++)
    {
        for(int j = 0; j <= w; j++)
        {
            dp[i][j] = 0;
        }
    }

    for(int i = 0; i < n; i++)
    {
        for(int j = 1; j <= w; j++)
        {
            ll x = dp[i][j];
            ll y = 0;
            if(values[i][0] <= j)
            {
                y = dp[i][j - values[i][0]] + values[i][1];
            }
            dp[i + 1][j] = max(x, y);
        }
    }
    cout << dp[n][w];
}

int main()
{
    fastio

    //ifstream fin(".in");
    //ofstream fout(".out");


    int t = 1;
    //cin >> t;

    while(t-- > 0) solve();
}

Measured memory_bytes: 82440
#pragma region noncode
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SORT(v) sort(all(v))
#define TROS(v) sort(all(v), std::greater<Type>());
#pragma endregion

int main() {
    // template
    int x;cin>>x;
    cout<<((x>=30) ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 3596
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    a,b = LI()
    if a+b >= 10:
        return 'error'

    return a+b



print(main())


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

using namespace std;

bool IsMonth(char ten, char one)
{
  return (ten == '1' && one <= '2') || (ten == '0' && one != '0'); 
}

int main()
{
  string str;
  cin >> str;
  
  if( IsMonth(str[0], str[1]))
  {
    if(IsMonth(str[2], str[3]))
      cout << "AMBIGUOUS" << endl;
    else
      cout << "MMYY" << endl;
  }
  else
  {
    if(IsMonth(str[2], str[3]))
      cout << "YYMM" << endl;
    else
      cout << "NA" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<stdio.h>
#include <algorithm>
#include <functional>

#define FOR(i,n) for(int i=0;i<n;i++)
#define SORT(v,n) std::sort(&v[0],&v[n])
#define INF 999999999
#define mod 1000000007



using namespace std;

int main(void){
	long N,M; // S:N  c:M
	cin >> N >> M;
	long ans=0;
	if(M - 2*N >=0){
		ans=N;
		M-=2*N;
		ans+=M/4;
	}else{
		ans=M/2;
	}
	cout << ans << endl;


}


Measured memory_bytes: 256
s = input()
t = input()
n = len(s)
check = False
for i in range(n):
	temp = True
	counter = 0
	while temp and counter != n:
		if i < n:
			if s[i] != t[counter]:
				temp = False
		else:
			if s[i-n] != t[counter]:
				temp = False
		counter += 1
		i += 1
	if temp:
		check = True
		break
if check:
	print('Yes')
else:
	print('No')

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,K;

signed main(){
    cin>>N>>K;
    int ans=K;
    rep(i,N-1)ans*=K-1;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = str(input())

r, g, b = set(), set(), set()
for i in range(len(s)):
    if s[i] == "R":
        r.add(i)
    elif s[i] == "G":
        g.add(i)
    else:
        b.add(i)
        
ans = len(r) * len(g) * len(b)
for r_idx in r:
    for g_idx in g:
        j, i = max(r_idx, g_idx), min(r_idx, g_idx)
        diff_ji = abs(j-i)
        cnt = 0
        for v in [j + diff_ji, i - diff_ji, (j + i) / 2]:
            if v in b:
                cnt += 1            
        ans -= cnt
print(ans)

Measured memory_bytes: 9340
import java.util.Arrays;
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      if(n<1000){
        System.out.println("ABC");
      }else{
        System.out.println("ABD");
      }

  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int read(){
	int x = 0,f = 0;char ch = getchar();
	while(!isdigit(ch)) {if(ch=='-')f=1;ch=getchar();}
	while(isdigit(ch)) {x=x*10+ch-'0';ch=getchar();}
	return f?-x:x;
}
char s[1100],t[1100];
int ans = 0x3f3f3f3f;
int main()
{
	int d=read(),t=read(),s=read();
	if(d<=s*t) cout << "Yes"<<endl;
	else cout <<"No" <<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long int a,b,c;
  cin >> a >> b >> c;
  if(c<a+b){
  cout << "No" << endl;
  }
  else{
   if(4*a*b<(c-a-b)*(c-a-b)){
   cout << "Yes" << endl;
   }
    else{cout << "No" << endl;} 
  }  
    
 }

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

int cnt[11];

int main() {
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n) cnt[n]++;

    if (cnt[5] == 2 && cnt[7] == 1) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount

int d[] = {1, 0, -1, 0, 1};

int main() {
    int h, w;
    cin >> h >> w;
    char grid[55][55];
    int bcnt = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> grid[i][j];
            if (grid[i][j] == '#')bcnt++;
        }
    }

    queue<int> q;
    vector<int> dis(h * w + 10, -1);
    q.push(0);
    dis[0] = 0;
    while (!q.empty()) {
        int cur = q.front();
        q.pop();
        int cy = cur / w, cx = cur % w;
        for (int i = 0; i < 4; ++i) {
            int ny = cy + d[i], nx = cx + d[i + 1];
            if (dis[ny * w + nx] != -1 || ny < 0 || ny >= h || nx < 0 || nx >= w)continue;
            if (grid[ny][nx] == '#')continue;
            dis[ny * w + nx] = dis[cur] + 1;
            q.push(ny * w + nx);
        }
    }
    if (dis[(h - 1) * w + (w - 1)] == -1)cout << -1 << endl;
    else cout << h * w - dis[(h - 1) * w + (w - 1)] - bcnt - 1 << endl;

    return 0;
}

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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  cout << max(a - k, 0LL) << " " << max(b - max(k - a, 0LL), 0LL) << endl;
  return 0;
}


Measured memory_bytes: 3576
package main

import "fmt"

func main() {
	var a, b, c, d [30]int
	var n int
	var id int
	fmt.Scanf("%d\n", &n)

	for i := 0; i < n; i++ {

		var B, f, r, v int
		fmt.Scanf("%d%d%d%d\n", &B, &f, &r, &v)
		if B == 1 {
			id = (f-1)*10 + r - 1
			a[id] = a[id] + v
		} else if B == 2 {
			id = (f-1)*10 + r - 1
			b[id] = b[id] + v
		} else if B == 3 {
			id = (f-1)*10 + r - 1
			c[id] = c[id] + v
		} else if B == 4 {
			id = (f-1)*10 + r - 1
			d[id] = d[id] + v
		}

	}

	for i := 0; i < 30; i++ {
		if i == 9 {
			fmt.Printf(" %d\n", a[i])
		} else if i == 19 {
			fmt.Printf(" %d\n", a[i])
		} else {
			fmt.Printf(" %d", a[i])
		}
	}
	fmt.Println("")
	fmt.Println("####################")
	for i := 0; i < 30; i++ {
		if i == 9 {
			fmt.Printf(" %d\n", b[i])
		} else if i == 19 {
			fmt.Printf(" %d\n", b[i])
		} else {
			fmt.Printf(" %d", b[i])
		}
	}
	fmt.Println("")
	fmt.Println("####################")
	for i := 0; i < 30; i++ {
		if i == 9 {
			fmt.Printf(" %d\n", c[i])
		} else if i == 19 {
			fmt.Printf(" %d\n", c[i])
		} else {
			fmt.Printf(" %d", c[i])
		}
	}
	fmt.Println("")
	fmt.Println("####################")
	for i := 0; i < 30; i++ {
		if i == 9 {
			fmt.Printf(" %d\n", d[i])
		} else if i == 19 {
			fmt.Printf(" %d\n", d[i])
		} else {
			fmt.Printf(" %d", d[i])
		}
	}
	fmt.Println("")

}



Measured memory_bytes: 1152
#include <stdio.h>

int main(void){
  int X[4];
  int i=0;
  for(i=0;i<4;i++)	scanf("%d", &X[i]);
  
  int ans;
  if( X[0] < X[1] )	ans += X[0];
  else 				ans += X[1];
  
  if( X[2] < X[3] ) ans += X[2];
  else 				ans += X[3];
  
  printf("%d\n", ans);
  
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        char[] a = sc.next().toCharArray();
        char[] b = sc.next().toCharArray();

        int res = 0;
        for(int i=0; i<3; i++) {
            if(a[i]==b[i]) res++;
        }
        System.out.println(res);


    }
}


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

# define F first
# define S second
# define mp make_pair
// everything go according to my plan
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right

using namespace std;

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

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput (string in = "s") {
  if (fopen (in.c_str(), "r"))
    freopen (in.c_str(), "r", stdin);
  else {
    cerr << "Input file not found" << endl;
  }
}    

int main()
{
  Read_rap();
  localInput(); 
  ll a, b;
  cin >> a >> b;
  if (a <= 0 && 0 <= b)
    cout << "Zero";
  else  if (a < 0) {
    cout << (((a - b) & 1) ? "Positive" : "Negative");
     
  }
  else
    cout << "Positive";


  return 0;
}










// Coded by Z..


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


int main(){
    ll N, K, S; cin >> N >> K >> S;
    rep(i, N){
        if(i < K){
            cout << S;
        }
        else{
            if(S == (ll)1e9){
                cout << S - 1;
            }
            else{
                cout << min(3*S, (ll)1000000000);
            }
        }
        if(i != N -1){
            cout << " ";
        }
    }
}

Measured memory_bytes: 1280
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) \
    do           \
    {            \
    } while (0)
#define dump(x) \
    do          \
    {           \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template <class T>
inline T sqr(T x) { return x * x; }

bool solve()
{
    int a, b, c;
    cin >> a >> b >> c;
    return c >= a && c <= b;
}

int main()
{
    if (solve())
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
x=int(input())
if x==0:
    print('0 0')
i=0
while True:
    flag=False
    a=pow(i,5)
    r=x-a
    if r<0:
        r*=-1
        flag=True
    j=1
    n=1
    while n<r:
        j+=1
        n=pow(j,5)
    if n==r and not flag:
        print(i,-1*j)
        break
    elif n==r and flag:
        print(i,j)
        break
    else:
        i+=1

Measured memory_bytes: 64724
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String S = sc.next();

		int count1 = 0;
		int count2 = 0;

		for (int i = 0; i <=3; i++) {
			if ( S.charAt(i) == '+') {
				count1 ++;
			} else {
				count2 ++;
			}
		}
		System.out.println( (1*count1) + (-1*count2) );
	}
}

Measured memory_bytes: 21972
import numpy as np

dishes = [int(input()) for _  in range(5)]

time = 0
drem_min = 100
for d in dishes:
	if d%10 == 0:
		tmp = d
	else:
		if d%10 < drem_min:
			drem_min = d%10 
		tmp = (d//10+1)*10
	time += tmp

if drem_min<10:
	time = time - 10 + drem_min
print(time)

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

string s;
int ind=0;
int saiki()
{
	int ret=0;
	vector<int> kati;
	ind++;
	while(1)
	{
		//cerr<<ind<<endl;
		if(s[ind]=='[')
		{
			ind++;
			if(s[ind]=='[')
			{
				ind--;
				int num=saiki();
				kati.push_back(num);
			}else{
				int num=0;
				while(s[ind]!=']')
				{
					num*=10;
					num+=s[ind]-'0';
					ind++;
				}
				kati.push_back(num/2+1);
				ind++;
			}
		}else if(s[ind]==']')
			break;
	}
	ind++;
	sort(kati.begin(),kati.end());
	for(int i=0;i<kati.size()/2+1;i++)
		ret+=kati[i];
	return ret;
}

int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		ind=0;
		cout<<saiki()<<endl;
	}
	return 0;
}


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

int main(){
  string A, B, C; cin >> A >> B >> C;
  int a=A.size();
  int b=B.size();
  if(A.at(a-1)==B.at(0) && B.at(b-1)==C.at(0)){
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}

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

int main(){
  string S;
  cin >> S;
  int ketasuu = S.size();
  int N = stoi(S);
  if (ketasuu == 1) {
    cout << N << endl;
  }
  else if (ketasuu == 2) {
    cout << 9 << endl;
  }
  else if (ketasuu == 3) {
    cout << N - 90 << endl;
  }
  else if (ketasuu == 4) {
    cout << 909 << endl;
  }
  else if (ketasuu == 5) {
    cout << N - 9090 << endl;
  }
  else if (ketasuu == 6) {
    cout << 90909 << endl;
  }
}

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

int main(){
  int n;
  while(cin>>n){
    if(n%39==0){
      cout<<"3C39"<<endl;
    }
    else if(n%39<10){
      cout<<"3C0"<<n%39<<endl;
    }
    else{
      cout<<"3C"<<n%39<<endl;
    }
  }
  return 0;
}
  

Measured memory_bytes: 1160
using System;
using System.Linq;
using static System.Console;

namespace abc103_d
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();
            int m = input[1];
            int[][] arr = new int[m][];

            for(int i=0; i<m; i++){
                int[] tmp = ReadLine().Split().Select(int.Parse).ToArray();
                arr[i] = new int[2];
                arr[i][0] = tmp[0];
                arr[i][1] = tmp[1];
            }

            Array.Sort(arr, (a,b) => a[1]-b[1]);

            int index=0;
            int cnt=0;
            for(int i=0; i<m; i++){
                if(index<arr[i][0]){
                    index = arr[i][1]-1;
                    cnt++;
                }
            }
            WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 23868
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"
#define int ll

using namespace std;
typedef string::const_iterator State;
#define eps 1e-8L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}
int grid[100][100];
int ut[10000];
int uf(int now) {
	if (ut[now] == now) return now;
	return ut[now] = uf(ut[now]);
}
int um(int a, int b) {
	a = uf(a);
	b = uf(b);
	if (a == b) return 0;
	ut[a] = b;
	return 1;
}
void solve() {
	while (true) {
		int n, m;
		cin >> n >> m;
		if (n == 0) return;
		REP(i, n) {
			string s;
			cin >> s;
			REP(q, m) {
				if (s[q] == '.')grid[i][q] = 0;
				else grid[i][q] = 1;
			}
		}
		int ok = 1;
		REP(i, n) {
			REP(q, m) {
				if ((i == 0 or  i == n - 1) and (q == 0 or q == m - 1)) continue;
				int memo = grid[i][q];
				{
					grid[i][q] = 1;
					REP(t, n * m) {
						ut[t] = t;
					}
					REP(t, n) {
						REP(p, m) {
							if (grid[t][p] == 1) continue;
							int xe[4] = { 1,-1,0,0 };
							REP(a, 4) {
								int next_x = t + xe[a];
								int next_y = p + xe[3 - a];
								if (next_x >= 0 and next_x < n and next_y >= 0 and next_y < m) {
									if (grid[next_x][next_y] == 0) {
										um(next_x * m + next_y, t * m + p);
									}
								}
							}
						}
					}
					if (uf(0) != uf(m - 1) or uf(0) != uf((n-1) * m + (m-1)) or uf(0) != uf(m * (n - 1))) {
						ok = 0;
						break;
					}
					grid[i][q] = memo;
				}
			}
			if (ok == 0) break;
		}
		if (ok == 1) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}
#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3216
package main

import "fmt"

func main() {
	grid := make([][]int, 3)

	for i := range grid {
		grid[i] = make([]int, 3)
		if i != 2 {
			fmt.Scanf("%d %d %d\n", &grid[i][0], &grid[i][1], &grid[i][2])
		} else {
			fmt.Scanf("%d %d %d", &grid[i][0], &grid[i][1], &grid[i][2])
		}
	}

	a := make([]int, 3)
	b := make([]int, 3)

	a[0] = 0
	b[0] = grid[0][0]
	b[1] = grid[1][0]
	b[2] = grid[2][0]
	a[1] = grid[0][1] - b[0]
	a[2] = grid[0][2] - b[0]

	flg := true
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			if grid[i][j] == (a[j] + b[i]) {
				continue
			} else {
				flg = false
			}
		}
	}

	if flg {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 1836
#include<bits/stdc++.h>
using namespace std;
#define int long long

int n, x, mod;

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    cin>>n>>x>>mod;

    vector<int> visited(mod);

    vector<int> v;
    int initial_sum = 0;
    int initial_cnt = 0;
    while(true){
        if (visited[x]) break;
        visited[x] = 1;
        initial_sum += x;
        v.push_back(initial_sum);
        initial_cnt++;
        x = (x*x)%mod;
    }

    v.insert(v.begin(), 0);

    vector<int> vc;
    int cycle_sum = 0;
    int cnt = 0;
    for (auto &e:visited) e = 0;
    while(true){
        if (visited[x]) break;
        visited[x] = 1;
        cycle_sum += x;
        vc.push_back(cycle_sum);
        x = (x*x)%mod;
        cnt++;
    }

    vc.insert(vc.begin(), 0);


//
//    for (auto e:v) cout<<e<<" ";
//    cout<<endl;
//    for (auto e:vc) cout<<e<<" ";
//    cout<<endl;

    if (n<=initial_cnt){
        cout<<v[n]<<endl;
    }
    else{
        n -= initial_cnt;
        cout<<initial_sum+(cycle_sum*(n/cnt)+ vc[n%cnt])<<endl;
    }

    return 0;
}





Measured memory_bytes: 5028
#include<bits/stdc++.h>
#define L 1000000000000000000
#define ll long long int
#define ld long double
using namespace std;
int main(void){

  ll ans=1,n,i,c=0;
  cin>>n;
  ll a[n];
  for(i=0;i<n;i++){
    cin>>a[i];
    if(a[i]==0)
    c++;
	}
	if(c>0)
	cout<<0<<endl;
	else{
  for(i=0;i<n;i++){
    if(ans==0)
      continue;
    ll ans2=L/ans;
    if(a[i]>ans2)
      break;
    ans*=a[i];
  //  cout<<ans<<endl;
  }
  if(i<n)
    cout<<-1<<endl;
  else
  cout<<ans<<endl;
  }
}


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<double, int> d_i;

vector<int> bfs(int N, vector<vector<int> >& G, int s) {
	vector<int> d(N, INT_MAX); d[s] = 0;
	queue<int> q; q.push(s);
	while (q.size()) {
		int u = q.front(); q.pop();
		for (int v: G[u])
			if (d[v] > d[u] + 1) {
				d[v] = d[u] + 1;
				q.push(v);
			}
	}
	return d;
}

void dfs_h(int u, int p, vector<vector<int>>& G, vector<int>& h) {
	for (int v: G[u]) if (v != p) dfs_h(v, u, G, h), h[u] = max(h[u], h[v] + 1);
}

int unko = 0;

void dfs_ans(int u, int p, vector<vector<int>>& G, vector<int>& h, vector<int>& ans) {
	int x = -1, y = -1;
	for (int v: G[u]) if (v != p) {
		if (h[v]) {
			if (x != -1) {
				cout << -1 << endl;
				exit(0);
			}
			x = v;
		}
		y = v;
	}
	if (x == -1) x = y;
	if (x != -1) dfs_ans(x, u, G, h, ans);
	int cnt = 0;
	for (int v: G[u]) if (v != p && v != x) cnt++;
	ans.pb(unko + cnt);
	for (int v: G[u]) if (v != p && v != x) ans.pb(unko++);
	unko++;
}

vector<int> solve(int N, vector<vector<int>> G) {
	vector<int> d0 = bfs(N, G, 0);
	int x = 0;
	rep(u, N) if (d0[u] > d0[x]) x = u;
	vector<int> dx = bfs(N, G, x);
	int y = 0;
	rep(u, N) if (dx[u] > dx[y]) y = u;
	vector<int> rs = {x, y};
	vector<int> P = {INT_MAX};
	for (int r: rs) {
		vector<int> h(N);
		dfs_h(r, -1, G, h);
		vector<int> ans;
		unko = 0;
		dfs_ans(r, -1, G, h, ans);
		vector<int> p(N);
		rep(t, N) p[ans[t]] = t;
		P = min(P, p);
	}
	return P;
}

int main() {
	int N; cin >> N;
	vector<vector<int>> G(N);
	rep(i, N - 1) {
		int u, v; scanf("%d%d", &u, &v), u--, v--;
		G[u].pb(v), G[v].pb(u);
	}
	vector<int> p = solve(N, G);
	if (p.empty()) cout << -1 << endl;
	else {
		for (int x: p) printf("%d ", x + 1);
		cout << endl;
	}
}


Measured memory_bytes: 21500
n, m, x = map(int, input().split())
cA = [[int(x) for x in input().split()] for _ in range(n)]

ans = []
for i in range(2**n):
    v = i

    c_sum = 0
    a = [0 for _ in range(m)]
    for j in range(n):
        if v % 2 == 0:
            c_sum += cA[j][0]
            for k in range(m):
                a[k] += cA[j][k + 1]
        v //= 2

    if min(a) >= x:
        ans += [c_sum]

if len(ans) == 0:
    print(-1)
else:
    print(sorted(ans)[0])


Measured memory_bytes: 9132