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

int D, G;
int p[12], c[12];

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> D >> G;
    rep(i, D) cin >> p[i] >> c[i];
    
    int ans = 100000;
    rep(S, 1<<D) {
        int ans_cand = 0;
        int now = 0;
        rep(i, D) {
            if ((S>>i)&1) {
                ans_cand += p[i];
                now += 100*(i+1)*p[i]+c[i];
            }
        }
        if (now>=G) {
            ans = min(ans, ans_cand);
            continue;
        }
        for (int i=D-1; i>=0; i--) {
            if (!((S>>i)&1)) {
                if (now+100*(i+1)*(p[i]-1)<=G) {
                    ans_cand += p[i]-1;
                    now += 100*(i+1)*(p[i]-1);
                }
                else {
                    int need = (G-now)/(100*(i+1));
                    ans_cand += need;
                    now += 100*(i+1)*need;
                }
            }
        }
        if (now>=G) ans = min(ans, ans_cand);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

string s="CODEFESTIVAL2016";

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string t;
    cin>>t;
    
    int cnt=0;
    rep(i,16){
        if(s[i]!=t[i]) cnt++;
    }
    cout1(cnt)
}

Measured memory_bytes: 256
#include <algorithm>
#include <iterator>
#include <vector>
#include <iomanip>
#include <iostream>
#include <stack>
#include <queue>
#include <list>
#include <utility>
 
#include <string>
#include <cstring>
 
#include <cstdio>
#include <cassert>
 
// M_PI for pi
#define _USE_MATH_DEFINES
#include <cmath>
 
using namespace std;
 
static const int MAX = 100005;

int v[MAX];
int u[MAX];
int n;

int t;

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

    cin >> n;

    for (int i = 0; i < n; ++i) {
        cin >> t;

        v[i] = t;
        u[i] = t;
    }

    sort(v, v + n);

    int d = 0;
    int c = 0;
    
    for (int i = 0; i < n; ++i) {
        if (i % 2 == 0) {
            continue;
        }

        d = find(v, v+n, u[i]) - v;

        if (d % 2 == 0) {
            c++;
        }
    }

    cout << c << endl;


    //for (int i = 0; i < ne; ++i) {
    //    cout << ve[i] << endl;
    //}
    //cout << endl;
    //for (int i = 0; i < no; ++i) {
    //    cout << vo[i] << endl;
    //}
    //cout << ne << " " << no << endl;


    //bool f = true;

    //while (f) {
    //    f = false;

    //    for (int i = 0; i < n-2; ++i) {
    //        if (v[i] > v[i+2]) {
    //            swap(v[i], v[i+2]);
    //            f = true;
    //        }
    //    }
    //}

    //int c = 0;
    //bool f = true;

    //while (f) {
    //    f = false;

    //    for (int i = 0; i < n-1; ++i) {
    //        if (v[i] > v[i+1]) {
    //            swap(v[i], v[i+1]);
    //            f = true;
    //            c += 1;
    //        }
    //    }
    //}



    ////for (int i = 0; i < n; ++i) {
    ////    cout << v[i] << endl;
    ////}

    //cout << c << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>A>>B>>C>>N;
    ll ans = 0;
    rep(i,A+1){
        rep(j,B+1){
            rep(k,C+1){
                ans += N == i*500 + j*100 + k*50;
            }
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main(){
    int n,t=0,h=0;
    string s1,s2;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s1>>s2;
        if(s1>s2)t+=3;
        else if(s1<s2)h+=3;
        else{
            t++;
            h++;
        }
    }
    cout<<t<<" "<<h<<endl;

    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <string>
#include <sstream>
#include <set>

using namespace std;

int main(int argc, char *argv[]) {
  int n, h, s, t;
  string sur;
  while (true) {
    cin >> n >> h;
    if (n == 0 && h == 0)
      break;

    set<string> points;
    long long cube = n * n * n;
    for (int i = 0; i < h; i++) {
      cin >> sur >> s >> t;
      ostringstream os;
      string emptystr = "";
      if (sur == "xy")
        for (int j = 0; j < n; j++) {
          os << s << ' ' << t << ' ' << 1+j;
          string hoge = os.str();
          os.str(emptystr);
          os.clear();
          if (points.find(hoge) == points.end()) {
            cube--;
            points.insert(hoge);
          }
      }
      else if (sur == "xz")
        for (int j = 0; j < n; j++) {
          os << s << ' ' << 1+j << ' ' << t;
          string hoge = os.str();
          os.str(emptystr);
          os.clear();
          if (points.find(hoge) == points.end()) {
            cube--;
            points.insert(hoge);
          }
        }
      else if (sur == "yz")
        for (int j = 0; j < n; j++) {
          os << 1+j << ' ' << s << ' ' << t;
          string hoge = os.str();
          os.str(emptystr);
          os.clear();
          if (points.find(hoge) == points.end()) {
            cube--;
            points.insert(hoge);
          }
        }
    }

    cout << cube << endl;
  }
  return 0;
}

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

int main() {
	int A, B, Q;
    cin >> A >> B >> Q;

	vector<long long> s(A), t(B);
    for (int i = 0; i < A; ++i){
    	cin >> s[i];
    }
    for (int i = 0; i < B; ++i){
    	cin >> t[i];
    }
    for (int i = 0; i < Q; ++i){

    	long long x;
    	cin >> x;
	    int sr = lower_bound(s.begin(), s.end(), x) - s.begin();
	    int sl = sr - 1;
	    int tr = lower_bound(t.begin(), t.end(), x) - t.begin();
	    int tl = tr - 1;

	    long long ret = 1LL << 60;
	    if (sr < A && tr < B) {
	      ret = min(ret, (s[sr] - x) + abs(s[sr] - t[tr]));
	      ret = min(ret, (t[tr] - x) + abs(s[sr] - t[tr]));
	    }
	    if (sl >= 0 && tl >= 0) {
	      ret = min(ret, (x - s[sl]) + abs(s[sl] - t[tl]));
	      ret = min(ret, (x - t[tl]) + abs(s[sl] - t[tl]));
	    }
	    if (sr < A && tl >= 0) {
	      ret = min(ret, (s[sr] - x) + abs(s[sr] - t[tl]));
	      ret = min(ret, (x - t[tl]) + abs(s[sr] - t[tl]));
	    }
	    if (sl >= 0 && tr < B) {
	      ret = min(ret, (x - s[sl]) + abs(s[sl] - t[tr]));
	      ret = min(ret, (t[tr] - x) + abs(s[sl] - t[tr]));
	    }
	    cout << ret << endl;
    }
}

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

int main() {
  int N,S=0;
  int M=4000000;
  cin>>N;
  vector<int> X(N);

    for(int i=0;i<N;i++){
      cin>>X.at(i);
    }

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

    for(int i=X.at(0);i<=X.at(N-1);i++){
      for(int j=0;j<N;j++){
        S+=(X.at(j)-i)*(X.at(j)-i);
      }
      M=min(M,S);
      S=0;
    }

  cout<<M;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kishan Sairam Adapa
 */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define ll long long int
#define MOD ((int)(1e9) + 7)

using namespace std;

class BGoodDistance {
public:
    bool isSquare(ll x) {
        if(x == 1) return true;
        ll start = 1, end = x/2;
        while(start <= end) {
            ll mid = (start+end)/2;
            if(mid*mid <= x) start = mid+1;
            else end = mid-1;
        }
        return (start-1)*(start-1) == x;
    }
    void solve(istream& cin, ostream& cout) {
        int n, d;
        cin >> n >> d;
        vector<vector<int>> s;
        for(int i=0; i<n; i++) {
            vector<int> x;
            for(int j=0; j<d; j++) {
                int tp;
                cin >> tp;
                x.push_back(tp);
            }
            s.push_back(x);
        }
        ll cnt=0;
        for(int i=0; i<n-1; i++) {
            for(int j=i+1; j<n; j++) {
                ll dist = 0;
                for(int k=0; k<d; k++) {
                    dist += (s[i][k] - s[j][k]) * (s[i][k] - s[j][k]);
                }
                if(isSquare(dist)) cnt++;
            }
        }
        cout << cnt << '\n';
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    BGoodDistance solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let k: usize = iterator.next().unwrap().parse().unwrap();

    let mut ans: f64 = 0.0;
    for i in 1..(n + 1) {
        let mut tmp: f64 = 1.0 / n as f64;
        let mut now = i;
        while now < k {
            now *= 2;
            tmp /= 2.0;
        }
        ans += tmp;
    }

    return format!("{:.12}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace __gnu_pbds; 
using namespace std;
typedef long long ll;
int main()
{
    ll k,a,b;cin>>k>>a>>b;
  for(ll i=a;i<=b;i++)
  {if(i%k==0)return cout<<"OK",0;}
  return cout<<"NG",0;
}

Measured memory_bytes: 3636
N = int(input())
C = list(input().split())
_C = C.copy()

for i in range(N):
    for j in range(N-1, i, -1):
        if (C[j][1] < C[j-1][1]):
            C[j], C[j-1] = C[j-1], C[j]
print(*C)
print("Stable")

for i in range(N):
    m = i
    for j in range(i, N):
        if (_C[j][1] < _C[m][1]):
            m = j
    _C[i], _C[m] = _C[m], _C[i]
print(*_C)
if(C ==_C):
    print("Stable")
else:
    print("Not stable")

Measured memory_bytes: 7744
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
#define inf (ll)1e9

#define debugone(x) cout << #x << " " << x << "\n"; cout.flush();
#define debugtwo(x) cout << #x << "-------------" << "\n";for(auto &it: x) cout << it << " ";cout << "\n"; cout.flush();
#define debugthree(x, i, j) cout << #x << "------------" << "\n";cout << "from " << i << " to " << j << "\n";for(ll k=i; k<=j; k++) cout << x[k] << " ";cout << "\n"; cout.flush();



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

	ll a[n+1];

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

	ll dp[n+1][2];

	dp[0][0] = 0;
	dp[0][1] = 0;

	dp[1][0] = a[1];
	dp[1][1] = 0 - a[1];

	for(int i=2; i<=n; i++){
		dp[i][0] = max(dp[i-1][0] + a[i], dp[i-1][1] - a[i]);
		dp[i][1] = max(dp[i-1][1] + a[i], dp[i-1][0] - a[i]);
	}

	cout << dp[n][0] << endl;
	return 0;	

}

Measured memory_bytes: 2560
#include<stdio.h>
int main(){
  int n,i,m,j,t;
  unsigned long c;
  int d[10000];
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<n;i++){
      scanf("%d",&d[i]);
    }
    for(i=0;i<n;i++){
      for(j=1;i+j<n;j++){
	if(d[j-1]>d[j]){
	  t=d[j];
	  d[j]=d[j-1];
	  d[j-1]=t;
	}
      }
    }
    c=0;
    for(i=0;i<n-1;i++){
      c+=(n-i-1)*d[i];
    }
    printf("%ld\n",c);
  }
  return 0;
}

Measured memory_bytes: 636
N = int(input())
L = []
for i in range(N):
  L.append(list(map(int,input().split())))
H = 0
for X in range(101):
  for Y in range(101):
    for i in range(N):
      h = 0
      if L[i][2] != 0:
        h = L[i][2]
        break
    flag = True
    H = h+abs(L[i][0]-X)+abs(L[i][1]-Y)
    for j in range(N):
      if L[j][2] != max(H-abs(L[j][0]-X)-abs(L[j][1]-Y),0):
        flag = False
        break
    if flag:
      print(X,Y,H)
      exit()

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

int main(void){
  int d[100];
  int i,n,ans=1;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    scanf("%d",&d[i]);

  sort(d,d+n);

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

  printf("%d\n",ans);

  return 0;

}


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

using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<double>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using PI = pair<int, int>;
using PL = pair<ll, ll>;
using VPI = vector<PI>;
using VPL = vector<PL>;
using VS = vector<string>;

#define ln '\n'
#define REP(t, n) for (int t = 0; t < (n); ++t)
#define FOR(t, a, b) for (int t = (a); t <= (b); ++t)
#define FORR(t, a, b) for (int t = (a); t >= (b); --t)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int N, K;
    cin >> N >> K;
    VI V(N);
    REP(i, N)
    cin >> V[i];
    int ans = 0;
    FOR(l, 0, K) {
        FOR(r, 0, K - l) {
            if (l + r > N) break;
            VI have;
            REP(i, l)
            have.emplace_back(V[i]);
            REP(i, r)
            have.emplace_back(V[N - i - 1]);
            sort(ALL(have), [](const int &a, const int &b) { return a > b; });

            REP(i, K - r - l) {
                if (have.size() > 0 && have.back() < 0)
                    have.pop_back();
                else
                    break;
            }
            int sum = accumulate(ALL(have), 0);
            if (ans < sum) ans = sum;
        }
    }

    cout << ans << ln;

    return 0;
}


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

int main() {
    int n, i, temp, ans = 1, num = 1;
    cin >> n;
    int a[n];
    for (i = 0; i < n; i++){
        cin >> a[i];
    }

    while(ans < n) {
        num = a[num-1];
        temp = a[num-1];
        temp = a[temp - 1];
        if(num == 2) break;
        ans++;
    }

    if (ans < n){
        cout << ans << endl;
        return 0;

    }else{
        cout << "-1" << endl;
        return 0;
    }
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9

using namespace std;

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

int main() {
    int c[4][4];
    for (int i = 1; i <= 3; ++i) {
        for (int j = 1; j <= 3; ++j) {
            cin >> c[i][j];
        }
    }
    
    if (c[1][1] - c[1][2] == c[2][1] - c[2][2] &&
        c[2][1] - c[2][2] == c[3][1] - c[3][2] &&
        c[1][2] - c[1][3] == c[2][2] - c[2][3] &&
        c[2][2] - c[2][3] == c[3][2] - c[3][3]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


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

using namespace std;

int main()
{
  	int n; cin >> n;
  	vector<pair<string, int>> arr;
  	for (int i = 0; i < n; ++i) {
    	string s; cin >> s;
      	int p; cin >> p;
      	arr.push_back({s, p});
    }
  	vector<pair<string, int>> cpy(arr);
  	sort(cpy.begin(), cpy.end(), [](pair<string, int> a, pair<string, int> b) {
    	if (a.first == b.first) {
        	return a.second > b.second;
        } else {
        	return a.first < b.first;
        }
    });
  	for (int i = 0; i < n; ++i) {
    	cout << (int)(find(arr.begin(), arr.end(), cpy[i]) - arr.begin()) + 1 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define con_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define con_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    int n;
    cin>>n;
    int ans;
    if(n%2==0)ans=n/2-1;
    else ans=n/2;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;
typedef vector<int> VI;
#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )

template<typename T>
T gcd(T m, T n) {
    return n == 0 ? m : gcd(n, m % n);
}

template<typename T>
T lcm(T m, T n) {
    return (m * n) / gcd(m, n);
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    
    vector<pair<long, long>> pairs;
    long ta, tb;
    while (cin >> ta >> tb) {
        pair<long, long> tmp;
        tmp.first = ta;
        tmp.second = tb;
        pairs.push_back(tmp);
    }
    
    for (auto p : pairs) {
        cout << gcd(p.first, p.second) << " " << lcm(p.first, p.second) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1196
import java.util.Arrays
import java.util.ArrayList

const val MOD: Long = (1e9+7).toLong()
fun Double.format(digits: Int) = String.format("%.${digits}f", this)

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = Array(n, {readLine()!!})

    var cnt = 0
    var cnta = 0
    var cntb = 0
    var cntd = 0
    var non = 0
    for (t in s) {
        for (i in 0..t.length-2) {
            cnt += if (t.slice(i..i+1) == "AB") 1 else 0
        }
        if (t.last() == 'A' && t[0] == 'B') {
            cntd += 1
        } else {
            cnta += if (t.last() == 'A') 1 else 0
            cntb += if (t[0] == 'B') 1 else 0
        }
        non += if (t.last() != 'A' && t[0] != 'B') 1 else 0
    }

    if (cnta > 0 && cntb > 0) {
        if (cntd > 0) {
            println(cnt + cntd+1 + Math.min(cnta-1, cntb-1))
        } else {
            println(cnt + Math.min(cnta, cntb))
        }
    } else if (cnta > 0 || cntb > 0) {
        if (cntd > 0) {
            println(cnt + cntd)
        } else {
            println(cnt)
        }
    } else {
        println(cnt + Math.max(cntd, 1) - 1)
    }
}


Measured memory_bytes: 39028
import std.stdio;
import std.string;
import std.conv;
import std.algorithm.comparison;
import std.algorithm.searching;

void main(){
	int a, b, k;
	readf("%d %d %d", &a, &b, &k);
	int s = a;
	int e = min(a + k, b);
	for(int i = s; i < e; ++i){
		i.writeln;
	}
	s = max(e, b - k + 1);
	e = b;
	for(int i = s; i <= e; ++i){
		i.writeln;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int, int>P;
typedef pair<int, pair<int, int>>PP;
typedef long long ll;
ll inf = 1e9;

vector<P> grid[100010];
int n, m;
vector<int> g(100010,inf);

bool dfs(int i) {
	for (int j = 0; j < grid[i].size(); j++) {
		int a = grid[i][j].first;
		int b = grid[i][j].second;
		if (g[a] == inf) {
			g[a] = g[i] + b;
			if (dfs(a) == false) {
				return false;
			}
		}
		else if (g[a] != g[i] + b) {
			return false;		
		}
	}
	return true;
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int l, r, d; cin >> l >> r >> d;
		grid[l].push_back(P(r, d));
		grid[r].push_back(P(l, -d));
	}
	for (int i = 1; i < n + 1; i++) {
		if (g[i] == inf) {
			g[i] = 0;
			if (dfs(i) == false) {
				cout << "No" << endl; 
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 12032
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
##########################################################
from collections import Counter
# c=sorted((i,int(val))for i,val in enumerate(input().split()))
import heapq
# c=sorted((i,int(val))for i,val in enumerate(input().split()))
# n = int(input())
# ls = list(map(int, input().split()))
#n=int(input())
#arr = list(map(int, input().split()))

#for _ in range(int(input())):

def find(x,root):
    if root[x]==x:
        return x
    else:
        return find(root[x],root)


def unioin(x,y):
    uroot=find(u,root)

    vroot=find(v,root)

    if uroot!=vroot:
        if rank[uroot]>rank[vroot]:
            root[vroot]=root[uroot]
            rank[uroot]+=rank[vroot]
        elif rank[vroot]>rank[uroot]:
            root[uroot]=root[vroot]
            rank[vroot]+=rank[uroot]
        else:
            rank[uroot]+=rank[vroot]
            root[vroot]=root[uroot]




n,m= map(int, input().split())
rank=[1]*(n+1)
root=[i for i in range(n+1)]
for i in range(m):
    u,v = map(int, input().split())
    unioin(u,v)
ans=0
print(max(rank))

Measured memory_bytes: 21832
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート

#入力受け取り
def getlist():
	return list(map(int, input().split()))

def warshall_floyd(d, n):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

#処理内容
def main():
	n,w = map(int,input().split())
	d = [[float("inf") for i in range(n)] for i in range(n)]
	a = []
	b = []
	weight = []
	for i in range(w):
		x,y,z = map(int,input().split())
		a.append(x - 1)
		b.append(y - 1)
		weight.append(z)
		d[x - 1][y - 1] = z
		d[y - 1][x - 1] = z
		for i in range(n):
			d[i][i] = 0
	d = warshall_floyd(d, n)
	ans = 0
	for i in range(w):
		if d[a[i]][b[i]] < weight[i] :
			ans += 1
	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 45036
#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 ll long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 1000006
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d\n", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 998244353
#define PI acos(-1.0)
#define eps 1e-9

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

clock_t t_Start;
void Start()
{
    t_Start = clock();
}
void End()
{
    double Time = (double)(clock()-t_Start)/CLOCKS_PER_SEC;
    error(Time);
}

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Start();

    ll N, M, V, P;
    cin>>N>>M>>V>>P;
    vector<ll>A(N), sum(N+1, 0);
    for(int i = 0; i < N; i++)
        cin>>A[i];
    sort(A.begin(), A.end(), greater<ll>());
    for(int i = 0; i < N; i++)
        sum[i+1] = sum[i] + A[i];
    ll ans = P;
    for(int i = P; i < N; i++)
    {
        ll sumn = sum[i+1] - sum[P-1] - A[i] * (i-P+2);
        if(A[P-1]>A[i]+M || sumn>(N-V)*M)
            break;
        ans++;
    }
    cout<<ans<<endl;

    //End();
    return 0;
}


Measured memory_bytes: 1920
//ITNOA
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <fstream>
#include <cstring>
#include <cstdlib>
#include <iomanip>

using namespace std;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;

#define rep(i, s, e) for(int i = s; i < e; i ++)
#define X first
#define Y second

typedef long long ll;
typedef long double ld;

const int maxN = 1000 + 5;
const int mod = 1000*1000*1000 + 7;
const int base = 701;
const int SQ = 500;
const int maxL = 20;



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

	cout << s.substr(0,4) << ' ' << s.substr(4) << endl;
	return 0;
}


Measured memory_bytes: 256
/*ॐॐ*/
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different.
Change variable names or change some Data structres or anything just make sure MOSS do not
Detect Anything.
Yours Faithfully
Shobhit Yadav */

/* I do not fear this new challenge. Rather like a true warrior I will rise to meet it. 
                                       -Prince Vegeta  */

 /* “Strength is the only thing that matters in this world. Everything else is just a delusion for the weak.” – Vegeta */

#include<bits/stdc++.h>
using namespace std;
#define ll long long 



ll A,B,K;
/*ll freq[200005];*/
void solve(){
   /*memset(freq,0,sizeof(freq));*/
 cin>>A;

 cout<<A+pow(A,2)+pow(A,3)<<'\n';


}



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

  return 0;
}


Measured memory_bytes: 4128
N=int(input())

def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    table.pop(0)
    
    return table


table=num_divisors_table(N)
goukei=0
for i in range(N-1):
  goukei=goukei+table[i]
  
print(goukei)

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

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

    string ans = s;
    rep(i, ans.size()){
        if(ans[i] == '?'){
            ans[i] = 'z';
        }
    }
    string ans_tmp = ans;

    rep(i, s.size()){
        bool check = true;
        string tmp = s;
        if(i + t.size() > s.size()){
            check = false;
            break;
        }
        rep(j, t.size()){
            if(t[j] != s[i+j] && s[i+j] != '?'){
                check = false;
                break;
            }
            if(s[i+j] == '?')
                tmp[i+j] = t[j];
        }

        if(check){
            rep(j, s.size()){
                if(tmp[j] == '?')
                    tmp[j] = 'a';
            }
            if(ans >= tmp){
                ans = tmp;
            }
        }
    }


    if(ans == ans_tmp && ans_tmp != s){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int cnt[30];

int main() {
	int n, k, fl, ans = 0, x[30];
	priority_queue <int> pq;
	char s[15];
	
	scanf("%d %d", &n, &k);
	for(int i=0; i<n; i++) {
		scanf("%s", &s);
		fl = s[0] - 'A';
		cnt[fl]++;
	}
	
	for(int i=0; i<26; i++) {
		if(cnt[i] > 0) pq.push(cnt[i]);
	}
	
	while(pq.size() >= k) {
		for(int i=0; i<k; i++) {
			x[i] = pq.top();
			pq.pop();
		}
		
		for(int i=0; i<k; i++) {
			if(x[i]-1 == 0) continue;
			pq.push(x[i] - 1);
		}
		ans++;
	}
	
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

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

        String a = sc.next();
        String b = sc.next();

        int n = Integer.parseInt(a + b);

        if(Math.sqrt(n)==(int)Math.sqrt(n)){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    } 
}

Measured memory_bytes: 21716
//BISMILLAHIR RAHMANIR RAHIM
//SOTO MEAW
//SOTO SONDESH
#include<bits/stdc++.h>

#define ls ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define __ <<" "<<
#define loop(m,n) for(m=0;m<n;m++)
#define rloop(m,n) for(m=n-1;m>=0;m--)
#define case(z) "Case " << z++ << ": "
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define quit return 0

using namespace std;

bool isprime(int n)
{
    for (int i = 2; i <= n/2; i++)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}

void showmyDS(set<int> ds)
{
    set<int> ::iterator it;
    for (it=ds.begin();it!=ds.end();it++)
    {
        cout << *it << endl ;
    }
    cout << endl;
}
int main()
{
    ls
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //int t,l=1;cin>>t;while(t>0){
        vector<char>s;
        int j;
        string s1;
        cin>>s1;
        loop(j,s1.size()) s.push_back(s1[j]);
        int n,i,c=0;
        cin>>n;
        char a[n];
        int p,index[255];
        memset(index,0,sizeof(index));
        loop(i,n)
        {
            cin>>a[i];
            p=(int)a[i];
            index[p]=1;
        }
        loop(i,s.size())
        {
            p=(int)s[i];
            if(c==1)
                p=48;
again:
            if(index[p]==1 && p==57)
            {
                if(i!=0)
                    p=48;
                else
                    p=49;
                s.push_back('0');
                c=1;
            }
            if(index[p]==1)
            {
                p++;
                c=1;
                goto again;
            }
            else
            {
                cout<<(char)p;
            }
        }
        cout<<endl;
    //t--;}

    quit;
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

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

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

	int ans = arr[k - 1] - arr[0];
	for (int i = k; i < n; i++)
	{
		int cur = arr[i] - arr[i - k + 1];
		ans = min(ans, cur);
	} 

	cout << ans << endl;
}

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

ll solve() {
    ll N;
    cin >> N;
    if ( N == 3 ) {
        cout << "2 5 63" << "\n";
        return 0;
    }
    ll n = 2, c = 0, s = 0;
    vector<ll> v;
    ll ng = -1;
    while ( c < N ) {
        if ( n % 2 == 0 || n % 3 == 0 || n % 5 == 0) {
            v.push_back(n);
            s += n;
            c++;
        }
        n++;
    }
    while ( s % 30 != 0 ) {
        for(;;) {
            if ( n % 2 == 0 || n % 3 == 0 || n % 5 == 0) {
                ll ss = s + n;
                for ( int i = 0; i < v.size(); i++ ) {
                    if ( (ss - v[i]) % 30 == 0 ) {
                        v.push_back(n);
                        ng = v[i];
                        s += n;
                        s -= v[i];
                        break;
                    }
                }
            }
            if ( ng > 0 ) break;
            n++;
        }
    }
    vector<ll> ans;
    for ( int i = 0; i < v.size(); i++ ) {
        if ( v[i] != ng ) {
            ans.push_back(v[i]);
        }
    }
    for ( int i = 0; i < ans.size(); i++ ) {
        cout << (i != 0 ? " " : "") << ans[i];
    }
    cout << "\n";

    return 0;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 764
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long A[] = new long[N];
    
    for (int i=0;i<N;i++){
      A[i]=sc.nextLong();
    }
    
    int ans = 0;
    for (int i=0;i<N;i++){
      while (i+1 < N && A[i] == A[i+1]){
        i++;
      }
      if (i+1<N && A[i] < A[i+1]){
        while (i+1 < N && A[i] <= A[i+1]){
          i++;
        }
      }else if (i+1 < N && A[i] > A[i+1]){
        while (i+1 < N && A[i] >= A[i+1]){
          i++;
        }
      }
      ans++;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 59444
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void _main() {
  int N;
  cin >> N;

  ll ans = 1;
  rep(i, 1, N+1) {
    ans *= i;
    ans %= 1000000007;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
# Title: Christmas Eve
# Link: https://abc115.contest.atcoder.jp/tasks/abc115_c

import sys


sys.setrecursionlimit(10 ** 6)

read_list_int = lambda: list(map(int, sys.stdin.readline().strip().split(' ')))
read_single_int = lambda: int(sys.stdin.readline().strip())


def solution(n: int, k: int, hs: list):
    sorted_hs = sorted(hs)
    min_diff = 99999999999999999
    for start in range(0, n-k+1):
        diff = sorted_hs[start+k-1] - sorted_hs[start]
        if min_diff > diff:
            min_diff = diff
    return min_diff


def main():
    n, k = read_list_int()
    hs = []
    for _ in range(n):
        hs.append(read_single_int())
    print(solution(n, k, hs))


if __name__ == '__main__':
    main()

Measured memory_bytes: 8284
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int a,i,x;
	x=0;
	for(i=0;i<5;i++){
		cin>>a;
		if(a<=40) x=x+40;
		else x=x+a;
	}
	x=x/5;
	cout<<x<<endl;
	return 0;
}



Measured memory_bytes: 3104
object Main{
	def main(args:Array[String]){
		val s = new java.util.Scanner(System.in)
		val n=s.nextInt
		val a=(1 to n).map(_=>(s.next,-s.nextInt)).toArray
		(1 to n).sortBy(i=>a(i-1)).foreach(println)
	}
}


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
typedef vector<vector<int>> VV;
#define INF (int)(1e9)
#define MAXX (int)1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (ll)(1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PRALL(a) a.begin(),a.end(),greater<pair<int,int>>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
//printf("myco\n");//for debug
/*--------------------------------------------*/

int main(){
    int n,W;cin>>n>>W;
    V w(n),v(n);
    rep(i,n){
        cin>>w[i]>>v[i];
    }
    const int Max=100001;
    vector<vector<int>> dp(n+1,vector<int>(Max));
    rep(i,Max){
        dp[0][i]=INF+1;
    }
    dp[0][0]=0;
    REP(i,n){//i-1番の商品を使うのか？
        rep(j,Max){
            dp[i][j]=dp[i-1][j];
            if(j-v[i-1]>=0)dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i-1]]+w[i-1]);
        }
    }
    int ans;
    rep(i,Max){
        if(W>=dp[n][i])ans=i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 40192
def is_on_the_same_side(p0, p1, p2, p3):
    s2 = (p1[0]-p0[0]) * (p2[1]-p0[1]) - (p2[0]-p0[0]) * (p1[1]-p0[1])
    s3 = (p1[0]-p0[0]) * (p3[1]-p0[1]) - (p3[0]-p0[0]) * (p1[1]-p0[1])
    if s2 * s3 > 0:
        return True
    else:
        return False

while True:
    try:
        data = list(map(float, input().split(',')))
        a = data[0:2]
        b = data[2:4]
        c = data[4:6]
        d = data[6:8]

        if not is_on_the_same_side(a, c, b, d) and is_on_the_same_side(b, c, a, d) and is_on_the_same_side(a, b, c, d):
            print('YES')
        else:
            print('NO')
    except:
        break

Measured memory_bytes: 5576
#include<stdio.h>
int f[512],g[512];
int c[305][305];
int main()
{
	int n,k,m;
	scanf("%d%d%d",&n,&k,&m);
	n++;
	k++;
	for(int i=0;i<=n;i++)
	{
		c[i][0]=1;
		for(int j=1;j<=i;j++)
		{
			c[i][j]=c[i-1][j-1]+c[i-1][j];
			if(c[i][j]>=m)
			{
				c[i][j]-=m;
			}
		}
	}
	while(k--)
	{
		f[1]=1;
		for(int i=2;i<=n;i++)
		{
			f[i]=0;
			for(int j=1;j<i;j++)
			{
				int inc=(long long)g[j]*f[i-j]%m;
				f[i]+=(long long)inc*c[i-2][j-1]%m;
				if(f[i]>=m)
				{
					f[i]-=m;
				}
			}
		}
		for(int i=1;i<=n;i++)
		{
			g[i]+=f[i];
			if(g[i]>=m)
			{
				g[i]-=m;
			}
		}
	}
	printf("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T>inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

string s[110];
char strbuf[55];
set<char> mom{'a', 'i', 'u', 'e', 'o'};

void solve(int n) {
    for (int i = 0; i < n; i++) {
        scanf("%s", strbuf);
        s[i] = strbuf;
    }
    set<string> se;
    for (int i = 0; i < n; i++) {
        const int L = s[i].length();
        string code = "";
        code += s[i][0];
        for (int j = 0; j < L - 1; j++) {
            if (mom.count(s[i][j])) code += s[i][j + 1];
        }
        if (se.count(code)) {
            puts("-1");
            return;
        }
        se.insert(code);
    }
    using state = pair<int, string>;//(length, word)
    priority_queue<state> pq;
    for (string e : se) pq.push(make_pair(e.length(), e));
    int k = INF;
    while (!pq.empty()) {
        vector<string> vec;
        vec.emplace_back(pq.top().second);
        const int L = vec.front().length();
        pq.pop();
        while (!pq.empty() && pq.top().first == L) {
            vec.emplace_back(pq.top().second);
            pq.pop();
        }
        chmin(k, L);
        for (string &e : vec) {
            se.erase(e);
            e.pop_back();
            if (se.count(e)) {
                printf("%d\n", k);
                return;
            }
            se.insert(e);
        }
        for (string &e : vec) {
            pq.push(make_pair(e.length(), e));
        }
    }
    puts("1");
}

int main(void) {
	int a, b, c, x, y, z, n, m, p;
	string s;
	while (cin >> n, n) {
		solve(n);
		//break;
	}
}

Measured memory_bytes: 3272
// I make this just for fun because i'm done
// Aimi Haraguni >> Konomi Suzuki >> Yui >>  Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi.   .. dude? 
// problems that involves any kind of persistent data structures are the best of the best, are not them?
 
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb push_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
 
#define N 2005
// #define M 19
 
#define mod  998244353
#define mod1 1000000007
#define mod2 1000000009
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF 2000000000000000000
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii > tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> S_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
template<typename t> void fff(const char* x, t&& val1) { cout<<x<< " : "<<val1<<"\n";}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

ll dist[1<<13][1<<13];

int main(){
    fastio;
    ll n, a, b; cin>>n>>a>>b;
    FER(i, 1, n+1) FER(j, 1, n+1) dist[i][j] =abs(j-i);
    FER(i, 1, n+1) FER(j, i+1, n+1) dist[i][j] = min({dist[i][j], dist[i][a]+1+dist[b][j], dist[i][b]+1+dist[a][j]});
    map<ll, ll > m;
    FER(i, 1, n+1) FER(j, i+1, n+1) m[dist[i][j]]++;
    FER(i, 1, n) cout<<m[i]<<"\n";
    return 0;
}

Measured memory_bytes: 128000
#include <stdio.h>

int main(void) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if(a + b == c  ||  b + c == a  ||  c + a == b) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    string s; cin >> s;
    cout << s.substr(0,3) << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>

int n,a[20];

int solve(int p,int key){
  if(!key){
    return 1;
  }

  if(key < 0 || p >= n){
    return 0;
  }

  if(solve(p+1,key) || solve(p+1,key-a[p])){
    return 1;
  }

  return 0;
}

int main(){
  int i,q,key;
  scanf("%d" ,&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d" ,a + i);
  }

  scanf("%d" ,&q);
  while(q--){
    scanf("%d" ,&key);
    if(solve(0,key)){
      printf("yes\n");
    }else{
      printf("no\n");
    }
  }

  return 0;
}

Measured memory_bytes: 580
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    string s;
    cin>>s;
    int n=s.size();
    if(s[0]=='0'||s[n-2]=='0'||s.back()=='1'){
        cout<<-1<<"\n";
        return 0;
    }
    V<P> ans;
    int now=1;
    n--;
    bool ng=false;
    for(int i=0;i<n;i++){
        if(s[i]=='0'){
            int t=1;
            while(i<n&&s[i]=='0'){
                ans.emplace_back(now,now+t);
                t++;i++;
            }
            if(i!=n&&s[i]=='1'){
                ans.emplace_back(now,now+t);
                if(s[n-i-1]=='0')ng=true;
            }
            now+=t;
        }else{
         if(s[n-i-1]=='0')ng=true;
         ans.emplace_back(now,now+1);
         now++;
        }
    }
    if(ng){
        cout<<-1<<"\n";
        return 0;
    }
    for(int i=0;i<ans.size();i++){
        cout<<ans[i].fi<<" "<<ans[i].se<<"\n";
    }
}

Measured memory_bytes: 3264
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <tuple>
#include <algorithm>
#include <cmath>
using namespace std;
const double PI=3.14159265358979323846;

int main(){
    int A,B,H,M;
    cin >> A >> B >> H >> M;

    //cout << A << " " << B << " " << H << " " << M << endl;

    double h = H+(double)M/60;

    double a = (double)h/6.0 *PI;
    double b = (double)M/30.0*PI;

    

    //cout << "rad A" << a << " : " << H/6.0  << endl;
    //cout << "rad B" << b << " : " << M/30.0 << endl;

    //double ax = A*cos(a);
    //double ay = A*sin(a);
    //double bx = B*cos(b);
    //double by = B*sin(b);

    double ax = A*cos(a);
    double ay = A*sin(a);
    double bx = B*cos(b);
    double by = B*sin(b);

    //cout << "a: (" << ax << " " << ay << ")" << ax*ax+ay*ay << endl;
    //cout << "b: (" << bx << " " << by << ")" << bx*bx+by*by << endl;
    //cout << "( ( (" << bx << ") - ("<< ax << ") )**2 + ( (" << by << ") - (" << ay << ") )**2 )**0.5" << endl;

    double res = sqrt( (bx-ax)*(bx-ax) + (by-ay)*(by-ay) );

    printf("%.10lf\n",res);
    //cout << sqrt( (bx-ax)*(bx-ax) + (by-ay)*(by-ay) ) << endl;


    return 0;
}


Measured memory_bytes: 4064