akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include <assert.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
#include <climits>
using namespace std;
typedef unsigned long long ull;
#define ll long long int
static const double PI = 3.141592653589793;
ll mod = 1000000007;
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;


int main() {
	ll m, d,y=0;
	cin >> m>>d;
	for (int i = 1; i <= m; i++) {
		for (int j = 22; j <= d; j++) {
			if (j % 10 >= 2) {
				ll a = j % 10,b=j/10;
				if (i == a * b)y++;
			}
		}
	}
	cout<< y<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll N;
  cin>>N;
  vector<ll> V(N),C(N);
  FORi(N){
    cin>>V[i];
  }
  FORi(N){
    cin>>C[i];
  }
  ll sum=0;
  FORi(N){
    if(V[i]>C[i])sum+=V[i]-C[i];
  }
  cout<<sum<<endl;
  
  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
x, cnt = 0, 0
vis = [-1]*N
if K > N:
    while 1:
        vis[x] = cnt
        cnt += 1
        x = A[x]-1
        if vis[x] != -1:
            break
    for i in range((K-vis[x])%(cnt-vis[x])):
        x = A[x]-1
else:
    for i in range(K):
        x = A[x]-1
print(x+1)

Measured memory_bytes: 92284
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)
const ll mod = 1e9+7;

ll dp[2010];
int main(){
  int s;
  cin >> s;
  dp[0] = 1;
  for (int i = 0; i <= s;i++){
    for (int j = i-3; j >= 0; j--){
      dp[i] += dp[j];
      dp[i]%=mod;
    }
  }
  cout << dp[s] << endl;

  return 0;
}

Measured memory_bytes: 3608
from bisect import bisect_left

N = int(input())
L = list(map(int, input().split(" ")))
L.sort()

ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        idx = bisect_left(L, L[i]+L[j], j+1)
        ans += idx-j-1
print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,X;cin>>N>>X;
  vector<int> a(N);
  for(int i=0;i<N;i++)cin>>a.at(i);
  sort(a.begin(),a.end());
  X-=accumulate(a.begin(),a.end(),0);
  int ans=N+X/a.at(0);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 unsigned long long s,sum = 0,i=0;
 cin>>s;
 while(++i<=s){
      if(!(i%3==0 || i%5==0))sum+=i;
    }
 cout<<sum<<endl;
 return 0;
}

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

int main(){
	int n,x;
	cin>>n>>x;
	vector <long long int> rj(x+1,0);
	long long int a,b;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		for(int j=x-a;j>=0;j--)
			rj[j+a]=max(rj[j+a],rj[j]+b);
	}
	
	cout<<rj[x];
}

Measured memory_bytes: 1024
open System

[<EntryPoint>]
let main argv =
    let w = System.Console.ReadLine().[0]
    let res = match w with
        | 'a'| 'i' | 'u' | 'e' | 'o' -> "vowel"
        | _ -> "consonant"
    printfn "%s" res
    0


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

// #define int long long

inline bool is753(int n) {
  int three = 0;
  int five = 0;
  int seven = 0;

  while(true){
    switch (n % 10){
    case 3:
      ++three;
      break;
    case 5:
      ++five;
      break;
    case 7:
      ++seven;
      break;
    default:
      return false;
    }
    n /= 10;
    if (n==0)
      break;
  }
  if(three * five * seven == 0)
    return false;
  return true;
}

// bool is753(int n) {
//   string s = to_string(n);
//   if(s.find("0") != string::npos)
//     return false;
//   if(s.find("1") != string::npos)
//     return false;
//   if(s.find("2") != string::npos)
//     return false;
//   if(s.find("4") != string::npos)
//     return false;
//   if(s.find("6") != string::npos)
//     return false;
//   if(s.find("8") != string::npos)
//     return false;
//   if(s.find("9") != string::npos)
//     return false;

//   if(s.find("3") == string::npos)
//     return false;
//   if(s.find("5") == string::npos)
//     return false;
//   if(s.find("7") == string::npos)
//     return false;

//   return true;
// }

signed main(void) {
  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  int n;

  cin >> n;

  int i = 357;
  while(true){
    if(i>n)
      break;
    if (is753(i)) // **7
      ++num;
    i += 6;
    if(i>n)
      break;
    if (is753(i)) // **3
      ++num;
    i += 2;
    if(i>n)
      break;
    if (is753(i)) // **5
      ++num;
    i += 2;
  }

  cout << num << endl;
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	VI day = { 31,29,31,30,31,30,31,31,30,31,30,31 };
	VS name = { "Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday" };
	while (true) {
		int x, y;
		cin >> x >> y;
		if (x == 0 && y == 0)break;

		int sum = 0;
		rep(i, x - 1)sum += day[i];
		sum += y;
		cout << name[(sum - 1) % 7] << endl;
	}
}


Measured memory_bytes: 3064
n,k=map(int,input().split())
if k%2==0:
  s=n//k
  if k*(s+1)<=n:
    s+=1
  ans=s*s*s
  r=n//(k//2)
  if k*(r+1)<=2*n:
    r+=1
  print(ans+(r-s)**3)
else:
  r=n//k
  if k*(r+1)<=n:
    r+=1
  print(r**3)
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
  int n;
  cin >> n;
  vector<double>x(n);
  vector<double>y(n);
  for(int i=0;i<n;i++){
    cin >> x.at(i) >> y.at(i);
  }
  vector<int>in(n);
  for(int i=0;i<n;i++){
    in.at(i)=i;
  }
  double ans=0,num=0;
  do{
    for(int i=0;i<n-1;i++){
      double x_long=pow(x.at(in.at(i))-x.at(in.at(i+1)),2.0);
      double y_long=pow(y.at(in.at(i))-y.at(in.at(i+1)),2.0);
      num+=sqrt(x_long+y_long);
    }
    ans+=num;
    num=0;
  }while(next_permutation(in.begin(),in.end()));
  ans/=facctorialMethod(n);
  cout << fixed << setprecision(10);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll n,x;
ll ps[51];
ll ss[51];

ll rec(ll n,ll x){
    if(n==0)return 1;
    if(x==1)return 0;
    if(x<1+ss[n-1])return rec(n-1, x-1);
    if(x==1+ss[n-1])return ps[n-1];
    if(x==2+ss[n-1])return 1 + ps[n-1];
    if(x<ss[n])return 1 + ps[n-1] + rec(n-1, x-ss[n-1]-2);
    return ps[n];
}

int main(void) {
    cin >> n >> x;
    ps[0]=1;ss[0]=1;
    rep(i,51){
        if(i==0)continue;
        ps[i]=ps[i-1]*2+1;
        ss[i]=ss[i-1]*2+3;
    }
    cout << rec(n,x) << endl; 
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i > n; --i)
const int MOD = 1000000007;

bool solve() {
  int N; cin >> N;
  vector<int> A(N), B(N);
  rep(i, 0, N) cin >> A[i] >> B[i];
  using P = pair<int, int>;
  vector<P> C(N);
  rep(i, 0, N) C[i].first = B[i], C[i].second = A[i];
  sort(C.begin(), C.end());
  ll now = 0;
  rep(i, 0, N) {
    now += C[i].second;
    if(now > C[i].first) return false;
  }
  return true;
}

int main() {
  cout << (solve() ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <cstdio>
#include <algorithm>
#include <climits>
#include <vector>
using namespace std;
  
const int SIZE = 1 << 17; // 2^17 = 131072
template<typename T>
struct segtree {
    // ?????????????????????
    T I;
    vector<T> node;
  
    // ????????¬????????§??? (update, query ??? 2 ???????????????)
    T (*upd_f)(T, T), (*qry_f)(T, T);
  
    // ???????????¨?????????????????????????????¨?????? node ??????????????§?????????
    segtree(T (*op1)(T, T), T (*op2)(T, T), T X) {
        upd_f = op1;
        qry_f = op2;
        I = X;
        node.resize(2*SIZE, I);
    }
  
    // ??´??? idx ?????? val ????????? (upd_f ?????¨?????? update)
    void update(int idx, T val) {
        idx += SIZE - 1;
        node[idx] = upd_f(node[idx], val);
        while(idx > 0) {
            // ????????¨?????? qry_f ??????????????¨?????¨????????????
            idx = (idx - 1) / 2;
            node[idx] = qry_f(node[2*idx+1], node[2*idx+2]);
        }
    }
  
    // ???????????? [a, b) ?????????????????¨???????????????
    // (qry_f ?????¨????????????)
    T query(int a, int b, int l=0, int r=SIZE, int k=0) {
        if(b <= l || r <= a) return I;
        if(a <= l && r <= b) return node[k];
        int mid = (l + r) / 2;
        T vl = query(a, b, l, mid, 2*k+1);
        T vr = query(a, b, mid, r, 2*k+2);
        return qry_f(vl, vr);
    }
};
  
int upd(int a, int b) {return b;}
int fnd(int a, int b) {return min(a, b);}
int main() {
    segtree<int> seg(upd, fnd, INT_MAX);
    int N, Q; scanf("%d%d", &N, &Q);
    for(int i=0; i<Q; i++) {
        int c, x, y; scanf("%d%d%d", &c, &x, &y);
        if(c == 0) seg.update(x, y);
        else printf("%d\n", seg.query(x, y+1));
    }
    return 0;
}


Measured memory_bytes: 3288
while True:
    H, W = input().split()
    H = int(H)
    W = int(W)

    if H == 0 and W == 0:
        break
    for a in range(H):
        for b in range(W):
            if a % 2 == 0:
                if b % 2 == 0:
                    print('#', end='')
                else:
                    print('.', end='')
            else:
                if b % 2 == 0:
                    print('.', end='')
                else:
                    print('#', end='')
        print('')
    print('')


Measured memory_bytes: 7012
n = int(input())
b = list(map(int,input().split()))
a = [int() for i in range(n)]

for i in range(n-1):
    if i == 0:
        a[i] = b[i]
    if i == n-2:
        a[i+1] = b[i]
    else:
        a[i+1] = min(b[i],b[i+1])
print(sum(a))





Measured memory_bytes: 3060
#include <iostream>
#include <limits>
#include <vector>

using namespace std;

template <typename T>
struct edge {
  int from, to;
  T cost;
  edge(int t, T c) { to = t, cost = c; }
  edge(int f, int t, T c) { from = f, to = t, cost = c; }
};

template <typename T>
using Edges = vector<edge<T>>;

template <typename T>
vector<T> bellman_ford(Edges<T> &edges, T n, T s) {  // nは頂点数, sは開始頂点
  const auto INF = numeric_limits<T>::max();
  vector<T> dist(n, INF);
  dist[s] = 0;

  for (int i = 0; i < n; i++) {
    for (auto e : edges) {
      if (dist[e.from] == INF) continue;
      if (dist[e.to] > dist[e.from] + e.cost) {
        dist[e.to] = dist[e.from] + e.cost;
        if (i == n - 1) {
          return vector<T>();
        }
      }
    }
  }

  return dist;
}

int main() {
  int n, m, r;
  cin >> n >> m >> r;
  Edges<int> edges;
  for (int i = 0; i < m; i++) {
    int from, to, cost;
    cin >> from >> to >> cost;
    edges.emplace_back(from, to, cost);
  }

  auto dist = bellman_ford(edges, n, r);

  if (dist.empty()) {
    cout << "NEGATIVE CYCLE\n";
  }

  for (auto d : dist) {
    if (d == numeric_limits<int>::max())
      cout << "INF\n";
    else
      cout << d << endl;
  }

  return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int a, b, c; cin >> a >> b >> c;
  if (b / a < c) cout << b / a << endl;
  else cout << c << endl;
}


Measured memory_bytes: 256
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include<bits/stdc++.h>
using namespace std;
#define  fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll         long long
#define  debug      printf("Come here!")
#define  inf        1000000000000000000
#define  pb         push_back
#define  mp         make_pair
#define  sz(a)      a.size()
#define  mem(a,b)   memset(a,b,sizeof(a))
#define  clr(x)     x.clear()
#define  ff         first
#define  ss         second
#define  case(x)    cout << "Case " << x <<": "

#define  md         1000000007
#define  pi         acos(-1.0)
#define  cos(a)     cos(a*pi/180)
#define  sin(a)     sin(a*pi/180)
#define  tan(a)     tan(a*pi/180)
#define  cosi(a)    acos(a)/(pi/180)
#define  sini(a)    asin(a)/(pi/180)
#define  tani(a)    atan(a)/(pi/180)

#define  vl         vector <ll>
#define  vs         vector <string>
#define  vc         vector <char>
#define  vpll       vector < pair <ll, ll> >
#define  vpsl       vector < pair <string, ll> >
#define  vpls       vector < pair <ll, string> >
#define  pql        priority_queue<ll>
#define  minpql     priority_queue<ll,vector<ll>,greater<ll> >

#define  setbits(x)     __builtin_popcountll(x)
#define  zerobits(x)    __builtin_ctzll(x)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}

/* mpp.max_load_factor(0.25); mpp.reserve(1024); */
/* cout << fixed << setprecision(12);*/

int main()
{


        ll k, h, n;
        string a;
        cin>>n>>a;
        h=(a[0]-'0')*100 + (a[2]-'0')*10 + (a[3]-'0');
        k=n*h;
        k/=100;
        cout<<k<<endl;

    return 0;
}



Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <queue>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
    ll N, A, B, ans=0;
    cin >> N >> A >> B;

    if((B-A)%2 == 0){
        ans = (B-A)/2;
    } else {
        ans = min((A+B-1)/2, N-(A+B-1)/2);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000

int partition(int,int);
int n;
int A[MAX];
int main( ){
  int i,j,k;

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

  k = partition(0,n-1);

  for(i = 0; i < n; i++){
    if(i) printf(" ");
    if(i == k) printf("[");
    printf("%d",A[i]);
    if(i == k){
      printf("]");
    }
  }
  printf("\n");

  return 0;
}

int partition(p,r){
  int i,j,x,y;

  x = A[r];
  i = p-1;
  for(j = p; j < r; j++){
    if(A[j] <= x){
      i++;
      y = A[i];
      A[i] = A[j];
      A[j] = y;
    }
  }

  y = A[i+1];
  A[i+1] = A[r];
  A[r] = y;
  return i+1;
}
  



Measured memory_bytes: 2084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	int K,X;
	//long long N, M;
	//double d, e;
	//string s, t;
	//vector<int> v;
	//vector<pair<int, int>> pl;

	//while() {}
	//for(int i=0; i<N; i++) {}
	
	cin >> K >> X;
	cout << ((K*500)>=X ? "Yes" : "No");
	// cout << "[deb: val ]" << val <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100

struct Info{
	Info(int arg_from,int arg_to,int arg_cost){
		from = arg_from;
		to = arg_to;
		cost = arg_cost;
	}
	int from,to,cost;
};

int N,M;

int boss[100],height[100];

int get_boss(int id){
	if(boss[id] == id)return id;
	else{
		return boss[id] = get_boss(boss[id]);
	}
}


void unite(int x,int y){
	int boss_x = get_boss(x);
	int boss_y = get_boss(y);

	if(boss_x == boss_y)return;

	if(height[x] > height[y]){

		boss[boss_y] = boss_x;

	}else if(height[x] < height[y]){

		boss[boss_x] = boss_y;

	}else{ //height[x] == height[y]

		boss[boss_y] = boss_x;
		height[x]++;
	}
}

void init(){
	for(int i = 0; i < N; i++){
		boss[i] = i;
		height[i] = 0;
	}
}

vector<Info> V;

void func(){

	init();
	V.clear();

	int from,to,cost;
	int ans = 0;

	for(int i = 0; i < M; i++){
		scanf("%d %d %d",&from,&to,&cost);
		if(cost < 0){
			ans  += cost;
		}else{
			unite(from,to);
			V.push_back(Info(from,to,cost));
		}
	}

	int group_num = 0;
	for(int i = 0; i < N; i++){
		if(get_boss(i) == i)group_num++;
	}
	if(group_num >= 2){
		printf("%d\n",ans);
		return;
	}

	int ans_1 = BIG_NUM;
	for(int i = 0; i < V.size(); i++){
		init();
		for(int k = 0; k < V.size(); k++){
			if(i == k)continue;
			unite(V[k].from,V[k].to);
		}
		group_num = 0;
		for(int k = 0; k < N; k++){
			if(get_boss(k) == k)group_num++;
		}
		if(group_num >= 2){
			ans_1 = min(ans_1,ans+V[i].cost);
		}
	}

	int ans_2 = BIG_NUM;

	for(int i = 0; i < V.size()-1; i++){
		for(int k = i+1; k < V.size(); k++){
			init();
			for(int p = 0; p < V.size(); p++){
				if(p == i || p == k)continue;
				unite(V[p].from,V[p].to);
			}
			group_num = 0;
			for(int p = 0; p < N; p++){
				if(get_boss(p) == p)group_num++;
			}
			if(group_num >= 2){
				ans_2 = min(ans_2,ans+V[i].cost+V[k].cost);
			}
		}
	}
	printf("%d\n",min(ans_1,ans_2));
}


int main(){

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}

	return 0;
}

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

class DisjointSet {
public:
  vector<int> p, rank, size;
  int group_num;
  DisjointSet(int n) {
    p.assign(n, 0);
    rank.assign(n, 0);
    size.assign(n, 0);
    group_num = n;
    for (int i = 0; i < n; i++) {
      make_set(i);
    }
  }

  void make_set(int x) {
    p[x] = x;
    rank[x] = 0;
    size[x] = 1;
  }

  bool same(int x, int y) {
    return find_set(x) == find_set(y);;
  }

  int find_set(int x) {
    if (x != p[x]) {
      p[x] = find_set(p[x]);
    }
    return p[x];
  }

  int union_size(int x) {
    if (x != p[x]) {
      size[x] = union_size(find_set(x));
    }
    return size[x];
  }

  void link(int x, int y) {
    if(rank[x]  > rank[y]) {
      p[y] = x;
      size[x] = size[x] + size[y];
    }else if(rank[x] < rank[y]){
      p[x] = y;
      size[y] = size[x] + size[y];
    }else if(x != y) {
      p[y] = x;
      rank[x]++;
      size[x] = size[x] + size[y];
    }
  }

  void unite(int x, int y) {
    if (find_set(x) != find_set(y)) group_num--;
    link(find_set(x), find_set(y));
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  int X[M], Y[M], Z[M];
  DisjointSet ds(N);
  for (int i = 0; i < M; i++) {
    cin >> X[i] >> Y[i] >> Z[i];
    X[i]--;
    Y[i]--;
    ds.unite(X[i], Y[i]);
  }
  
  cout << ds.group_num << "\n";

  return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<queue>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
int n,a,b;
int main()
{
    scanf("%d%d%d",&n,&a,&b);
    if((b-a-1)&1) printf("Alice\n");
    else printf("Borys\n");
	return 0;
}

Measured memory_bytes: 256
from heapq import (
    heapify,  # 優先度付きキューの生成
    heappop,
    heappush,
    heappushpop,
    heapreplace
    )

N, M = map(int, input().split())

#heapqは最小値しか取り出さないので-1倍する
A = [-i for i in map(int,input().split())]
heapify(A)

for _ in range(M):
    s = -heappop(A)
    s //= 2
    heappush(A, -s)

print(-sum(A))

Measured memory_bytes: 14180
#include<stdio.h>

int main(void) {
   int n;

   scanf("%d",&n);
     
   if(n%10 == 2 || n%10 == 4 || n%10 == 5 || n%10 == 7 || n%10 == 9) {
      printf("hon");
   } else if(n%10 == 0 || n%10 == 1 || n%10 == 6 || n%10 == 8) {
      printf("pon");
   } else {
      printf("bon");
   }
   return 0;
}
      
      


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

int main(){
  int N,K;
  cin >> N >> K;
  int a[N];
  for(int i = 0 ; i < N ; i++){
    cin >> a[i];
  }
  int res = 0;
  for(int i = 0 ;  ; i++){
    if(N <= 0)break;
    if(i == 0)N -= K;
    else N -= (K-1);
    res++;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 640
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1160&lang=jp
import sys
read = sys.stdin.read
readline = sys.stdin.readline

def main():
    ans = []
    while True:
        w, h = map(int, readline().split())
        if w == 0:
            break

        c = [[0] * (w+2)]
        for _ in range(h):
            c.append([0] + [int(i) for i in readline().split()] + [0])
        c.append([0] * (w+2))

        cnt = 0
        seen = [[-1] * (w+2) for _ in range(h+2)]
        def dfs(sx, sy):
            stack = [(sx, sy)]
            
            while stack:
                x, y = stack.pop()

                for dx in [-1, 0, 1]:
                    for dy in [-1, 0, 1]:
                        if dx == 0 and dy == 0:
                            continue
                        nx = x + dx
                        ny = y + dy

                        if c[nx][ny] and seen[nx][ny] == -1:
                            seen[nx][ny] = 1
                            stack.append((nx, ny))

        for i in range(1,h+1):
            for j in range(1,w+1):
                if c[i][j] and seen[i][j] == -1:
                    cnt += 1
                    dfs(i, j)

        ans.append(cnt)
    
    print("\n".join(map(str, ans)))    


if __name__ == "__main__":
    main()


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

//#pragma comment(linker, "/stack:200000000")
#pragma GCC optimaxze("O3", "Ofast", "unroll-loops", "fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define endl '\n'

using namespace std;


bool check(long long &num){
    string s = to_string(num);
    bool f = true;
    for (int i = 0; i < (int)s.size() - 1; i++){
        int cur = int(s[i]) - 48;
        int next = int(s[i + 1]) - 48;
        f = f && abs(cur - next) <= 1;
    }
    return f;
}
signed main(){
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    long long n, k;
    cin >> n >> k;
    cout << min(k - n % k, n % k) << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[[int(i) for i in input().split()] for i in range(n)]
b=[[int(i) for i in input().split()] for i in range(n)]
maxi=-10**9
check=[0]*10
for i in range(2**10):
    check=[0]*10
    tmp=0
    for j in range(10):
        if (i>>j)&1:
            check[j]=1
    if any(check)==False:
        continue
    for i in range(n):
        cnt=0
        for j in range(10):
            if a[i][j]==1 and check[j]==1:
                cnt+=1
        tmp+=b[i][cnt]
    if tmp>maxi:
        maxi=tmp
print(maxi)

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] scores = new int[N];
        boolean[] color = new boolean[8];
        int masterCnt = 0;

        for (int i = 0; i < 8; i++) {
            color[i] = false;
        }

        for (int i = 0; i < N; i++) {
            int score = sc.nextInt();

            if (score < 400) {
                color[0] = true;
            } else if (score < 800) {
                color[1] = true;
            } else if (score < 1200) {
                color[2] = true;
            } else if (score < 1600) {
                color[3] = true;
            } else if (score < 2000) {
                color[4] = true;
            } else if (score < 2400) {
                color[5] = true;
            } else if (score < 2800) {
                color[6] = true;
            } else if (score < 3200) {
                color[7] = true;
            } else if (score >= 3200) {
                masterCnt++;
            }
        }

        int cnt = 0;
        int ansMin;
        int ansMax;

        for (boolean bl : color) {
            if (bl)
                cnt++;
        }

        // System.out.println("DEBUG cnt:" + cnt);
        // System.out.println("DEBUG mscnt:" + masterCnt);

        if (cnt >= 1) {
            ansMin = cnt;
        } else {
            ansMin = 1;
        }

        ansMax = cnt + masterCnt;

        System.out.println(ansMin + " " + ansMax);
    }
}


Measured memory_bytes: 21844
import math

while(True):
  n = int(input())
  if (n == 0):
    break
    
  s = [float(num) for num in input().split()]
  m = sum(s)/len(s)
  
  a2 = 0
  for ss in s:
    a2 += (ss-m)**2
  a2 /= n
  print(math.sqrt(a2))


Measured memory_bytes: 5780
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    auto n = readInt();
    auto p = readInts();
    auto a = new long[](n+1);
    auto b = new long[](n+1);
    foreach(i; iota(n)) {
        a[p[i]] = p[i] * n + i + 1;
        b[p[i]] = (n+1-p[i]) * n;
    }
    writeln(a[1..$].map!(to!string).join(" "));
    writeln(b[1..$].map!(to!string).join(" "));
}



Measured memory_bytes: 2556
import java.util.*;

class Main{

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

	int n = sc.nextInt();
	int dx = sc.nextInt();
	int dy = sc.nextInt();

	while(n!=0){

	    int posX = 0;
	    int posY = 0;

	    int maxX = 0;
	    int maxY = 0;
	    double max = 0;
	    for(;;){
		posX += dx;
		posY += dy;
		double dist = (posX*posX)+(posY*posY);
		if(dist>max){maxX=posX; maxY=posY; max=dist;}
		if(dist==max && posX>maxX){maxX=posX; maxY=posY;}

		dx = sc.nextInt();
		dy = sc.nextInt();
		if(dx==0 && dy==0)break;
	    }

	    System.out.println(maxX + " " + maxY);

	    n--;
	}
    }
}

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

#include <iostream>
using namespace std;
int main() {
  uint64_t n, m;
  cin >> n >> m;
  vector<uint64_t> a(m);
  uint64_t total = 0;
  for (auto& ai : a) {
    cin >> ai;
    total += ai;
  }

  int diff = n - total;
  if (diff >= 0) {
    cout << diff << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3704
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
#include <deque>
#include <stack>
using namespace std;
    
int main(){
    string S;
    cin >> S;
    int Q,t,f,cnt=0;
    char c;
    cin >> Q;
    //cout << Q << "!";
    for (int i = 0; i < Q; i++){
        cin >> t;
        if(t==1){
            cnt++;
        }
        else{
            cin >> f >> c;
            if(f==2){
                if(cnt%2==0){
                    S.push_back(c);
                }
                else{
                    S.insert(S.begin(),c);
                }
            }
            else{
                if(cnt%2==0){
                    S.insert(S.begin(),c);
                }
                else{
                    S.push_back(c);
                }
            }
        }
    }

    if(cnt%2==0){
        cout << S;
    }
    else{
        reverse(S.begin(),S.end());
        cout << S;
    }
}



Measured memory_bytes: 900
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 10050

bool dp[SIZE][SIZE];

int main(){
  int n, m, a;
  int able[10] = {};

  cin >> n >> m;

  for(int i=0;i<m;i++){
    cin >> a;
    able[a]++;
  }

  dp[0][0] = true;

  int num[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

  for(int i=0;i<n/2;i++){
    for(int j=0;j<n;j++){
      for(int k=1;k<=9;k++){
        if(able[k])
          dp[i+1][j+num[k]] |= dp[i][j];
      }
    }
  }

  int K = 0;

  for(int i=0;i<=n/2;i++){
    if(dp[i][n]) K = i;
  }

  debug(K);

  string ans;

  for(int i=K;i>=1;i--){
    for(int j=9;j>=1;j--){
      if(able[j] && n >= num[j] && dp[i-1][n-num[j]]){
        n -= num[j];
        ans += '0' + j;
        break;
      }
    }
    debug(n);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 49408
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int main(){
    int H,W;
    string S[1001];
    cin>>H>>W;
    for(int i=0;i<H;i++)cin>>S[i];
    int cou[26]={0};
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cou[S[i][j]-'a']++;
        }
    }
    int coucou[4]={0};
    //printf("[%d][%d][%d][%d]\n",coucou[0],coucou[1],coucou[2],coucou[3]);
    for(int i=0;i<26;i++)coucou[cou[i]%4]++;
    if(H%2==1&&W%2==0)swap(H,W);
    if(H%2==0&&W%2==0){
        if(coucou[1]||coucou[2]||coucou[3])puts("No");
        else puts("Yes");
    }
    else if(H%2==0&&W%2==1){
        if(coucou[1]||coucou[3])puts("No");
        else if(H/2<coucou[2])puts("No");
        else puts("Yes");
    }
    else if(H%2==1&&W%2==1){
        if(1!=coucou[1]+coucou[3])puts("No");
        else if(H/2+W/2<coucou[2]+coucou[3])puts("No");
        else puts("Yes");
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;

char str[15];
ll ans;
void dfs(ll sum,int now,int len)
{
    if(now==len)
    {
        ans+=sum;
        return;
    }
    for(int i=now; i<len; i++)
    {
        ll tmp=0;
        for(int j=now; j<=i; j++)
            tmp=tmp*10+(str[j]-'0');
        dfs(sum+tmp,i+1,len);
    }
    return;
}
int main()
{   ios::sync_with_stdio(false);

    cin>>str;
    ans=0;
    int len=strlen(str);
    dfs(0,0,len);
    cout<<ans<<endl;

return 0;
}

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

int main(){
	int N;
	cin >> N;
	vector<bool> memo(32, false), memo2(32, false);
	for(int i = 0; i < N; i++){
		int A;
		cin >> A;
		bool flag = false;
		for(int j = 0; j < 32; j++){
			if(A & (1 << j)){
				if(!flag){
					flag = true;
					memo2[j] = true;
				}
				memo[j] = !memo[j];
			}
		}
	}
	int res = 0;
	for(int i = 31; i >= 0; i--){
		if(memo[i]){
			if(!memo2[i]){
				cout << -1 << endl;
				return 0;
			}
			res++;
			for(int j = i; j >= 0; j--){
				memo[j] = !memo[j];
			}
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int n, k;
    cin >> n >> k;
    vector<int> p(n), c(n);
    for (int i = 0; i < n; i++) cin >> p[i];
    for (int i = 0; i < n; i++) cin >> c[i];
    for (int i = 0; i < n; i++) p[i]--;
    ll ans = -LINF;

    for (int si = 0; si < n; si++) {
        int x = si;
        vector<int> s;
        ll tot = 0;
        while (1) {
            x = p[x];
            s.push_back(c[x]);
            tot+= c[x];
            if (x == si) break;
        }
        int l = s.size();
        ll t = 0;  // start位置からの和
        // start位置を全て調べる
        for (int i = 0; i < l; i++) {
            t += s[i];
            if (k < i+1) break;
            ll now = t;
            // 周期の和が正の場合はループできるだけ追加する
            if (tot > 0) {
                // 何周できるか
                ll e = (k-(i+1)) / l;
                now += tot*e;
            }
            ans = max(ans, now);
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3720
n=int(input())
h=list(map(int,input().split()))
dp=[0 for i in range(n)]
for i in range(1,n):
    if i==1:
        dp[i]=dp[i-1]+abs(h[i]-h[i-1])
    else:
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])

Measured memory_bytes: 20572
def yes():
    print(1)
def no():
    print(0)


X=int(input())
left,right=divmod(X,100)
left_min=0
r=right
for i in range(0,5):
    i=5-i
    count,r=divmod(r,i)
    left_min=left_min+count
if left>=left_min:
    yes()
else:
    no()

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int b[200001];

int main(){
    int N;
    int cnt = 0;
    cin >> N;
    int a[200001];
    for(int i = 1; i <= N; i++) cin >> a[i];
    for(int i = N; i >= 1; i--){
        int sum = 0;
        for(int j = 2; j*i <= N; j++){
            sum += b[j*i];
        }
        sum %= 2;
        if(sum != a[i]){
            b[i] = 1;
            cnt++;
        }
    }
    cout << cnt << endl;
    for(int i = 1; i <= N; i++){
        if(b[i] != 0) cout << i << endl;
    }
}

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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

int main(){
    char a,b;
    cin>>a>>b;
    string ans="";
    if(a<=b){
        for(int i=0;i<(b-'0');i++)ans+=a;
    }
    else{
        for(int i=0;i<(a-'0');i++)ans+=b;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define maxn 202
using namespace std;
string s[maxn];
int dp[2][maxn][maxn][maxn];
int main(){
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; ++ i)
		cin >> s[i];
	for (int i = n; i; -- i)
		for (int j = i; j <= n; ++ j)
			for (int x = m - 1; x >= 0; -- x){
				if (i == j){
					if (x == m - 1)
						dp[0][i][j][x] = m;
					else
						dp[0][i][j][x] = s[i][x] == s[i][x + 1] ? dp[0][i][j][x + 1] : x + 1;
				}
				else
					dp[0][i][j][x] = s[i][x] == s[i + 1][x] ? min(dp[0][i][i][x], dp[0][i + 1][j][x]) : x;
			}
	for (int ans = 0, t = 0; ; ++ ans, t ^= 1){
		if (dp[t][1][n][0] == m){
			cout << ans << endl;
			return 0;
		}
		for (int i = n; i; -- i)
			for (int j = i; j <= n; ++ j)
				for (int x = m - 1; x >= 0; -- x){
					dp[t ^ 1][i][j][x] = dp[t][i][j][x] == m ? m : dp[t][i][j][dp[t][i][j][x]];
					if (i < j){
						int l = i, r = j - 1;
						while (l <= r){
							int m = l + r >> 1;
							if (dp[t][i][m][x] <= dp[t][m + 1][j][x]){
								dp[t ^ 1][i][j][x] = max(dp[t ^ 1][i][j][x], dp[t][i][m][x]);
								r = m - 1;
							}
							else
								l = m + 1;
						}
						l = i, r = j - 1;
						while (l <= r){
							int m = l + r >> 1;
							if (dp[t][i][m][x] > dp[t][m + 1][j][x]){
								dp[t ^ 1][i][j][x] = max(dp[t ^ 1][i][j][x], dp[t][m + 1][j][x]);
								l = m + 1;
							}
							else
								r = m - 1;
						}
					}
				}
	}
}


Measured memory_bytes: 63488
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
lst1 = [list(map(int,readline().split())) for i in range(n)]
lst1.sort()
cost = 1
if n == 1:
    print(cost)
    exit()
#同じベクトルでつなげる要素を最大化する。全点対象にベクトルを求め、多数決。
dic1 = dict()

for i in range(n-1):
    for j in range(i+1,n):
        x,y = lst1[i][0] - lst1[j][0] , lst1[i][1] - lst1[j][1]
        """
        if x < 0 and y < 0:
            x,y = -x,-y
        elif x < 0 and y >= 0:
            x,y = -x,-y"""
        if (x,y) in dic1:
            dic1[(x,y)] += 1
        else:
            dic1[(x,y)] = 1

#線分は頂点-1個。そのうち同ベクトル数が免除される。
cost += n-1
cost -= max(dic1.values())

print(cost)

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

input_list = input().split()

r = int(input_list[0])
D = int(input_list[1])
x_2000 = int(input_list[2])
total = x_2000

for i in range(10):
    total = total * r - D
    print(total)    



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

int main(){
    int N;
    long A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    for(long i = 0; i < N; i++){
        long left = C * i - D * (N - i - 1), right = D * i - C * (N - i - 1);
        if(A + min(left, right) <= B && B <= A + max(left, right)){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>//万能头文件 
using namespace std;
int main(){
  int n;    
  string a;
  int i,ans=0,sum=0;//ans:当前爬到哪里了；sum：当前爬到过最高的海拔 
  cin>>n>>a;//输入    
  for(i=0;i<n;i++){
    if(a[i]=='D') ans--;//判断如果为D的话 ,海拔降低1米 
    else ans++;//海拔升高1米 
    sum=max(ans,sum);}//更新当前最大的海拔 
  cout<<sum;//输出，做岛国题不要忘记换行！ 
  return 0;//结束 
}

Measured memory_bytes: 256
import java.util.Scanner; 
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		String line = in.nextLine();
		String[] Array = line.split(" ");
		int[] numArray = parseInt(Array);
		for(int i = 0; i<numArray.length-1;i++){
			for(int j = numArray.length-1 ; j>i;j--){
				if(numArray[j]<numArray[j-1]){
					int number = numArray[j-1];
					numArray[j-1] = numArray[j];
					numArray[j] = number;

				}
			}
		}
		System.out.println(numArray[0]+" "+numArray[1]+" "+numArray[2]);
		/*for(int i=0; i<numArray.length;i++){
			if(i==0){
			System.out.print(numArray[i]);
		}else{
			System.out.print(" "+numArray[i]);
		}
	}*/
	}
	public static int[] parseInt(String[] Array){
		int[] numArray = new int[Array.length];
		for(int i = 0; i<Array.length ; i++){
			numArray[i] = Integer.parseInt(Array[i]);
		}
		return numArray; 
	} 

}

Measured memory_bytes: 26048
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll k, a, b;
    cin >> k >> a >> b;
    if (b - a < 3) {
        cout << k + 1 << endl;
    }
    else {
        k -= a - 1;
        cout << a + (b - a) * (k / 2) + k % 2 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
 
#define endl '\n'
#define loop(i, m, n) for (ll i = m; i < n; i++)
#define loope(i, m, n) for (ll i = m; i <= n; i++)
#define epool(i, m, n) for (ll i = m; i >= n; i--)
#define mod 1000000007
#define mod2 998244353
#define vi vector<ll>
#define fi first
#define se second
#define pb push_back
#define MP make_pair
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x,0;
#define all(v) v.begin(),v.end()
const ll INF=1e18;
const double PI=4*atan(1);

#define SpeedForce                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;

ll mpow(ll base,ll exp);
void solve();
ll POW(ll base,ll exp);
ll gcd(ll a,ll b);

ll modInverse(ll n) { 
    return mpow(n, mod-2); 
}
 
ll nCr(ll n, ll r){ 
   if (r==0) 
      return 1; 
    ll fac[n+1]; 
    fac[0] = 1; 
    for (int i=1 ; i<=n; i++) 
        fac[i] = (fac[i-1]*i)%mod; 
    return ((fac[r]%mod)*(fac[n]* modInverse(fac[r]) % mod * 
            modInverse(fac[n-r]) % mod)*(fac[n]* modInverse(fac[r]) % mod * 
            modInverse(fac[n-r]) % mod) % mod)%mod; 
}

int32_t main(){
    SpeedForce
    ll i = 0,j = 0;

    int t;
    t=1;
    //cin >> t;
    while (t--){
        //cout << fixed << setprecision(10);
        solve();
    }
}



void solve(){
    ll k,n;
    cin  >> n >> k;
    ll a[n];
    loop(i,0,n) cin >> a[i];

    sort(a,a+n);
    ll ans=0;
    loop(i,0,k) ans+=a[i];
    cout << ans << endl;

}

ll POW(ll base,ll exp){
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base);
        base = ((ll)base * base);
        exp >>= 1;
    }
    return result;
}

ll mpow(ll base, ll exp){
    base %= mod;
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

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

Measured memory_bytes: 3600
N = int(input())
slist = []
for _ in range(N):
    slist.append(input())

M = int(input())
tlist = []
for _ in range(M):
    tlist.append(input())

slist_set = set(slist)
tlist_set = set(tlist)
all_set = list(slist_set | tlist_set)

anslist = []
for i in range(len(all_set)):
    ans = 0
    for j in range(N):
        if all_set[i] == slist[j]:
            ans += 1
    
    for j in range(M):
        if all_set[i] == tlist[j]:
            ans -= 1
    anslist.append(ans)
    
if max(anslist) < 0:
    print(0)
else:
    print(max(anslist))

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

#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define ll             long long
#define int            long long
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define hell           1000000007
#define elasped_time   1.0 * clock() / CLOCKS_PER_SEC
using namespace std;


template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}


int solve(){
 	int r;cin>>r;
 	int val=8;
 	int del=r-400;
 	val-=del/200;
 	cout<<val<<endl;
 return 0;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef SIEVE
    sieve();
    #endif
    #ifdef NCR
    init();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
 

Measured memory_bytes: 3632
INF = 10**10
def rec(cur, cycle):
    if   dp[cur][cycle] > -1: pass
    elif cur == 100: dp[cur][cycle] = 0
    elif until[cur] < t[cycle]: dp[cur][cycle] = INF
    else: dp[cur][cycle] = min(rec(cur+1, (cycle+1)%T), 1+rec(cur+1, 0))
    return dp[cur][cycle]
    
while 1:
    T = int(raw_input())
    if T == 0: break
    t = map(int,raw_input().split())
    N = int(raw_input())
    until = [INF]*100
    for loop in xrange(N):
        D,M = map(int,raw_input().split())
        until[D-1] = min(until[D-1], M)
    
    dp = [[-1]*33 for i in xrange(101)]
    print rec(0,0)

Measured memory_bytes: 4344
#include <cstring>
#include <cstdio>

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

  for (int i=0; i<len; i++){
    int flg = 1;
    for (int j=0; j<len; j++){
      if (s[(i+j)%len] != t[j]) flg = 0;
    }
    if (flg) ans = 1;
  }
  puts(ans?"Yes":"No");

  return 0;
}


Measured memory_bytes: 128
N = int(input())
L = list(map(int, input().split()))
L.sort()

if N < 3:
  print(0)
else:
  sum = 0
  for i in range(N):
    for j in range(i, N):
      for k in range(j, N):
        x = L[i]
        y = L[j]
        z = L[k]
        if (x<y) and (y<z) and (z < (x+y)):
          sum += 1
  print(sum)

Measured memory_bytes: 68244
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define loopi(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define loop(i, n) for (int i = 0; i < (int)n; i++)
#define loopeq(i, n) for (int i = 0; i <= (int)n; i++)
#define loopll(i, n) for (ll i = 0; i < (ll)n; i++)
#define looplleq(i, n) for (ll i = 0; i <= (ll)n; i++)

int main() {
    int n; cin >> n;
    int m; cin >> m;
    vi a(m, 0);
    int sum = 0;
    loop(i, m) { cin >> a[i]; sum+= a[i]; }
    if (n - sum < 0) { cout << -1 << endl; return 0; }
    cout << n - sum << endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> v(n);
  for(int i=0;i<n;++i) cin >> v[i];
  int ans = 1000000000;
  for(int k=-100;k<=100;k++){
    int sum = 0;
    for(int j=0;j<n;++j){
      sum += (v[j] - k) * (v[j] - k);
    }
    ans = min(ans, sum);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256