akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower, islower
#include <math.h>

#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
//using ll = long long; using ld = long double;
//using P = pair<int, int>;
long long n, m, x, y, z;
const long long template_arry_size = 1000625;
long long a[template_arry_size];
long long b[template_arry_size];
long long c[template_arry_size];
string s, t;
long long ans = 0;

void solve(int tc = 0) {
    cin >> x >> y >> z;

    cout << ((x + y - 1) / y) * z << endl;
}

int main(){

    solve();

}



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

#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
typedef long double ld;

using namespace std;

void solve(ll X){
	ll i = 0;
	ll s = 0;
	while (1) {
		s = (i +1) * i / 2;
		if (X <= s) break;
		i++;
	}
	cout << i << endl;

	
}

int main(){
    // 提出時は削除 //////////////////////////////
//	FILE* fp_in = freopen("/Users/kokinakamura/git/ToolsForAtCoder/workspace/abc056/C/in_C_1.txt", "r", stdin);
    ////////////////////////////////////////////

	ll X;
	scanf("%lld",&X);
	solve(X);

    // 提出時は削除 //////////////////////////////
//    fclose(fp_in);
    ////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  LL n, k;
  cin >> n >> k;
  VLL a(n), f(n);
  INPUT(a); INPUT(f);
  SORT(f); sort(ALL(a), greater<LL>());
  LL max_s = -1;
  REP(i, n) chmax(max_s, a[i]*f[i]);
  LL l = 0, r = max_s;
  while(r - l > 0)
  {
    LL mid = (r+l)/2;
    LL tmp_k = k;
    bool flg = false;
    REP(i, n)
    {
      if (a[i] * f[i] <= mid) continue;
      else
      {
        if (tmp_k == 0)
        {
          flg = true;
          break;
        }
        LL tmp = (a[i]*f[i] - mid - 1) / f[i] + 1;
        if (tmp <= a[i])
        {
          if (tmp <= tmp_k) tmp_k -= tmp;
          else
          {
            flg = true;
            break;
          }
        }
        else
        {
          flg = true;
          break;
        }
      }
    }
    if (flg) l = mid+1;
    else r = mid;
  }
  cout << l <<endl;

  return 0;
}

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

int main()
{
  int n;
  cin >> n;
  
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  int p = 0;
  int cnt = 0;
  bool flag = false;
  
  for(int i = 0; i < n; i++){
    cnt++;
    
    if(a[p] == 2){
      flag = true;
      break;
    }
    
    else{
      p = a[p] - 1;
    }
  }
  
  if(flag){
    cout << cnt << endl;
  }
  
  else cout << "-1" << endl;
  
  return 0;
  
}

Measured memory_bytes: 640
#include <bits/stdc++.h> 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const ll inf = 1e18;
const int N = 2e5 + 10;

int Ddim_dist(vector<int> y, vector<int> z){
    double dist = 0;
    int d = (int)y.size();
    for(int i=0; i<d; ++i){
        dist += pow((y[i] - z[i]),2); 
    }
    return dist;
}


int main(){
    int n,d;
    cin >> n >> d;
    vector<vector<int>> X(n,vector<int>(d));
    rep(i,n){
        rep(j,d){
            cin >> X[i][j];
        }
    }

    int ans = 0;
    for(int i=0; i<n; ++i){
        for(int j=i+1; j<n; ++j){
            int norm = Ddim_dist(X[i],X[j]);

            bool flag = false;
            for(int k=0; k<=norm; ++k){
                if(k*k==norm) flag=true;
            }
            if(flag) ans += 1;
        }
    }
    cout(ans);





    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n,k;
int l[55];
ll ans;
int main(void){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>l[i];
        ans+=l[i];
    }
    sort(l,l+n);
    for(int i=0;i<n-k;i++){
        ans-=l[i];
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 3604
import java.io.*;
import java.util.*;

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

    public static void solve(){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        String s = sc.next();
        int[] l = new int[q];
        int[] r = new int[q];
        for(int i=0;i<q;i++){
        	l[i] = sc.nextInt();
        	r[i] = sc.nextInt();
        }
        int[] len = new int[n];
        for(int i=1;i<n;i++){
        	if(s.charAt(i)=='C' && s.charAt(i-1)=='A'){
        		len[i] = len[i-1] + 1;
        	}
        	else{
        		len[i] = len[i-1];
        	}
        }

        for(int i=0;i<q;i++){
        	System.out.println(len[r[i]-1] - len[l[i]-1]);
        }
    }
}

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

int main() {
  bool flag = false;
  int h,w,k,cnt = 1,sp,ep;
  cin >> h >> w >> k;
  vector<string>data(h);
  vector<vector<int>>ans(h,vector<int>(w,-1));
  vector<int>c(h,0);
  for(int i = 0;i < h;i++) cin >> data[i];
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      if(data[i][j] == '#'){
        if(!flag){
          flag = true;
          sp = i;
        }
        ep = i;
        c[i]++;
      }
    }
  }
  for(int i = sp;i <= ep;i++){
    int ctmp = 0;
    if(c[i] != 0){
      for(int j = 0;j < w;j++){
        if(data[i][j] == '#') ctmp++;
        if(ctmp > 1 && data[i][j] == '#') cnt++;
        ans[i][j] = cnt;
      }
      cnt++;
    }
    else{
      for(int j = 0;j < w;j++) ans[i][j] = ans[i-1][j];
    }
  }
  for(int i = 0;i < sp;i++){
    for(int j = 0;j < w;j++){
      ans[i][j] = ans[sp][j];
    }
  }
  for(int i = ep;i < h;i++){
    for(int j = 0;j < w;j++){
      ans[i][j] = ans[ep][j];
    }
  }
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      cout << ans[i][j];
      if(j != w-1) cout << " ";
      else cout << "" << endl;
    }
  }
}


Measured memory_bytes: 1280
#include<stdio.h>
int main()
{
  int H,W,i,j;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0 && W==0){
        break;
    }
    for(i=1;i<=H;i++){
      for(j=1;j<=W;j++){
	    if((i>1 && i<H) && (j<W && j>1)){
	        printf(".");
	    }else{
	       printf("#"); 
	    }
	   }
        printf("\n");
    }
    printf("\n");
    
  }
  return 0;
}


Measured memory_bytes: 2148
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

ll gcd(ll m, ll n){
  ll m1 = m, n1 = n, tmp;

  while(n1 != 0){
    tmp = n1;
    n1 = m1 % n1;
    m1 = tmp;
  }

  return m1;
}

int main(){
  ll N;
  cin >> N;
  vl A(N);
  rep(i, N) cin >> A[i];

  ll ans = gcd(A[0], A[1]);

  rep2(i, 2, N) ans = gcd(ans, A[i]);

  cout << ans << "\n";
  
  return 0;
}


Measured memory_bytes: 4032
#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 H,W,N;
  cin>>H>>W>>N;
  int l = max(H,W);
  cout<<(N+l-1)/l<<endl;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define int long long  
#define INF 1145141919810893
signed main(){
    int N,M;
    int Ans=0;
    cin >> N >> M;
    if(N>=M/2){
        cout << M/2 << endl;
    }else{
        Ans+=N;
        M-=2*N;
        Ans+=(M/4);
        cout << Ans << endl;
    }
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> dataA(N),dataB(N),ans(N);
  int i,sum;
  sum=0;
  for (i=0; i<N; i++) {
    cin >> dataA.at(i);
    sum = sum + dataA.at(i);
    dataB.at(i) = dataA.at(i)*2;
  }
  int M, kari;
  M = (N-1)/2;
  for (i=0; i<M; i++) {
    kari = kari + dataA.at(2*i);
  }
  ans.at(N-1)=sum-kari*2;
  ans.at(0)=dataB.at(N-1)-ans.at(N-1);
  for(i=1;i<N-1;i++){
    ans.at(i)=dataB.at(i-1)-ans.at(i-1);
  }
  cout << ans.at(0);
  for(i=1;i<N;i++) {
    cout << " "<< ans.at(i);
  }
}


Measured memory_bytes: 2432
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using mcl = map<char, LL>;
using vpi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

void y_n(bool p) {
	p ? _y() : _n();
}

void Y_N(bool p) {
	p ? _Y() : _N();
}

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 




/*****************************************************************************/

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

	int n;
	cin >> n;
	vvi a(n, vi(3));
	f(i, 0, n) {
		f(j, 0, 3) {
			cin >> a[i][j];
		}
	}
	vvi dp(n + 1, vi(3, 0));
	f(i, 0, n) {
		f(j, 0, 3) {
			f(k, 0, 3) {
				if (j == k)continue;
				dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i][j]);
			}
		}
	}
	cout << max(dp[n][0], max(dp[n][1], dp[n][2]));
	return 0;
}

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

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}

bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

int n;
int a[2][101];
int sum1[100], sum2[100];
int main(){
    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> a[0][i];
        sum1[i] = a[0][i];
    }
    for(int i = 0; i < n; i++){
        cin >> a[1][i];
        sum2[i] = a[1][i];
    }
    for(int i = 0; i < n-1; i++){
        sum1[i+1] += sum1[i];
        sum2[i+1] += sum2[i];
    }
    int ans = 0;
    int st;
    for(int i = 0; i < n; i++){
        st = sum1[n-1-i] + sum2[n-1]-sum2[n-1-i] + a[1][n-1-i];
        ans = max(ans, st);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll a,b,c,k;
int main(){
	cin>>a>>b>>c>>k;
	if(k%2 == 0) cout<<a-b<<endl;
	else cout<<b-a<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define REP(i,n) for(int i=0;i<(int)n;++i)
using namespace std;
typedef long long ll;
int main(){
    int D,G;
    cin >> D >> G;
    vector<int> P(D);
    vector<int> C(D);
    REP(i,D) cin >> P[i] >> C[i];

    int mi=1e9;
    for(int p=0; p<(1<<D); p++){
        int all_solve_score=0, x=0;
        for(int problem=0; problem<=D-1; problem++)
            if(p >> problem & 1) {
                all_solve_score += 100*(problem+1) * P[problem] + C[problem];
                x += P[problem];
            }

        for(int problem=D-1; -1<=problem; problem--){
            if(problem==-1) mi = min(mi, x);
            if(p >> problem & 1) continue;
            for(int solve_num=0; solve_num<=P[problem]-1; solve_num++){
                int total_score = all_solve_score + 100*(problem+1) * solve_num;
                int last_x = x+solve_num;
                if(total_score >= G) mi = min(mi, last_x);
            }
            break;
        }

    }
    cout << mi << endl;
    return 0;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, '%d', $n);
$dmy = trim(fgets(STDIN));
$a = explode(' ', $dmy);
$dmy = trim(fgets(STDIN));
$b = explode(' ', $dmy);
$dmy = trim(fgets(STDIN));
$c = explode(' ', $dmy);

$cnt = 0;

sort($a);
sort($c);

for ($j = 0; $j < $n; $j++) {
    // ソートした配列 $array に対して、「値が $target 以上になる範囲のうちの一番左のインデックス」を返す関数
    // $aのうち$b[$j]より小さい値の個数 * $cのうち$b[$j]より大きい値の個数
    $index_a = binarySearchMin($a, $b[$j]);
    $index_c = binarySearchMin($c, $b[$j],'right');

    $cnt_a = $index_a;

    // 値が同じだったら含まない
    if ($b[$j] == $c[$index_c]) {
        /*
        // 一番左のインデックスが返されるが一番右が欲しいので同じ値だったらインデックスを進める
        while (true) {
            if ($index_c + 1 >= $n) {
                break;
            }
            if ($b[$j] == $c[$index_c + 1]) {
                $index_c++;
            } else {
                break;
            }
        }
         * 
         */
        $cnt_c = $index_c + 1;
    } else {
        $cnt_c = $index_c;
    }
    $cnt_c = $n - $cnt_c;
    // echo $index_a . ' ' . $index_c . ' ' . $cnt_a . ' ' . $cnt_c . "\n";
    $cnt += $cnt_a * $cnt_c;
}

// 二分検索
// ソートした配列 $array に対して、「値が $target 以上になる範囲のうちの一番左のインデックス」を返す関数
// 右が欲しかったら $bothにright を指定
// http://d.hatena.ne.jp/ku-ma-me/20161117/p1
function binarySearchMin($array, $target, $both = 'left') {
    // $array = [1,1,1]
    // $target = 2;
    // return 4
    $left = 0;
    $right = count($array) - 1; //5

    while ($left <= $right) {
        $m = $left + intval(($right - $left) / 2); //1
        // echo $left.' '.$right.' '.$m."\n";

        if ($both == 'right') {
            if ($array[$m] <= $target) {
                $left = $m + 1; // 2
            } else {
                $right = $m - 1; // 3
            }
        } else {
            if ($array[$m] < $target) {
                $left = $m + 1; // 2
            } else {
                $right = $m - 1; // 3
            }
        }
    }
   // echo $left . ' ' . $right . ' ' . $m . "\n";
    return $left;
}

// $index_c = binarySearchMin([1, 2, 2, 3, 4, 5], 2);

echo $cnt;


Measured memory_bytes: 29296
n=int(input())
inp = list(map(int,input().split()))
ini=(0,1000)
now=(0,1000)
m=inp[0]
now=(1000//m,1000%m)
flag=0
for i in range(1,len(inp)):
    if inp[i]>m:
        ini=(0,now[0]*inp[i]+now[1])
        now=(ini[1]//inp[i],ini[1]%inp[i])
        m=inp[i]
    else:
        now=(ini[1]//inp[i],ini[1]%inp[i])
        m=inp[i]
print (ini[1])

Measured memory_bytes: 9152
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<iomanip>
#include<algorithm>

using namespace std;

int main(){

    long long a,b,x=0;
  	cin>>a>>b;
  	vector<long long> v(a);
  	for(int i=0;i<a;i++){cin>>v[i];}
	if(b>=a){cout<< 0 << endl;return 0;}
    sort(begin(v),end(v));
    for(int j=0;j<(a-b);j++){
        x+=v[j];
    }

    cout<< x << endl;

}
    

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

void BubbleSort(int a[], int n)
{
	for (int i = 0; i < n; i++) {
		for (int j = n - 1; j > i; j--) {
			if (a[j] < a[j - 1]) {
				int temp = a[j];
				a[j] = a[j - 1];
				a[j - 1] = temp;
			}
		}
	}
}

int main()
{
	int n[3] = { 0 };
	for (int i = 0; i < 3; i++) {
		cin >> n[i];
	}
	BubbleSort(n, 3);

	for (int i = 0; i < 3; i++) {
		cout << n[i];
		cout << ((i < 2) ? " " : "\n");
	}

	return 0;
}


Measured memory_bytes: 3096
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let N = readInt()!
var ans = "No"
for i in 0...N/7 {
    for j in 0...N/4 {
        if 7*i + 4*j == N {
            ans = "Yes"
            break
        }
    }
}
print(ans)


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)

using namespace std;



int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n)   cin >> a[i];

    set<ll> st;
    map<ll, ll> m;
    for(auto x : a){
        st.insert(x);
        m[x]++;
    }

    ll d = st.size() - k;
    priority_queue<ll, vector<ll>, greater<ll>> que;
    for(auto s : st) que.push(m[s]);
    
    ll sum = 0;
    rep(i, d){
        ll l = que.top(); que.pop();
        sum += l;
    }

    cout << sum << endl;


    return 0;
}

Measured memory_bytes: 25844
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

int main(void) {
	ll N, i,j,k, tmp,ans,sum = 0;
	
	vector<ll>A,B;

	scanf("%lld",&N);

	rep(i, N+1) {
		scanf("%lld", &tmp);
		A.push_back(tmp);
	}
	rep(i, N) {
		scanf("%lld", &tmp);
		B.push_back(tmp);
	}
	for (i = N - 1; i >= 0; i--) {
		if (A.at(i+1) > B.at(i)) {
			sum += B.at(i);//引ける値Aはどうでもいい
			B.at(i) = 0;//Bが小さければ全部使い切る
		}
		else {//Bが大きければ
			tmp = A.at(i + 1);
			sum += tmp;//A全部使う
			B.at(i) -= tmp;//A使った分使う
		}
		if (A.at(i) > B.at(i)) {
			tmp = B.at(i);//引ける値Aはどうでもいい
			sum += tmp;
			A.at(i) -= tmp;//引いた分使う
			B.at(i) = 0;//Bが小さければ全部使い切る
		}
		else {//Bが大きければ
			tmp = A.at(i);
			sum += tmp;//A全部使う
			A.at(i) = 0;
			B.at(i) -= tmp;//A使った分使う
		}
		
	}
	printf("%lld", sum);
	


	
	return 0;
}

Measured memory_bytes: 2548
#include <bits/stdc++.h>
#define debug(x) cout << #x << " -> " << x << endl
#define booga cout << "booga" << endl
#define ll long long int
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int printDivisibleNumber(int arr[], int n){
   unordered_set<int> s;
   int maxElement = INT_MIN;
   for (int i = 0; i < n; i++) {
      s.insert(arr[i]);
      maxElement = max(maxElement, arr[i]);
   }
   unordered_set<int> res;
   for (int i = 0; i < n; i++) {
      if (arr[i] != 0) {
         for (int j = arr[i] * 2; j <= maxElement; j += arr[i]) {
            if (s.find(j) != s.end())
               res.insert(j);
            }
         }
      }
   unordered_map<int, int> mp;
   for (int i = 0; i <n; i++)
      mp[arr[i]]++;
   unordered_map<int, int>::iterator it;
   vector<int> ans;
   for (it = mp.begin(); it != mp.end(); it++) {
      if (it->second >= 2) {
         if (res.find(it->first) == res.end()) {
            int val = it->second;
            while (val--)
               ans.push_back(it->first);
         }
      }
      if (res.find(it->first) != res.end()) {
         int val = it->second;
         while (val--)
            ans.push_back(it->first);
      }
   }
   return ans.size();
}
void testcase(){
	int n,a[200005];
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	
	cout << n - printDivisibleNumber(a,n) << "\n";
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t;
	t = 1;
	while(t--){
		testcase();
	}
	return 0;
}


Measured memory_bytes: 30528
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll a,b,c;
	cin>>a>>b>>c;
	ll k;
	cin>>k;
	ll cnt=0;
	while(a>=b){
		cnt++;
		b*=2;
	}
	while(b>=c){
		cnt++;
		c*=2;
	}
	if(cnt<=k){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3620
N, A, B = gets.split.map{|i|i.to_i}
s = Array.new(N){gets.split.map{|i|i.to_i}}
s.sort_by!{|o|o[2]}

a = []
b = []
q = []
N.times{|i|
	q << [1 << i, s[i]]
	case A * s[i][1] <=> B * s[i][0]
	when -1
		a << i
	when 1
		b << i
	end
}

closed = Hash.new{false}
min = nil
until q.empty?
	o = q.shift
	next if closed[o[0]]
	closed[o[0]] = true
	next if min && min <= o[1][2]
	w = (A * o[1][1] <=> B * o[1][0])
	case w
	when 0
		if !min or min > o[1][2]
			min = o[1][2]
			warn "#{min}:#{o.inspect}"
		end
	when -1
		b.each{|i|
			next if o[0][i] == 1
			sum = o[1].dup
			sum[0] += s[i][0]
			sum[1] += s[i][1]
			sum[2] += s[i][2]
			q << [o[0] | (1 << i), sum]
		}
	when 1
		a.each{|i|
			next if o[0][i] == 1
			sum = o[1].dup
			sum[0] += s[i][0]
			sum[1] += s[i][1]
			sum[2] += s[i][2]
			q << [o[0] | (1 << i), sum]
		}
	end
end

if min
	puts min
else
	puts -1
end



Measured memory_bytes: 1916
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

def check(A,B):
    plus,minus = 0,0
    for i in range(N):
        diff = B[i]-A[i]
        if diff>0:
            plus += diff//2
        else:
            minus -= diff
    if plus >= minus:
        return True
    return False 

if check(A,B):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 4600
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::collections::HashSet;

fn main() {
    input! {
        n: usize,
        m: usize,
        ab: [(usize1, usize1); n-1+m],
    }

    let mut g = vec![vec![]; n];
    let mut rg = vec![vec![]; n];

    for &(a, b) in ab.iter() {
        g[a].push(b);
        rg[b].push(a);
    }

    let mut root = 0;
    for i in 0..n {
        if rg[i].len() == 0 {
            root = i;
            break;
        }
    }

    let mut par = vec![None; n];
    let mut hist = HashSet::new();

    rec(root, None, &g, &mut par, &mut hist);

    for i in 0..n {
        if let Some(p) = par[i] {
            println!("{}", p + 1);
        } else {
            println!("0");
        }
    }
}

fn rec(
    cur: usize,
    prev: Option<usize>,
    g: &Vec<Vec<usize>>,
    par: &mut Vec<Option<usize>>,
    hist: &mut HashSet<usize>,
) {
    // println!("cur: {}", cur);

    hist.insert(cur);

    for &next in g[cur].iter() {
        if Some(next) == prev {
            continue;
        }

        if let Some(np) = par[next] {
            if hist.contains(&np) {
                par[next] = Some(cur);
            }
        } else {
            // println!("hoge: {} -> {}", cur, next);
            par[next] = Some(cur);
            rec(next, Some(cur), g, par, hist);
        }
    }

    hist.remove(&cur);
}


Measured memory_bytes: 61820
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  int X;
  cin >> X;
  if (X < 100) {
    cout << 0 << endl;
  } else if (X <= 105) {
    cout << 1 << endl;
  } else {
    vec<int> dp(X + 1);
    REP(i, 100) dp[i] = 0;
    FOR(i, 100, 106) dp[i] = 1;
    FOR(i, 106, X + 1) REP(j, 6) dp[i] |= dp[(i - 100) - j];
    cout << dp[X] << endl;
  }
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>

using namespace std;

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


#define MAX_N 100000
int par[MAX_N];
int myrank[MAX_N];

void init(int n){
    for(int i = 0; i < n; i++){
        par[i] = i;
        myrank[i] = 0;
    }
}

//木の根を求める
int find(int x){
    if(par[x] == x){
        return x;
    }
    else{
        return par[x] = find(par[x]);
    }
}

// xとyの属する集合を併合
void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y)  return;

    if(myrank[x] < myrank[y]){
        par[x] = y;
    }
    else{
        par[y] = x;
        if(myrank[x] == myrank[y])  myrank[x]++;
    }
}

//xとyが同じ集合に属するかどうか
bool same(int x, int y) {
    return find(x) == find(y);
}

int main(){
    int N, M;
    int p[110000];
    int x[110000], y[110000], ind[110000];
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        cin >> p[i];
        ind[p[i]] = i+1;
    }
    for(int i = 0; i < M; i++){
        cin >> x[i] >> y[i];
    }
    init(N+1);
    for(int i = 0; i < M; i++){
        unite(x[i], y[i]);
    }
    int res = 0;
    for(int i = 1; i <= N; i++){
        if(same(i, ind[i])){
            res++;
        }
    }

    cout << res << endl;

    return 0;

}



Measured memory_bytes: 2560
//Use valgrind once if the submission doesn't go through. It can detect uninitialized variables and see where they could be an issue.
#include <bits/stdc++.h>
#include <numeric>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
class DSU{
	vector<int> rank, parent, _size;
	int _Size;
	public:
	DSU(int n): parent(n), rank(n,0), _size(n,1), _Size(n){
		iota(parent.begin(),parent.end(),0);
	}
	int Find(int x){
		if(x!=parent[x]){
			parent[x]=Find(parent[x]);
		}
		return parent[x];
	}
	int Union(int x,int y){
		x=Find(x);
		y=Find(y);
		if(rank[x]<rank[y]){
			parent[x]=y;
			return _size[y]+=_size[x];
		}
		else if(rank[x]>rank[y]){
			parent[y]=x;
			return _size[x]+=_size[y];
		}
		else if(x!=y){
			parent[y]=x;
			++rank[x];
			return _size[x]+=_size[y];
		}
		return 0;
	}
	int size(){
		return _Size;
	}
	int size(int i){
		return _size[i];
	}
};
int main(){

	ios_base::sync_with_stdio(false);
    	cin.tie(NULL);

	int n,m,ans=1;
	cin>>n>>m;
	DSU d(n);
	for(int i=0;i<m;++i){
		int a,b;
		cin>>a>>b;
		ans=max(ans,d.Union(a-1,b-1));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 5568
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF 1e9
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int,int> p;

char m[1001][1001];
int H,W,N,gx[10],gy[10],d[1001][1001],dx[]={1,0,-1,0},dy[]={0,1,0,-1};

int bfs(int no){
	queue<p> q;
	rep(i,H)rep(j,W)d[i][j]=INF;
	q.push(p(gx[no],gy[no]));
	d[gy[no]][gx[no]]=0;
	while(!q.empty()){
		p c=q.front();q.pop();
		if(c.first==gx[no+1]&&c.second==gy[no+1])return d[gy[no+1]][gx[no+1]];
		rep(i,4){
			int nx=c.first+dx[i],ny=c.second+dy[i];
			if(nx>=0&&nx<W&&ny>=0&&ny<H&&m[ny][nx]!='X'&&d[ny][nx]==INF){
				q.push(p(nx,ny));
				d[ny][nx]=d[c.second][c.first]+1;
			}
		}
	}
}

int main(){
	cin>>H>>W>>N;
	rep(i,H)rep(j,W){
		cin>>m[i][j];
		if(m[i][j]=='S'){gx[0]=j;gy[0]=i;}
		if('1'<=m[i][j]&&m[i][j]<='9'){gx[m[i][j]-'0']=j;gy[m[i][j]-'0']=i;}
	}
	int ans=0;
	rep(i,N)ans+=bfs(i);
	cout<<ans<<endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <climits>
#include<iomanip>
#define int int64_t
#define endl "\n"

using namespace std;

void io()
{
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    
}
int n;
int shift = 3010;
vector<vector<double>> dp(3000,vector<double>(3500 + shift,-1));
double solve(vector<double> &coins, int i,int counthead){
    //base case
    if(i==n){
        if(counthead >0) return 1; // as odd number 
        else return 0;
    }
    //recursive case
    if(dp[i][counthead + shift]!=-1){
        return dp[i][counthead + shift];
    }
    double ans1 = coins[i] * solve(coins,i+1,counthead+1);
    double ans2 = (1 -coins[i]) * solve(coins,i+1,counthead-1);
    return dp[i][counthead + shift] = ans1+ans2;
}

void Solution()
{
    cin >> n;
    vector<double> coins(n);
    for (int i = 0; i < n; i++)
    {
        cin >> coins[i];
    }

    cout <<setprecision(10) << solve(coins,0,0);
    
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //io();
    Solution();
}

Measured memory_bytes: 153216
def less(ah, ad, bh, bd):
    if ad == bd:
        return ah < bh
    return ad < bd

def check(aw, ah, bw, bh, cw, ch):
    ad, bd, cd = aw * aw + ah * ah, bw * bw + bh * bh, cw * cw + ch * ch
    return less(ah, ad, bh, bd) and less(bh, bd, ch, cd)

while True:
    h, w = map(int, input().split())
    if not w:
        break
    d = w * w + h * h
    aw, ah = 1000, 1000
    for hh in range(1, 151):
        for ww in range(hh + 1, 151):
            if check(w, h, ww, hh, aw, ah):
                aw, ah = ww, hh
    print(ah, aw)

Measured memory_bytes: 6724
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
//        string[] read = ReadLine().Split(' ');
//        int read_leng = read.Length;
//        int[] readR = new int[mochinum];
        int a = int.Parse(ReadLine());
//        int b = int.Parse(read[1]);
//        int c = int.Parse(read[2]);
//        int d = int.Parse(read[3]);
        long ans=1;
        for(int i=1;i<=a;i++){
            ans *= i;
            ans %= 1000000007;
        }
        WriteLine(ans);
    }
}

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

public class Main {
    static Scanner sc = new Scanner(System.in);
    static final int inf = 0x3f3f3f3f;
    public static void main(String[] args) {
        int N = sc.nextInt(), W = sc.nextInt();
        int bound = 100 * 1000;
        int[] v = new int[N + 1], w = new int[N + 1];
        long[] f = new long[bound  + 1];
        Arrays.fill(f,inf);
        f[0] = 0;
        for(int i = 1; i <= N; i ++){
            v[i] = sc.nextInt();
            w[i] = sc.nextInt();
        }
        for(int i = 1; i <= N; i++){
            for(int j = bound; j >= w[i]; j --){
                f[j] = Math.min(f[j],f[j - w[i]] + v[i]);
            }
        }
        int res = 0;
        for(int i = 0; i <= bound; i ++){
            if(f[i] <= W)res = i;
        }
//        for(int i = 1; i <= 300; i ++) {
//            if(i % 10 == 0) System.out.println();
//            System.out.print(f[i] + " ");
//        }
        System.out.println(res);
    }
}

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

using namespace std;

int a;

string cal() {
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i * j == a) return "Yes";
        }
    }
    return "No";
}

int main() {
    cin >> a;
    cout << cal() << endl;
    return 0;
}

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

int32_t n, m;
int32_t a[1000000];

int64_t imos[1000000];
int64_t ruiseki_minus[1000000];

int main(void) {
	int32_t i;
	int64_t honrai = 0;
	int64_t max_sakugen = 0;
	int64_t current_honrai;
	if (scanf("%"SCNd32"%"SCNd32, &n, &m) != 2) return 1;
	for (i = 0; i < n; i++) {
		if (scanf("%"SCNd32, &a[i]) != 1) return 1;
	}
	/* マーク */
	for (i = 1; i < n; i++) {
		if (a[i - 1] < a[i]) {
			honrai += (current_honrai = a[i] - a[i - 1]);
			if (a[i - 1] + 2 <= a[i]) {
				imos[a[i - 1] + 2]++;
				imos[a[i] + 1]--;
				ruiseki_minus[a[i] + 1] += current_honrai - 1;
			}
		} else {
			honrai += (current_honrai = a[i] + (m - a[i - 1]));
			if (a[i - 1] + 2 <= m) {
				imos[a[i - 1] + 2]++;
				imos[m + 1]--;
				imos[1] += m - a[i - 1];
				imos[2] -= m - a[i - 1];
				imos[2]++;
				imos[a[i] + 1]--;
			} else if (a[i - 1] == m - 1) {
				imos[1]++;
				imos[a[i] + 1]--;
			} else { /* a[i - 1] == m */
				imos[2]++;
				imos[a[i] + 1]--;
			}
			ruiseki_minus[a[i] + 1] += current_honrai - 1;
		}
	}
	/* いもす→累積和 */
	for (i = 1; i <= m; i++) imos[i] += imos[i - 1];
	for (i = 1; i <= m; i++) imos[i] += imos[i - 1] - ruiseki_minus[i];
	/* 探す */
	for (i = 1; i <= m; i++) {
		if (imos[i] > max_sakugen) max_sakugen = imos[i];
	}
	printf("%"PRId64"\n", honrai - max_sakugen);
	return 0;
}

/*
「削減できる」を記録
いもす
* * * s * * d * *
0 0 0 0 0 1 1 0 0
0 0 0 0 0 1 2 0 0

* * * d * s * * *
3 1 1 1 0 0 0 1 1
3 4 5 6 0 0 0 1 2

* * * d * * * s *
1 1 1 1 0 0 0 0 0
1 2 3 4 0 0 0 0 0

* * * d * * * * s
0 1 1 1 0 0 0 0 0
0 1 2 3 0 0 0 0 0

* * * d s * * * *
4 1 1 1 0 0 1 1 1
4 5 6 7 0 0 1 2 3
*/


Measured memory_bytes: 7040
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
typedef long long ll;
typedef long double ld;
#define PI  3.14159265358979323846

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

int main() {
    ld A, B, H, M;
    cin >> A >> B >> H >> M;
    ld X1, Y1, X2, Y2;
    X1 = A * cos((360.0 / 12.0) * (H+M/60.0) * (PI / 180.0));
    Y1 = A * sin((360.0 / 12.0) * (H+M/60.0) * (PI / 180.0));
    X2 = B * cos((360.0 / 60.0) * M * (PI / 180.0));
    Y2 = B * sin((360.0 / 60.0) * M * (PI / 180.0));
    ld lenght = pow(pow(X2-X1,2)+pow(Y2-Y1,2),0.5);
    cout << std::fixed << std::setprecision(15) << lenght << endl;

    return 0;
}

Measured memory_bytes: 4176
n,q = map(int,input().split())
s = input()
l = [list(input().split()) for i in range(q)]

def rb(x):
    st = x
    for i in range(q):
        if st == n:
            return True
        if st == -1:
            return False
        if l[i][0] == s[st]:
            if l[i][1] == "R":
                st += 1
            else:
                st -= 1
    if st == n:
        return True
    return False
def lb(x):
    st = x
    for i in range(q):
        if st == -1:
            return True
        if st == n:
            return False
        if l[i][0] == s[st]:
            if l[i][1] == "R":
                st += 1
            else:
                st -= 1
    if st == -1:
        return True
    return False
def bs():
    p = n
    ng = -1
    while abs(p - ng) > 1:
        m = (p+ng)//2
        if rb(m):
            p = m
        else:
            ng = m
    return p
def bs2():
    p = -1
    ng = n
    while abs(p-ng) > 1:
        m = (p+ng)//2
        if lb(m):
            p = m
        else:
            ng = m
    return p
print(bs() - bs2() -1)




Measured memory_bytes: 87500
#include <stdio.h>
#include <stdlib.h>
int main() {
	int n, a[200000];
	long long sum = 0, Spt = 0, min = 1e18;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		sum += a[i];
	}
	for (int i = 0; i < n - 1; i++) {
		Spt += a[i];
		if (min > llabs(Spt - (sum - Spt))) {
			min = llabs(Spt - (sum - Spt));
		}
	}
	printf("%lld\n", min);
	return 0;
}

Measured memory_bytes: 896
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  string s;
  cin >>s;
  
  vector<string> month = {"01", "02", "03", "04", "05", "06",
                          "07", "08", "09", "10", "11", "12"};
  bool jou = false;
  bool ge = false;
  
  for(string mo : month) {
    if(mo==s.substr(0,2)) jou = true;
    if(mo==s.substr(2,2)) ge = true;
  }
  
  if(jou && ge) puts("AMBIGUOUS");
  else if (jou) puts("MMYY");
  else if (ge) puts("YYMM");
  else puts("NA");
  
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

int gcd(int a,int b){return b?gcd(b,a%b):a;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}

template<typename T>
void ppp(T n){cout << n << endl;}

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


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<string> vstr;



vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int r;
    cin >> r;

    if(r<1200){
        cout << "ABC" << endl;
        return 0;
    }
    else if(r>=1200 && r < 2800){
        cout << "ARC" << endl;
        return 0;
    }
    else{
        cout << "AGC" << endl;
        return 0;
    }
    








    
}


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

string s;
string key = "keyence";
int len;

void init() {
	cin >> s;
	len = s.length();
}

string solve(){
    int iS, iKey;
    iS = 0;
    iKey = 0;
    while(iKey < 7){
        if(s.at(iS) == key.at(iKey)){
            iS++;
            iKey++;
            continue;
        }
        if(s.substr(len - (7 - iKey), 7 - iKey) == key.substr(iKey, 7 - iKey)) return "YES";
        return "NO";
    }
    return "YES";
}

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

	init();
    
    cout << solve() << "\n";

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int K, N;
    cin >> K >> N;

    vector<int> a(N);
    REP(i, N) {
        cin >> a[i];
    }

    int b = abs(K + a[0] - a[N-1]);
    REP(i, N-1) {
        b = max(b, a[i+1] - a[i]);
    }

    cout << K - b << endl;
    
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define max 1000000000
using namespace std;
int n,m;
int cost[1000];
int num[1000];
int keys[1000][12];
int visited[1000][5000];
int memo[1000][5000];
int dp(int pos,int arg)
{
//	cout<<"pos "<<pos<<" arg "<<arg<<" ";
	if(arg == (pow(2,n)-1))
	 return 0;
	if(pos==m)
	 return max;
	if(visited[pos][arg])
	 return memo[pos][arg];
	visited[pos][arg]=1;
	int cost1=dp(pos+1,arg);
	int var=arg;
	for(int i=0; i<num[pos]; i++)
	{
		int temp=keys[pos][i]-1;
		var=(var)|(1<<temp);
	}
	int cost2=cost[pos]+dp(pos+1,var);
	memo[pos][arg]=min(cost1,cost2);
	return memo[pos][arg];
}
int main()
{
	cin>>n>>m;
	for(int i=0; i<m; i++)
	{
		cin>>cost[i]>>num[i];
		for(int j=0; j<num[i]; j++)
		 cin>>keys[i][j];
	}
	for(int i=0; i<1000; i++)
	{
		for(int j=0; j<5000; j++)
		 visited[i][j]=0;
	}
	int ans=dp(0,0);
	if(ans>=max)
	 cout<<"-1";
	else
	 cout<<ans;
	return 0;
	
}

Measured memory_bytes: 39248