akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define LL long long
#define PLL pair<LL, LL>
#define LD long double
#define VI vector<int>
#define VPII vector<PII>
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define pb pop_back
#define FOR(a,s,d) for (int a = (s); a <= (int)(d); ++a)
#define FORD(a,s,d) for (int a = (s); a >= (int)(d); --a)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RE(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ALL(x) x.begin(), x.end()
#define siz(x) ((int)x.size())
#define Sim template <class s
Sim, class d> ostream & operator<<(ostream &os, pair<s,d> x){return os << "<" << x.F << ", " <<
  x.S << "> ";}
Sim> auto operator<<(ostream &os, s x) -> typename enable_if<!is_same<s,string>::value,
  decltype(x.begin(), os)>::type
{ int o = 0; os << "{"; for (auto c : x) {if(o++) os << ", "; os << c;}return os << "} ";}
void dor() {cerr << endl;}
Sim, class ...t> void dor(s x, t...y) {cerr << x << " "; dor(y...);}
#ifdef DEB
#define debug(c...) dor(__FUNCTION__, ":", __LINE__, ": ", c)
#else
#define debug(...)
#endif

int main()
{
  //ios_base::sync_with_stdio(0);
  //cin.tie(0);
  LL a, b, c, k;
  scanf("%lld%lld%lld%lld", &a, &b, &c, &k);
  if (k % 2)
  {
    printf("%lld\n", b - a);
  }
  else
  {
    printf("%lld\n", a - b);
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>

using namespace std;

void b_battle(void) {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	bool turn_a = true;
	while ((a > 0) && (c > 0)) {
		if (turn_a) {
			c -= b;
		}
		else {
			a -= d;
		}
		turn_a = !turn_a;
	}
	if (a > 0) cout << "Yes" << endl;
	else       cout << "No" << endl;
}

int main()
{
    b_battle();

    return 0;
}

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

int main() {
  string S;
  cin >> S;

  set<char> st;
  for (char c : S) st.insert(c);
  if (st.size() == S.size()) {
    cout << "yes" << endl;
  } else {
    cout << "no" << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP1_8_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var target = Console.ReadLine();
            var word = Console.ReadLine();

            target = target + target.Substring(0, word.Length - 1);
            //var find = target.Contains(word);
            //Console.WriteLine(find ? "Yes" : "No");

            var index = 0;
            for (var h = 0; h < (target.Length - word.Length + 1); ++h)
            {
                index = 0;
                for (var i = 0; i < word.Length; ++i)
                {
                    if (target[h + i] != word[index])
                    {
                        break;
                    }
                    ++index;
                }

                if (index == word.Length)
                {
                    break;
                }
            }

            Console.WriteLine((index == word.Length) ? "Yes" : "No");
        }
    }
}

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

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	
	int plan_1 = a * n;
	int plan_2 = b;
	
	if (plan_1 <= plan_2) {
		cout << plan_1 << endl;
	}
	else {
		cout << plan_2 << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
int N;
vector<int> paths[100500];
int A, B;

int dfs(int border, int now, int from) {
    multiset<int> st;
    for(auto to : paths[now]) {
        if(to == from) continue;
        int tmp = dfs(border, to, now);
        if(tmp == -1) return -1;
        st.insert(tmp + 1);
    }
    if(paths[now].size() % 2 == 1) st.insert(0);
    int ansval = -1;
    /*
    cerr << "--" << now << "--" << endl;
    for(auto val: st) cerr << val << " ";
    cerr << endl;
    */
    auto itr = st.end();
    while(true) {
        if(itr == st.begin()) break;
        itr--;
        int val = *itr;
        itr = st.erase(itr);
        auto itr2 = st.upper_bound(border - val);
        if(itr2 == st.begin()) {
            if(ansval != -1) {
                //cerr << "NG: " << now << endl;;
                return -1;
            }
            else {
                ansval = val;
                continue;
            }
        }
        itr2--;
        if(itr == itr2) {
            if(itr == st.end()) itr--;
            else itr++;
        }
        itr2 = st.erase(itr2);
    }
    //cerr << ansval << endl;
    if(now == 0) return 0;
    else return ansval;
}

bool f(int border) {
    //cerr << "-----" << border << "--------" << endl;
    int ret = dfs(border, 0, -1);
    if(ret == 0) return true;
    else return false;
}


int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 1; i <= N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        paths[a].push_back(b);
        paths[b].push_back(a);
    }
    A = 1;
    for(int i = 0; i < N; i++) {
        A += (paths[i].size() - 1) / 2;
    }
    int ok = 1e6;
    int ng = 0;
    while(ok - ng > 1) {
        int mid = (ok + ng) / 2;
        if(f(mid)) ok = mid;
        else ng = mid;
    }
    B = ok;
    cout << A << " " << B << endl;
    return 0;
}

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

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m);
    rep(i,m) cin >> a[i];
    ll sum=0;
    rep(i,m) sum+=a[i];
    if(sum>n) cout << "-1" << endl;
    else cout << n-sum << endl;

    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
	long int n;
	cin>>n;
	long int arr[n];
	long int min_val=INT_MAX;
	long int count=0;
	for(long int i=0;i<n;i++){
		cin>>arr[i];
		if(arr[i]<=min_val)
		min_val=arr[i];
		if(i>=1 && arr[i]<=min_val)
		count++;
	}
	cout<<count+1;
	return 0;
}

Measured memory_bytes: 1792
/*                                  deepyadav442 --> :     c++14     <--                                */
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
/*                                           input                    */
#define si(i) scanf("%d",&i)
#define sii(i,j) scanf("%d%d",&i,&j)
#define siii(i) scanf("%lld",&i)
#define sss(s) scanf("%s",s)
/*                                           output                   */
#define pi(i) printf("%d",i)
#define pii(i,j) printf("%d%d",i,j)
#define piii(i) printf("%lld",i)
#define pp(p) printf("p")
#define space printf(" ")
#define newline printf("\n")
/*                                          loops &stls                      */
#define loop(i,s,n) for(i=s;i<n;i++)
#define looprev(i,s,n) for(i=s;i>=n;i--)
#define itervec vector<int>::iterator itv
#define iterrev vector<int>::reverse_iterator it
#define itermap map<string,int>::iterator itm
#define pb(S) push_back(S)
#define mp(i,j) make_pair(i,j)
#define f first
#define s second
#define MAX(a,b) 	(a>b) ? (a) : (b)
#define MIN(a,b) 	(a<b) ? (a) : (b)
using namespace std;
int main()
{
    int i,n,p,arr[100001];
    si(n),si(p);
    loop(i,0,n)
    {
        si(arr[i]);
    }
    int flagodd=0;
    loop(i,0,n)
    {
        if(arr[i]&1)
        {
            flagodd=1;
            break;
        }
    }
    if(flagodd==0)
    {
        if(p==0)
        {
            ll ans=pow(2,n);
            piii(ans),space;
        }
        else
        {
            printf("0"),space;
        }
    }
    else
    {
        ll ans=pow(2,(n-1));
        piii(ans),space;
    }
    return 0;
}

/*   fast input output
inline ll input() //for input integers call it long long int n=input();
{
    ll n=0;
    char ch=getchar_unlocked();
    while( ch < '0' || ch > '9' )
    {
        ch=getchar_unlocked();
    }
    while( ch >= '0' && ch <= '9' )
    {
        n = (n<<3)+(n<<1) + ch-'0', ch=getchar_unlocked();
    }
    return n;
}
inline void output(ll n)     //for output call output(count) and then for space use put('\n');
{
    char b[35];
    ll i=0;
    do
    {
        b[i++]=n%10+48;
        n=n/10;
    }while(n!=0);
    --i;
    while(i>=0)
    putchar_unlocked(b[i--]);
}
inline void faststring(char *str)  //for entering a string use faststring(p);
{
    register char c = 0;
    register long long i = 0;
    while (c < 33)
    c = getchar_unlocked();
    while (c != '\n')
    {
        str[i] = c;
        c = getchar_unlocked();
        ++i;
    }
    str[i] = '\0';
}


*/


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var a, b int
  
  fmt.Scanf("%d %d", &a, &b)
  
  ans := "Draw"
  if a > b {
    if b == 1 {
      ans = "Bob"
    }else{
      ans = "Alice"
    }
  }
  if a < b {
    if a == 1 {
      ans = "Alice"
    }else{
      ans = "Bob"
    }
  }
  fmt.Printf("%s", ans)
}

Measured memory_bytes: 1836
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    if(x*4<y)cout<<"No"<<endl;
    else if(x*2>y)cout<<"No"<<endl;
    else if(y%2!=0)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    //main();
}


Measured memory_bytes: 3636
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;;

int main(){
    int n, m;
    cin >> n >> m;
    int n_student[n][2];
    int m_point[m][2];
    // n student
    for(int i=0; i<n; i++){
        cin >> n_student[i][0] >> n_student[i][1];
    }
    // m point
    for(int i=0; i<m; i++){
        cin >> m_point[i][0] >> m_point[i][1];
    }

    int kouho[m];
    int result[n];
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            // calc
            kouho[j] = abs(n_student[i][0] - m_point[j][0]) + abs(n_student[i][1] - m_point[j][1]);
        }
        // min
        int temp;
        temp = kouho[0];
        int ind;
        ind = 0;
        for(int k=0;k<m; k++){
   
            if(kouho[k] < temp){
                temp = min(temp,kouho[k]);
                ind = k;
            }
            if(kouho[k] == temp){
                temp = min(temp,kouho[k]);
                ind = min(ind,k);
            }
        }
        result[i] = ind;
    }

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

    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(x) cout << fixed << setprecision(x);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n; cin >> n; ll cnt = 0;
  
  for(ll i=1; i <= n; i++){
    ll x; cin >> x;
    if(x == i) cnt++;
  }
  
  if(cnt >= n-2) cout << "YES" << endl;
  else  cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    ll N, X, M; cin >> N >> X >> M;

    ll A = X;
    int s = -1, t = -1;
    vector<ll> sums(M + 1, 0);
    vector<int> index(M + 1, -1);
    REP(i, 0, M + 1) {
        // cout << "# i : " << i << ", A : " << A << endl;
        if (index[A] != -1) {
            s = index[A];
            t = i - 1;
            break;
        }
        index[A] = i;
        // cout << "DEBUG : sums[i] : " << sums[i] << ", prev : " << ((i > 0) ? sums[i - 1] : 0)  << endl;
        sums[i] += A + ((i > 0) ? sums[i - 1] : 0);
        A = A * A % M;
        // cout << "--> sum : " << sums[i] << endl;
    }

    // cout << "# loop : " << s << " " << t << endl;

    ll loop_sum = 0;
    if (s != -1) {
        loop_sum = sums[t] - ((s > 0) ? sums[s - 1] : 0);
    }

    ll ans = 0;
    ans += ((min((ll)s - 1, N - 1) >= 0) ? sums[min((ll)s - 1, N - 1)] : 0);
    // cout << "before loop : " << ans << endl;
    N -= s;
    if (N > 0) {
        ans += N / (t - s + 1) * loop_sum;
        if (N % (t - s + 1) != 0) ans += sums[s + N % (t - s + 1) - 1] - ((s - 1) >= 0 ? sums[s - 1] : 0);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4504
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
#define mp make_pair

void print(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cout<<a[i]<<' ';
    cout<<endl;
}

void get(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cin>>a[i];
}

const ll p = 1e9 + 7;

int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    s = s%p;
    if (s<0) s+=p; 
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

vector<vector<int>> G;

vector<bool> visited;

vector<int> topsort;

void dfs(int start)
{
    visited[start] = true;
    for (auto s: G[start]) if (!visited[s]) dfs(s);
    topsort.push_back(start);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int h, w;
    cin>>h>>w;
    vector<vector<char>> a(h, vector<char>(w));
    for (int i = 0; i<h; i++) get(a[i]);
    //for (int i = 0; i<h; i++) print(a[i]);
    vector<vector<ll>> dp(h, vector<ll>(w));
    for (int i = 0; i<h; i++)
    for (int j = 0; j<w; j++)
    {
        if (i>=1) dp[i][j] = add(dp[i][j], dp[i-1][j]);
        if (j>=1) dp[i][j] = add(dp[i][j], dp[i][j-1]);
        if (a[i][j]=='#') dp[i][j] = 0;
        if (i==0&&j==0) dp[i][j] = 1;
    }
    cout<<dp[h-1][w-1];
}

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

#define mx 100005

using namespace std;

int n, q, a[mx], ans, x;
long long ac[mx], ac1[mx];

int main(){
  scanf("%d%d", &n, &q);
  for(int i = 0; i < n; i++){
    scanf("%d", a+i);
    ac[i+1] = a[i] + ac[i];
    if(i+n&1) ac1[i/2+1] = a[i] + ac1[i/2];
  }
  for(int i = 0; i < q; i++){
    scanf("%d", &x);
    int l = 1, r = (n+1)/2+1;
    while(r-l > 1){
      int mid = (l + r) / 2;
      (a[n+1 - mid*2] + a[n - mid] < x*2 ? r : l) = mid;
    }
    printf("%lld\n", ac[n]-ac[n-l]+ac1[(n-l*2+1)/2]);
  }
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007

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

int n,k;
int used[111111];
int mp[111111];
int a[111111];
int dist[111111];
vector<vector<int>> v(111111);

int bfsa(){
	queue<pair<int,int>> que;
	
	REP(i,n)dist[i] = -1;
	que.push(MP(0,0));
	
	while(!que.empty()){
		auto now = que.front();que.pop();
		if(dist[now.FI] != -1)continue;
		dist[now.FI] = now.SE;
		REP(i,v[now.FI].size()){
			que.push(MP(v[now.FI][i], now.SE+1));
		}
	}
}

int main(){
	
	REP(i,111111)used[i] = -1;
	cin >> n >> k;
	
	REP(i,n){
		cin >> a[i],a[i]--;
		mp[a[i]]++;
		v[a[i]].PB(i);
	}
	bfsa();
	int ans = 0;
	if(a[0] != 0)ans++;
	used[0] = 0;
	a[0] = 0;
	
	priority_queue<pair<int,int>> pq;
	
	REP(i,n)pq.push(MP(dist[i],i));
	while(!pq.empty()){
		auto tmp = pq.top();pq.pop();
		int now = tmp.SE;
		//cout << now << endl;
		if(used[now] != -1 || k >= dist[now])continue;
		int cou = 0;
		while(1){
			//cout << " " << now << endl;
			if(used[now] > cou)break;
			used[now] = cou;
			if(now == 0)break;
			cou++;
			if(cou == k && a[now] != 0){
				a[now] = 0;
				ans++;
			}
			now = a[now];
		}
	}
	
	cout << ans << endl;
		
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;

template <typename T>
bool chmax(T& a, const T& b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}

template <typename T>
bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}


int main() {
	int X, Y;
	cin >> X >> Y;
	X--; Y--;
	cout << X * Y << endl;
	return 0;
}


Measured memory_bytes: 256
n,m = list(map(int, input().split()))
a = []
for i in range(n):
    a.append(list(map(int, input().split())))
a.sort()
count = 0
kin = 0
ban = 0
while count < m :
    if a[ban][1] != 0 :
        count += 1
        kin += a[ban][0]
        a[ban][1] -= 1
    else :
        ban += 1
print(kin)


Measured memory_bytes: 27760
#include<bits/stdc++.h>
using namespace std ; 
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define endl "\n"
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define pii pair<int,int> 
long long M  = 1e9+7;
 
 
signed main(){
    fast;
    int n,m; cin >> n >> m;
    vector <int> a(n);
    int k = 1/(4*m);
    int ans = 0;
    long double sum = 0;
    for(int i=0 ; i<n ; i++){
        cin >> a[i];
        sum += a[i];
    }
    sum = sum/(4.0*m);
    for(auto x : a){
        long double xx = x;
        if(xx >= sum)
            ans++;
    }

    if(ans >= m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

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

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

int calc(int a,int b,int c){
    a*=10;
    return a+b+c;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c;
    cin>>a>>b>>c;
    
    int ans=0;
    chmax(ans,calc(a,b,c));
    chmax(ans,calc(a,c,b));
    chmax(ans,calc(b,a,c));
    chmax(ans,calc(b,c,a));
    chmax(ans,calc(c,b,a));
    chmax(ans,calc(c,a,b));
    cout1(ans)
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
	Scanner sc = new Scanner(System.in);

	int N = sc.nextInt();

	int a = String.valueOf(N).length();

	if(a==1) System.out.print(N);

	else if(a==2) System.out.print(9);

	else if(a==3) System.out.print(9+(N-99));

	else if(a==4) System.out.print(909);

	else if(a==5) System.out.print(909 + (N-9999));

	else if(a==6) System.out.print(90909);



}
}

Measured memory_bytes: 21332
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
#define int long long
int stairs[100005];
set <int> s;
const int mod = 1000000007;
int32_t main()
{
	stairs[0] = 1;
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		int x; cin >> x;
		s.insert(x);
	}
	if (!(*s.lower_bound(1) == 1)) stairs[1] = 1;
	for (int i = 2; i <= n; i++)
	{
		stairs[i] = (stairs[i-1] + stairs[i-2]) % mod;
		if (*s.lower_bound(i) == i) stairs[i] = 0;
	}
	cout << stairs[n] % mod;
	return 0;
}

Measured memory_bytes: 5760
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


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

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

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

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;

	cin >> n;
	vector<ll> b(n);

	rep(i, 0, n) {
		ll a;
		cin >> a;
		b[i] = a - i;
	}
	sort(b.begin(), b.end());

	ll mid = b[n / 2];

	ll ans = 0;

	rep(i, 0, n) {

		ans += abs(mid - b[i]);
	}
	

	cout << ans << endl;

}
	

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

int main(){
	int n,t,temp,last,ans;

	cin >>n >>t >>temp;
	last=temp;
	ans=t;
	for(int i=1;i<n;i++){
		cin >>temp;
		if(temp>=last+t)ans+=t;
		else ans+=temp-last;
		last=temp; 
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>                                             
#include <string>
using namespace std;
  
int N;
int bs[400] = {0};
int ls[100] = {0};
int rs[100] = {0};
int top = 0;
string str;
  
int main(){
  cin >> N;
  cin >> str;
  for(int i = 0; i < N; i++){
    if(str[i] == '(') bs[200+i] = 1;
    else bs[200+i] = 2;
  }
  if(bs[200] == 1){
    int i = 0;
    while(bs[200+i] == 1)
      i++;
    bs[200+i] = 2;
    ls[0] = 200+i-1;
    rs[0] = 200+i;
  }else{
    bs[199] = 1;
    ls[0] = 199;
    rs[0] = 200;
  }
  while(!(top == 0 && bs[ls[0]-1] == 0 && bs[rs[0]+1] == 0)){
    if(top != 0 && ls[top] - rs[top-1] == 1){
      rs[top-1] = rs[top];
      rs[top] = ls[top] = 0;
      top--;
    }
// ~(
    if(bs[rs[top]+1] == 1){ 
      int i = 2;
      while(bs[rs[top]+i] == 1)
        i++;
      bs[rs[top]+i] = 2;
      ls[top+1] = rs[top]+i-1;
      rs[top+1] = rs[top]+i;
      top++;
    } else if(bs[rs[top]+1] == 2){ 
      // ~)
      bs[ls[top]-1] = 1;
      rs[top]++;
      ls[top]--;
    } else {
      bs[rs[top]+1] = 2;
      rs[top]++;
      ls[top]--;
    }   
    if(top != 0 && ls[top] - rs[top-1] == 1){ 
      rs[top-1] = rs[top];
      rs[top] = ls[top] = 0;
      top--;
    }   
  }
  for(int i = 0; i < 400; i++){
    if(bs[i] == 1) cout << '(';
    if(bs[i] == 2) cout << ')';
  }
  cout << endl;
  return 0;
}       

Measured memory_bytes: 256
class Stack:
    #li = []
    def __init__(self):
        self.li = []
        self.top = 0
    def push(self,value):
        #self.li.insert(0,argv)
        self.li.append(int(value))
        self.top += 1
    def pop(self):
        self.top -= 1
        return self.li.pop()
    def isEmpty(self):
        return len(li)==0
    def __str__(self):
        return str(self.li[0])

l = list(map(str,input().split()))

save = Stack()

symble = ["+","-","*"]

for i in l:
    #print(save)
    if i in symble:
        b = save.pop()
        a = save.pop()
        if i=="+":
            save.push(a + b)
        elif i=="-":
            save.push(a - b)
        else:
            save.push(a * b)
    else:
        save.push(i)
else:
    print(save)



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define sortall(obj) sort(ALL(obj))
#define revall(obj) reverse(ALL(obj))
#define SortRevAll(obj) revall(sortall(obj))
typedef string str;
typedef long long ll;
const int mod=1e9+7;
const int INF=1e9;
const ll LINF=1e18;
#define V vector
#define P pair
#define M map
#define F first()
#define S second()
#define PB(a) push_back(a)
#define IN(a) insert(a)
#define ins(a) int a;cin >> a
#define lls(a) ll a;cin >> a
#define in(a) cin >> a
#define sts(a) string (a);cin >> a
#define For(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) For(i,0,n)
#define Forr(i,m,n) for(int i=n-1;i>=m;i--)
#define repr(i,n) Forr(i,0,n)
#define print(a) cout << a << endl
#define Endl cout << endl
#define YES(n) cout << ((n)? "YES" : "NO") << endl
#define Yes(n) cout << ((n)? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

int main(){
    ins(N);
    print(N*800-N/15*200);
    return 0;
}


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

using namespace std;

namespace mod {

template <class T, int M>
class MInt;

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp);

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n);

template <class T, int M>
class MInt {
  T n_;

 public:
  MInt() : n_(0) {}
  MInt(T n) : n_((n % M + M) % M) {}

  MInt &operator+=(const MInt &rhs) {
    n_ += rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator-=(const MInt &rhs) {
    n_ += M - rhs.n_;
    if (n_ >= M) {
      n_ -= M;
    }

    return *this;
  }

  MInt &operator*=(const MInt &rhs) {
    n_ = n_ * rhs.n_ % M;
    return *this;
  }

  MInt &operator/=(const MInt &rhs) { return (*this) *= Inv(rhs); }

  T Get() { return n_; }
};

template <class T, int M>
MInt<T, M> operator-(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res -= rhs;
}

template <class T, int M>
MInt<T, M> operator+(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res += rhs;
}

template <class T, int M>
MInt<T, M> operator*(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res *= rhs;
}

template <class T, int M>
MInt<T, M> operator/(const MInt<T, M> &lhs, const MInt<T, M> &rhs) {
  MInt<T, M> res(lhs);
  return res /= rhs;
}

template <class T, int M>
MInt<T, M> Pow(const MInt<T, M> &base, T exp) {
  if (exp == 0) {
    return 1;
  }

  auto a = Pow(base, exp / 2);
  a *= a;
  if (exp % 2 == 1) {
    a *= base;
  }

  return a;
}

template <class T, int M>
MInt<T, M> Inv(const MInt<T, M> &n) {
  return Pow(n, static_cast<T>(M - 2));
}
}  // namespace mod

const int md = 1e9 + 7;
using MInt = mod::MInt<long long, md>;
class BinCoef {
  vector<MInt> f;

 public:
  BinCoef(int n) : f(n + 1) {
    f[0] = f[1] = 1;
    for (int i = 2; i <= n; i++) {
      f[i] = MInt(i) * f[i - 1];
    }
  }

  MInt NCM(int n, int m) {
    if (n < m) {
      return 0;
    }
    return f[n] * mod::Inv(f[m] * f[n - m]);
  }
};

int main(int argc, const char *argv[]) {
  int n, k;
  cin >> n >> k;

  BinCoef bc(4000);
  for (int i = 1; i <= k; ++i) {
    auto ans = bc.NCM(n - k + 1, i) * bc.NCM(k - 1, i - 1);
    cout << ans.Get() << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    a=list(map(int,input().split()))
    S=[0]*(N+1)
    for i in range(N):
        S[i+1]=S[i]+a[i]
    ans=INF
    for i in range(1,N):
        tmp=abs(S[-1]-2*S[i])
        ans=min(ans,tmp)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 71464
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

ll n;

ll findH(ll cx, ll cy, vl x, vl y, vl h){
  ll pred = 0;
  ll isPredSet = false;
  F0R(i,n){
    if(h[i] > 0){
      ll r = abs(x[i] - cx) + abs(y[i] -cy);
      if(!isPredSet) {pred = h[i] + r;isPredSet=true;}
      else if(pred != h[i]+r)
        return -1;
    }
  }
  if(isPredSet) {
    F0R(i,n){
      if(h[i] == 0){
        ll r = abs(x[i] - cx) + abs(y[i] -cy);
        if(pred > r) return -1;
      }
    }
    return pred;
  }
  if(!isPredSet){
    ll mn = INF;
    F0R(i,n){
      if(h[i] == 0){
        ll r = abs(x[i] - cx) + abs(y[i] -cy);
        if(mn > r) mn = r;
      }
    }
    if(mn == 1) return 1;
    return -1;
  }
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;
    cin >> n;
    vl x,y,h;
    ll temp;
    F0R(i,n){
      cin >> temp ;
      x.pb(temp);
      cin >> temp ;
      y.pb(temp);
      cin >> temp ;
      h.pb(temp);
    }
    FOR(i,0,101){
      FOR(j,0,101){
          ll ans = findH(i,j,x,y,h);

          if(ans == -1) continue;
          cout << i<<" " << j << " "<< ans << endl;
          return 0;
      }
    }

    // ll ans = findH(i,j,x,y,h);
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/function.hpp>
using namespace std;
typedef long long int llint;
typedef unsigned long long int ullint;
std::string YesNo[] = {"No","Yes"};
#define loop(i,N) for(int i=0; i<(N); i++)
template<typename T>
auto sort_all(T v) { return std::sort(v.begin(),v.end()); }
template<typename T>
auto sum_all(T v) { auto z = v[0]; z = 0;
    return std::accumulate(v.begin(),v.end(),z); }
template<typename T>
auto input(int N) {
    std::vector<T> v(N);
    loop(i,N) std::cin >> v[i];
    return std::move(v);
}

typedef int dtype;

int main(void)
{
    dtype N;
    cin >> N;
    auto A = vector<vector<int>>(N,vector<int>(N-1));
    loop(i,N) loop(j,N-1) {
        cin >> A[i][j];
    }
    auto nextgame = vector<int>(N,0);

    auto day = 0;
    auto totalgames = N*(N-1)/2;
    auto donegames = 0;
    auto tomorrow_candidates = new vector<int>(N);
    auto today_candidates = new vector<int>;
    loop(i,N) {
        (*tomorrow_candidates)[i] = i+1;
    }

    while(donegames < totalgames) {
        day += 1;
        auto readyflag = vector<bool>(N,true);
        auto todaygames = 0;
        delete today_candidates;
        today_candidates = tomorrow_candidates;
        tomorrow_candidates = new vector<int>;
        for( auto player : *today_candidates) {
            if( !readyflag[player-1] || nextgame[player-1] >= N-1) {
                continue;
            }
            auto opp = A[player-1][nextgame[player-1]];
            if(!readyflag[opp-1]) {
                continue;
            }
            auto opp_opp = A[opp-1][nextgame[opp-1]];
            if(opp_opp == player) {
                nextgame[player-1] += 1;
                nextgame[opp-1] += 1;
                tomorrow_candidates->push_back(player);
                tomorrow_candidates->push_back(opp);
                readyflag[player-1] = false;
                readyflag[opp-1] = false;
                todaygames += 1;
            }
        }

        if(todaygames == 0) {
            cout << -1 << endl;
            return 0;
        } else {
            donegames += todaygames;
        }
    }
    cout << day << endl;

    return 0;
}

Measured memory_bytes: 4224
from sys import stdin

D = 60
MAX_N = 200005


def input():
    return stdin.readline()[:-1]

def main():
    from builtins import int, map
    N, K = map(int, input().split())
    to = [[None for _ in range(N)] for _ in range(D)]
    to[0] = list(map(lambda x: int(x) - 1, input().split()))
    for i in range(D - 1):
        for j in range(N):
            to[i + 1][j] = to[i][to[i][j]]

    v = 0
    for i in range(D - 1, -1, -1):
        l = 1 << i
        if l <= K:
            v = to[i][v]
            K -= l
    print(v + 1)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 220072
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        var line = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var n = line[0];
        var p = line[1];
        var ans = 0L;
        var biscuits = Console.ReadLine().Split(' ').Select(long.Parse).ToList();
        
        if(biscuits.Count(x => x % 2 == 0) == n){
            if(p == 0){
                Console.WriteLine((long)Math.Pow(2,n));
            }else{
                Console.WriteLine(0);
            }
        }else{
            Console.WriteLine((long)Math.Pow(2,n - 1));
        }
    }
}


Measured memory_bytes: 13396
import java.util.Scanner;

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

        String x = sc.next();
        String y = sc.next();
        if (x.compareTo(y) > 0)
            System.out.println(">");
        else if (x.compareTo(y) == 0)
            System.out.println("=");
        else
            System.out.println("<");
    }
}

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

int findMax(int B[], int N){
  int ma = B[0];
  for(int i = 1; i < N; i++){
    if(B[i] > ma) ma = B[i];
  }
  return ma;
}

int findMin(int B[], int N){
  int mi = B[0];
  for(int i = 1; i < N; i++){
    if(B[i] < mi) mi = B[i];
  }
  return mi;
}

int main(){
  int N, maxA, minB, A[100000], B[100000];
  cin >> N;

  for(int i = 0; i < N; i++) cin >> A[i] >> B[i];

  maxA = findMax(A, N);
  minB = findMin(B, N);

  cout << maxA + minB << endl;
  return 0;
}

Measured memory_bytes: 1024
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

int main(){
		
	string a,b;
	cin>>a>>b;
	cout<<b<<a<<endl;
	


	

	return 0;
}

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

int main() {
    int N; cin >> N;
    map<int, int> id;
    for(int i = 0; i < N; ++i) {
        int a; cin >> a;
        id[-a] = i;
    }
    multiset<int> st({-1, -1, N, N});
    int64_t ans = 0;
    for(auto &[x, i] : id) {
        auto l = [&](int x, int y) -> int64_t { return abs(x - y); };
        auto c = st.lower_bound(i);
        auto d = next(c);
        auto b = prev(c);
        auto a = prev(b);
        ans -= l(*a, *b) * l(*c, i) * x;
        ans -= l(*b, i) * l(*c, *d) * x;
        st.insert(i);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 12836
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll N,M;

ll extgcd(ll a, ll b, ll &x, ll &y){
    if(a < b) swap(a, b);
    ll d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x=1;
        y=0;
    }
    return d;
}
 
int main(){
    cin>>N>>M;
    ll x, y;
    vec a(N);
    rep(i,N) cin>>a[i], a[i] /= 2;
    ll lcm = a[0];
    reps(i,1,N) {
        ll temp = extgcd(lcm, a[i], x, y);
        lcm = lcm * a[i] / temp;
        if(lcm > M){
            cout<<0<<endl;
            return 0;
        }
    }
    int rest = (lcm / a[0])%2;
    reps(i, 1, N){
        if(rest != (lcm / a[i])%2){
            cout<<0<<endl;
            return 0;
        }
    }
    cout<<1 + (M - lcm) / (lcm * 2)<<endl;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	int gct =0, pct =0;
	int ans =0;
	for(auto ch: s){
		if(pct < gct){
			pct++;
			ans += ch == 'g';
		}else{
			gct++;
			ans -= ch == 'p';
		}
	}
	
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
  public static void main(String[] args)  {
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    for(int i=0;;i++){
      if(n <= 1000*i){
        System.out.println(1000*i - n);
        break;
      }
    }
  }
}

Measured memory_bytes: 35692
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


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

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)





















int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	ll cnt = 0;
	while (a >= b) {
		b *= 2;
		cnt++;
	}
	while (b >= c) {
		c *= 2;
		cnt++;
	}
	cout << ((cnt <= k) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3596
#include<cstdio>
#include<algorithm>
#include<vector>
using std::sort;
using std::vector;
typedef long long ll;
const int N=1e5+5,M=2e5+5;
int n,m,ans;
int dis[N],book[N];
ll a[N];
struct edge
{
	int u,v,w;
}e[M];
int can[M],bk[M];
vector<edge> V[N];
inline int find(int x)
{
	return dis[x]==x?x:(dis[x]=find(dis[x]));
}
inline void merge(int x,int y)
{
	x=find(x);y=find(y);
	if(x==y)
		return;
	dis[x]=y;a[y]+=a[x];
	return;
}
void dfs(int x,int w)
{
	register int i;
	for(auto c:V[x])
		if(c.w<=w&&!bk[c.u])
		{
			bk[c.u]=1;
			if(!book[c.v])
				book[c.v]=1,dfs(c.v,w);
		}
	return;
}
signed main()
{
	register int i;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)
		dis[i]=i,scanf("%lld",&a[i]);
	for(i=1;i<=m;i++)
		scanf("%d%d%d",&e[i].u,&e[i].v,&e[i].w);
	sort(e+1,e+m+1,[](edge a,edge b)->bool
	{
		return a.w<b.w;
	});
	for(i=1;i<=m;i++)
	{
		V[e[i].u].push_back(edge{i,e[i].v,e[i].w});
		V[e[i].v].push_back(edge{i,e[i].u,e[i].w});
	}
	for(i=1;i<=m;i++)
	{
		merge(e[i].u,e[i].v);
		if(a[find(e[i].u)]>=e[i].w)
			can[i]=1;
	}
	for(i=m;i>=1;i--)
		if(!bk[i]&&can[i])
			book[e[i].u]=1,book[e[i].v]=1,bk[i]=1,dfs(e[i].u,e[i].w),dfs(e[i].v,e[i].w);
	for(i=1;i<=m;i++)
		if(bk[i])
			ans++;
	printf("%d\n",m-ans);
	return 0;
}

Measured memory_bytes: 14208
#include<cstdio>
#include<list>
#include<string>
using namespace std;

int main(void) {
	int num,time;
	char str[100];
	list<int> l;

	scanf("%d", &time);

	for (int i = 0; i < time; i++) {
		scanf("%s",str);
		if (str[0] == 'i') {
			scanf("%d",&num);
			l.push_front(num);
		} else if(str[6] == 'F') {
			l.pop_front();
		} else if (str[6] == 'L') {
			l.pop_back();
		} else {//delete?????´???
			scanf("%d", &num);
			for (list<int>::iterator i = l.begin(); i != l.end(); i++) {
				if (num == *i) {
					l.erase(i);
					break;
				}
			}
		}
	}
	int j = 0;
	for (list<int>::iterator i = l.begin(); i != l.end(); i++) {
		if (j++) printf(" ");
		printf("%d",*i);
	}
	printf("\n");
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  if(s[0]==s[1]&&s[1]==s[2])cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct UnionFind{
	vector<int> data;
	UnionFind (int n) : data(n, -1){}

	void Unite(int a, int b){
		a = root(a), b = root(b);
		if (a == b)return;
		if (data[a] > data[b])
			swap(a,b);
		
		data[b] += data[a];
		data[a] = b;
	}

	bool Find(int a, int b){
		return root(a) == root(b);
	}

	int root(int a){
		return data[a] < 0 ? a : data[a] = root(data[a]);
	}

	int size(int a){
		return -data[root(a)];
	}
};

signed main() {
	int n;

	cin >> n;

	printf("%d\n", n * 800 - (n/15) * 200);


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    int n,m;
    cin >> n >> m;
    cout << n*(n-1)/2+m*(m-1)/2;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  double A,B;
  cin >> A >> B;
  double H,M;
  cin >> H >> M;
  double pi = 3.1415926535;
  double rad1 = H / 6 * pi + M * pi / 360;
  double rad2 = M * pi / 30;
  double ans = A*A + B*B - 2 * A * B * cos(rad2-rad1);
  cout << pow(ans,0.5) << endl;
  return 0;
}


Measured memory_bytes: 4356
n = int(input())
alist = list(map(int, input().split()))
len_alist = len(alist)

mod = 10**9 + 7

if len_alist % 2 == 0:
  nums = [2 for _ in range(n//2)]
  for a in alist:
    nums[(a-1)//2] -= 1
    if nums[(a-1)//2] < 0:
      break
  if all(num == 0 for num in nums):
    print(2**(n//2)%mod)
  else:
    print(0)
else:
  nums = [1] + [2 for _ in range((n-1)//2)]
  for a in alist:
    nums[(a)//2] -= 1
    if nums[(a)//2] < 0:
      break
  if all(num == 0 for num in nums):
    print(2**((n-1)//2)%mod)
  else:
    print(0)

Measured memory_bytes: 14008
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
#include<numeric>
#include<complex>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void printVector(vector<ll> A){
    cout << "[vector]" << endl;
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    string S;
    ll K;

    cin >> S >> K;

    // check if one only
    bool oneOnly = true;
    int hitIndex;
    FOR(i, 0, S.length()){
        if(S[i] != '1'){
            oneOnly = false;
            hitIndex = i;
            break;
        }
    }

    if(oneOnly){
        p('1');
    }
    else{
        if(K-1 < hitIndex){
            p('1');
        }else{
            p(S[hitIndex]);
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
suits = ['S', 'H', 'C', 'D']
cards = [[False for i in range(13)] for j in range(4)]
n = int(input())

for i in range(n):
    suit, rank = input().split()
    rank = int(rank)
    cards[suits.index(suit)][rank-1] = True

for i in range(4):
    for j in range(13):
        if not cards[i][j]:
            print(suits[i], j+1)



Measured memory_bytes: 5600
#include <iostream>
#include <string>
#include <vector>

int main()
{
	int N = 0;
	std::string S;
	

	std::cin >> N;

	int move = N % 26;

	std::cin >> S;

	for (int count = 0; count < S.size(); count++)
	{
		if (S[count] + move > 90)
		{
			S[count] -= 26;
		}

		S[count] += move;
		std::cout << S[count];
	}
	std::cout << std::endl;
}

Measured memory_bytes: 256