akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
/* struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
}; */


/** Problem1135 : Ohgas' Fortune **/
int main()
{
	int M; cin>>M;
	rep(i, M) {
		int A, B, N;
		cin>>A>>B>>N;
		int ans = 0;
		rep(j, N) {
			int t; double r, s;
			int tA = A, tmp=0;
			cin>>t>>r>>s;
			rep(k, B) {
				if (t) {
					tA *= (1+r);
					tA -= s;
				} else {
					tmp += tA*r;
					tA -= s;
				}
			}
			ans = max(ans, tmp+tA);
		}
		cout << ans << endl;
	}
}

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


int main(){
    ll n;cin>>n;
    map<ll,ll> mp;
    rep(i,0,n){
        ll a;
        cin>>a;
        if(mp[a]==0){
            mp[a]++;
        }
        else{
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

    









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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<int> a, b, A, B;
  Solver(LL n) : n(n), a(n), b(n), A(n), B(n){};

  void solve() {
    deque<int> p(n);
    vector<int> curp(n), initp(n);
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
      cin >> b[i];
      p[i] = i;
      curp[i] = i;
      initp[i] = i;
    }
    sort(p.begin(), p.end(), [&](int x, int y) -> bool { return b[x] < b[y]; });
    for (int i = 0; i < n; ++i) {
      A[i] = a[p[i]];
      B[i] = b[p[i]];
    }
    DBG(A, B)
    sort(p.begin(), p.end(), [&](int x, int y) -> bool { return A[x] < A[y]; });
    set<int> S;
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
      while (!p.empty() && A[curp[p.front()]] <= B[i]) {
        S.insert(curp[p.front()]);
        p.pop_front();
      }
      if (S.upper_bound(i) == S.end()) {
        if (A[i] > B[i]) {
          cout << "No" << endl;
          return;
        } else {
          continue;
        }
      }
      auto it = S.end();
      it--;
      int pos = *it;
      swap(A[i], A[pos]);
      int initi = initp[i];
      int initpos = initp[pos];
      swap(curp[initi], curp[initpos]);
      swap(initp[i], initp[pos]);
      S.erase(pos);
      if (A[pos] <= B[i]) S.insert(pos);
      DBG(A)
      cnt++;
      if (cnt == n - 2) break;
    }
    bool ok = true;
    for (int i = 0; i < n; ++i) {
      if (A[i] > B[i]) ok = false;
    }
    if (ok) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 4096
#include<stdio.h>
int main(void) {
	int n, k;
	char s[51];
	scanf("%d", &n);
	scanf("%d", &k);
	scanf("%s", s);
	int i;
	for (i = 0; s[i] != '\0'; i++) {
		if (i + 1 == k) {
			s[i] = (s[i] + 32);
		}
	}
	for (i =0 ; i < n; i++) {
		printf("%c", s[i]);
	}
	printf("\n");
	return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n;
    cin >> n;
    int ans = 0;
    rep(i, n+1)
    {
        if(i % 2 == 0)continue;
        vector<int> v;
        int x = i;
        for (int j = 2; j <= x; j++)
        {
            int cnt = 0;
            while (x % j == 0)
            {
                cnt++;
                x /= j;
            }
            if(cnt)v.push_back(cnt);
        }
        int tmp = 1;
        for (auto e : v)
        {
            tmp *= (e + 1);
        }
        if(tmp == 8)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
K=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n=int(input())
print(K[n-1])

Measured memory_bytes: 38256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

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

int l1,l2,n,p1,p2;
string a,b;

bool licz(char sub, char add,int gd, int dl){
  int po = 0, ko = dl;
  for(int i = n - 1; i >= 0; i--){
    if(b[i] == add){
      po = max(po-1, 0ll);
    }else if(b[i] == sub){
      ko = min(ko + 1, dl);
    }
    
    if(a[i] == sub){
      po++;
    }else if(a[i] == add){
      ko--;
    }
    if(po >= ko)return 0;
  }
  gd--;
  return po <= gd && gd < ko;
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> l1 >> l2 >> n >> p1 >> p2;
  cin >> a >> b;
  if(!licz('U','D',p1,l1) || !licz('L', 'R', p2, l2)){
    cout << "NO\n";
  }else{
    cout << "YES\n";
  }
}


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

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(gcd(a, b) == 1) {
        cout << "YES" << endl;
    } 
    else {
        if(c % gcd(a, b) == 0) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]

at = AB[-1][0]
bt = AB[-1][1]
if at % bt == 0:
    cnt = 0
elif at > bt:
    cnt = bt - (at % bt)
else:
    cnt = bt - at

res = cnt
for tmp, b in reversed(AB[:-1]):
    a = tmp + res
    if a % b == 0:
        continue
    if a > b:
        res += b - (a % b)
    elif a < b:
        res += b - a
    # res += cnt

print(res)


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

int main(){
long long a,b,c,k,m,n;
cin >> a >> b >> c >> k;
m=k-a-b;
n=k;
if(m<0) k=0;
//cout << k << endl;
if(k !=0){
cout << (1*a)-(1*(k-a-b)) << endl;
}
else cout << 1*n << endl;

}



Measured memory_bytes: 3676
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll rwpw(ll a, ll p){
	ll ret = 1ll;
	while(p){
		if(p%2){
			mul_mod(ret,a);
		}
		mul_mod(a,a);
		p /= 2;
	}
	return ret;
}

ll a[100100],cnt[1001001];

int main(void){
	int n,i;
	ll g = 0ll, j, ans = 0ll, c;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
	}
	for(i=0; i<n; ++i){
		g = a[i];
		for(j=2ll; j*j<=g; ++j){
			c = 0ll;
			while(!(g%j)){
				++c;
				g /= j;
			}
			cnt[j] = max(cnt[j],c);
		}
		if(g>1ll){
			cnt[g] = max(cnt[g],1ll);
		}
	}
	g = 1ll;
	for(i=2ll; i<=1000000; ++i){
		mul_mod(g,rwpw((ll)i,cnt[i]));
	}
	for(i=0; i<n; ++i){
		a[i] = rwpw(a[i],MOD-2);
		mul_mod(a[i],g);
		add_mod(ans,a[i]);
	}
	cout << ans << endl;
	return 0;
}


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

ll V, E;
struct edge {ll from, to, cost;};
edge edges[2020];
const ll INF = 1LL << 50;

template <typename T>
bool FindNegativeLoop(T& d){
	for (int i = 0; i < V; i++) d[i] = 0;

	for (int i = 0; i < V; i++){
		for (int j = 0; j < E; j++){
			edge e = edges[j];
			if (d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;

				if ((i == V - 1) && (e.to == V - 1)) return true;
			}
		}
	}
	return false;
}

template <typename T>
void BellmanFord(T& d, ll s){
	for (int i = 0; i < V; i++) d[i] = INF;
	d[s] = 0;

	for (int  loop = 0; loop < V - 1; loop++){
		for (int i = 0; i < E; i++){
			edge e = edges[i];
			if ((d[e.from] != INF) && (d[e.to] > d[e.from] + e.cost)){
				d[e.to] = d[e.from] + e.cost;
			}
		}
	}
}

int main(){
	cin >> V >> E;
	for (int i = 0; i < E; i++){
		ll a, b, c;
		cin >> a >> b >> c;
		edges[i].from = a - 1;
		edges[i].to = b - 1;
		edges[i].cost = -c;
	}

	vector<ll> d(V);
	if (FindNegativeLoop(d)){
		cout << "inf" << endl;
	} else { 
		BellmanFord(d, 0);
		cout << -d[V - 1] << endl;
	}

	return 0;
}


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

const ll INF = pow(10, 9) + 7;

int kaijou(int x){
  if(x==1||x==0) return 1;
  return x*kaijou(x-1);
};

int main() {
  int N;
  cin >> N;
  vector<int> p(N),q(N),ch(N,1);
  rep(i,N){
    cin >> p[i];
    p[i]--;
  }
  rep(i,N){
    cin >> q[i];
    q[i]--;
  }
  int pp=0,qq=0;
  rep(i,N){
    ch[p[i]]=0;
    int a = 0;
    rep(j,p[i]) a += ch[j];
    pp += a*kaijou(N-i-1);
  }
  vector<int> ch2(N,1);
  rep(i,N-1){
    ch2[q[i]]=0;
    int a = 0;
    rep(j,q[i]) a += ch2[j];
    qq += a*kaijou(N-i-1);
  }
  if(pp<qq) swap(pp,qq);
  cout << pp-qq;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define rev1(i,n) for(ll i=n;i>0;i--)
#define pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int> >
#define vb vector<bool>
#define pii pair<int,int>
#define F first
#define S second
#define INF 1e9+7
typedef long long int ll;
int arr[26];

void solve(){
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes";
    else cout<<"No";
    
}
signed main() {
    // your code goes here
    IOS
    ll t=1;
    //cin>>t;
    rep1(i,t){
        solve(); 
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] a = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			a[i] = in.nextInt();
		}
		solve(n, a);
		in.close();
	}

	private static void solve(int n, int[] a) {
		boolean[] b = new boolean[n + 1];
		int m = 0;
		for (int i = n; i > 0; i--) {
			int r = 0;
			for (int j = i; j <= n; j += i)
				if (b[j])
					r++;
			r %= 2;
			if (r == a[i])
				continue;
			else {
				b[i] = true;
				m++;
			}
		}
		System.out.println(m);
		for (int i = 1; i <= n; i++)
			if (b[i])
				System.out.println(i);
	}
}


Measured memory_bytes: 75352
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cassert>

using namespace std;

#define sz(x) (int)(x.size())
#define fr(i, a, b) for(int i=a;i<b;++i)
#define fdr(i, a, b) for(int i=b-1;i>=a;--i)
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;

/////////////////

int const N = 55;
int n, p, a[N];
ll d[N][2];

void solve(){
	cin >> n >> p;
	fr(i, 0, n){
		cin >> a[i];
		a[i] %= 2;
	}
	d[0][0] = 1;
	fr(i, 0, n){
		fr(j, 0, 2) d[i+1][j] += d[i][j];
		fr(j, 0, 2) d[i+1][(a[i] + j) % 2] += d[i][j];
	}
	ll ans = d[n][p];
	cout << ans << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();


	return 0;
}


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

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

    double x=(double)(a+b)/2.0;
    if((int)(x*10.0)%10!=0){
         ans = (int)x+1;
    }else{
        ans = (int)x;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3644
#include <stdio.h>
#include <string.h>
 
int main(int argc, const char * argv[]) {
     
    int i,j,x;
    int count = 0;
     
    char str[202];
    char fstr[101];
     
    scanf("%s",str);
     
    scanf("%s",fstr);
     
    int len = strlen(str);
    int flen = strlen(fstr);
     
    for (i = len; i < len+len; i++) {
        str[i] = str[i-len];
    }
     
    for (i = 0; i < len+len; i++) {
        if (str[i] == fstr[0]) {
            for (j = 0; j < flen; j++) {
                if (str[i+j] != fstr[j]) {
                    break;
                }
            }
             
            if (j == flen) {
                printf("Yes\n");
                return 0;
            }
        }
    }
     
    printf("No\n");
     
    return 0;
}


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

#define ll long long
#define ld long double
#define mod 1000000007LL
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define endl '\n'
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define pb(x) push_back(x)
#define fo(i, a, n) for (i = (a); i < (n); i++)
#define foe(i, a, n) for (i = (a); i <= (n); i++)
// clang-format off
#define vin(a) for (ll i = 0; i < sz(a); i++) { cin >> a[i]; } 
#define vout(a) for (auto x : a) { cout << x << " "; }
#define sws                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0)
// clang-format on
#define pd(x) cout << x
#define sd(x) cin >> x
#define nl cout << endl
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define foreach(i, a)                                                          \
  for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
// int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
void solve() {
  ll m, n;
  ll i, j;
  string s, t;

  cin >> s >> t;
  n = s.length(), m = t.length();

  ll ans = m;

  foe(i, 0, n - m) {
    ll cur = 0;
    fo(j, 0, m) {
      if (s[i + j] != t[j]) {
        cur++;
      }
    }
    ans = min(cur, ans);
  }

  cout << ans << endl;
}

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

Measured memory_bytes: 3628
N, X, Y = map(int, input().split())

X -= 1
Y -= 1

ans = [0] * (N - 1)
for i in range(N):
    for j in range(i + 1, N):
        dist = min(abs(i - j), abs(X - i) + abs(Y - j) + 1, abs(Y - i) + abs(X - j) + 1)
        ans[dist - 1] += 1
        # print("i:{}, j:{}, dist:{}".format(i, j, dist))
for k in ans:
    print(k)


Measured memory_bytes: 3444
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort(key = lambda x: x[0])

ans = 0
for i in range(N):
    if AB[i][1] >= M:
        ans += AB[i][0] * M
        print (ans)
        break
    ans += AB[i][0] * AB[i][1]
    M -= AB[i][1]

Measured memory_bytes: 18052
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, X;
  int B;
  cin>>N>>M>>X;
  vector<int> A(N,0);
  for(int i=0;i<M;i++){
    cin>>B;
    A.at(B)=1;
  }
  int countA=0;
  int countB=0;
  for(int i=0;i<X;i++){
    if(A.at(i)==1){
      countA++;
    }
  }
  for(int i=X;i<N;i++){
    if(A.at(i)==1){
      countB++;
    }
  }
  cout<<min(countA,countB)<<endl;
}

    

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 701
#define INF 1e9
#define int ll
int N,M;
vi adj[maxn];
bool matrix[maxn][maxn];
int num[maxn];
bool vis[maxn];
bool color[maxn];

int f(int a,int b){
	return (a*(a-1) + b*(b-1))/2;
}

bool np = 0;
pi sz[maxn];
void dfs(int x,int p){
	if (vis[x]) return;
	vis[x] = 1;
	
	
	if (color[x]) sz[p].s++;
	else sz[p].f++;
	
	aFOR(i,adj[x]){
		if (vis[i] && color[i] == color[x]){
			np = 1;
			break;
		}
		
		color[i] = !color[x];
		dfs(i,p);
	}
	return;
}
		
int32_t main(){
	fast;
	
	cin>>N>>M;
	
	FOR(i,0,M-1){
		int a,b; cin>>a>>b;
		matrix[a][b] = matrix[b][a] = 1;
	}
	
	FOR(i,1,N){
		FOR(j,i+1,N){
			//if (i == j) continue;
			if (!matrix[i][j]) adj[i].pb(j), adj[j].pb(i);
		}
	}
	
	vi vect;
	FOR(i,1,N){
		if (!vis[i]){
			vect.pb(i);
			dfs(i,i);
		}
	}
	
	if (np){
		cout<<-1;
		return 0;
	}
	
	
	set <int> dp[maxn];
	
	
	FOR(i,0,vect.size() - 1){
		//cout<<sz[vect[i]].f<<' '<<sz[vect[i]].s<<'\n';
		if (i == 0) dp[i] = set <int>({sz[vect[i]].f,sz[vect[i]].s});
		else{
          
            aFOR(j,dp[i-1]) dp[i].insert(j + sz[vect[i]].f);

			
			aFOR(j,dp[i-1]) dp[i].insert(j + sz[vect[i]].s);
		}
	}
	
	
	auto it = dp[vect.size()-1].lower_bound((double)N/(double)2);
	int ans = INF;
	if (it != dp[vect.size()-1].end()) ans = min(ans,f(*it,N-*it));
	if (it != dp[vect.size()-1].begin()){
		it--;
		ans = min(ans,f(*it,N-*it));
	}
	
	
	cout<<ans;
}


Measured memory_bytes: 12288
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

void kiyaku(int a, int b){
  int n = max(a, b);
  for(int i = 2; i < n; ++i){
    if(a % i == 0 && b % i == 0){
      while(a % i == 0 && b % i == 0){
        a /= i; b /= i;
      }
    }
  }
  cout << a << "/" << b << endl;
}

int main(){

  string s;
  cin >> s;

  int len = s.length();
  
  //()ない時
  bool f = false;
  REP(i,len){
    if(s[i] == '('){
      f = true;
    }
  }

  int a, b;

  if(f){
    string tmp = "", tmp2 = "";
    int cnt = 0, cnt2 = 0;
    int p_idx;
    bool kakko = false;
    REP(i,len-1){
      if(s[i] == '('){
        kakko = true;
        cnt2 = i - p_idx - 1;
        continue;
      }else if(s[i] == '.'){
        cnt = (len-1) - i - 2;
        p_idx = i;
      }else{
        tmp += s[i];
        if(!kakko){
          tmp2 += s[i];
        }
      }
    }
    a = stoi(tmp) - stoi(tmp2);
    b = pow(10, cnt) - pow(10, cnt2);
    kiyaku(a, b);
  }else{
    string tmp = "";
    int cnt = 0;
    REP(i,len){
      if(s[i] == '.'){
        cnt = len - 1 - i;
      }else{
        tmp += (s[i]);
      }
    }
    b = pow(10, cnt);
    a = stoi(tmp);
    kiyaku(a, b);
    return 0;
  }

  return 0;
}




Measured memory_bytes: 3380
#include<iostream>
 
using namespace std;
int main()
{
	int a,b,c,x;
	cin >> a >> b;
	char s[15];
	cin >> s;
	int tmp = 1;
	for(int i=0; i<=a+b; i++){
		bool flag = false;
		if(i == a && s[i] == '-') flag = true;
		if(i != a){
			if(s[i] == '0') flag = true;
			if(s[i] == '1') flag = true;
			if(s[i] == '2') flag = true;
			if(s[i] == '3') flag = true;
			if(s[i] == '4') flag = true;
			if(s[i] == '5') flag = true;
			if(s[i] == '6') flag = true;
			if(s[i] == '7') flag = true;
			if(s[i] == '8') flag = true;
			if(s[i] == '9') flag = true;
		}
		if(!flag) tmp = -1;
	}
	if(tmp == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	
	return 0;
}


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

int main(){
    string s;
    cin >> s;
    cout << s[0] << s.size() - 2 << s[s.size()-1] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	char Sa[100],Sb[100],Sc[100];
	scanf("%s %s %s",&Sa,&Sb,&Sc);
	int winner=0;
	int next=1;
	int NumA=0,NumB=0,NumC=0;
	while(1){
		switch(next){
			case 1:
				if(Sa[NumA]=='\0'){
					printf("A");
					return 0;
				} else{
					if(Sa[NumA]=='a'){
						next=1;
						NumA++;
					}else if(Sa[NumA]=='b'){
						next=2;
						NumA++;
					}else{
						next=3;
						NumA++;
					}
				}
			break;
			case 2:
				if(Sb[NumB]=='\0'){
					printf("B");
					return 0;
				} else{
					if(Sb[NumB]=='a'){
						next=1;
						NumB++;
					}else if(Sb[NumB]=='b'){
						next=2;
						NumB++;
					}else{
						next=3;
						NumB++;
					}
				}
			break;
			case 3:
				if(Sc[NumC]=='\0'){
					printf("C");
					return 0;
				} else{
					if(Sc[NumC]=='a'){
						next=1;
						NumC++;
					}else if(Sc[NumC]=='b'){
						next=2;
						NumC++;
					}else{
						next=3;
						NumC++;
					}
				}

			break;
		}


	}




	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 1000000009
#define tc(t) 			int t;cin >> t;while(t--)
#define for0(i , n)		for(int i=0;i<n;i++)
#define loop(i , a, b)	for(int i=a;i<=b;i++)
#define endl '\n'

int n;
int a[100005];
int dp[100005];

int frogA(int ind){
	if(ind == (n-1))
		return 0;

	if(dp[ind] != -1){
		return dp[ind];
	}

	int c1 = abs(a[ind]-a[ind+1])+frogA(ind+1);
	int c2 = INT_MAX;
	if((ind+2) < n){
		c2 = abs(a[ind]-a[ind+2])+frogA(ind+2);
	}

	return dp[ind] = min(c1,c2);
}


signed main() {

	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif

	cin >> n;

	for0(i,n){
		cin >> a[i];
	}

	memset(dp,-1,sizeof(dp));

	cout << frogA(0);

	return 0;
}

Measured memory_bytes: 8172
/// Swift5 -> Swift2.2
extension String {
    // split(separator:maxSplits:omittingEmptySubsequences:)
    func split(separator separator: Character) -> [String] {
        return self.characters.split(separator).map(String.init)
    }
}
extension Array {
    // init(repeating:count:)
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
extension Array where Element: Comparable {
    // sorted()
    func sorted() -> [Element] {
        return self.sort( { $0 < $1 } )
    }
}
// stride(from:through:by:)
func stride(from start: Int, through end: Int, by stride: Int) -> StrideThrough<Int> {
    return start.stride(through: end, by: stride)
}
/// end

let N = Int(readLine()!)!

enum Activity {
    case swimming, catching, homework
}

var happiness = [[Activity: Int]]()
happiness.append([:])
for _ in 0 ..< N {
    let input = readLine()!.split(separator: " ").map { Int($0)! }
    happiness.append([
        .swimming: input[0],
        .catching: input[1],
        .homework: input[2]
    ])
}

var dp = Array(repeating: [Activity: Int](), count: N + 1)
dp[1][.swimming] = happiness[1][.swimming]
dp[1][.catching] = happiness[1][.catching]
dp[1][.homework] = happiness[1][.homework]

for i in stride(from: 2, through: N, by: 1) {
    dp[i][.swimming] = max(
        dp[i - 1][.catching]! + happiness[i][.swimming]!,
        dp[i - 1][.homework]! + happiness[i][.swimming]!
    )

    dp[i][.catching] = max(
        dp[i - 1][.swimming]! + happiness[i][.catching]!,
        dp[i - 1][.homework]! + happiness[i][.catching]!
    )

    dp[i][.homework] = max(
        dp[i - 1][.swimming]! + happiness[i][.homework]!,
        dp[i - 1][.catching]! + happiness[i][.homework]!
    )
}

print(dp.last!.map { $1 }.sorted().last!)


Measured memory_bytes: 55524
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;


long long N, A[200000], sum[200001];

int main(){
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  for(int i = 1; i <= N; i++){
    sum[i] = sum[i-1] + A[i-1];
  }
  sort(sum, sum + N + 1);
  /*for(int i = 0; i <= N; i++){
    if(i) printf(" ");
    cout << sum[i];
  }puts("");
  */
  long long ans = 0;
  long long tmp = 1;
  for(int i = 1; i <= N; i++){
    if(sum[i-1] == sum[i]){
      tmp++;
    }else{
      ans += tmp * (tmp-1) / 2;
      tmp = 1;
    }
  }
  ans += tmp * (tmp-1) / 2;
  cout << ans << endl;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> weight(n);
  for(int i=0;i<n;i++){
    cin >> weight.at(i);
  }
  int min_gap,s1,s2;
  for(int i=0;i<n;i++){ 
    for(int j=i;j<n-1;j++){//分かれ目
      s1 = 0;
      s2 = 0;
      for(int k=0;k<=j;k++){
        s1 += weight.at(k);
      }
      for(int k=j+1;k<n;k++){
        s2 += weight.at(k);
      }
      if(i==0 && j==i){
        min_gap = abs(s1-s2);
      }
      if( min_gap > abs(s1-s2) ){
        min_gap = abs(s1-s2);
      }
    }
  }
  cout << min_gap << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll N;
    cin >> N;
    ll step;
    ll min_person_times = pow(10, 15);
    for(int i = 0; i < 5; i++) {
        cin >> step;
        min_person_times = min(min_person_times, step);
    }

    ll ans = 5;
    if(min_person_times < N) {
        ans += (N / min_person_times) - 1;
        if(N % min_person_times != 0) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import math
M = 256
while 1:
    N = int(raw_input())
    if N == 0: break
    H = 1e10
    l = map(int,raw_input().split())
    ans = [0,0,0]
    for S in range(16):
        for A in range(16):
            for C in range(16):
                R = S
                O = [0]*256
                for i in range(N):
                    R = (A*R+C)%M
                    O[(l[i]+R)%M] += 1
                tmp = -sum(float(x)/N*math.log(float(x)/N,2) for x in O if x != 0)
                if tmp < H:
                    H = tmp
                    ans = [S,A,C]
    print " ".join(map(str,ans))

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

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

using namespace std;
using lint=long long;

int main(){
	lint n,d,a; scanf("%lld%lld%lld",&n,&d,&a);
	vector<pair<lint,lint>> mon(n);
	rep(i,n){
		lint x,hp; scanf("%lld%lld",&x,&hp);
		mon[i]={x,hp};
	}

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

	lint ans=0,power=0;
	queue<pair<lint,lint>> Q; // rightmost point, damage
	rep(i,n){
		lint x,hp; tie(x,hp)=mon[i];

		while(!Q.empty() && Q.front().first<=x){
			power-=Q.front().second;
			Q.pop();
		}

		if(power>=hp) continue;

		lint cnt=(hp-power+a-1)/a;
		ans+=cnt;
		power+=cnt*a;
		Q.emplace(x+2*d+1,cnt*a);
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 4992
n,x = map(int,input().split())
m = [0 for i in range(n)]

for i in range(n):
    m[i] = int(input())
    
m.sort()


cnt = 0

for i in m:
    x -= i
    if x < 0:
        break
    cnt += 1

while 1:
    x -= m[0]
    if x < 0:
        break
    cnt += 1
    
print(cnt)

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

#define rep_(v, f, l) for (int v = (f); v < (l); ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

int main()
{
    double fh, om;
    while (~scanf("%lf %lf", &fh, &om)){
        if (fh < 35.5 && om < 71.0){
            puts("AAA");
        }
        else if (fh < 37.5 && om < 77.0){
            puts("AA");
        }
        else if (fh < 40.0 && om < 83.0){
            puts("A");
        }
        else if (fh < 43.0 && om < 89.0){
            puts("B");
        }
        else if (fh < 50.0 && om < 105.0){
            puts("C");
        }
        else if (fh < 55.0 && om < 116.0){
            puts("D");
        }
        else if (fh < 70.0 && om < 148.0){
            puts("E");
        }
        else {
            puts("NA");
        }
    }
    return (0);
}

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

int main() {
  int x, N, a;
  bool bl=true;
  cin >> x >> N;
  if(N==0){
    cout << x << endl;
    return 0;
  }
  a=101;
  vector<int> vec(N);
  for (int i=0; i<N; i++){
    cin >>vec.at(i);
  }
  for(int j=0; j<100; j++){
    bl=true;
    for(int j2=0; j2<N; j2++){
      if( (x-j)==vec.at(j2) && (x-j)>=0 ){
        bl = false;
      }
    }
    if(bl) {
      cout << x-j << endl;
      return 0;
    }
    bl=true;
    for(int j2=0; j2<N; j2++){
      if( (x+j)==vec.at(j2) && (x+j)<=100 ){
        bl = false;
      }
    }
    if(bl) {
      cout << x+j << endl;
      return 0;
    }
  }
 return 0;
}


Measured memory_bytes: 3624
object Main {
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)
    val bells = List.fill(3)(sc.nextInt)

    val minBells = bells.filter( _ != bells.max )
    if (minBells.length <= 1) {
      println(bells(0)* 2)
    } else {
      println(minBells.sum)
    }
  }
}



Measured memory_bytes: 27204
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
const ll INF=1e10+1;
using namespace std;
#define NOT_EXIST -1

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

signed
main(){
		int N,K;
		cin >> N >> K;
		vector<int> v(N);
		rep(i,N){
				cin >> v[i];
		}
		int ans = INT_MIN;

		for(int take = 0;take<=min(N,K);take++) {
				for(int left = 0;left <= take;left++) {
						vector<int> tmp;
						int right = take - left;
						for(int i = 0;i < left;i++) {
								tmp.push_back(v[i]);
						}
						for(int i = 0;i < right;i++) {
								tmp.push_back(v[N-1-i]);
						}
						sort(All(tmp));
						int minus_max = K - take;
						int t_sum = 0;
						int minus = 0;
						for(int i = 0; i < tmp.size();i++) {
								if(tmp[i] < 0 && minus < minus_max){
										minus++;
										continue;
								}
								t_sum += tmp[i];
						}
						ans = max(ans, t_sum);

				}
		}
		cout << ans << endl;
}

Measured memory_bytes: 256
import collections

n,m=map(int,input().split())
g=[[] for _ in range(n+1)]
for _ in range(m):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
q=collections.deque()
q.append(1)
check=[0]*(n+1)
check[1]=1
ans=[0]*(n+1)
while len(q)!=0:
  v=q.popleft()
  for u in g[v]:
    if check[u]==0:
      check[u]=1
      ans[u]=v
      q.append(u)
print('Yes')
for i in range(2,n+1):
  print(ans[i])

Measured memory_bytes: 94768
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
#define INF 2147483647
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
int main(){
    string s;
    int n;
    cin>>s>>n;
    set<string> t;
    for(int i=0;i<s.size();i++){
        string r="";
        for(int j=i;j<min((int)s.size(),i+5);j++){
            r+=s[j];
            t.insert(r);
        }
    }
    int co=0;
    for(auto x:t){
        co++;
        if(co==n){cout<<x<<endl;break;}
    }
    
}

Measured memory_bytes: 1664
#include<stdio.h>
int main()
{
    long long int a,b,d=0;
    long long int c;
    while(scanf("%lld%lld",&a,&b)!=EOF)
    {
        d=0;
        c=a+b;
        for(;c!=0;)
        {
            c=c/10;
            d++;
        }
        printf("%lld\n",d);
    }
    return 0;
}

Measured memory_bytes: 600
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int iinf = 0x7fffffff;
const ll linf = ~(1LL<<63);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;
template<typename T>
inline T gcd(T a, T b) {
	if(a < 0) return gcd(-a, b);
	if(b < 0) return gcd( a,-b);
	if(a < b) return gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a%b);
}

ll qpow(ll a, ll n, ll mod) {
	a %= mod;
	ll ans = 1LL;
	while(n) {
		if(n & 1) ans = (ans*a % mod);
		a = (a*a % mod);
		n >>= 1;
	}
	return ans;
}

// unsigned
ll qmul(ll a, ll b, ll mod) {
	a %= mod;
	b %= mod;
	ll ans = 0LL;
	while(b) {
		if(b & 1) ans = (ans+a) % mod;
		a = (a<<1) % mod;
		b >>= 1;
	}
	return ans;
}
inline ll rev(ll a, ll p) {
	return qpow(a, p - 2, p);
}

struct Point {
	int x, y;
};

#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define rep(x, st, en) for(int x = st; x < en; x++)
#define pb push_back
#define mp make_pair
#define dbgm(msg, var) cerr<<#msg<<" "<<#var<<" = "<<var<<endl; 
#define dbg(var) cerr<<#var<<" = "<<var<<endl;
#ifdef ALNDBG
clock_t s, e;
#endif

inline void tic() {
#ifdef ALNDBG
	s = clock();
#endif
}

inline void toc() {
#ifdef ALNDBG
	e = clock();
	cerr<<1000.0 * (e - s) / CLOCKS_PER_SEC<<" ms"<<endl;
#endif
}

// -------------------- Spliters ------------------------
const int maxn = 1010;

int main() {
	ios::sync_with_stdio(0);
	int T;
	cin>>T;
	while(T--) {
		int N; cin>>N;
		int D; cin>>D;
		int ans = 0;
		for(int i = 0; i < N - 1; i++) {
			D = 127 - D;
			ans += 127;
		}
		ans+=D;
		cout<<ans<<endl;
	}
	return 0;
}





Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N,R;
  cin>>N>>R;
  int r;
  if(N>=10){
    r=R;
  }else{
    r=R+100*(10-N);
  }
  cout<<r<<endl;

  return 0;
}


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

int main()
{
    int x,y;
    for(;;)
    {
        cin>>x>>y;
        if(x==0 && y==0)
            return 0;
        else if(x>=y)
        {
            int temp=x;
            x=y;
            y=temp;
        }
        cout<<x <<" "<<y<<endl;
    }
    return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
constexpr int M = 1e9 + 7;
constexpr int INF = 1e9;
 
int main() {
    int N;
    cin >> N;
    vector<int> t(N), v(N);
    for(int i = 0; i < N; ++i) {
        cin >> t[i];
    }
    for(int i = 0; i < N; ++i) {
        cin >> v[i];
    }
    v.push_back(0);
 
    vector<double> dp(201, -1);
    dp[0] = 0;
    for(int i = 0; i < N; ++i) {
        vector<double> nxt(201, -1);
        for(int j = 0; j <= v[i]; ++j) {
            if(dp[j] == -1) {
                continue;
            }
            for(int nv = 0; nv <= min(v[i + 1], v[i]); ++nv) {
                if(abs(nv - j) > t[i]) {
                    continue;
                }
                double ma_v = 0;
                if(abs(v[i] - j) + abs(v[i] - nv) > t[i]) {
                    double tt = (nv - j + t[i]) * 0.5;
                    ma_v = j + tt;
                } else {
                    ma_v = v[i];
                }
                double t1 = (ma_v - j), t2 = (ma_v - nv);
                double move = (j + ma_v) / 2 * t1 + ma_v * (t[i] - t1 - t2) + (ma_v + nv) / 2 * t2;
                nxt[nv] = max(nxt[nv], dp[j] + move);
            }
        }
        dp = move(nxt);
    }
    cout << fixed << setprecision(10) << dp[0] << endl;
}

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

int main() {
	int N,K;
	cin>>N>>K;
	int ans=1;
	int x=1;
	while(1){
		if(N/(x*K)==0)break;
		ans++;x*=K;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long long a[10001]={0};
    int n;
    long long min;
    long long max;
    int i;
    long long sum=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    min=a[0];
    for(i=0;i<n;i++){
        if(min>a[i])    min=a[i];
        }
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    max=a[0];
    for(i=0;i<n;i++){
        if(max<a[i])    max=a[i];
        }    
    for(i=0;i<n;i++)    sum=sum+a[i];        
    cout<<min;
    cout<<" ";
    cout<<max;
    cout<<" ";
    cout<<sum;
    cout<<endl;
}


Measured memory_bytes: 3184
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

double func_distance(double x1, double y1, double x2, double y2) {
    double x_length = x2 - x1;
    double y_length = y2 - y1;
    double distance = sqrt(pow(x_length, 2) + pow(y_length, 2));
    return distance;
}

int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    printf("%f\n", func_distance(x1, y1, x2, y2));
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first

const int N=102000;
ll dp[N];
int n;
int a[N];

ll go(int idx){
    if(idx==n-1)
        return 0;
    if(idx>=n)
        return 2e18;
    ll &ret=dp[idx];
    if(ret != -1)
        return ret;
    ret=2e18;
    ret = min(ret, go(idx+1)+abs(a[idx+1]-a[idx]) );
    ret = min(ret, go(idx+2)+abs(a[idx+2]-a[idx]) );
    //cout<<idx<<' '<<dp[idx]<<endl;
    return ret;
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    memset(dp,-1,sizeof dp);
    cout<<go(0);

}


Measured memory_bytes: 4608
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	int a, b;
	V[] vs;

	void run(){
		a=sc.nextInt();
		b=sc.nextInt();
		vs=new V[a+b];
		for(int i=0; i<a+b; i++){
			vs[i]=new V();
		}
		for(int i=0; i<a; i++){
			for(int n=sc.nextInt(); n>0; n--){
				int j=sc.nextInt()-1;
				vs[i].add(vs[a+j]);
			}
		}
		solve();
	}

	void solve(){
		println(bipartiteMathing(vs)==b?"Bob":"Alice");
	}

	int bipartiteMathing(V[] vs){
		int match=0;
		for(V v : vs){
			if(v.match==null){
				for(V u : vs)
					u.used=false;
				if(dfs(v))
					match++;
			}
		}
		return match;
	}

	boolean dfs(V v){
		v.used=true;
		for(V u : v){
			if(u.match==null||!u.match.used&&dfs(u.match)){
				v.match=u;
				u.match=v;
				return true;
			}
		}
		return false;
	}

	class V extends ArrayList<V>{
		V match;
		boolean used;

		void connect(V v){
			add(v);
			v.add(this);
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 14000
#include<bits/stdc++.h>
using namespace std;
#define num 1000000007
//#define num 998244353
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define inarr(i,a,n,A) for(ll i=a;i<n;i++) { cin>>A[i]; }
#define vll vector<long long>
#define pii pair <int,int>
#define pll pair<long long, long long>
#define vpii vector< pair <int,int>>
#define vpll vector< pair<long long, long long>>
//#define max(a,b) ((a>b)?a:b)
//#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define avg(a,b) ((a)+(b))/2
#define pb push_back
#define pob pop_back
#define sf int flag=0     //Remember semicolon
// #define assmin(a,b) if(b<=a) { a=b; }
// #define assmax(a,b) if(b>=a) { a=b; }
#define f first
#define s second
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define all(x) x.begin(), x.end()
#define M_PI 3.14159265358979323846
#define epsilon (double)(0.00000000001)
#define side 1e9
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
ll mod(ll a, ll b)
{
	if(a%b<0)
	{
		return a%b + b;
	}
	return a%b;
}
 
 
ll mod_exp(ll a, ll b, ll c)
{
	ll res=1;
	a=a%c;
	while(b>0)
	{
		if(b%2==1)
		{
			res=(res*a)%c;
		}
		b/=2;
		a=(a*a)%c;
	}
	return res;
}
ll mymod(ll a,ll b)
{
    return ((a%b)+b)%b;
}
bool prime[200001];
void SieveOfEratosthenes() 
{ 
    memset(prime, true, sizeof(prime)); 
    prime[1]=false;
    for (int p=2; p*p<=200000; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=200000; i += p) 
                prime[i] = false; 
        } 
    } 
    return;
}
ll powe[200005];
void power()
{
    powe[0]=1;
    REP(i,1,200005)
    {
        powe[i]=mymod(2*powe[i-1],num);
    }
}
ll gcdExtended(ll,ll,ll *,ll *);
ll modInverse(ll a, ll m) 
{ 
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
        ll res = (x%m + m) % m;
        return res;
} 
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    ll x1, y1; 
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
    return gcd; 
}
struct node
{
	vpll adj;
    ll biggest;
    ll op;
    ll size;
};

ll find(ll n, ll wt, ll nm)
{
    ll st = 1;
    ll en = nm;
    ll mid = (st) + (en - st)/2;
    while(st<=en)
    {
        if(wt+3*(nm+mid)>=n && wt+2*(nm+mid)<=n)
        {
            return mid;
        }
        else if(wt+3*(nm+mid)<n)
        {
            st = mid+1;
        }
        else
        {
            en = mid-1;
        }
        mid = (st) + (en - st)/2;
    }
    if(wt+3*(nm+mid)>=n && wt+2*(nm+mid)<=n)
    {
            return mid;
     }
    return 0;
}
bool my(pair<ll, char> p1, pair<ll, char> p2)
{
    return p1.first > p2.first;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s[1]=='B') cout<<"ARC\n";
    else cout<<"ABC\n";
    return 0;
}


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

int main() {

	string a, b, c; cin >> a >> b >> c;
	int x1 = stoi(a + b) + stoi(c);
	int x2 = stoi(b + c) + stoi(a);
	int x3 = stoi(c + a) + stoi(b);
	cout << max({ x1,x2,x3 }) << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

vector<pii> a(1000010);
//int b[5]={1,4,10,20,35};
//int c[3]={1,10,35};
int main(){
	int n;
	vint b,c;
	ll lim=1000010;
	for(ll i=0;i<lim;i++){
		a[i]=mkp(INT_MAX,INT_MAX);
		//cout<<a[i].S<<endl;
	}
	a[0]=mkp(0,0);
	rep(i,1000000){
		if(!i) continue;
		int t=i*(i+1)*(i+2)/6;
		if(t>1000000) break;
		b.PB(t);
		if(t&1) c.PB(t);//cout<<t<<endl;
	}
	// for(int i=1;i<INT_MAX;i+=2){
		// int t=i*(i+1)*(i+2)/6;
		// if(t>1000000) break;
		// c.PB(t);
		//cout<<t<<endl;
	// }
	rep(i,b.size()){
		int t=b[i];
		while(t<=lim){
			a[t].F=min(a[t].F,a[t-b[i]].F+1);
			t++;
		}
	}
	//cout<<"hoge"<<endl;
	rep(i,c.size()){
		int t=c[i];
		while(t<=lim){
			a[t].S=min(a[t].S,a[t-c[i]].S+1);
			//if(t==14) cout<<a[t].S<<" "<<c[i]<<endl;
			t++;
		}
	}
	while(cin>>n,n){
		cout<<a[n].F<<" "<<a[n].S<<endl;
	}
	return 0;
}

Measured memory_bytes: 8796