akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
#define mod 1000000007
ll t,n,m,i,j,k,l,arr[sz],brr[sz],crr[sz];
char c[sz];
int main()
{
    scanf("%lld",&t);
    while(t--)
    {
     scanf("%s",&c);
     if(c[0]=='A')
        n++;
     else if(c[0]=='W')
        m++;
     else if(c[0]=='T')
        i++;
     else
        j++;
    }
     printf("AC x %lld\n",n);
     printf("WA x %lld\n",m);
     printf("TLE x %lld\n",i);
     printf("RE x %lld\n",j);

    return 0;
}



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

int main(){
  ll a;
  string s;
  cin >> a >> s;
  int k = 0;
  k += s[0]-'0';
  k = k*10+s[2]-'0';
  k = k*10+s[3]-'0';
  a*=k;
  cout << a/100 << endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main()
{
	int n, m;
	cin >> n >> m;
	if(n == 1 or m == 1)
		cout << 1 << '\n';
	else
	{
		int r = ((n*m)+1)/2;
		cout << r << '\n';
	}
}

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

int main() {
    int n;
    cin >> n;
    int N = pow(2, n);
    vector<int> t(2 * N - 1);
    multiset<int> st;
    for (int i = 0; i < N; i++) {
        int s;
        cin >> s;
        st.insert(s);
    }
    t[0] = *st.rbegin();
    st.erase(st.find(t[0]));
    int k = 1;
    for (int i = 0; i < N - 1; i = 2 * i + 1) {
        for (int j = i; j <= 2 * i; j++) {
            t[2 * j + 1] = t[j];
            auto ite = st.lower_bound(t[j]);
            if (ite == st.begin()) {
                cout << "No" << endl;
                return 0;
            } else {
                t[2 * j + 2] = *(--ite);
                st.erase(ite);
            }
            k++;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 14720
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
typedef long long ll;
using namespace std;
int size10(ll c){
    ll n=0;
    while(c>=1){
        c = c/10;
        n++;
    }
    return n;
}
int topn(ll n){
    return n/pow(10,size10(n)-1);
    }


int main(){
    int n;
    cin >> n;
    map<int,int> memo1;
    map<int,int[2]> memo2;
    for(int i=1;i<10;i++)memo1[i]=0;
    for(int i=1;i<9;i++){
        for(int j=i+1;j<10;j++){
            memo2[i*10+j][0]=0;
            memo2[i*10+j][1]=0;
        }        
    }

int top,down;
    for(int i=1;i<=n;i++){
        top = topn(i);
        down = i%10;
        if(down != 0){
            if(top == down)memo1[i%10]++;
            else if(top>down)memo2[down*10+top][1]++;
            else memo2[top*10+down][0]++;
            }    
    }
ll num =0;
auto itr1 = memo1.begin();
auto itr2 = memo2.begin();
for(int i=0;i<9;i++){
    num += pow(itr1->second,2);
    
    itr1 = next(itr1,1);
}
for(int i=0;i<36;i++){
    num += itr2->second[0]*itr2->second[1]*2;
    itr2 = next(itr2,1);
}
cout << num <<endl;
    
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N,M;
  cin>>N>>M;
  VI A(N),B(N);
  rep(i,N) cin>>A[i]>>B[i];
  priority_queue<int> Q;
  vector<P> pair;
  rep(i,N) pair.push_back(make_pair(A[i],B[i]));
  sort(all(pair));
  ll ans=0;
  int X=0;
  rep(i,M){
    while(pair[X].first==i+1){
      Q.push(pair[X].second);
      X++;
      if(X==N) break;
    }
    if(Q.size()){
      ans+=Q.top();
      Q.pop();
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2676
#include <bits/stdc++.h>
using namespace std;
bool rMax(int &a, int b) {
    return b > a ? a = b, true : false;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int n;
    cin>>n;
    vector<int> dp(3);
    for(int i = 0; i< n; i++){
        vector<int> nextDP(3, 0);
        int a[3];
        cin>>a[0]>>a[1]>>a[2];
        for(int j : {0, 1, 2}){
            for(int k : {0, 1, 2}){
                if(j!=k)
                    rMax(nextDP[k], a[k] + dp[j]);
            }    
        }
        dp = nextDP;
    }
    cout<< *max_element(dp.begin(), dp.end()) <<"\n";
}


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

int main(){
  int a,b,c=0;
  vector<int> year;
  for(;;){
    cin>>a>>b;
    if(!(a||b))break;

    if(c!=0)
      cout<<endl;

    for(int i=a;i<=b;i++){
      if(i%4==0){
	if(i%100==0){
	  if(i%400==0) year.push_back(i);
	  continue;
	}else{
	  year.push_back(i);
	}
      }
    }

    if(year.size()==0) {
      cout<<"NA"<<endl;
      goto NEXT;
    }

    for(vector<int>::iterator it=year.begin(); it != year.end(); ++it)
      cout<<*it<<endl;

  NEXT:
    year.clear();
    c++;
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
#include <map>
using namespace std;

int main() {
  int N;
  int ans = 0;
  string s;

  cin >> N;

  vector<int> a(N);
  vector<int> b(N);
  vector<long long > c(N, 0);
  int mx = 0;
  for(int i = 0; i < N; i++){
    cin >> a[i];
    b[i] = a[i];
    mx = max(mx, a[i]);
  }
  sort(b.begin(), b.end());
  int bct = 0;
  int bf = 0;
  map<int, int> freq;
  for(int i = 0; i < N; i++){
    freq[a[i]]++;
    if(i > 0){
      if(bf == b[i]){
      }else{
        bct++;
      }
    }
    c[bct]++;
    bf = b[i];
  }
  int fq = c.size();
  long long  allcnt = 0;
  for(int i = 0; i < fq; i++){
    allcnt += c[i]*(c[i]-1)/2;
    // cout << "c[" << i << "] = " << c[i];
    // cout << ", allcnt = " << allcnt << endl;
  }

  // cout << " --- " << endl;
  for(int i = 0; i < N; i++){
    long long mns = 0;
    long long pls = 0;
    mns = freq[a[i]]*(freq[a[i]]-1)/2;
    pls = (freq[a[i]]-1)*(freq[a[i]]-2)/2;
    cout << allcnt - mns + pls << endl;
    // cout << "allcnt = " << allcnt;
    // cout << ", mns = " <<  mns;
    // cout << ", pls = " <<  pls << endl;
  }

}


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

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

vector<ll> fact,inv;

ll f(ll a,ll b, ll p)  // a^b mod pを求める
{
	if (b == 0)
	{
		return 1;
	}else if (b % 2 == 0)
	{
		ll d = f(a,b/2,p);  //a^b = a^(2k) = (a^k)^2  k = b / 2
		return d * d % mod;
	}else
	{
		return a * f(a,b-1,p) % mod;
	}
}

void init(ll n)
{
	fact.resize(n+1,1);
	inv.resize(n+1,1);

	for(int i = 2; i <= n; i++)  //　nまでの階乗を求める
	{
		fact[i] = fact[i-1] * i % mod;
	}
	for(int i = 2; i <= n; i++)  //a^(-1) mod p = a^(p-2) mod p  ここをもう少し早くできるぽい
	{
		inv[i] = f(fact[i],mod-2,mod) % mod;
	}
}

ll comb(ll n,ll k)  //n_C_k
{
	if (n < k)
	{
		return 0;
	}
	return (fact[n] * inv[k] % mod) * inv[n-k] % mod;
}

ll g(ll k, ll i){
	if(k<i) return 0;
	if(i==1) return 1;
	return comb(k-1,i-1);
}

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

	init(2*n);
	ll res = 0;
	for(ll i = 1; i <= k; i++){
		cout<<g(k,i)*comb(n-k+1,i)%mod<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


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

    vector<int> c(9);
    for(int i = 0;i < 9;i ++){
        cin >> c.at(i);
    }

    bool ans = true;
    if(c.at(3) - c.at(0) != c.at(4) - c.at(1)) ans = false;
    if(c.at(3) - c.at(0) != c.at(5) - c.at(2)) ans = false;
    if(c.at(6) - c.at(3) != c.at(7) - c.at(4)) ans = false;
    if(c.at(6) - c.at(3) != c.at(8) - c.at(5)) ans = false;
    if(c.at(1) - c.at(0) != c.at(4) - c.at(3)) ans = false;
    if(c.at(1) - c.at(0) != c.at(7) - c.at(6)) ans = false;
    if(c.at(2) - c.at(1) != c.at(5) - c.at(4)) ans = false;
    if(c.at(2) - c.at(1) != c.at(8) - c.at(7)) ans = false;

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;

}



Measured memory_bytes: 256
def c_colon():
    from math import pi, cos, sqrt
    A, B, H, M = [int(i) for i in input().split()]

    theta = (60 * H - 11 * M) * pi / 360
    return sqrt(A**2 + B**2 - 2 * A * B * cos(theta))

print(c_colon())

Measured memory_bytes: 9500
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
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>;


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(0);   
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

  int n;
  cin>>n;
  int degree[n+1]={0};
  int x,y;
  for(int i=0;i<n-1;i++)
  {
    cin>>x;
    degree[x]++;
  }

  for(int i=1;i<=n;i++)
    cout<<degree[i]<<'\n';

 
// -------------------------------------Code ends here------------------------------------------------------------------
    clock_t clk;
  clk = clock();

    clk = clock() - clk;
  cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
  return 0;
}


Measured memory_bytes: 5372
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  char a[26],b[26],p,q,r;
  fr(i,26){a[i]=i+'a';b[i]=i+'a';}
  string s,t;
  cin>>s>>t;
  fr(i,s.length()){
    p=a[s[i]-'a'];r=b[t[i]-'a'];
    if(p==t[i]) continue;
    a[s[i]-'a']=t[i];
    a[r-'a']=p;
    b[t[i]-'a']=s[i];
    b[p-'a']=r;
  }
  fr(i,s.length()) s[i]=a[s[i]-'a'];
  cout<<(s==t?"Yes":"No")<<endl;
}

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

int main() {
    ll n, m, a, b;
    cin >> n >> m;
    vector<pair<ll,ll>> edges;
    vector<vector<ll>> paths(n+1);
    for (ll i=0; i<m; i++) {
        cin >> a >> b;
        paths[a].push_back(b);
        paths[b].push_back(a);
        edges.push_back(make_pair(a,b));
    }
    ll res = m;
    queue<ll> moves;
    for (auto i : edges) {
        while (moves.size()>0) moves.pop();
        vector<bool> visited(n+1,0);
        ll x = i.first;
        ll y = i.second;
        for (auto j : paths[x]) if (j!=y) moves.push(j);
        visited[x] = true;
        while (moves.size()>0) {
            ll curr = moves.front();
            moves.pop();
            if (visited[curr]) continue;
            visited[curr] = true;
            if (curr==y) {
                res--;
                break;
            }
            for (auto j : paths[curr]) {
                moves.push(j);
            }
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    //freopen("Inp.txt","r", stdin);
    //freopen("Out.txt","w", stdout);

    int n,k; cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    vector<vector<bool>>dp(k+1,vector<bool> (n,false));
    //dp[k][n] is result when Taro choose k_th number in the set and the pile consists of n stones
    //true means Taro win
    int cnt = 0;
    for (int i = 1; i <= k; i++)
        for (int j = 0; j < n;j++)
    {
        if (i < a[j]){
            dp[i][j] = false;
//            cout << dp[i][j] << " ";
        }
        else{
            for (int t = 0; t < n; t++)
                if (dp[i-a[j]][t] == true){
                    dp[i][j] = false;
                    break;
                }
                else dp[i][j] = true;
//            cout << dp[i][j] <<" ";
        }
    }
    for (int i = 0; i < n; i++)
        if (dp[k][i]){
            cout << "First";
            return 0;
        }
    cout << "Second";
    return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
struct dreapta
{
    long double a,b,c;
};
dreapta V[50005];
struct punct
{
    long double x,y;
    int dr;
};
bool cmp1(dreapta a,dreapta b)
{
    long double x=-1e9;
    return (-a.c-a.a*x)/a.b<(-b.c-b.a*x)/b.b;
}
bool cmp2(dreapta a,dreapta b)
{
    long double y=-1e9;
    return (-a.c-a.b*y)/a.a<(-b.c-b.b*y)/b.a;
}
bool cmp3(punct a,punct b)
{
    return a.y<b.y;
}
bool cmp4(punct a,punct b)
{
    return a.x<b.x;
}
int nr;
int N;
int AIB[50005];
punct P[50005];
long long q(int pos)
{
    long long rez=0;
    for(;pos;pos-=(-pos)&pos)rez+=AIB[pos];
    return rez;
}
void u(int pos,int val)
{
    for(;pos<=N;pos+=(-pos)&pos)AIB[pos]+=val;
}
int main()
{
    cin>>N;
    for(int i=1;i<=N;i++){cin>>V[i].a>>V[i].b>>V[i].c;V[i].c*=-1;}
    sort(V+1,V+1+N,cmp1);
    long double st=-1e9,dr=1e9;
    long long nrp=(1LL*N*(N-1))/2;
    while(dr-st>1e-10)
    {
        long double mid=(st+dr)/2;
        for(int i=1;i<=N;i++)
        {
            P[i].x=mid;
            P[i].y=(-V[i].c-V[i].a*mid)/V[i].b;
            P[i].dr=i;
        }
        sort(P+1,P+1+N,cmp3);
        long long rez=0;
        for(int i=N;i;i--)
        {
            rez+=q(P[i].dr);
            u(P[i].dr,1);
        }
        if(rez<nrp/2+nrp%2)st=mid;
        else dr=mid;
        memset(AIB,0,sizeof(AIB));
    }
    cout<<fixed<<setprecision(10)<<st<<" ";
    sort(V+1,V+1+N,cmp2);
    for(int i=1;i<=N;i++)
    st=-1e9,dr=1e9;
    while(dr-st>1e-10)
    {
        long double mid=(st+dr)/2;
        for(int i=1;i<=N;i++)
        {
            P[i].x=(-V[i].c-V[i].b*mid)/V[i].a;
            P[i].y=mid;
            P[i].dr=i;
        }
        sort(P+1,P+1+N,cmp4);
        long long rez=0;
        for(int i=N;i;i--)
        {
            rez+=q(P[i].dr);
            u(P[i].dr,1);
        }
        if(rez<nrp/2+nrp%2)st=mid;
        else dr=mid;
        memset(AIB,0,sizeof(AIB));
    }
    cout<<fixed<<setprecision(10)<<st<<" ";
    return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;
typedef vector<map<lli,lli>> graph;

lli n;
lli a,b;
vll h;
lli max_h;

int main(){
	cin >> n;
	cin >> a >> b;
	h = vll(n);
	for(lli i = 0;i < n;i++) 
		cin >> h[i];
	for(lli i = 0;i < n;i++) 
		max_h = max(max_h,h[i]);
	lli l,m,t;
	t = max_h/b+1;
	l = 0;
	while(l < t){
		m = (l+t)/2;
		lli m_ = 0;
		for(lli i = 0;i < n;i++){
			if(h[i]-b*m >= 0){
				m_ += (h[i]-b*m)/(a-b)+((h[i]-b*m)%(a-b) ? 1 : 0);
			}
		}
		if(m_ <= m) t = m;
		else l = m+1;
	}
	cout << t << endl;
	return 0;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <string>
//#include <boost/multiprecision/cpp_int.hpp>
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define llu  long long 
#define fp cout<<fixed<<setprecision(9);
#define ifor(j,n) for(int i=j ;i<n;i++)
#define jfor(k,n) for(ll j=k ;j<n;j++)
#define pb push_back
#define mod 1000000007
using namespace std;
//using namespace boost::multiprecision;

//Compiler version g++ 6.3.0
int search (vector <long long> v,long long m,int n) 
{ 

    int start = 0;
    int ans = -1; 
    while (start <=n) 
    { 
     int mid = (start + n) / 2;
     if (v[mid] <= m) 
         start = mid + 1;
     else
   { 
   ans = mid; 
   n = mid - 1; 

       } 

    } 
    return ans; 
} 

int main()
{
 FAST 

   int t;
   cin>>t;
  if(t%1000!=0)
  	cout<<1000-(t%1000);
  else
    cout<<0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==5 && b==5 && c==7) cout<<"YES";
    else if(a==5 && b==7 && c==5) cout<<"YES";
    else if(a==7 && b==5 && c==5) cout<<"YES";
    else cout<<"NO";

}


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

int main() {
  string N;
  cin >> N;
  if(N=="3" || N=="5"||N=="7"){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 3636
import math

num = int(input())

for i in range(num):
    try:
        sides = list(map(int, input().split(" ")))
        sides.sort()

        if int(math.pow(sides[0], 2)) + int(math.pow(sides[1], 2)) == int(math.pow(sides[2], 2)):
            print("YES")
        else:
            print("NO")

    except:
        break


Measured memory_bytes: 5676
def main():
    N = int(input())
    A = [(i+1,int(people)) for i,people in enumerate(input().split())]
    A.sort(key=lambda x: x[1])
    for i in range(N):
        print(A[i][0],end="")
        if i != N-1:
            print(" ",end="")
    else:
        print()
if __name__ == '__main__':
    main()

Measured memory_bytes: 69740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    set<ll> st;
    ll n;cin>>n;
    rep(i,0,n-1){
        ll a;cin>>a;
        st.insert(a);
    }
    cout<<st.size()<<endl;
    return 0;
}




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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    int X,N; cin >> X >> N;
    VI p(N), exist(301,0);
    REP(i,N){
        cin >> p[i];
        exist[p[i]+100] = 1;
    }

    int dif = INF, ans;
    REP(i,301){
        if(exist[i] == 1) continue;
        if(chmin(dif, abs(X-(i-100)))){
            ans = i-100;
        }
    }

    cout << ans << en;

    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3660
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
ab = [list(map(int, readline().split())) for i in range(n)]
memo = [0] * n
ans = 0
for i, ab_ in enumerate(ab):
    memo[i] = ab_[0] + ab_[1]
    ans -= ab_[1]
memo.sort(reverse=True)
for i in range(n):
    if i % 2 == 0:
        ans += memo[i]
print(ans)


Measured memory_bytes: 31792
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	a := make([]int, 3)
	for i := 0; i < 3; i++ {
		a[i] = nextInt()
	}
	sort.Sort(sort.IntSlice(a))
	for i := 0; i < 3; i++ {
		fmt.Printf("%v", a[i])
		if i == 2 {
			fmt.Println()
		} else {
			fmt.Printf(" ")
		}
	}
}



Measured memory_bytes: 1140
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)

	flg := true
	var t, x, y int
	for i := 0; i < N; i++ {
		fmt.Scan(&t, &x, &y)

		if (t-x-y) < 0 || (t-x-y)%2 != 0 {
			flg = false
		}
	}
	if flg {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


Measured memory_bytes: 5504
//#define _CRT_SECURE_NO_WARNINGS
//#include <bits/stdc++.h>
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()

#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	bool ans = 1;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) {
			ans = false;
		}
	}
	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3616
import numpy as np

DEG = 16
MOD = 10 ** 9 + 7

even_coef = np.array(
    [0, 530289159, 384702529, 781298570, 90480784, 891754269, 348592099, 833888760, 898908474,
     505425073, 312827475, 794140068, 663894405, 565007911, 300594255, 98196225], dtype=np.int64)
odd_coef = np.array(
    [0, 231379733, 814507152, 631092340, 912089085, 58225824, 706460451, 264043077, 508834119,
     558179703, 136167972, 662064550, 384875310, 496818569, 537065939, 98196225], dtype=np.int64)

t = int(input())
buf = []
for _ in range(t):
    n = int(input())
    if n % 2 == 0:
        m = n // 2
        coef = even_coef
    else:
        m = (n - 1) // 2
        coef = odd_coef

    ms = np.ones(DEG, dtype=np.int64)
    for i in range(1, DEG):
        ms[i] = ms[i - 1] * m % MOD

    ans = (ms * coef % MOD).sum() % MOD
    buf.append(ans)

print('\n'.join(map(str, buf)))


Measured memory_bytes: 27228
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    string s;
    cin >> s;
    bool ans = true;
    int cou = 0;

    for (int i = 0; i < s.size(); i++) {
        if (i == 0) {
            if (s[i] != 'A') ans = false; 
        }
        else if (i >= 2 && i <= s.size()-2 && s[i] == 'C') {
            cou++;
            if (cou > 1) ans = false;
        }
        else if (!islower(s[i])) ans = false;
    }
    if (cou == 0) ans = false;

    if(ans) cout << "AC" << endl;
    else cout << "WA" << endl;

    return 0;
}

Measured memory_bytes: 3604
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-05-03 21:00:58
*/

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

#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF 1000000000

int main()
{
    int n, k;
    cin >> n >> k;
    
    vector<int> t(n, 1);
    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int a;
            cin >> a;
            t[a-1] = 0;
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += t[i];
    }

    cout << ans << endl;

    return 0;
}


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

int main()
{
    int n, A[200];
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> A[i];
    int count = 0;
    for(int i=0; i<n; i++)//??????????°??????´??\?????´????´??????¢
    {
        int minj = i;
        for(int j=i+1; j<n; j++)
        {
            if(A[j]<A[minj])
            {
                minj = j;
            }
        }
        if(i!=minj)
        {
            int temp = A[i];
            A[i] = A[minj];
            A[minj] = temp;
            count++;
        }
    }
    for(int i=0; i<n-1; i++)
       cout << A[i] << " ";
    cout << A[n-1] << endl;
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3108
n = int(input())

red = [list(map(int, input().split())) for _ in range(n)]
blue = [list(map(int, input().split())) for _ in range(n)]

red.sort(key=lambda x: x[1], reverse=True)  # yの大きい順に並べ替え
blue.sort(key=lambda y: y[0])  # xの小さい順に並べ替え

ans = 0

# 貪欲法
# 青をx座標が小さいものから見ていく。
# ペアにできる赤のうち、できるだけ上にあるものを選ぶ
for b in blue:
    for r in red:
        if r[0] < b[0] and r[1] < b[1]:
            red.remove(r)
            ans += 1
            break

print(ans)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for (int i=x;i<=y;i++)
#define per(i,x,y) for (int i=x;i>=y;i--)
typedef long long ll;

inline int read()
{
    int x=0;
    char c=getchar();
    bool flag=0;
    while(c<'0'||c>'9')
	{
		if(c=='-') flag=1;
		c=getchar();
	}
    while(c>='0'&&c<='9')
	{
		x=(x<<3)+(x<<1)+c-'0';
		c=getchar();
	}
    return flag?-x:x;
}

int main()
{
	int n,k;
	cin>>n>>k;
	cout<<n-k+1<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  static final int previousPayment = 4280;

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

    while(true){
      int usedWater = sc.nextInt();

      if(usedWater < 0){
        break;
      }

      int payment = 1150;

      for(int i = 11; i <= usedWater; i++){
        if(30 < i) payment += 160;
        else if(20 < i) payment += 140;
        else if(10 < i) payment += 125;
      }

      System.out.println(previousPayment - payment);
    }
  }
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	scanf("%d", &n);
	if (n == 1) printf("Hello World\n");
	else {
		int a, b;
		scanf("%d%d", &a, &b);
		printf("%d\n", a + b);
	}
}

Measured memory_bytes: 256
//え？
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
inline int getintA() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	return tmp;
}
char dn[1300000], *di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}
int N;
int A[200001];
int E[400001], ne[400001], he[200001], it[200001];
int V[200001], v;
int S[200001], s;

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

	N = getint();
	rep1(i, N) A[i] = getintA();
	int k = 1;
	rep(i, N - 1) {
		int u = getint(), v = getint();
		E[k] = v;
		ne[k] = he[u];
		he[u] = k++;
		E[k] = u;
		ne[k] = he[v];
		he[v] = k++;
	}

	V[v++] = 2000000000;
	S[s++] = 1;
	while (s) {
		int p = S[s - 1];
		if (p > 0) {
			S[s - 1] = -p;
			if (V[v - 1] < A[p]) {
				it[p] = v;
				swap(V[v++], A[p]);
				for (auto to = he[p]; to; to = ne[to]) {
					if (he[E[to]] > 0) {
						S[s++] = E[to];
					}
				}
			}
			else {
				it[p] = lower_bound(V, V + v, A[p]) - V;
				swap(V[it[p]], A[p]);
				for (auto to = he[p]; to; to = ne[to]) {
					if (he[E[to]] > 0) {
						S[s++] = E[to];
					}
				}
			}
			he[p] = -v;
		}
		else {
			s--;
			p = -p;
			V[it[p]] = A[p];
			v -= !A[p];
		}
	}

	rep1(i, N) putint(-he[i]);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 10200
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>

using namespace std;

int main(){

   string w,s;
   int ans = 0;

   cin >> w;

   cin >> s;

   for(;s != "END_OF_TEXT";){
      
      transform(s.begin(), s.end(), s.begin(), ::tolower);

      if(w == s){
         ans++;
      }

      cin >> s;
   }

   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define fi(i,a,b) for(int i=a; i<=b; i-=-1)
#define fid(i,a,b) for(int i=a; i>=b; i--)
#define ll long long
#define F first
#define S second
#define VanLoi "vacation"
#define maxn 100005
#define pii pair<int, int>
#define MOD 1000000007
#define B 107
#define gb(i,j) ((i >> j) & 1)
#define pb push_back
#define reset(x) memset(x, 0, sizeof(x))
#define Block 400
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

int n, a[maxn][5], l[maxn][5];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen(VanLoi".inp","r",stdin);
    freopen(VanLoi".out","w",stdout);
    #endif // ONLINE_JUDGE
    cin >> n;
    fi(i, 1, n) cin >> a[i][1] >> a[i][2] >> a[i][3];
    fi(i, 1, 3) l[1][i] = a[1][i];
    fi(i, 2, n) {
        fi(j, 1, 3)
            fi(t, 1, 3) if (t != j) l[i][j] = max(l[i][j], l[i - 1][t] + a[i][j]);
    }
    cout << max(l[n][1], max(l[n][2], l[n][3]));
}


Measured memory_bytes: 7444
function main() {
  var
  i, n,
  len = input.length;
  for(i = 0; i < len; i++) {
    n = parseInt(input[i], 10);
    if(n === 0) break;
    console.log(primes.slice(0, n).reduce(function(a, b){
      return a + b;
    }, 0));
  }
}

var
primes = (function(n){
  var
  i, j, flag,
  primes = [2];
  if(n < 1) return [];
  for(i = 3; primes.length <= n; i += 2) {
    flag = true;
    for(j = 0; primes[j] < i*i; j++) {
      if(i % primes[j] == 0) {
        flag = false;
        break;
      }
    }
    if(flag) {
      primes.push(i);
    }
  }
  return primes;
})(10000);

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 11052
N = int(input())
s_list = {}
already = set()
for _ in range(N):
    s = input()
    if s in already:
        s_list[s] += 1
    else:
        s_list[s] = 0
    already.add(s)

max_value = max(s_list.values())
max_kv_list = [kv for kv in s_list.items() if kv[1] == max_value]
kv_list = []
for kv in max_kv_list:
    kv_list.append(kv[0])
kv_list.sort()
for kv in kv_list:
    print(kv)

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

int main()
{
	int a;
	std::cin >> a;
	
	if (a < 3200)
	{
		std::cout << "red" << std::endl;
		return 0;
	}
	
	std::string s;
	std::cin >> s;
	std::cout << s << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll p,ll n){
   ll result=1;
   while(n!=0){
   if(n%2==0){
    n/=2;
    p*=p;
   }
   else{
    n--;
    result=result*p;
   }
   }
    return result;
}
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

   ll n,t,a,b,c,d;
   ll mod =1e9+7;
   string s1,s2;
   stack<ll>stck1;
   stack<ll>stck2;

   set<ll>st;
   cin>>a>>b>>c;
   st.insert(a);
   st.insert(b);
   st.insert(c);

   if(st.size()==2){
    cout<<"Yes"<<endl;
   }
   else{
    cout<<"No"<<endl;
   }
}


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

int main(){
    while(1){
        int N,X;
        cin >> N >> X;

        if(!N && !X) break;

        int counter = 0;

        for(int i = 1; i <= N; i++){
            for(int j = i+1; j <= N; j++){
                for(int k = j+1; k <= N; k++){
                    if(i+j+k == X) counter++;
                }
            }
        }

        cout << counter << endl;
    }
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n+1, 0);
    vector<ll> ar(n);
    for(int i = 0; i < n; ++i){
        cin >> ar[i];
        ++a[ar[i]];
    }
    ll res = 0;
    for(int i = 0; i <= n; ++i){
        if(a[i] >= 2){
            res += a[i]*(a[i]-1)/2;
        }
    }
    vector<ll> r(n);
    for(int i = 0; i < n; ++i){
        r[i] = res;
        if(a[ar[i]] >= 2){
            r[i] -= a[ar[i]]*(a[ar[i]]-1)/2;
        }
        if(a[ar[i]] > 2){
            r[i] += (a[ar[i]]-1)*(a[ar[i]]-2)/2;
        }
    }
    for(auto el : r){
        cout << el << endl;
    }
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
typedef pair<int,int> pii;
typedef pair <long long,long long> pll;
typedef long long ll; 
typedef long double ld; 
const ll mod = 1e9+7;
ll dp[3001][3001][2];
ll solve(vector <ll > &v , int i, int j, bool turn)
{
	if(i > j)
		return 0;
	if(dp[i][j][turn] != -1)
		return dp[i][j][turn];
	if(turn == 1)
		return dp[i][j][turn] = max(v[i] + solve(v, i+1 , j, 0), v[j] + solve(v, i, j-1, 0));
	else
		return dp[i][j][turn] = min(solve(v, i+1 , j, 1), solve(v, i, j-1, 1));
	
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); 
    ll n,sum = 0 ; cin >> n;
    vector <ll> v(n+1);
    memset(dp, -1, sizeof(dp));
    for(ll i = 1; i<=n ; i++)
    {	cin >> v[i];
		sum+=v[i];
	}
	ll x = solve(v, 1, n, true);
	cout<< 2*x -sum;
	return 0;
}
 


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

using namespace std;

typedef long long ll;

#define MAXN 20002

int main(void) {
  ll H;
  cin >> H;
  
  int ex = (int)log2(H);
  
  ll sum = 0;
  while(ex >= 0) {
    //cout << ex << " ";
    //cout << sum << " ";
    sum += (ll)pow(2, ex);
    --ex;
  }
  
  cout << sum << endl;  
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sort(vec) sort(vec.begin(),vec.end())
#define int long long
long long ans;

int gcd(int x,int y){
	if(y==0) return x;
	else return gcd(y,x%y);
}

int lcm(int x,int y){
	return x*y/gcd(x,y);
}
 
signed main(){
	int n;
	cin>>n;
	vector<int>h(n),dp(n);
	for(int i=0;i<n;i++)cin>>h[i];
	dp[0]=0;
	for(int i=1;i<n;i++){
		if(i==1)dp[1]=abs(h[1]-h[0]);
		else{
			dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
		}
	}
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
<?php
$a = array_map('intval', str_split(trim(fgets(STDIN))));
$n = 3;
for ($i = 0; $i < 2 ** $n; ++$i) {
    $cnt = $a[0];
    $ans = (string) $a[0];
    for ($j = 0; $j < $n; $j++) {
        if (($i >> $j) & 1) {
            $cnt += $a[$j + 1];
            $ans .= '+' . (string) $a[$j + 1];
        } else {
            $cnt -= $a[$j + 1];
            $ans .= '-' . (string) $a[$j + 1];
        }
    }
    $ans .= '=7';
    if ($cnt === 7) break;
}
echo $ans;


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

using namespace std;
int main() {
    int n;
    cin >> n;
    
    vector<double> f(n + 1);
    f[0] = 1;
    //f[i] stores the answer for i heads in total n tosses
    for(int i = 1; i<=n; i++){
        double p;
        scanf("%lf", &p);
        
        for(int j = i; j >= 0; j--){
            f[j] = (i == 0 ? 0 : f[j-1] * p) + f[j] * (1 - p);
        }
    }
    
    double ans = 0;
    for(int h = 0; h<=n; h++){
        if(2*h > n){
            ans += f[h];
        }
    }
    
    printf("%.10lf\n", ans);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const int INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

ll mi(ll x, ll y){
    if(x<y)return x;
    return y;
}
int a[100000];
int main(void){
    int n, k; cin >> n >> k; for(int i = 0;i < n;i++)cin >> a[i];
    cout << ceil((double)(n-1)/(double)(k-1)) << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n+10, -1) { }
    void init(int n) { par.assign(n+10, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    ll N;
    cin >> N;
    vector<ll> P(N);
    ll midx=0,madx=0;
    for(int i=0;i<N;i++) {
        cin >> P[i];
    }

    set<ll> se;
    UnionFind uf(N);

    for(int i=0;i<N;i++){
        se.insert(P[i]);
        if(se.count(P[i]-1)){
            uf.merge(P[i],P[i]-1);
        }
    }
    ll ct=1;
    for(int i=0;i<N;i++){
        ct=max(ct,(ll)uf.size(i));
    }

    cout << N-ct << endl;
    return 0;
}

Measured memory_bytes: 12032
R = lambda: map(int, input().split())
n, k = R()
v = list(R())
a = sorted((x, i) for i, x in enumerate(v) if x < 0)
ans = max(sum(v[:i - j] + v[n - j:]) -
          sum([x for x, m in a if m < i - j or m >= n - j][:k - i])
          for i in range(1, min(n, k) + 1) for j in range(i))
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define MAX 500005
using namespace std;

int n;
int a[15];

int main(){
//    for(int t = 1; t <= 200; t++){
        cin>>n;
//    n = t;
        memset(a, 0, sizeof(a));
    int i = 1, now = 1;
    while(n){
        a[i]++;
        if(a[i] > 9 || (a[i] > a[i+1]+1 && i+1 <= now) || (i > 1 && a[i] > a[i-1])){
            while(a[i] > 9 || (a[i] > a[i+1]+1 && i+1 <= now) || (i > 1 && a[i] > a[i-1])) a[i+1]++, i++;
            now = max(now, i);
            for(int j = i-1; j >= 1; j--){
                a[j] = max(a[j+1]-1, 0);
            }
            i = 1;
        }
        n--;
    }
    int j = 10;
    while(!a[j]) j--;
    for(int i = j; i >= 1; i--){
        cout<<a[i];
    }
    puts("");
//}

    return 0;
}

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

int main(){
	string s;
	while(getline(cin, s)){
		for(int i=0; i < 26; i++){
			for(int j=0; j < s.size(); j++){
				if('a' <= s[j] && s[j] < 'z') s[j] = s[j] + 1;
				else if(s[j] == 'z') s[j] = 'a';
			}
			if(s.find("the") != string::npos || s.find("this") != string::npos || s.find("that") != string::npos){
				cout << s << endl;
			}
		}
	}
}

Measured memory_bytes: 1176
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
x=list(map(int,input().split()))

rui=[0]
for i in range(n-1):
    rui.append(x[i+1]-x[i]+rui[i])
# print(rui)

ans=float('inf')
for i in range(n-k+1):
    tmp=rui[i+k-1]-rui[i]
    ans=min(ans,tmp+min(abs(x[i]),abs(x[i+k-1])))
print(ans)

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

template <typename T>
T Gcd(T a, T b) {
  if (b == 0) {
    return a;
  }
  return Gcd(b, a % b);
}

int main() {
  in(ll, a, b);
  out(a * b / Gcd(a, b));
}


Measured memory_bytes: 256
s=input()
ans=0
bc=0
i=len(s)-1
while i>=0:
  if s[i]=="A":
    ans+=bc
    i-=1
  elif i>0 and s[i-1:i+1]=="BC":
    bc+=1
    i-=2
  else:
    bc=0
    i-=1
print(ans)

Measured memory_bytes: 3500
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int d, t, s;
  cin >> d >> t >> s;
  if(s*t>=d){
    cout <<"Yes" << endl;
  } else {
    cout <<"No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,a,b;
    int n,m;
    scanf("%d%d%d",&x,&a,&b);
    m=x-a;
    n=x-b;
    m=(m>0)?m:-m;
    n=(n>0)?n:-n;
     if(m<n)
    {
       printf("A\n");
    }
    else
    {
        printf("B\n");
    }
     return 0;
}

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

#define rep(i, n) for ( ll i = 0; i < (n); ++i )
#define reps(i, n) for ( ll i = 1; i <= (n); ++i )
#define _rep(i, n) for ( ll i = (n) - 1; i >= 0; --i )
#define _reps(i, n) for ( ll i = n; i > 0; --i )
#define all(x) (x).begin(), (x).end()
#define _all(x) (x).rbegin(), (x).rend()

using namespace std;
using ll =  long long;
using P = pair<ll, ll>;

int main( void )
{
	ll a, b, c, k;
	cin >> a >> b >> c >> k;

	ll sum = 0;
	if ( k >= a ) {
		sum += a;
		k -= a;

		if ( k >= b ) {
			k -= b;

			if ( k > 0 ) {
				sum -= k;
			}
		}
	}
	else {
		sum += k;
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3640
function main(input) {
    var x = input[0]-0;
    var y = Math.floor(x/11);
    if(x-y*11>6) console.log(y*2+2);
    else if(x-y*11>0) console.log(y*2+1);
    else console.log(y*2);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int a, b;
    cin >> a >> b;

    // 処理
    // 出力
    if (a + b >= 10) {
        cout << "error" << endl;
    } else {
        cout << a + b << endl;
    }

    // cout << ((a + b) >= 10 ? "error" : a + b) << endl;

    return 0;
}


Measured memory_bytes: 256