akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int N = 2e6 + 6;
int A[N];
int n;
vector<vector<int>> vec;

void solve()
{
	int n , m;
	cin >> n >> m;

	vec.clear();
	vec.resize(n+1);

	loop(i,0,n)cin >> A[i];

	loop(i,0,m)
	{
		int u , v;
		cin >> u >> v;
		u--,v--;
		vec[u].pb(v);
		vec[v].pb(u);
	}

	int ans = 0;

	loop(i,0,n)
	{
		if(vec[i].size() == 0)
		{
			ans++;
			continue;
		}
		int ok = 1;
		loop(j,0,vec[i].size())
		{
			if(A[i] <= A[vec[i][j]])ok = 0;
		}
		if(ok)ans++;
	}

	cout << ans;
}
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);

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

 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 9772
#include "bits/stdc++.h"
using namespace std;
const long long mod = 1000000007;
const int maxn = 100100;
int main(){
    int n;
    cin >> n;
    string zero;
    cout << 0 << endl;
    cin >> zero;
    int lo = 1, hi = n - 1;
    while(lo <= hi){
        int mid = (lo + hi)>>1;
        cout << mid << endl;
        string now; cin >> now;
        if(now == "Vacant") return 0;
        if(mid%2 == 1){
            if(now != zero) lo = mid + 1;
            else hi = mid - 1;
        } else {
            if(now == zero) lo = mid + 1;
            else hi = mid - 1;
        }
    }
    return 0;
}


Measured memory_bytes: 852
/// RIFAT SHARIAR SAKIL
/// SOFTWARE ENGINEERING, SUST
/// 2019831024

#include<bits/stdc++.h>
#define ll long long
#define t INT_MAX
using namespace std;
int main()
{
   // while(1)
  //  {
        int n,m,i;
    cin >> n >> m;
   // int a[n]={0},mx[3]={t,t,t};
    set <int> s1,s2,s3;
    set <int>::iterator it,ti,iu;
    for(i=0;i<m;i++)
    {
        int s,c;
        cin >> s >> c;
        /*if(s==1)
        {
            if(c && c<mx[s-1])
            {
                mx[s-1]= c;
                a[s-1] = c;
            }
        }
        else if( c<mx[s-1] )
        {
            mx[s-1] = c;
            a[s-1] = c;
        }*/
        if(s==1) s1.insert(c);
        else if(s==2)s2.insert(c);
        else s3.insert(c);
    }
    if(s1.size()>1 || s2.size()>1 || s3.size()>1 ) {cout << "-1";return 0;}
    if(s1.size()==0 && n>1){cout << "1";}
    else if(s1.size() && *(s1.begin())==0 && n>1){cout << "-1";return 0;}
    else if(s1.size()==0) cout << "0";
    else cout << *(s1.begin());


     //   cout << s1.size() << " " << s2.size() << " " << s3.size() << endl;
          ti = s2.begin();
         if(n>=2)
         {
            // if(*it==0 && )
             if(s2.size()==0) cout << "0";
              //  {cout << "-1";return 0;}
             else cout << *ti;
         }
        iu = s3.begin();
        if(n==3)
        {
            if(s3.size()==0)cout << "0";
            else cout << *iu;
        }


      //  cout << endl;
  //  }



}


Measured memory_bytes: 3604
/**
    Bismillahir Rahmanir Rahim
    Md. Rakibul Islam
    Dept. of CSE, CoU
    **/
#include<bits/stdc++.h>
#define SQR(n) (n*n)
#define CHR getchar()
#define NL printf("\n")
#define PI 2.0*acos(0.0)
#define ll              long long int
#define ull             unsigned long long int
#define sc              scanf
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        ((a)*(b))/gcd(a,b)
#define pf              printf
#define MOD             1000000007
#define mx              123456789
#define Max(a,b) ((a>b)?a:b)
#define Min(a,b) ((a<b)?a:b)
#define ff first
#define D double
#define sz size()
#define ss second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()

#define _Max(a,b,c) Max(a,Max(b,c))
#define _Min(a,b,c) Min(a,Min(b,c))

#define BitCnt(a) __builtin_popcountll(a)
#define MEM(a,val) memset(a,val,sizeof(a))
using namespace std;
int main()
{
    string s;
    int l, n, m, i, j, k;
    cin>>s>>n;
    cout<<s[0];
    for(i=1; i<s.size(); i++)
    {
        if(i%n==0)
            cout<<s[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 10000
using namespace std;
typedef long long ll;

int main(){
  int n;  cin >> n;
  vector<int> vec(100000);
  vector<bool> visited(100000, false);
  int ans=0;
  int now=0;
  rep(i, 0, n){
    cin >> vec[i];
    vec[i]--;
  }
  while(!visited[now] && now!=1){
    ans++;
    visited[now] = true;
    now=vec[now];
  }
  if(now==1){
    cout << ans << endl;
  }else{
    cout << -1 << endl;
  }
  return 0;
}

Measured memory_bytes: 640
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

a, b = ISS()
c = int(a + b)
if c ** 0.5 % 1 == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  char c;cin>>c;
  cout<<(char)(c+1)<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args){
	Scanner  scan =new Scanner(System.in);
	while(scan.hasNext()){
	    int s;
	    s=scan.nextInt();
	    boolean bool=false;
	    for(int i=0;i<10;i++){
		if((s%2)==1){
		    if(bool){
			System.out.printf(" ");
		    }else{
			bool=true;
		    }
		    System.out.printf("%d",(int)Math.pow(2,i));
		}
		s/=2;
		if(s==0)break;
	    }
	    System.out.println();
	}
    }
}

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

int main(){
  long long a, b, c, k;
  cin >> a >> b >> c >> k;
  
  const long long inf = pow(10, 18);
  long long ans = a - b;
  if(abs(ans) > inf){
    cout << "Unfair" << endl;
    return 0;
  }
  if(k % 2) cout << -ans << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int main(){
    lli n, m;
    vector<lli> x_vec;

    cin >> n >> m;
    for(lli i = 0; i < m; i++){
        lli x_input;
        cin >> x_input;
        x_vec.push_back(x_input);
    }

    if(n >= m){
        cout << "0" << endl;
    }else{
        sort(x_vec.begin(), x_vec.end());
        lli ans = 0;
        /*for(lli i = 0; i < m; i++){
            if(i == m - 1){
                cout << x_vec[i] << endl;
            }else{
                cout << x_vec[i] << " ";
            }
        }*/

        /*for(lli i = 1; i < m; i++){
            if(i == m - 1){
                cout << x_vec[i] - x_vec[i - 1] << endl;
            }else{
                cout << x_vec[i] - x_vec[i - 1] << " ";
            }
        }*/

        lli del;
        vector<lli> del_vec;
        for(lli i = 1; i < m; i++){
            del = x_vec[i] - x_vec[i - 1];
            ans += del;
            del_vec.push_back(del);
        }

        if(n > 1){
            sort(del_vec.begin(), del_vec.end(), greater<lli>());
            /*for(lli i = 0; i < m - 1; i++){
                if(i == m - 2){
                    cout << del_vec[i] << endl;
                }else{
                    cout << del_vec[i] << " ";
                }
            }*/
            for(lli i = 0; i < n - 1; i++){
                ans -= del_vec[i];
            }
        }
        
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2548
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

signed main(){
	double n;
	cin >> n;

	cout << fixed << setprecision(10) << ceil(n / 2.0) / n << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mkp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
int main()
{
	ll a,b,n;
	cin>>a>>b>>n;
	ll choose = min(n,b-1);
	ll k = (choose*a)/b;
	cout<<k<<endl;
	return 0; 
}

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

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

  if( ( a == 1 && b == 2) || ( a == 2 && b == 1) ){
    
    cout << 3 << endl;
    
  }
  
  else if( ( a == 1 && b == 3) || ( a == 3 && b == 1) ){
    
    cout << 2 << endl;
    
  }
  
  else if( ( a == 2 && b == 3) || ( a == 3 && b == 2) ){
    
    cout << 1 << endl;
    
  }
  
}
  
  
  
 

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int T[35][MAX];
int L[30];

int main(){
    int N, C;
    cin >> N >> C;

    rep(i, N) {
        int s, t, c;
        cin >> s >> t >> c;
        s--, t, c--;
        if (s == t) {
            T[c][s] ^= 1;
        } else {
            T[c][s] ^= 1;
            T[c][t] ^= 1;
        }
    }

    int ans = 0;
    rep(i, MAX) {
        int res = 0;
        rep(j, C) {
            L[j] ^= T[j][i];
            if (L[j]) res++;
        }
        ans = max(ans, res);
    }

    cout << ans << endl;
}

Measured memory_bytes: 12544
nm = input().split(" ")
alot = input().split(" ")

n = int(nm[0])
m = int(nm[1])

sum = 0
for i in range(n):
    sum = sum + int(alot[i])

count = 0
for i in range(n):
    if int(alot[i]) >= sum/(4*m):
        count = count + 1

if count >= m:
    print("Yes")
else:
    print("No")

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

int main() {
  
  string S;
  
  cin >> S;
  
  int A = S.size();
    
  char B = 'x';
  
  for(int i = 0; i < A; i++) {
    
    
    S.at(i) = B;
    
  }
  cout << S << endl;
  
}

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin >> n >> m;
    int h[n];
    for(int i = 0; i < n; i++) {
        cin >> h[i];
    }

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

    vector<bool> highest(n,true);
    for(int i = 0; i < m; i++) {
        if(h[a[i]-1] == h[b[i]-1]){
            highest[a[i]-1]=false;
            highest[b[i]-1]=false;
        }
        else if(h[a[i]-1] > h[b[i]-1]) highest[b[i]-1]=false;
        else                           highest[a[i]-1]=false;
    }

    int count=0;
    for(int i = 0; i < n; i++) {
        if(highest[i]) count++;
    }
    cout << count << "\n";

    return 0;
}

Measured memory_bytes: 4768
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  map<int,int> mp;
  for(int i=0;i<n;++i){
    int curr;cin>>curr;
    mp[curr]++;
  }
  // case
  if(mp.size()==1 && mp[0]>0){
    cout<<"Yes"<<endl;
  }else if(mp.size()==3 && n%3==0){
    vector<int> arr;
    bool f = true;
    for(auto i:mp){
      if(i.second != n/3){
        f = false;
      }
      arr.push_back(i.first);
    }
    if((arr[0]^arr[2])!=arr[1] || (arr[0]^arr[1])!=arr[2]  || (arr[2]^arr[1])!=arr[0] ){
      f = false;
    }
    
    if(f){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }else if (mp.size()==2 && n%3==0 && mp[0]==n/3){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3840
#include "bits/stdc++.h"

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

// #define int long long
#define YES "Yes"
#define NO  "No"

using namespace std;

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

  bool flag = false;
  int num = 0;

  int n, m; cin >> n >> m;

  cout << (n - 1) * (m - 1) << endl;
  
  // cout << num << endl;
  // cout << (flag ? YES : NO) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

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;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	vector<int> a(n);
	rep(i,n){
		cin>>a[i];
	}
	vector<vector<mint>> dp(n+1,vector<mint>(k+1,0));
	rep(i,n+1) dp[i][0]=1; 
	rep(i,n)FOR(j,1,k+1){
		dp[i+1][j]=dp[i][j]+dp[i+1][j-1];
		if(j-1>=a[i]) dp[i+1][j]-=dp[i][j-1-a[i]];
	}
	cout<<dp[n][k].x<<endl;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define inf 1e17
#define MAX_SIZE 1000005 

void pr(int arr[], int size) 
{ for (ll i=0; i < size; i++) {printf("%d ", arr[i]); }cout << endl;}

ll s(ll a , ll b){
    return (pow(a ,5) - pow(b,5));
}

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll x;
  cin >> x;
  ll ai[200];
  for(ll i = 0;i < 200;i++){
      ai[i] = pow(i , 5);
  }
  ll a , b;
  for(ll i = 0; i < 200;i++){
      if(binary_search(ai , ai + 200, llabs(x - ai[i]))){
          a = i;
          if(x - ai[i] > 0){
              b = - (lower_bound(ai , ai + 200 , llabs(x - ai[i])) - ai);
          }
          else{
              b = (lower_bound(ai , ai + 200 , llabs(x - ai[i])) - ai);
          }
      }
  }
  
  cout << a << " " << b << endl;
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  bool flag = false, ans = false;
  for(int i = 0; i < s.length(); i++) {
    if(s[i] == 'C') flag = true;
    if(s[i] == 'F' && flag) ans = true;
  }
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < (n); i++)
using pint = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int n;
    cin >> n;
    int a[n];
    rep (i, n) cin >> a[i];
    int now = 1;
    rep (i, n) {
        if (now == a[i]) {
            now = a[i] + 1;
        }
    }
    int ans = now == 1 ? -1 : n - now + 1;
    cout << ans << "\n";
}

Measured memory_bytes: 4420
parseInt(x::SubString{String}) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function hpush(h::Array{Tuple{Int,Int},1},x::Tuple{Int,Int})
	push!(h,x)
	if length(h) > 1
		l = length(h)
		k = div(l,2)
		while h[k][2]>x[2]&&k>=1
			tmp = h[k]
			h[k] = x
			h[l] = tmp
			k = max(div(k,2),1)
			l = div(l,2)
		end
	end
end

function hpop(h::Array{Tuple{Int,Int},1})
	x = h[1]
	z = pop!(h)
	if !isempty(h)
		h[1] = z
		k = 1
		l = length(h)
		while k <= l
			if 2*k>=l
				break
			elseif 2*k+1>=l
				if h[2*k][2]>=z[2]
					break
				else
					tmp = h[2*k]
					h[2*k] = z
					h[k] = tmp
					k = 2*k
				end
			else
				if h[2*k][2]>=z[2]&&h[2*k+1][2]>=z[2]
					break
				else
					t = h[2*k][2]<h[2*k+1][2]?2*k:2*k+1
					tmp = h[t]
					h[t] = z
					h[k] = tmp
					k = t
				end
			end
		end
	end
	x
end


function main()
	n,m = readline() |> split |> parseMap
	e = [Int[] for i in 1:3*n]
	for i in 1:m
		u,v = readline() |> split |> parseMap
		push!(e[u],n+v)
		push!(e[n+u],2*n+v)
		push!(e[2*n+u],v)
	end
	s,t = readline() |> split |> parseMap
	dis = -ones(Int,3*n)
	h = Array{Tuple{Int,Int},1}()
	push!(h,(s,0))
	while !isempty(h)
		v,w = hpop(h)
		dis[v]=dis[v]<0?w:min(dis[v],w)
		if v == t
			break
		end
		for i in 1:length(e[v])
			if dis[e[v][i]]<0　|| dis[e[v][i]]>w+1
				dis[e[v][i]] = w+1
				hpush(h,(e[v][i],w+1))
			end
		end
	end
	println(dis[t]>=0?div(dis[t],3):-1)

end

main()

Measured memory_bytes: 165384
k, s = [int(x) for x in input().split()]
cnt = 0
for x in range(k + 1):
    if x > s:
        continue
    for y in range(x, k + 1):
        if y > s:
            break
        z = s - x - y
        if y <= z and z <= k:
            if x + y + z == s:
                if x == y == z:
                    cnt += 1
                elif x == y or y == z:
                    cnt += 3
                else:
                    cnt += 6
print(cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);

	int K, N; cin >> K >> N;
	if (K & 1) {
		vector<int> ans(N, (K + 1) / 2);
		for (int i = 0; i < N / 2; ++i) {
			if (ans.back() == 1) ans.pop_back();
			else {
				--ans.back();
				while (ans.size() < N) ans.push_back(K);
			}
		}
		for (int i : ans) cout << i << ' ';
	}
	else {
		cout << K / 2 << ' ';
		for (int i = 1; i < N; ++i) cout << K << ' ';
	}	
}

Measured memory_bytes: 4480
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

ll solve() {
  int N, M; cin>>N>>M;
  vector<ll> X(M), d(M-1);
  if(N>=M) return 0LL;
  REP(i,M) cin>>X[i];
  sort(X.begin(), X.end());
  REP(i,M-1) d[i] = X[i+1] - X[i];
  sort(d.begin(), d.end());
  ll ans = 0;
  REP(i,M-N) ans += d[i];
  return ans;
}

int main() {
  ll ans = solve();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b + c >= 22)
        cout << "bust\n";
    else
        cout << "win\n";
}

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

const int mod = 1e9 + 9;
int n, m, a[1005], b[1005], c[1005][15], f[1005][1 << 15];

int attempt(int u, int num)
{
    if (num != 0 && u > m) return 1e18;
    if (!num) return 0;
    if (f[u][num] != -1) return f[u][num];
    int res = 1e18;
    res = min(res,attempt(u+1,num));
    int p = num;
    for (int i = 1; i <= b[u]; i++)
    {
        int c1 = c[u][i];
        if (num & (1 << (c1-1)))
            num ^= (1 << (c1-1));
    }
    res = min(res, attempt(u+1, num) + a[u]);
    return f[u][p] = res;
}

int32_t main()
{
    cin >> n >> m;
    for (int j = 0; j < m; j++)
    {
        cin >> a[j] >> b[j];
        for (int i = 1; i <= b[j]; i++)
        {
            cin >> c[j][i];
        }
    }
    memset(f,-1,sizeof(f));
    int ans = attempt(0, (1<<n)-1);
    if (ans == 1e18) cout << -1;
    else
    cout << ans;
}


Measured memory_bytes: 257792
#include <stdio.h>
#include <algorithm>
#include <iostream>

using namespace std;

#define INF 100000001

#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a<b)?a:b)

int main(void){
    int m,n,i,j,p[10000],q[10000],c[501],e[501],dp[2][10001],x,ans=0;
    scanf("%d%d",&m,&n);
    // ????????????????????????
    for(i=0; i<m; i++){
        scanf("%d",&p[i]);
    }
    sort(p,p+m,greater<int>());
    for(i=0; i<m; i++){
        q[i]=0;
        for(j=0; j<=i; j++){
            q[i] += p[j];
        }
    }
    // ??±?????????
    for(i=1; i<=n; i++){
        scanf("%d%d",&c[i],&e[i]);
    }
    for(i=0; i<2; i++){
        dp[i][0]=0;
        for(j=1; j<=m; j++){
            dp[i][j]=INF;
        }
    }
    for(i=1; i<=n; i++){
        for(j=1; j<=m; j++){
            x = max(j - c[i],0);
            x = dp[(i-1)%2][x]+e[i];
            dp[i%2][j]=min(x,dp[(i-1)%2][j]);
        }
    }
    for(i=0; i<m; i++){
        ans = max(ans, q[i]-dp[n%2][i+1]);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1364
def main():
    A, B, C, X, Y = map(int, input().split())

    ans = 1 << 30
    c = 0  # even
    while True:
        j = c // 2
        t = A * max(0, X - j) + B * max(0, Y - j) + C * c
        if ans <= t: break
        ans = t
        c += 2

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
@h=(<>!~$",sort{$b-$a}glob<>);map{$%=$h[$i=1]/2;$h[$i/2]=$h[$i]while$%<$h[$i+=$h[$i*=2]<$h[$i+1]];$h[$i/2]=$%}1..$';$\+=$_ for@h;print

Measured memory_bytes: 31364
#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 <math.h> // sqrt
#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 <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

int main() {
    int N;
    cin >> N;
    vi data(N);
    for (int i = 0; i < N; i++) {
        cin >> data[i];
    }
    ll k = 0;
    ll money = 1000;
    if (data[0] <= data[1]) {
        k = floor(money / data[0]);
        money -= k * data[0];
    }
    vi vec(N, 0);
    for (int i = 1; i < N - 1; i++) {
        if (data[i] >= data[i - 1] && data[i] >= data[i + 1]) {
            vec[i] = 1;
            continue;
        }
        if (data[i] <= data[i - 1] && data[i] <= data[i + 1]) {
            vec[i] = 2;
        }
    }
    for (int i = 1; i < N - 1; i++) {
        if (vec[i] == 1) {
            money += k * data[i];
            k = 0;
            continue;
        }
        if (vec[i] == 2) {
            ll a = floor(money / data[i]);
            k += a;
            money -= a * data[i];
        }
    }
    money += k * data[N - 1];
    cout << money << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define F first
 #define S second
#define PB push_back
#define MP make_pair
#define ll long long int

#define PI 3.14159




using namespace std;

int main()
{
 	ios_base::sync_with_stdio(0);
	cin.tie(0);
	const int maxn = 2e5 + 10;
	
	int a[maxn];
	int n,x;
	memset(a,0,sizeof(a));
	cin>>n;
	for(int i=1;i<n;i++)
	{
		cin>>x;
		a[x]++;
	}
	for(int i=1;i<=n;i++)
		cout<<a[i]<<endl;
	
	
return 0;
}


Measured memory_bytes: 4392
#include <iostream>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    int ans = 0;
    for(int i=0; i<N; i++) {
        int A;
        cin >> A;
        if(A == ans+1) {
            ans++;
        }
    }
    if(ans) {
        cout << N - ans << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

from heapq import *
def solve():
    n,a,b,c,d = [int(i) for i in readline().split()]

    ans = 10**18
    q = [(0,n)] #(そこまでの距離、点)
    dic = {n:0}
    while q:
        cost,v = heappop(q)
        if dic[v] < cost: continue

        ans = min(ans,cost+d*v)
        for x in [2,3,5]:
            for y in range(-x+1,x):
                if (v+y)%x==0:
                    nv = (v+y)//x
                    nc = cost + d*abs(y) + a*(x==2) + b*(x==3) + c*(x==5)
                    if nv not in dic or nc < dic[nv]:
                        dic[nv] =  nc
                        heappush(q,(nc,nv))
                    

    print(ans)
    return



t = int(input())
for _ in range(t):
    solve()



Measured memory_bytes: 83636
n,m = map(int,input().split())

lmax = 0
rmin = n+1

for i in range(m):
    l,r = map(int,input().split())
    if l > lmax:
        lmax = l
    if r < rmin:
        rmin = r

if lmax <= rmin:
    print(rmin-lmax+1)
else:
    print(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;

int main(){
    ll A,B,X;
    cin>>A>>B>>X;
    if((A+B)>=X&&A<=X)cout<<"YES";
    else cout<<"NO";
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

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

if n >= m:
    print(0)
    exit()

x = sorted(x)

d = []

for i in range(m-1):
    d.append(x[i + 1] - x[i])

d = sorted(d)

print(sum(d[0:m - n]))

Measured memory_bytes: 13968
main()
{
    int S, A, B, AA=0, BB=0;
    scanf("%d", &S);
    A = S/100;
    B = S%100;
    AA = A>0 && A <= 12 ? 1 : 0;
    BB = B>0 && B <= 12 ? 1 : 0;
    if(AA && BB) printf("AMBIGUOUS");
    else if(AA) printf("MMYY");
    else if(BB) printf("YYMM");
    else printf("NA");
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MN 100005
#define inf 0x3f3f3f3f
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
struct edge{int t,nex,w;}e[MN*2];int hr[MN],cnt;
void ins(int f,int t,int w){e[++cnt]=(edge){t,hr[f],w};hr[f]=cnt;}
int n,a,b,c,dind,l[MN],r[MN],sons[MN],mson[MN],mins=inf,mid;
long long ans;
void dfs(int x,int fa,int w){
	l[x]=++dind;int maxi=0;
	for(int i=hr[x];i;i=e[i].nex)
		if(e[i].t!=fa){
			dfs(e[i].t,x,e[i].w);
			sons[x]+=sons[e[i].t]+1;
			maxi=max(maxi,sons[e[i].t]+1);
	}
	r[x]=dind;
	int mini=min(r[x]-l[x]+1,n-r[x]+l[x]-1);
	ans+=(long long) mini*w*2;
	maxi=max(maxi,n-1-sons[x]);
	mson[x]=maxi;
	if(maxi<mins) mins=maxi,mid=x;
}
int main(){
	n=read();register int i;
	for(i=1;i<n;i++){
		a=read(),b=read(),c=read();
		ins(a,b,c);ins(b,a,c);
	}
	dfs(1,0,0);int lowe=inf;
	for(i=hr[mid];i;i=e[i].nex){
		lowe=min(lowe,e[i].w);
		if(mson[e[i].t]==mson[mid]){
			printf("%lld\n",ans-e[i].w);
			return 0;
		}
	}
	printf("%lld\n",ans-lowe);
	return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char b;
  cin >> b;
  
  if (b =='A'){
    cout << 'T' << endl;
  }
  else if (b =='C'){
    cout << 'G' << endl;
  }
  else if (b =='G'){
    cout << 'C' << endl;
  }
  else if (b =='T'){
    cout << 'A' << endl;
  }
}
  
  

Measured memory_bytes: 3548
#include <stdio.h>

int main() {
  int a,b,c,d;
  int i, j;
  int n;
  
  scanf("%1d %1d %1d %1d", &a, &b, &c, &d);
  
  
  for(i = 0; i < (1 << 4); i++){ //全てのパターンをbitによって列挙
    n = a;
    n += (i&1) ? b : -b; //1にフラグが立ってたらプラス。否だとマイナス
    n += (i&2) ? c : -c; //2にフラグが立ってたらプラス。否だとマイナス
    n += (i&4) ? d : -d; //3にフラグが立ってたらプラス。否だとマイナス
    if(n == 7){
      printf("%d%c%d%c%d%c%d=7\n", a, i&1? '+':'-',  b, i&2? '+':'-', c, i&4? '+' : '-', d);
      return 0;
    }
  }
}


Measured memory_bytes: 128
import math
import bisect
from queue import Queue
from collections import deque

h, w = [int(i) for i in input().split()]
n = int(input())
a = [int(i) for i in input().split()]

table = [[0 for _ in range(w)] for _ in range(h)]

x = 0
y = 0
z = 0
s = 0


for i in range(h*w):
    table[y][x] = z + 1

    if(s < a[z]-1):
        s += 1
    else:
        s = 0
        z += 1

    if(y % 2 == 0):
        if(x == w-1):
            y += 1
        else:
            x += 1
    else:
        if(x == 0):
            y += 1
        else:
            x -= 1

for i in range(h):
    L = [str(j) for j in table[i]]
    L = " ".join(L)
    print(L)



Measured memory_bytes: 4464
#include <stdio.h>

int main(void){
	int a[2];
	int yard = 0;

	scanf("%d", &a[0]);
	scanf("%d", &a[1]);

	yard = a[0]*a[1]-(a[0]+a[1])+1;

	printf("%d\n", yard);

	return 0;
}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <stdio.h>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORa(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define FORs(i,st) for(auto i : st)
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    string s;
    vector<ll> mp(26,1);
    cin>>n>>s;
    FOR(i,0,n){
      mp[s[i] - 'a']++;
    }

    ll res=1;
    FOR(i,0,26){
      res =  res * mp[i] % ((ll)1e9+7);
    }
    cout<<res-1<<endl;
}


Measured memory_bytes: 512
/**********************************************************
* @Author: 			   Kirito
* @Last Modified by:   Kirito
* @Remark:
**********************************************************/
#include <bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define CSE(x,y) memset(x,y,sizeof(x))
#define INF 0x3f3f3f3f
#define Abs(x) (x>=0?x:(-x))
#define FAST ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll , ll> pll;

const int maxn=111111;


int main()
{
	string s,t;
	cin>>s>>t;
	int len=s.length();
	for(int i=0;i<len;i++){
        if(s[i]!=t[i]){
            cout<<"No"<<endl;
            return 0;
        }
	}
	cout<<"Yes"<<endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  map<ll, ll> A;
  rep(i,N){
    ll a;
    cin >> a;
    A[a] += 1;
  }
  
  int M;
  cin >> M;
  map<ll, ll> B;
  rep(i, M){
    ll b; 
    cin >> b;
    B[b] += 1;
  }
  if (N < M) {
    cout << "NO" << endl;
    return 0;
  }
  
  bool judge;
  for (auto p : B){
    ll value = p.second;
    if (A[p.first] >= value) judge = 1;
    else {
      judge = 0;
      break;
    }
  }
  
  if (judge) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}

Measured memory_bytes: 25216
#include <cstdio>
#include <algorithm>

const int N(1e5 + 10);
int n, L, T, x[N], sum;

int main()
{
	scanf("%d%d%d", &n, &L, &T);
	for (int i = 1, w; i <= n; i++)
	{
		scanf("%d%d", x + i, &w);
		if (w == 1 && T - L + x[i] >= 0) sum += (T - L + x[i]) / L + 1;
		else if (w == 2 && T - x[i] > 0) sum -= (T - x[i] - 1) / L + 1;
		if (w == 1) x[i] = (x[i] + T) % L;
		else x[i] = (x[i] - T % L + L) % L;
	}
	std::sort(x + 1, x + n + 1), sum = (sum % n + n) % n;
	for (int i = sum + 1; i <= n; i++) printf("%d\n", x[i]);
	for (int i = 1; i <= sum; i++) printf("%d\n", x[i]);
	return 0;
}


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

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

struct dict {
  string s;
  ll p;
  ll num;
  dict(){};
  dict(string s, ll p, ll num) {
    s = s;
    p = p;
    num = num;
  }
};

bool comp_s(dict p, dict q) {
  if (p.s != q.s) {
    return p.s < q.s;
  } else {
    return p.p > q.p;
  }
}

ll N;
vector<dict> SP;
void solve() {
  sort(SP.begin(), SP.end(), comp_s);
  for (int i = 0; i < N; i++) {
    cout << SP[i].num << "\n";
  }
}

int main() {
  cin >> N;
  SP.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> SP[i].s >> SP[i].p;
    SP[i].num = i + 1;
  }
  solve();
  return 0;
}


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

using namespace std;

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

        std::map<char, char> s_map;
        std::map<char, char> t_map;

        for (int i = 0; i < S.length(); ++i) {
                if (s_map.find(S[i]) != std::end(s_map)) {
                        if (s_map[S[i]] != T[i]) {
                                cout << "No" << endl;
                                return 0;
                        }
                }
                else {
                        s_map.insert(make_pair(S[i], T[i]));
                }
                if (t_map.find(T[i]) != std::end(t_map)) {
                        if (t_map[T[i]] != S[i]) {
                                cout << "No" << endl;
                                return 0;
                        }
                }
                else {
                        t_map.insert(make_pair(T[i], S[i]));
                }
        }

        cout << "Yes" << endl;
        return 0;
}

Measured memory_bytes: 776
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int INF = 1e9 + 7;

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

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

	vector<int> sum(1010, 0);
	for (int i = 1; i <= 999; i++) sum[i] = sum[i - 1] + i;

	cout << sum[b - a] - b << endl;
}

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

const string YES = "POSSIBLE";
const string NO = "IMPOSSIBLE";

void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b){
    vector<set<ll> > G(N);
    for(ll i=0; i< M; i++){
        G[a[i]-1].insert(b[i]-1);
        G[b[i]-1].insert(a[i]-1);
    }
    for(auto it=G[0].begin(); it != G[0].end(); it++){
        if(G[*it].count(N-1)) {
            cout << YES << endl;
            return;
        }
    }
    cout << NO << endl;
    

}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(M);
    std::vector<long long> b(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    solve(N, M, std::move(a), std::move(b));
    return 0;
}


Measured memory_bytes: 31488
#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
using namespace std;

#define ll long long
typedef int vt; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define MOD 1000000007

vt pow_rep_square(vt n, vt p) { //modなし
	if (p == 0) return 1;
	else if (p % 2 == 0) {
		vt t = pow_rep_square(n, p / 2);
		return t * t;
	}
	else return n * pow_rep_square(n, p - 1);
}

int main() {
	int x, t, ans = 1;
	cin >> x;
	if (x < 4) {
		cout << 1;
		return 0;
	}
	reps(i, 2, x) {
		reps(j, 2, 10) {
			t = pow_rep_square(i, j);
			if (t > x) break;
          	if (t > ans) ans = t;
			
		}
	}
	cout << ans << endl;
	return 0;
}

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


void trace(int A[], int N){
  int i;
  for (i=0; i<N; i++){
    if (i>0)printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

void insertionSort(int A[], int N){
  int i, j, v;
  for (i=1; i<N; i++){
    v = A[i];
    j = i-1;
    while (j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
      /* code */
    }
    A[j+1] = v;
    trace(A, N);
  }
}

int main() {
  int N, i;
  int A[100];

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

  trace(A, N);
  insertionSort(A, N);
  return 0;
}

Measured memory_bytes: 2700
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long
#define vi vector <int>
#define pii pair <int, int>
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i,n) for (int i = 0; i < (int) (n); ++ i)
#define foreach(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); ++ it)

inline int read() {
	int x = 0, f = 1, c = getchar();
	for (;!isdigit(c);c = getchar()) if (c == '-') f ^= 1;
	for (; isdigit(c);c = getchar()) x = x * 10 + c - '0';
	return f ? x : -x;
}

int main() {
	int n = read();
	int K = read();
	int cnt = 0;
	rep(i, n) if (read() >= K) ++ cnt;
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

int k,n;
void test() {
    cin>>k>>n;
    vector<int> a(n),b(n);
    for (int i=0; i<n; ++i) {
        cin>>a[i];
        if (i) b[i]=a[i]-a[i-1];
    }
    b[0]=k-a[n-1]+a[0];
    cout<<k-*max_element(b.begin(),b.end())<<endl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int t; cin>>t;
    // while (t--) {
    //     test();
    // }
    test();
    // for (int i=1; i<=t; ++i) {
    //     cout<<"Case #"<<i<<": ";
    //     test();
    // }
    return 0;
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    if (K <= A)
        cout << K << endl;
    else if (K <= A + B)
        cout << A << endl;
    else cout << 2*A+B-K << endl;
}


Measured memory_bytes: 3632
package main

import "fmt"

var (
	n, k int
	hs   []int
	dp   []int
)

const INF = 1 << 60

func chmin(a *int, b int) {
	if *a > b {
		*a = b
		return
	}
	return
}

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func main() {
	fmt.Scan(&n, &k)
	hs = make([]int, n)
	dp = make([]int, n+k+1)
	for i := range hs {
		fmt.Scan(&hs[i])
	}
	for i := range dp {
		dp[i] = INF
	}
	dp[0] = 0

	for i := 0; i < n; i++ {
		for j := 1; j <= k; j++ {
			if i+j < n {
				chmin(&dp[i+j], dp[i]+abs(hs[i+j]-hs[i]))
			}
		}
	}
	fmt.Println(dp[n-1])
}


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

int check(LL a[],LL n,LL k)
{
    LL tot_cost=0;
    LL i=1;
    LL cost[n+1];
    for(LL i=0;i<=n;i++){
        cost[i]=INT_MAX;
    }
    if(n==2)
    {
        return abs(a[n]-a[n-1]);
    }
    cost[1]=0;
    i=2;
    while(i<=n)
    {   LL minn=INT_MAX,tmp;
        for(int j=1;j<=k;j++){
                if(i-j>=0)
                    tmp=cost[i-j]+abs(a[i]-a[i-j]);
                else
                    break;
                if(tmp<minn)
                    minn=tmp;
        }
        cost[i]=minn;
        i++;
    }
   /* for(LL i=1;i<=n;i++)
        cout<<cost[i]<<" ";
    cout<<endl;*/

    return cost[n];
}


int main()
{
    LL n,k;
    cin>>n>>k;
    LL a[n+1];
    for(LL i=1;i<=n;i++)
        cin>>a[i];
    cout<<check(a,n,k)<<endl;

    return 0;
}




Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

int main()
{
    int N;
    std::cin >> N;
    std::string S;

    int red_cnt = 0;
    std::cin >> S;

    for(int i=0; i<N; i++)
    {
        if(S[i] == 'R')
        {
            red_cnt++;
        }
    }

    //red_cntより左に白がなく、右に赤がないようにする
    int exe = 0;
    for(int i=0; i<red_cnt; i++)
    {
        if(S[i] == 'W')
        {

                    exe++;
        }
    }

    std::cout << exe << std::endl;

    return 0;
}

Measured memory_bytes: 3716
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
constexpr int R=2e4+69, INF=2e9+6969;

ll ans[R],n;

int main()
{
	cin >> n;
	for(ll a=2;a*a<=n*2;++a)
	{
		for(ll b=2;b*b<=n*2;++b)
		{
			for(ll c=2;c*c<=n*2;++c)
			{
				if(a*a+b*b+c*c>n*2) continue;
				ll x,y,z;
				x=(a+b-c)/2;
				y=(a+c-b)/2;
				z=(b+c-a)/2;
				if(x<1 || y<1 || z<1) continue;
				if((x+y+z)*2!=a+b+c) continue;
				ll cur = x*x+y*y+z*z + x*y + x*z + y*z;
				if(cur*2!=a*a+b*b+c*c) continue;
				ans[cur]++;
			}
		}
	}
	for(int i=1;i<=n;++i) printf("%lld\n", ans[i]);
	return 0;
}


Measured memory_bytes: 3752
pub struct Scanner {
    line: Vec<String>,
    idx: usize,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        return Scanner {
            line: vec![],
            idx: 0,
        };
    }
    fn next<T: std::str::FromStr>(&mut self) -> T {
        if self.idx == self.line.len() {
            let mut buffer = String::new();
            std::io::stdin().read_line(&mut buffer).ok();
            let a: Vec<&str> = buffer.trim().split(' ').collect();
            self.line = a.iter().map(|&s| String::from(s)).collect();
            self.idx = 0;
        }
        let ret: T = self.line[self.idx].parse::<T>().ok().expect("Parse error.");
        self.idx += 1;
        ret
    }
    fn next_string(&mut self) -> Vec<char> {
        let s: String = self.next();
        return s.chars().collect::<Vec<char>>();
    }
    fn next_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        let mut v: Vec<T> = Vec::with_capacity(n);
        for _i in 0..n {
            v.push(self.next());
        }
        v
    }
}

const MOD : u64 = 1_000_000_007;

fn main(){
    let mut scan = Scanner::new();
    let n: u64 = scan.next();
    let k: u64 = scan.next();
    let mut ans:u64 = 0;

    for i in k..n+2{
        let c: u64 = i;
        let min = (c - 1) * c / 2;
        let max = (n + 1 - c + n) * c / 2;
        ans += max - min + 1;
        ans %= MOD;
    }
    println!("{}", ans);
}


Measured memory_bytes: 2112
#include <iostream>
#include <math.h>
using namespace std;
struct pyrimid
{
	int h,x,y;
	inline int center(int& H,int& a,int& b)
	{
		int o = H - abs(x - a) - abs(y - b);
		return h ==( o > 0 ? o : 0);
	}
};
int main()
{
	int n,i,j,k;
	cin >> n;
	pyrimid *p = new pyrimid[n];
	for(i = 0;i < n;i ++)
		cin >> p[i].x >> p[i].y >> p[i].h;
	for(i = p[0].h,k = 1;k < n;k ++)
	{
		i = i > p[k].h ? i : p[k].h;
	}
	for(;;i ++)
		for(j = 0;j <= 100;j ++)
			for(k = 0;k <= 100;k ++)
			{	
				int f = 0;
				for(int g = 0;g < n;g ++)	
					if(p[g].center(i,j,k) == 1)
						f ++;
				if(f == n)
				{
					cout << j << ' ' << k << ' ' << i << endl;
					return 0;
				}
			}
}

Measured memory_bytes: 256
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

n, m = MI()

ac = 0
wa = 0
acp = [False] * (n+1)
wap = [0] * (n+1)
for i in range(m):
    id, result = MS()
    id = int(id)
    if acp[id]:
        continue

    if result == "WA":
        wap[id] += 1
    else:
        acp[id] = True
        ac += 1
        wa += wap[id]

print(ac, wa)

Measured memory_bytes: 13720