akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int,int>
#define vvi vector<vector<int> >
#define vpi vector<pii>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 998244353
#define lowbit(x) x&(-x)
#define N 55
using namespace std;
int n,m,cnt=0,num=0,dfsnum[N],low[N];
vector<int> edge[N];
void dfs(int x,int par)
{
	dfsnum[x]=++num;
	low[x]=dfsnum[x];
	for(int i=0;i<edge[x].size();i++)
	{
		if(edge[x][i]==par) continue;
		if(!dfsnum[edge[x][i]])
		{
			dfs(edge[x][i],x);
			low[x]=min(low[x],low[edge[x][i]]);
		}
		else low[x]=min(low[x],dfsnum[edge[x][i]]);
	}
	if(low[x]==dfsnum[x]) cnt++;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	dfs(1,-1);
	cout<<cnt-1<<endl;
	return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
#define INF 1010101010
#define MOD 1000000007

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

    string s;
    cin >> s;
    cin >> s;
    cout << 'A' << s[0] << 'C' << endl;
    cin >> s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<P> v(n);
    rep(i, n)
    {
        int x, y;
        cin >> x >> y;
        v[i] = P(y, x);
    }
    sort(all(v));
    int now = 0;
    rep(i, n)
    {
        P p = v[i];
        int y = p.first, x = p.second;
        now += x;
        if (now > y)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D,N;
  cin >> D >> N;
  
  if (D==0) {
    if (N<100) {
      cout << N << endl;
    }
    else {
      cout << 101 << endl;
    }
  }
  
  if (D==1) {
    if (N<100) {
      cout << N*100 << endl;
    }
    else {
      cout << 10100 << endl;
    }
  }
  
  if (D==2) {
    if (N<100) {
      cout << N*10000 << endl;
    }
    else {
      cout << 1010000 << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main(){
    int n;
    cin >> n;
    int i = 1;
    while(i*i<=n)i++;
    i--;
    cout << i*i << endl;
    return 0;
}

Measured memory_bytes: 256
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Name        : Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define ff first
#define ss second
#define endl '\n'
#define INF 1e9 + 1
#define _INF INT32_MIN
#define pq priority_queue
#define MM multimap
#define PB push_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL gcd(LL a,LL b) {
	return !b ? a : gcd(b, a % b);
}
LL LCM(LL a, LL b) {
	return (a*b) / gcd(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		//printf("%d ", 2);
//		aa.insert(2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			//printf("%d ", i);
			//aa.insert(i);
			n /= i;
		}
	}
	if (n > 2){
		//printf("%d ", n);
	//	aa.insert(n);
	};
}
bool is_square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
LL power(LL x, LL y)
{
	LL temp;
	if (y == 0)return 1;
	temp = power(x, y / 2);
	if (y % 2 == 0)
		return temp*temp;
	else return x*temp*temp;
}
bool is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
const int N = 105;
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	int n,k;
	cin >> n>>k;
	vector<int>a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a.begin(), a.end());
	int ans = INF;
	for (int i = 0; i < n - k + 1; i++)
	{
		int aa = a[i];
		int b = a[i + k - 1];
		int val = b - aa + min(abs(aa), abs(b));
		ans = min(ans, val);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int a,b,c,count;
    count=0;
    cin>>a>>b>>c;
    for(int i=a;i<b+1;i++){
        if(i != 0 && c%i==0){
            count++;
        }
    }
    cout<<count<<endl;
    }

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+5;
typedef long long ll;
int a[maxn];

int main(){
	int n; cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	int sum = 0, now = 1, flag = 0;
	for(int i = 1; i <= n; i++){
		if(a[i] == now) now++, flag = 1;
		else sum++;
	}
	if(flag == 0) sum = -1;
	cout <<  sum;
}

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

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	n=int(io())
	s=io()[:n]
	ret='No'
	rr=sum([1 for c in s if c == 'R'])
	if rr > n - rr:
		ret='Yes'
	return ret

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	print (main(io))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,i,j;
    cin>>n;
    string s;
    int hash[n][26];
    memset(hash,0,sizeof(hash));
    for (i=0;i<n;i++)
    {
        cin>>s;
        for (j=0;j<s.size();j++)
            hash[i][s[j]-'a']++;
    }
    int com;
    string ans="";
    for (j=0;j<26;j++)
    {
        com=hash[0][j];
        for (i=0;i<n;i++)
            com=min(com,hash[i][j]);
        for (i=0;i<com;i++)
            ans+=(char)(97+j);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#define enld '\n'
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<ll> x(N),y(N);
  for(int i=0; i<N; i++){
    cin >> x[i] >> y[i];
  }
  map<pair<ll,ll>,int> mp;
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      ll p = x[j] - x[i];
      ll q = y[j] - y[i];
      if(p < 0){
        p *= -1;
        q *= -1;
      }
      if(p == 0) q = abs(q);
      if(q == 0) p = abs(p);
      mp[P(p,q)]++;
    }
  }
  int mx = 0;
  for(auto m: mp){
    chmax(mx,m.second);
  }
  cout << N-mx << "\n";
  return 0; 
}


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

int main(){
      string s;cin >> s;
      if(s[0] == s[1] && s[1] == s[2] ||
            s[1] == s[2] && s[2] == s[3] ||
            s[0] == s[1] && s[1] == s[2] && s[2] == s[3]){
                  cout << "Yes";
            }
      else cout << "No";
}

Measured memory_bytes: 256
import math

if __name__ == "__main__":
    A, B = map(int, input().split())
    a = math.ceil(A / 0.08)
    b = math.ceil(B / 0.1)
    # print(a , b)
    if math.floor(a * 0.08) == A and math.floor(a * 0.1) == B:
        ret = a
    elif math.floor(b * 0.08) == A and math.floor(b * 0.1) == B:
        ret = b
    else : 
        ret = -1
    print(ret)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;

ll func( long xx[40][2], ll k )
{
    ll sum=0;
    long i;
    for(i=0; i<40; i++) {
        long curr= (k & ((ll)1<<i)? 1: 0);
        sum += ((ll)xx[i][1-curr]<<i);
    }
    return sum;
}

int main(int argc, char* argv[])
{
    long n;
    ll   k;
    scanf("%ld%lld", &n, &k);

    vector<ll> a(n);
    long i, j;
    for(i=0; i<n; i++) {
        scanf("%lld", &a[i]);
    }

    long xx[40][2]={0};
    ll   c=0;
    for(j=0; j<40; j++) {
        for(i=0; i<n; i++) {    
            xx[j][(a[i]>>j)&1]++;
        }
        c += (xx[j][0]<=xx[j][1]? 0: (ll)1<<j);
    }

    ll max= func( xx, k );
    for(i=0; i<40; i++) {
        if( k & ((ll)1<<i) ) {
            ll  k2 = k - k % ((ll)1<<(i+1));
            k2 += c % ((ll)1<<i);
            ll tmp = func( xx, k2 );
            max = MAX(max, tmp);
        }
    }

    printf("%lld\n", max);

    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;

int main(){
    int N; cin >> N;
    vector<ll> X(N); REP(i, N) cin >> X[i];
    vector<ll> X_tmp(N); X_tmp = X;

    sort(all(X_tmp));

    int cnt = N / 2;
    int hantei = X_tmp[cnt];
    for(int i = 0; i < N; ++i) {
        if(X[i] < hantei) {
            cout << X_tmp[cnt] << endl;
        } else {
            cout << X_tmp[cnt - 1] << endl;
        }
    }
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000


int main(){
  int n,c,k;
  cin >> n >> c >> k;
  vint A(n);
  rep(i,n) cin >> A[i];
  sort(A.begin(),A.end());
  int ans = 1;
  int border = A[0];
  int num = 1;
  //cout << num << " " << border << " " << ans << endl;
  rep1(i,n){
    if(num == c){
      num = 1;
      border = A[i];
      ans++;
    }
    else if(A[i]-border <= k) num++;
    else{
      num = 1;
      border = A[i];
      ans++;
    }
    //cout << num << " " << border << " " << ans << endl;
  }
  cout << ans << endl;
}




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

int main() {
	int N;
	cin >> N; 
	int l = 0;
	int r = 0;
	int ans = 1001001001;
	vector<int>W(N);
	for (int n = 0; n < N; ++n) {
		cin >> W[n];
		l += W[n];
	}
	ans = min(ans, abs(l - r));
	for (int n = 0; n < N; ++n) {
		l -= W[n];
		r += W[n];
		ans = min(ans, abs(l - r));

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

Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pairs;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}


const double PI = acos(-1);
const int M = 1000005;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i = 0; i<n; i++){
        cin>>a[i];
    }
    vector<ll> cnt(M);
    for(ll j : a){
        if(cnt[j] != 0){
            cnt[j] = 2;
            continue;
        }
        for(ll i = j; i<M; i+=j){
            cnt[i]++;
        }
    }
    ll ans = 0;
    for(ll j : a){
            if(cnt[j] == 1) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 12756
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long
 
const int N = 18;
 
int n;
vector <int> a, ans[1 << 18];
 
void add(vector <int> &c, int x){
    for(auto &i : c) if(i == x) return;
    c.push_back(x);
    sort(c.begin(), c.end(), [&](int l, int r){
        return a[l] > a[r];
    });
    while(c.size() > 2) c.pop_back();
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    a.resize(1 << n);
    for(auto &i : a) cin >> i;
    for(int i = 0 ; i < (1 << n) ; i++){
        add(ans[i], i);
    }
    for(int i = 1 ; i < (1 << n) ; i++){
        for(int j = 0 ; j < n ; j++){
            if((i >> j) & 1){
                for(auto &k : ans[i ^ (1 << j)]){
                    add(ans[i], k);
                }
            }
        }
    }
    int res = 0;
    for(int i = 1 ; i < (1 << n) ; i++){
        res = max(res, a[ans[i][0]] + a[ans[i][1]]);
        cout << res << "\n";
    }
}


Measured memory_bytes: 18432
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{

  string s;
  cin >> s;
  int len = s.size();
  for (int i = 0; i < (1 << (len-1)); i++) {
    int v = s[0]-'0';

    for (int j = 0; j < (len-1); j++) {
      if (i & (1 << j)) {
        v += (s[j + 1]-'0');
      } else {
        v -= (s[j + 1]-'0');
      }
    }

    if (v == 7) {
      string ans = "";
      ans += s[0];

      for (int j = 0; j < (len-1); j++) {
        if (i & (1 << j)) {
          ans += "+";
          ans += s[j + 1];
          v += (s[j + 1]-'0');
        } else {
          ans += "-";
          ans += s[j + 1];
        }
      }
      printf("%s=7\n", ans.c_str());
      return 0;
    }
  }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>
#include<limits>
#include <unordered_map>
#include <numeric>
#include <array>
#include <queue>
#include <chrono>
#include <random>
#include <fstream>


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

#define rep(i,n,m) for(long long int i=n;i<(long long int)(m);i++)
#define INF (1<<29)
#define MD 1000000007




int main() {

	
	long n, k;
	cin >> n >> k;
	long cnt = 0;
	long s = k - 1;

	vector<long>num(n);

	rep(i, 0, n)cin >> num[i];

	if (n == k) {
		cout << "1" << endl;
		return 0;
	}
	vector<long>::iterator minIt = min_element(num.begin(), num.end());
	size_t minIndex = distance(num.begin(), minIt);

	long dis_first = (long)minIndex;
	long dis_last = n - (long)minIndex - 1;

	if (minIndex < s || n - k < minIndex) {
		long start = s;
		long dis = n - k;
		cnt++;

		cnt += (long)(dis / s);
		if (dis % s != 0)cnt++;
		cout << cnt << endl;
		return 0;
	}
	
	
	
	

	cnt += (long)(dis_first / s);
	

	cnt += (long)(dis_last / s);
	if (dis_last % s != 0 || dis_first % s != 0)cnt++;


	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 1024
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
int n,x,lg,ans;
int main(){
	scanf("%d",&n);
	int now;
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		lg=log2(x);
		if(x&(x-1)) now>lg?now=lg:++lg;
		if(lg>now) ans+=lg-now,now=lg;
		if(lg<now) now=lg;
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
//作者:中国江苏南京丁天行
using namespace std;
int n,k,a[200005],p[200005],s,ans;
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)scanf("%d",a+i);
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++){
        if(i==1||a[i]!=a[i-1])s++;
        p[s]++;
    }
    if(s<=k){
        puts("0");
        return 0;
    }
    sort(p+1,p+s+1);
    for(int i=1;i<=s-k;i++)ans+=p[i];
    printf("%d\n",ans);
	//system("pause");
	return 0;
}


Measured memory_bytes: 1792
// To the MOTHER OF DRAGONS	

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define ld long double
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define PI 3.14159265358979323846
#define all(x) x.begin(), x.end()
#define deb(x) cout << ">> " << #x << " : " << x << endl;
#define RAGE ios::sync_with_stdio(0); cin.tie(0);

void solve()
{
	ll x;
	cin >> x;
	ll ans = 0;
	ans += (x / 500) * 1000;
	x = x % 500;
	ans += (x / 5) * 5;
	cout << ans;
}

int main()
{
	RAGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ll t;
	//cin >> t;
	//while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define MAX 1000

int max(int a, int b)
{
	if(a>b) return a;
	else return b;
}

int main(void)
{
	int i, j, q, Xlen, Ylen, l[MAX+1][MAX+1];
	char X[MAX+1], Y[MAX+1];
	
	scanf("%d",&q);
	while (q--) {
		scanf("%s",X);
		scanf("%s",Y);
		Xlen = strlen(X);
		Ylen = strlen(Y);
		for (i=0; i<=Xlen; i++) {
			for (j=0; j<=Ylen; j++) {
				if (i==0 || j==0) {
					l[i][j] = 0;
				} else if (X[i-1] == Y[j-1]) {
					l[i][j] = l[i-1][j-1] + 1;
				} else {
					l[i][j] = max(l[i-1][j], l[i][j-1]);
				}
			}
		}
		printf("%d\n", l[Xlen][Ylen]);
	}
	
	return 0;
}

Measured memory_bytes: 4516
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;

	if (y + r > h || x + r > w || x < 0 || y < 0)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
}




Measured memory_bytes: 3232
from collections import defaultdict
n, k = list(map(int, input().split()))
d = defaultdict(int)
for i in range(n):
    a, b = list(map(int, input().split()))
    d[a] += b
cnt = 0
for i, j in sorted(list(d.items())):
    if cnt < k <= cnt+j:
        print(i)
        exit()
    cnt += j

Measured memory_bytes: 15336
#include <iostream>
#define ll long long
using namespace std;

int main(){
	ll a[2],b[2];
	cin>>a[0]>>a[1]>>b[0]>>b[1];
	
	
	ll ans = -1*(1e9*1LL*1e9);
	if(a[0]*a[1]<=0){
		ans=0;
	}
	if(b[0]*b[1]<=0){
		ans=0;
	}
	for(int i=0;i<2;++i){
		for(int j=0;j<2;++j){
			ans = max(ans,a[i]*b[j]);
		}
	}
	cout<<ans;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
   
    int n;
    cin>>n;
    vector<vector<pair<int,long long>>> tree(n+1);
    
    for(int i=0; i<n-1; i++){
        int x,y;
        long long c;
        cin>>x>>y>>c;
        tree[x].push_back({y,c});
        tree[y].push_back({x,c});
    }
    int cent=-1;
    vector<int> preds(n+1,-1), cts(n+1,0);
    
    stack<int> st;
    st.push(1);
    preds[1]=0;
    while(st.size() && cent==-1){
        int cur=st.top();
        for(auto p:tree[cur]){
            if(preds[p.first]==-1){
                preds[p.first]=cur;
                st.push(p.first);
            }
        }
        if(st.top()==cur){
            cts[cur]++;
            int test=n-cts[cur];
            for(auto p:tree[cur]){
                test=max(test,cts[p.first]);
            }
            if(test<=n/2) cent=cur;
            
            cts[preds[cur]]+=cts[cur];
            st.pop();
        }
    }
    
    fill(cts.begin(),cts.end(),0), fill(preds.begin(),preds.end(),-1);
    while(st.size()){
        st.pop();
    }
    st.push(cent);
    /*for(int i=1; i<=n; i++){
        cout<<i<<" "<<cts[i]<<endl;
    }*/
    preds[cent]=0;
    while(st.size()){
        int cur=st.top();
        for(auto p:tree[cur]){
            if(preds[p.first]==-1){
                preds[p.first]=cur;
                st.push(p.first);
            }
        }
        //cout<<cur<<endl;
        if(st.top()==cur){
            cts[cur]++;
            cts[preds[cur]]+=cts[cur];
            
            //cout<<cur<<" "<<cts[cur]<<endl;
            st.pop();
        }
    }
    /*
    for(int i=1; i<=n; i++){
        cout<<i<<" "<<cts[i]<<endl;
    }
    */
    //cout<<cent<<endl;
    vector<long long> dists(n+1,-1);
    dists[cent]=0;
    queue<int> q;
    q.push(cent);
    while(q.size()){
        int cur=q.front();
        q.pop();
        for(auto p: tree[cur]){
            if(dists[p.first]==-1){
                dists[p.first]=dists[cur]+p.second;
                q.push(p.first);
            }
        }
    }
    
    long long ans=0;
    
    for(int i=1;i<=n; i++){
        ans+=dists[i];
        //cout<<i<<" "<<dists[i]<<endl;
    }
    ans*=2; 
    if(!(n%2)){
        for(auto p:tree[cent]){
            //cout<<p.first<<" "<<cts[p.first]<<endl;
            
            if(cts[p.first]==n/2){
                //cout<<"hi"<<endl;
                cout<<ans-p.second;
                return 0;
            }
            
        }
    }
    
    long long m1=MOD;
    for(auto p:tree[cent]){
        m1=min(m1,p.second);
    }
    
    
    
    
    
    cout<<ans-m1;
    
    
    return 0;
}

Measured memory_bytes: 9856
import numpy as np
n, m = list(map(int, input().split()))

a = np.array(list(map(int, input().split())))

total = np.sum(a)
#print(len(a[a>=total/(4*m)]))

if len(a[a>=total/(4*m)])>=m:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 21536
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int[] nums = new int[N];
        int count = 0;
        for (int i = 0; i < N; i++) {
            nums[i] = sc.nextInt();
        }

        Arrays.sort(nums);
        if(nums[N/2-1] == nums[N/2]){
            System.out.println(0);
        }else{
            System.out.println(nums[N/2]-nums[N/2-1] );
        }


    }

}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

//////////////////ここの値は必ず確認！！！！！////////////////////
//---------------------------------------------------------//
const int MOD = 1e9+7;
const int MAXR = 510000;
//---------------------------------------------------------//

template<ll mod> class modint{
public:
    ll val=0;
    //コンストラクタ
    modint(ll x=0){while(x<0)x+=mod;val=x%mod;}
    //コピーコンストラクタ
    modint(const modint &r){val=r.val;}
    //算術演算子
    modint operator -(){return modint(-val);} //単項
    modint operator +(const modint &r){return modint(*this)+=r;}
    modint operator -(const modint &r){return modint(*this)-=r;}
    modint operator *(const modint &r){return modint(*this)*=r;}
    modint operator /(const modint &r){return modint(*this)/=r;}
    //代入演算子
    modint &operator +=(const modint &r){
        val+=r.val;
        if(val>=mod)val-=mod;
        return *this;
    }
    modint &operator -=(const modint &r){
        if(val<r.val)val+=mod;
        val-=r.val;
        return *this;
    }
    modint &operator *=(const modint &r){
        val=val*r.val%mod;
        return *this;
    }
    modint &operator /=(const modint &r){
        ll a=r.val,b=mod,u=1,v=0;
        while(b){
            ll t=a/b;
            a-=t*b;swap(a,b);
            u-=t*v;swap(u,v);
        }
        val=val*u%mod;
        if(val<0)val+=mod;
        return *this;
    }
    //等価比較演算子
    bool operator ==(const modint& r){return this->val==r.val;}
    bool operator <(const modint& r){return this->val<r.val;}
    bool operator !=(const modint& r){return this->val!=r.val;}
};

using mint = modint<MOD>;

//入出力ストリーム
istream &operator >>(istream &is,mint& x){//xにconst付けない
    ll t;is >> t;
    x=t;
    return (is);
}
ostream &operator <<(ostream &os,const mint& x){
    return os<<x.val;
}

//累乗
mint modpow(const mint &a,ll n){
    if(n==0)return 1;
    mint t=modpow(a,n/2);
    t=t*t;
    if(n&1)t=t*a;
    return t;
}

//二項係数の計算
mint fac[MAXR+1],finv[MAXR+1],inv[MAXR+1];
//テーブルの作成
void com_init() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    FOR(i,2,MAXR){
        fac[i]=fac[i-1]*mint(i);
        inv[i]=-inv[MOD%i]*mint(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}
//演算部分
mint com(ll n,ll k){
    if(n<k)return 0;
    if(n<0)return 0;
    if(k==0) return 1;
    return fac[n]*finv[k]*finv[n-k];
}

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

    if(abs(N-M) > 1) cout << 0 << endl;
    else if(abs(N-M) == 1) cout << fac[N] * fac[M] << endl;
    else cout << fac[N] * fac[M] * (mint)2 << endl;

    return 0;
}

Measured memory_bytes: 15580
scores = list(map(int, input().split()))
while scores != [-1, -1, -1]:
    if scores[0] == -1 or scores[1] == -1:
        print('F')
    elif scores[0] + scores[1] >= 80:
        print('A')
    elif scores[0] + scores[1] >= 65:
        print('B')
    elif scores[0] + scores[1] >= 50:
        print('C')
    elif scores[0] + scores[1] >= 30:
        if scores[2] >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')
    scores = list(map(int, input().split()))


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

#define rep(i,n) for(int i = 0;i < n; i++)
using namespace std;

int main() {
    int n,m,l,r,c_l,c_r;
    cin >> n >> m;
    cin >> c_l >> c_r;
    rep(i,m - 1){
        cin >> l >> r;
        if((c_r < l && c_l < r) || (c_r > l && c_l > r)){
            cout << 0 << endl;
            return 0;
        }
        c_l = min(c_l,l,greater<int>());
        c_r = min(c_r,r);
    }
    cout << c_r - c_l + 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
char board[12][12];

void f(int y,int x){
	board[y][x] = '\0';
	int dx[] = {0,-1,1,0},dy[] = {1,0,0,-1};
	for(int i = 0;i < 4;++i){
		int tx = x + dx[i],ty = y + dy[i];
		if(-1 < tx && tx < 12 && -1 < ty && ty < 12){
			if(board[ty][tx] == '1') f(ty,tx);
		}
	}
	return;
}

int main(){
	int c;
	char a[13];
	while(cin >> a){
		c = 0;
		if(a[0] == ' ') continue;
		else for(int i = 0;i < 12;++i) board[0][i] = a[i];
		for(int i = 1;i < 12;++i){
			cin >> board[i];
		}
		for(int i = 0;i < 12;++i){
			for(int j = 0;j < 12;++j){
				if(board[i][j] == '1'){
					f(i,j);
					++c;
				}
			}
		}
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include<string>
#include<vector>
using namespace std;
int main(void){
    int n,a[110000],ans=-1,t=1,w;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        w=a[t-1];
        t=w;
        if(t==2){ans=i+1;break;}
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<typename T> // key
struct RadixHeap{
	vector<pair<ll, T>> v[50];
	ll last;
	int size;
	inline int bsr(ll x){
		if(x==0) return -1;
		else return 63-__builtin_clzll(x);
	}
	RadixHeap():last(0), size(0){}
	bool empty(){
		return size==0;
	}
	void push(ll val, T key){
		size++;
		v[bsr(val^last)+1].push_back({val, key});
	}
	pair<ll, T> pop(){
		size--;
		if(!v[0].empty()){
			auto ret=v[0].back();
			v[0].pop_back();
			return ret;
		}
		int k=1;
		while(v[k].empty()) k++;
		ll minval=v[k][0].first;
		T minkey=v[k][0].second;
		for(auto p:v[k]){
			if(p.first<minval){
				minval=p.first;
				minkey=p.second;
			}
		}
		last=minval;
		bool myon=1;
		for(auto p:v[k]){
			if(myon && p.first==minval && p.second==minkey){
				myon=0;
				continue;
			}
			v[bsr(p.first^last)+1].push_back(p);
		}
		v[k].clear();
		return make_pair(minval, minkey);
	}
};
int main()
{
	int n, m, s;
	cin>>n>>m>>s;
	vector<P> g[51];
	int a[101]; ll b[101];
	for(int i=0; i<m; i++){
		int u, v; cin>>u>>v>>a[i]>>b[i];
		u--; v--;
		g[u].push_back({v, i});
		g[v].push_back({u, i});
	}
	int c[55]; ll d[55];
	for(int i=0; i<n; i++) cin>>c[i]>>d[i];
	ll dp[51][2525];
	const int mx=2500;
	s=min(s, mx);
	const ll INF=1e18;
	for(int i=0; i<n; i++){
		for(int j=0; j<=mx; j++){
			dp[i][j]=INF;
		}
	}
	RadixHeap<P> que;
	dp[0][s]=0;
	que.push(0, P(0, s));
	while(!que.empty()){
		auto p=que.pop();
		int x=p.second.first, y=p.second.second;
		if(p.first>dp[x][y]) continue;
		int y1=min(mx, y+c[x]);
		if(dp[x][y1]>dp[x][y]+d[x]){
			dp[x][y1]=dp[x][y]+d[x];
			que.push(dp[x][y1], P(x, y1));
		}
		for(auto q:g[x]){
			int x1=q.first, k=q.second;
			if(y<a[k]) continue;
			if(dp[x1][y-a[k]]>dp[x][y]+b[k]){
				dp[x1][y-a[k]]=dp[x][y]+b[k];
				que.push(dp[x1][y-a[k]], P(x1, y-a[k]));
			}
		}
	}
	for(int i=1; i<n; i++){
		ll ans=INF;
		for(int j=0; j<=mx; j++){
			ans=min(ans, dp[i][j]);
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 8420
"""Can't Wait for Holiday
https://atcoder.jp/contests/abc146/tasks/abc146_a
"""
S = input()
day_until_holiday = {'SUN': 7, 'MON': 6, 'TUE': 5, 'WED': 4, 'THU': 3, 'FRI': 2, 'SAT': 1}
print(day_until_holiday.get(S))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<int>
using namespace std;
using ll = long long;

int main(){
    string s;
    cin>>s;
    string t="\0";

    rep(i,0,s.size()){
        if(s[i]=='0'||s[i]=='1'){
            t.push_back(s[i]);
        }
        if(s[i]=='B'){
            if(t.size()!=0) t.erase(t.size()-1);
        }
    }
    cout<<t<<endl;
}

Measured memory_bytes: 256
def convert_time str
    h, m = str.split(":").map(&:to_i)
    h * 60 + m
end

while true
    n = gets.to_i
    break if n == 0

    hsh = Hash.new{|h, k| h[k] = [0, nil]}
    arr, mode = [], false
    n.times{
        date, time, io, id = gets.chomp.split(" ")
        if id == "000"
            if io == "I"
                arr.each{|pg| hsh[pg][1] = convert_time(time)}
            else
                arr.each{|pg| hsh[pg][0] += (convert_time(time) - hsh[pg][1])}
            end
            mode = !mode
        else
            if io == "I"
                hsh[id][1] = convert_time(time) if mode
                arr << id
            else
                hsh[id][0] += (convert_time(time) - hsh[id][1]) if mode
                arr.delete id
            end
        end
    }
    arr = hsh.to_a.sort_by{|k, v| -v[0]}
    puts (arr.empty? ? 0 : arr[0][1][0])  
end


Measured memory_bytes: 6936
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>

typedef int32_t i32;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

i32 eval (char *s, i32 *x, i32 *k) {
  if (s[*k] != '[') {
    i32 res = x[s[*k] - 'a'];
    *k += 1;
    return res;
  }
  i32 op = s[*k + 1];
  *k += 2;//[ op
  i32 l = eval (s, x, k);
  i32 r = eval (s, x, k);
  i32 res = 0;
  if (op == '+') {
    res = l | r;
  } else if (op == '*') {
    res = l & r;
  } else {
    res = l ^ r;
  }
  *k += 1;//]
  return res;
}

void loop (i32 p, i32 *x, char *s, i32 *cnt) {
  if (p == 4) {
    i32 k = 0;
    cnt[eval (s, x, &k)]++;
    return;
  }
  for (x[p] = 0; x[p] < 10; x[p]++) {
    loop (p + 1, x, s, cnt);
  }
}

void run (void) {
  char *s = ALLOC (80 + 1, char);
  char *d = ALLOC (4 + 1, char);
  i32 *cnt = ALLOC (16, i32);
  for (;;) {
    scanf ("%s", s);
    if (s[0] == '.') break;
    scanf ("%s", d);
    i32 x[4];
    for (i32 i = 0; i < 4; ++i) {
      x[i] = d[i] - '0';
    }
    i32 k = 0;
    const i32 v = eval (s, x, &k);
    memset (cnt, 0, sizeof (i32) * 16);
    loop (0, x, s, cnt);
    printf ("%" PRIi32 " %" PRIi32 "\n", v, cnt[v]);
  }
}

int main (void) {
  run();
  return 0;
}



Measured memory_bytes: 2040
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

int main()
{
  int n,i,j;
  scanf("%d", &n);
  //printf("%d\n", n);
  double sqr = sqrt(n);
  int result = 0;
  for(i = 1;i < n; i++){
    for(j = 1;j < n; j++){
      if(i*j < n){
        result = result + 1;
      }else{
        break;
      }
    }
  }
  printf("%d\n", result);
  return 0;
}

Measured memory_bytes: 2152
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int64_t N, A, B;
  cin >> N >> A >> B;
  cout << (N / (A + B) * A + min(N % (A + B), A)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    int t;
    cin>>t;
    map<string,int> m;
    while(t--){
        string s;
        cin>>s;
        m[s]++;
    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;
    return 0;
}

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

int main(){
    ll n;
    cin >> n;
    vector<ll> x(n),y(n);
    for(int i=0; i<n; i++){
        cin >> x.at(i) >> y.at(i);
    }
    ll zmax=0,zmin=pow(10,9),wmax=-pow(10,9),wmin=pow(10,9);
    for(int i=0; i<n; i++){
        zmax=max(zmax, x.at(i)+y.at(i));
        zmin=min(zmin, x.at(i)+y.at(i));
        wmax=max(wmax, x.at(i)-y.at(i));
        wmin=min(wmin, x.at(i)-y.at(i));
    }
    cout << max(zmax-zmin, wmax-wmin) << endl;
}

Measured memory_bytes: 6412
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string S;
    cin >> S;

    rep(i, S.size()) {
        cout << 'x';
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
class ProgramD
    {
        static void Main(string[] args)
        {
            
            //入力
            int k = int.Parse(Console.ReadLine());
            var q = new Queue<long>();

            for(int i = 0;i < 9;i++)
                q.Enqueue(i+1);
            
            long temp = 0;

            for(int i = 0; i < k;i++)
            {
                temp = q.Dequeue();
                if(temp % 10 == 0)
                {
                    q.Enqueue(temp*10);
                    q.Enqueue(temp*10 + 1);
                }
                else if(temp % 10 == 9)
                {
                    q.Enqueue(temp*10 + 8);
                    q.Enqueue(temp*10 + 9);
                }
                else
                {
                    q.Enqueue(temp*10 + temp % 10 - 1);
                    q.Enqueue(temp*10 + temp % 10);
                    q.Enqueue(temp*10 + temp % 10 + 1);
                }
                

            }

            Console.WriteLine(temp);
            
        }
 
    }

Measured memory_bytes: 15072
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	vvi cost(100, vi(100, INF));

	int n;
	cin >> n;
	int r, k, t;
	REP(i, n) {
		cin >> r >> k;
		REP(j, k) {
			cin >> t;
			cost[r-1][t-1] = 1;
		}
	}

	REP(k, 100) {
		REP(i, 100) {
			REP(j, 100) {
				cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j]);
			}
		}
	}

	cin >> n;
	REP(i, n) {
		cin >> r >> k >> t;
		if(cost[r-1][k-1]+1 <= t) {
			cout << cost[r-1][k-1]+1 << endl;
		} else {
			cout << "NA" << endl;
		}
	}

    return 0;
}

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

int main(int, char**) {
    int x, y;
    cin >> x >> y;
    while( (!(x == 0 && y == 0)) )
    {
        if( x > y ) cout << y << " " <<  x << endl;
        else cout << x << " " << y << endl;
        cin >> x >> y;
    }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    int n;
    cin >> n;
    if (n < 1200) {
        cout << "ABC" << endl;
    } else { 
        cout << "ARC" << endl; 
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  int a[n+1]={};
  int m=100,M=-100;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    m=min(m,a[i]);
    M=max(M,a[i]);
  }
  int ans=MOD;
  for(int i=m;i<=M;i++){
    int tmp=0;
    for(int j=1;j<=n;j++){
      tmp+=(i-a[j])*(i-a[j]);
    }
    ans=min(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

/*------------------------------------------------------------------------*/

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}
void solve() {
    ld w, h, x, y;
    std::cin >> w >> h >> x >> y;

    std::cout << h * w / 2 << '\n';
    std::cout << (x == w / 2 && y == h / 2) << '\n';
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    string s;cin>>s;
    int cnt=0;
    rep(i,s.size()-1){
        if(s[i]!=s[i+1])cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	int m;
	cin>>n;
	int a[n+1]={0};
	for(int i=1;i<=n-1;i++){
		cin>>m;
		a[m]++;
	}
	for(int i=1;i<=n;i++){
		cout<<a[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin>>N>>K;
  vector<int>vec(N);
  for(int X=0;X<N;X++){
    cin>>vec.at(X);
  }
  if((N-1)%(K-1)==0){
    cout<<(N-1)/(K-1)<<endl;
  }
  else{
    cout<<(N-1)/(K-1)+1<<endl;
  }
}

Measured memory_bytes: 3764
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    N = 200000
    f = [1]*N
    p = 2
    prime = []
    while p < N:
        while p < N and not f[p]:
            p += 1
        if p >= N:
            break
        j = 2*p
        prime.append(p)
        while j < N:
            f[j] = 0
            j += p
        p += 1
    x = I()
    print(prime[bisect.bisect_left(prime,x)])
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 42864