akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> void Max(T &m, const T q) { if (m < q) m = q; }
template<typename T> void Min(T &m, const T q) { if (m > q) m = q; }
template<typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int X;
lint N;

int main()
{
    cin >> X;
    N = 2;
    REP(_, X) N = (N + 1) * 2;
    cout << N << endl;
}


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

using namespace std;

int main(){

    int N;
    cin >> N;
    int wo;
    for(int i=0; i<N;i++){
        cin >> wo;
        if(wo % 2 == 1){
            cout << "first" << endl;
            return 0;
        }
    }
    cout << "second" << endl;
    return 0;
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//constexpr ll P = 1e9 + 7;
	//constexpr ll P = 998244353;

	ll n, m;
	cin >> n >> m;
	vector<ll> cnt(n, 0);
	while (m--) {
		ll a, b;
		cin >> a >> b;
		cnt[a - 1]++;
		cnt[b - 1]++;
	}
	for (ll i = 0; i < n; i++) cout << cnt[i] << endl;
}

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

int main(void){
    int n = 0; 
    int p[21];
    int ans = 0;

    scanf("%d", &n);

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

    for(int i = 1; i < n - 1; i++){
        if(p[i] > p[i - 1] && p[i] < p[i + 1]){
            ans++;
        }else if(p[i] < p[i - 1] && p[i] > p[i + 1]){
            ans++;
        }
    }

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

    return 0;

} 


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

namespace Programminng
{
    class AOJ_Volume0002
    {
        static void Main(string[] args)
        {
            while (true)
            {
                String i = Console.ReadLine();
                if (i != null)
                {
                    string[] values = i.Split(' ');
                    int value = int.Parse(values[0]);
                    int value_2 = int.Parse(values[1]);
                    int sum = value + value_2;

                    Console.WriteLine(sum.ToString().Length);
                }
                else
                {
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
	scanf("%d",&n);
	for(int i=0;i<=n;i++){
		int a=i,b=n-i;
		if(a%4==0 && b%7==0){
			printf("Yes");
			return 0;
		}
		else if(a%7==0 && b%4==0){
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

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

ll use[10] = {101010, 2, 5, 5, 4, 5, 6, 3, 7, 6};
string s[10] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
ll flg[10];

class mat{
    public:
    string str;
    mat(){
        str = "";
    }
    bool operator < (const mat &m)const{
        if(str.size() != m.str.size())return str.size() < m.str.size();
        return str < m.str;
    }
};

int main(){
    
    ll N, M;
    cin >> N >> M;
    vector<mat>dp(N+1);
    for(ll i = 0; i < M; i++){
        ll a;
        cin >> a;
        flg[a] = 1;
    }
    for(ll i = 0; i < N; i++){
        if(i && dp[i].str == "")continue;
        for(ll j = 1; j <= 9; j++){
            if(flg[j] == 0)continue;
            ll nxt = i + use[j];
            if(nxt > N)continue;
            mat tmp = dp[i];
            tmp.str += s[j];
            if(dp[nxt] < tmp)dp[nxt] = tmp;
        }
    }
    // for(ll i = 0; i <= N; i++){
    //     cout << i << " : " << dp[i].str << endl;
    // }
    cout << dp[N].str << endl;
    return 0;
}


Measured memory_bytes: 43648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N, M; cin >> N >> M;
	vector<P> ba(M);
	rep (i, M){
		int a, b; cin >> a >> b;
		ba[i].first = b;
		ba[i].second = a;
	} // end rep

	sort(ALL(ba));

	int res = 0;
	int x = 0;
	rep (i, M){
		int b = ba[i].first;
		int a = ba[i].second;
		if (x <= a){
			x = b;
			++res;
		} // end if
	} // end rep

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
 
  int FN = 0;
  int N2 = N;
  
  while (N2 != 0) {
    FN += N2 % 10 ;
    N2 /= 10;
  } 
  
  if (N % FN == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }      

}

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

int main(){
 int a,b,K,p;
  cin>>a>>b;
  vector<int> n(b+1);
  for(int i=0;i<a;i++){
    cin>>K;
    
    for(int j=0;j<K;j++){
      cin>>p;
      n[p]++;
    }
    }
  p=0;
  for(int i=0;i<b+1;i++){
    if(n[i]==a){
    p++;
    }
  }
       cout<<p<<endl;
}


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

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

using namespace std;

int main()
{
  string t[] = {"dreamer", "dream", "eraser", "erase"};
  string s;
  cin >> s;
  const int slen = s.length();
  int pos = 0;
  bool found = true;
  while(found)
  {
    for(int i = 0; i < 4; ++i)
    {
      int x = slen - pos - t[i].length();
      found = x >= 0 && s.find(t[i], x) == x;
      if(found)
      {
        pos += t[i].length();
        break;
      }
    }
  }
  if(pos == slen)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
 
int main(){
	int n;
 
	cin >> n ;
 
 	if(n % 2 == 0 ) {
    	cout << n / 2;
    } else {
    	cout << (n / 2) + 1;
    }
  
	return 0;		 
}

Measured memory_bytes: 256
using System;
					
public class Program
{
	public static void Main()
	{
		int K = int.Parse(Console.ReadLine()); 
		string[] str = Console.ReadLine().Split(' ');
		int A = int.Parse(str[0]); 
      	int B = int.Parse(str[1]); 
		double num = A / K;
		double ans;
		int amari = A%K;
		
		num = Math.Truncate(num);
		num++;
		ans = num * K;
		
		if(((A <= ans) &&(ans <= B))||(amari==0)){
			Console.WriteLine("OK");
		}else{
			Console.WriteLine("NG");
		}
		
	}
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, m;
int a[100];

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

	cout <<a[n-1]-a[0] << endl;
	return 0;
}

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

int main ()
{
    int a,b;
    cin>>a;
    b=a/111;
    if(a%111==0){
        cout<<b*111<<endl;
    }else{
        cout<<(b+1)*111<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        long m = sc.nextInt();
        long mod = 1000000007;
        if (n == m) {
            //n!m! x2
            long ans = 2;
            while (n > 0) {
                ans = (ans % mod) * (n % mod) % mod;
                n--;
            }
            while (m > 0) {
                ans = (ans % mod) * (m % mod) % mod;
                m--;
            }
            System.out.println(ans);
        } else if (Math.abs(n - m) == 1) {
            //n!m!
            long ans = 1;
            while (n > 0) {
                ans = (ans % mod) * (n % mod) % mod;
                n--;
            }
            while (m > 0) {
                ans = (ans % mod) * (m % mod) % mod;
                m--;
            }
            System.out.println(ans);
        } else {
            System.out.println(0);
        }

    }

}

Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>

#define ll long long int


using namespace std;

int Iterbinarysearch(int a[],int n,int x)
{
    int l=0,h=n-1;
	int res=-1;
    while(l<=h)
    {
        int mid=l+(h-l)/2;
        if(x>=a[mid])
		{
			res=mid;
			l=mid+1;
		}
		else
		h=mid-1;
    }
    return res;

}
// int Recurbinarysearch(int a[],int n,int x,int i,int j)
// {
//     if(i>j) return-1;
//     if(n>0)
//     {
//         int mid=i+(j-i)/2;
//         if(x==a[mid]) return mid;
//         else if(x>a[mid]) return Recurbinarysearch(a,n,x,mid+1,j);
//         else return Recurbinarysearch(a,n,x,i,mid-1);
//     }
    
// }

// int* func(int a[],int n)
// {
//     int k=1;
//     for(int i=0;i<n;i++)
//     a[i] +=k;
//     return a;
// } 



// bool isPossibleTriangle(int arr[], int n) 
//    {
//     if (n < 3) 
//     return false; 
  
   
//     sort(arr, arr + n); 
  
//     for (int i = 0; i < n - 2; i++) 
  
    
//         if (arr[i] + arr[i + 1] > arr[i + 2]) 
//         {
//             s1.insert(arr[i]);
//             s1.insert(arr[i+1]);
//             s1.insert(arr[i+2]);

            
//         }
       

//           cout<<"\n";
//         if(s1.size()!=0)
             
//         return true;
    
//         else
//      return false; 
// } 
int gcd (int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
int lcm (int a, int b) {
    return a / gcd(a, b) * b;
}
 ll isPossibleTriangle(ll arr[],
                                       int N)
     {

         // If number of elements are
         // less than 3, then no
         // triangle is possible


         // first sort the array


         // loop for all 3
         // consecutive triplets
         for (int i = 2; i < N ; i++) { // If triplet satisfies
             // triangle condition, break
             if (arr[0] + arr[1] <= arr[i]) {
                 return i;
             }
         }

         return -1;
     }


int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);   
 /*int k=Recurbinarysearch(a,n,x,0,n-1);
(k==-1)?cout<<"Not found":cout<<"found at "<<k;*/

		
		// ll n,k;
		// cin>>n>>k;
		// ll v[n+1];
		// int p;
		// for(int i=0;i<n;i++)
		// 	cin>>v[i];
		// 	ll sm=LONG_MIN;
		// 	bool c=false;
		// 	for(int i=0;i<n;i++)
		// 	{
		// 		if(k%v[i]==0)
		// 		{
		// 			c=true;
		// 			ll x=k/v[i];
		// 			sm=max(sm,v[i]);
		// 		}
				
		// 	}
		// 	(c)?cout<<sm:cout<<-1;
		// 	cout<<"\n";
		
		
		string s;
		cin>>s;
		s.push_back('S');
		int c=0,maxm=0;
		for(int i=0;i<s.size();i++)
		{
			if(s[i]=='R')
			c++;
			else{
				maxm=max(maxm,c);
				c=0;
			}
		}
		cout<<maxm<<"\n";
		


	
   
 return 0;
}

Measured memory_bytes: 3164
import java.util.Scanner;
import java.util.Locale;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

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

    Scanner sc = new Scanner(System.in);
    double T = sc.nextDouble();
    double X = sc.nextDouble();

    System.out.println(T / X);
  }
}


Measured memory_bytes: 24532
num = int(input())
if num >= 2:
  input_list = [int(i) for i in input().split()] 
  sorted_list = sorted(input_list)

  count = 0
  for input, sort in zip(input_list, sorted_list):
    if input != sort:
      count += 1

  if count <= 2:
    print('YES')
  else:
    print('NO')
else:
  print('NO')

Measured memory_bytes: 3060
#include<stdio.h>
#include<algorithm>
using namespace std;
pair<double,pair<int,int> > ev[110000];
int c[110000];int d[110000];
int e[110000];int f[110000];
int main(){
	int a;
	while(scanf("%d",&a),a){
		int b;scanf("%d",&b);
		double sum=0;
		int sz=0;
		for(int i=0;i<a;i++){
			int p,q,r,s;scanf("%d%d%d%d",&p,&q,&r,&s);
			c[i]=p;d[i]=q;e[i]=r;f[i]=s;
			if(s>0&&p>0){
				ev[sz++]=make_pair((double)s/p,make_pair(i,0));
			}
			if(s<=0&&p<0){
				ev[sz++]=make_pair((double)s/p,make_pair(i,1));
			}
		}
		std::sort(ev,ev+sz);
		double ret=0;
		double now=0;
		sum=b;
		for(int i=0;i<a;i++){
			if(f[i]>0){
				now+=(double)d[i]*f[i]/e[i];
				sum-=(double)c[i]*d[i]/e[i];
			}
		}
		ret=now;
		double last=0;
		for(int i=0;i<sz;i++){
		//	printf("%f %f %f\n",now,sum,ret);
			now+=(ev[i].first-last)*sum;
			last=ev[i].first;
			ret=min(ret,now);
			int at=ev[i].second.first;
			if(ev[i].second.second){
				sum-=(double)c[at]*d[at]/e[at];
			}else{
				sum+=(double)c[at]*d[at]/e[at];
			}
		
		}
		printf("%f\n",ret);
	}
}

Measured memory_bytes: 4364
using System;
using System.Linq;

class Program {
  static void Main() {
    int[] arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
    int a = arr[0];
    int b = arr[1];
    int c = arr[2];
    Console.WriteLine(a <= c && c <= b ? "Yes" : "No");
  }
}

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

int main(){
  int R,G,B,n;
  cin >> R >> G >> B >> n;
  int ans=0;
  int i=0,j=0,k=0;
  while( i*R <= n ){
    j=0;
    while( i*R+j*G <= n ){
      k=0;
      while(i*R+j*G+k*B <= n){
        //if( i*R+j*G+k*B == n ) ans++;
        if( (n-i*R-j*G)%B == 0 ){
          ans++;
          break;
        }
        k++;
      }
      j++;
    }
    i++;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a,b;
int t;
char c[1000000];
int main()
{
	cin>>a;
	int l=a.size();
	b=a;
	for(int i=l-1;i>=0;i--)
		c[l-i-1]=a[i];
	for(int i=0;i<=l-1;i++)
	{
		if(c[i]=='b')
			c[i]='d';
		else if(c[i]=='d')
			c[i]='b';
		else if(c[i]=='p')
			c[i]='q';
		else if(c[i]=='q')
			c[i]='p';
	}
	for(int i=0;i<l;i++)
	{
		if(c[i]!=b[i])
			t=1;
	}
	if(t==0)
		cout<<"Yes"<<'\n';
	else
		cout<<"No"<<'\n';
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x <<  " " << x << endl;
#define all(x) x.begin(), x.end()
typedef std::vector<int> vi;
typedef std::vector<vector<int>> vvi;
typedef std::vector<string> vs;
typedef std::vector<bool> vb;
typedef std::pair<int, int> pii;
typedef long long ll;
const int inf = 1e9 + 5;

template <typename T>
void print(T v){ for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(2)<<*i<<" ";cout<<endl; }
template <typename T>
void print_vv(T v, bool same_line=true){
for(auto i= 0; i<v.size(); i++){cout<<"{";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(3)<<v[i][j]<<",";}cout<<"},";if(same_line) cout<<endl;}cout<<endl;}

int main(){
    int n, W;
    while(cin>>n>>W){
        vector<ll> dp(W+1);
        // dp[i]: the maximum value that could be avaialble at weight i

        for(int item=0; item<n; item++){
            int weight, value;
            cin>>weight>>value;

            for(int weight_already = W - weight; weight_already>=0; weight_already--){
                dp[weight_already+weight] = max(dp[weight_already+weight], value+dp[weight_already]);
            }
        }

        cout<<*max_element(all(dp))<<endl;
    }

    

    return 0;

}

// int main2(){
//     int N, W;
//     while(cin>>N>>W){
//         vi wts(N+1);
//         vi val(N+1);
//         int dp[N+1][W+1]; // max value till ith item and w weight
//         memset(dp, 0, sizeof dp);

//         for(int i=1; i<=N; i++){
//             cin>>wts[i]>>val[i];
//         }
        
//         for(int i=1; i<=N; i++){
//             for(int w = 1; w<=W; w++){
//                 if(w-wts[i]>=0)
//                     dp[i][w] = max(dp[i-1][w], val[i] + dp[i-1][w-wts[i]] );
//                 else 
//                     dp[i][w] = dp[i-1][w];
//             }
//         }
    
//         cout<<dp[N][W]<<endl;
//     }

//     return 0;
// }

Measured memory_bytes: 1024
<?php
fscanf(STDIN, "%s", $s);

substr($s,0,1);
$bubun =[];
for($i=0;$i<4;$i++){
  if(isset($bubun[substr($s,$i,1)])){
$bubun[substr($s,$i,1)]+=1;
  }else{
    $bubun[substr($s,$i,1)]=1;
  }
}

if(count($bubun)==2){
  foreach($bubun as $val){
   if($val==2){
     echo "Yes"."\n";
   } else{
     echo  "No"."\n";
   }
    exit;
  }
}else{
  echo  "No"."\n";
}
?>

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

int main() {
	int n,l;
	cin >> n >> l;
	int ans = -125125;
	int _abs = 125125;
	for(int cda = 0; cda < n; cda++) {
		int temp = 0;
		int all = 0;
		for(int i = 0; i < n; i++) {
			if(i!=cda) temp += l+i;
			all += l+i;
		}
		int temp_abs = abs(temp-all);
		if(_abs>temp_abs) {
			ans = temp;
			_abs = temp_abs;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main() {
    int h, w, n;
    cin >> h >> w >> n;

    int m = max(h, w);
    cout << (n + m - 1) / m << endl;
    return 0;
}

Measured memory_bytes: 256
local N, M = io.read("*n", "*n")
local hights, is_good = {}, {}
for i = 1, N do
	hights[i] = io.read("*n")
	is_good[i] = true
end

for i = 1, M do
	local A, B = io.read("*n", "*n")

	if is_good[A] and hights[A] <= hights[B] then
		is_good[A] = false
	end
	if is_good[B] and hights[B] <= hights[A] then
		is_good[B] = false
	end
end


local count = 0
for i = 1, N do
	if is_good[i] then
		count = count + 1
	end
end

print(count)

Measured memory_bytes: 4852
import java.lang.Math.*

fun main(args: Array<String>){
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val h = readLine()!!.split(" ").map { it.toInt() }

    val dp = Array(n){0}

    for(i in 1 until n){
        var min = Int.MAX_VALUE
        for (j in 1 until min(i, k) + 1){
            min = min(min, dp[i - j] + abs(h[i] - h[i - j]))
        }
        dp[i] = min
    }
    println(dp.last())
}

Measured memory_bytes: 51900
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MOD = (1e+9) + 7;

int main() {
    ll ans = 0;
    cin>>N;
    multiset<ll> low,high;
    rep(i,N){
        cin>>M;
        if(M == 1){
            cin>>A>>B;
            ans += B;
            if(i == 0){
                low.insert(A);
                high.insert(A);
            }else{
                ll llc = *(--low.end());
                rep(j,2){
                    *(--low.end()) < A ? high.insert(A) : low.insert(A);
                }
                if(low.size() < high.size()){
                    low.insert(*high.begin());
                    high.erase(high.begin());
                }else if(low.size() > high.size()){
                    high.insert(*(--low.end()));
                    low.erase(--low.end());
                }

                if(low.size()%2 == 1){
                    ans += abs(*(--low.end()) - A);
                }else{
                    ans += abs(llc - A);
                }
            }
        }else{
            cout<<*(--low.end())<<' '<<ans<<endl;
        }
    }
}


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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    ll a, b, c, d;
    ll n;
    cin >> a >> b >> c >> d >> n;
    b = min(b, 2*a);
    c = min(c, 2*b);
    d = min(d, 2*c);
    ll res = 0;
    n *= 4;
    res += d*(n/8);
    n %= 8;
    res += c*(n/4);
    n %= 4;
    res += b*(n/2);
    n %= 2;
    res += a*n;
    cout << res;
    return 0;
}


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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef pair<ll, ll> pint;


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

class Dice
{
public:
  vint num;


  Dice(vint num);
  void roll(char d);
  ll top();
  ll front();
  ll left(){return num[3];}
  ll right(){return num[2];}
  ll right(ll top, ll front);


  bool operator ==(Dice obj){


    return true;
  }



};

Dice::Dice(vint num){
  this->num = num;
}

void Dice::roll(char d){
  vint tmp_num = num;
  if(d == 'E'){
    num[2] = tmp_num[0];
    num[0] = tmp_num[3];
    num[3] = tmp_num[5];
    num[5] = tmp_num[2];
  }else if(d == 'N'){
    num[0] = tmp_num[1];
    num[1] = tmp_num[5];
    num[5] = tmp_num[4];
    num[4] = tmp_num[0];
  }else if(d == 'S'){
    num[0] = tmp_num[4];
    num[4] = tmp_num[5];
    num[5] = tmp_num[1];
    num[1] = tmp_num[0];
  }else if(d == 'W'){
    num[0] = tmp_num[2];
    num[2] = tmp_num[5];
    num[5] = tmp_num[3];
    num[3] = tmp_num[0];
  }else{
    assert(false);
  }
  // cout<<d<<endl;

}

ll Dice::top(){
  return num[0];
}

ll Dice::front(){
  return num[1];
}

ll Dice::right(ll top, ll front){
  
  ll cnt = 0;
  while(this->top() != top && cnt < 4){
    this->roll('E');
    cnt++;
  }
  cnt = 0;
  while(this->top() != top && cnt < 4){
    this->roll('N');
    cnt++;
  }

  cnt = 0;
  while(this->front() != front && cnt < 4){
    this->roll('E');
    this->roll('N');
    this->roll('W'); // rotate clockwise
    cnt++;
  }

  assert(this->top() == top && this->front() == front);

  return this->right();
}


void print(const vint& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}

int main() {


  cout<<fixed<<setprecision(10);

  vint v1(6);
  rep(i,6)cin>>v1[i];


  Dice d1 = Dice(v1);

  ll n; cin>>n;
  rep(i,n){
    ll top, front;
    cin>>top>>front;
    cout<<d1.right(top, front)<<endl;
  }
}





//




Measured memory_bytes: 3104
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 29 20:44:35 2019

@author: Yamazaki Kenichi
"""

S = input()

a = S.count(S[0])
b = S.count(S[1])
c = S.count(S[2])
d = S.count(S[3])

if a*b*c*d == 16:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
N = int(input().strip())
A = [int(n)-1 for n in input().strip().split()]
B = list(map(int, input().strip().split()))
C = list(map(int, input().strip().split()))

c = 0
for i in range(N):
    c += B[A[i]]
    if i > 0 and A[i] == A[i-1]+1:
        c += C[A[i-1]]

print(c)

Measured memory_bytes: 3064
/*
(1)for binary shift operator always use 'LL' 1LL<<63

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set_pair tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
  
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;cin>>n;
	ll a=n%10;
	if(a==2 or a==4 or a==5 or a==7 or a==9)
		cout<<"hon";
	else if(a==0 or a==1 or a==6 or a==8)
		cout<<"pon";
	else cout<<"bon";

	return 0;
} 

Measured memory_bytes: 3652
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

char s[500][501],r[500][501],b[500][501];
int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	fup(i,0,n-1,1)fup(j,0,m-1,1)r[i][j]=b[i][j]='.';
	fup(i,0,n-1,1)scanf("%s",s[i]);
	fup(i,0,n-1,1)
	{
		if(i&1)
		{
			fup(j,0,m-1,1)
			{
				if(j==0)r[i][j]='#';
				else b[i][j]='#';
			}
		}
		else
		{
			fup(j,0,m-1,1)
			{
				if(j==m-1)b[i][j]='#';
				else r[i][j]='#';
			}
		}
	}
	fup(i,0,n-1,1)
		fup(j,0,m-1,1)
		if(s[i][j]=='#')r[i][j]=b[i][j]='#';
	fup(i,0,n-1,1)printf("%s\n",r[i]);
	puts("");
	fup(i,0,n-1,1)printf("%s\n",b[i]);
	puts("");
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;
const double pi = acos(-1.0);

int main() {
    string s, t; cin >> s >> t;
    sort(all(s));
    sort(all(t));
    reverse(all(t));
    if(s.size() < t.size()) {
        rep(i, s.size()) {
            if(s[i] < t[i]) {
                cout << "Yes" << endl;
                return 0;
            }
            if(s[i] > t[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
        return 0;
    }
    else if(s.size() == t.size()) {
        rep(i, s.size()) {
            if(s[i] < t[i]) {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    }
    else {
        rep(i, t.size()) {
            if(s[i] < t[i]) {
                cout << "Yes" << endl;
                return 0;
            }
        }
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3608
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;
int main ()
{
    int a ,b,i,j,x=0;

    scanf("%d%d",&a,&b);
    for(i=1,j=b;;i++)
        {j/=10;
         if(j<1)
            break;

        }
  // printf("%d %d %d ",a,b,i);
    j=a*pow(10,i)+b+0.5;
   //printf("%d " ,j);

    if(sqrt(j)==(int)sqrt(j))

printf("Yes");
else printf("No");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	
	int H, W, N;
	int max, min;
    scanf("%d%d%d", &H, &W, &N);

	if(H>W){
		printf("%d", (N - 1) / H + 1);
	} else {
		printf("%d", (N - 1) / W + 1);
	}
	return 0;	
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

ll moddividing(ll x,ll y){
    vector<ll> vec(30);
    rep(i,30){
        vec[i] = y;
        y = y * y % 1000000007;
    }
    ll c = x;
    c = c * vec[0] % 1000000007;
    c = c * vec[2] % 1000000007;
    c = c * vec[9] % 1000000007;
    c = c * vec[11] % 1000000007;
    c = c * vec[14] % 1000000007;
    c = c * vec[15] % 1000000007;
    c = c * vec[17] % 1000000007;
    c = c * vec[19] % 1000000007;
    c = c * vec[20] % 1000000007;
    c = c * vec[23] % 1000000007;
    c = c * vec[24] % 1000000007;
    c = c * vec[25] % 1000000007;
    c = c * vec[27] % 1000000007;
    c = c * vec[28] % 1000000007;
    c = c * vec[29] % 1000000007;
    return c;
}

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    ll all_sum = 0;
    ll square_sum = 0;
    rep(i,N){
        all_sum = (all_sum + A[i]) % 1000000007;
    }
    rep(i,N){
        square_sum = (square_sum + (A[i] * A[i]) % 1000000007) % 1000000007;
    }
    all_sum = (all_sum * all_sum) % 1000000007;
    ll ans = (all_sum + 1000000007 - square_sum) % 1000000007;
    ll y = 2;
    cout << moddividing(ans, y) << endl;
}

Measured memory_bytes: 4836
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <utility>
using namespace std;
typedef pair<string, string> pss;

map<string, map<int, int> > name;
map<string, int> limit;
bool isdeclare(string &s){
	for(int i=0; i<(int)s.length(); i++){
		if(s[i]=='=') return false;
	}
	return true;
}
int tonum(string &s){
	for(int i=0; i<(int)s.length(); i++){
		if(s[i] < '0' || '9' < s[i]){
			return -1;
		}
	}
	return stoi(s);
}
pss divbrac(string &s){
	int n = s.length();
	int i=0;
	while(s[i]!='[') i++;
	return make_pair(s.substr(0, i), s.substr(i+1, n-i-2));
}
pss diveq(string &s){
	int n = s.length();
	int i=0;
	while(s[i]!='=') i++;
	return make_pair(s.substr(0, i), s.substr(i+1, n-i-1));
}
int getnum(string &s){
	if(tonum(s)!=-1) return tonum(s);
	pss parse = divbrac(s);
	int idx = getnum(parse.second);
	string arrayname = parse.first;
	if(name[arrayname].find(idx) != name[arrayname].end()){
		return name[arrayname][idx];
	}
	return -1;
}

int main(){
	while(1){
		bool end = false;
		int ans = 0;
		name = map<string, map<int, int> >();
		limit = map<string, int>();
		for(int line=1; ; line++){
			string str;
			cin >> str;
			if(str == "."){
				if(line == 1) end = true;
				break;
			}
			if(ans != 0) continue;
			
			if(isdeclare(str)){
				pss parse = divbrac(str);
				limit[parse.first] = tonum(parse.second);
				name[parse.first] = map<int, int>();
			}else{
				pss parse = diveq(str);
				int val = getnum(parse.second);
				pss parse2 = divbrac(parse.first);
				int subidx = getnum(parse2.second);
				string subarray = parse2.first;
				if(val!=-1 && subidx!=-1 && limit[subarray]>subidx){
					name[subarray][subidx] = val;
				}else{
					ans = line;
				}
			}
		}
		if(end) break;
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a-1);i>=(b);i--)
#define all(x) (x).begin(), (x).end()
const int INF = 1e18;
const int MOD = 1e9+7;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef string str;
typedef vector<str> vstr;
void print() {cout<<endl;}template<class Head,class...Tail>void print(Head&&head,Tail&&...tail){cout<<head;if(sizeof...(tail)!=0)cout<<" ";print(forward<Tail>(tail)...);}template<class T>void print(vector<T>&vec){for(auto&a:vec){cout<<a;if(&a!=&vec.back())cout<<" ";}cout<<endl;}template<class T>void print(vector<vector<T>>&df){for(auto&vec:df){print(vec);}}
template<class T=int>T in() {T x;cin>>x;return(x);}
template<class T=int>vector<T> input_to_vector(int n) {vector<T>x;rep(i,n){T a;cin>>a;x.push_back(a);}return(x);}

signed main(){
    int n = in();
    if(n==1){
        print("Hello World");
    } else {
        int a = in();
        int b = in();
        print(a+b);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define REVE(x) reverse(x.begin(),x.end())
#define all(x) (x).begin(),(x).end()
#define fst first
#define mp make_pair
#define pb push_back
using LL = long long;
using ULL = unsigned long long;
#define FOR(i, m, n) for(int i = m;i < n;i++)
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K,A = 1;
     cin >> N >> K;
    rep(i,N){
        A = min(A*2,A+K);
    }
  cout << A;
}

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

using namespace std;

int n, m, x[505][505];
vector<vector<int>> v;

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			scanf("%d", x[i] + j);
	for (int i = 0; i < n; i++)
		if (i & 1) {
			for (int j = m - 1; j; j--)
				if (x[i][j] & 1) {
					x[i][j - 1]++;
					v.push_back({i, j, i, j - 1});
				}
			if (i != n - 1 && (x[i][0] & 1)) {
				x[i + 1][0]++;
				v.push_back({i, 0, i + 1, 0});
			}
		} else {
			for (int j = 0; j < m - 1; j++)
				if (x[i][j] & 1) {
					x[i][j + 1]++;
					v.push_back({i, j, i, j + 1});
				}
			if (i != n - 1 && (x[i][m - 1] & 1)) {
				x[i + 1][m - 1]++;
				v.push_back({i, m - 1, i + 1, m - 1});
			}
		}
	printf("%d\n", v.size());
	for (auto& i : v)
		for (int j = 0; j < 4; j++)
			printf("%d%c", i[j] + 1, j == 3 ? '\n' : ' ');
	return 0;
}

Measured memory_bytes: 10032
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    ll m;
    scanf("%lld%lld",&n,&m);
    ll maxl=m/n;
    if(m%n==0)
    {
        printf("%lld\n",m/n);
        return 0;
    }
    ll minl=1;
    ll mid=(maxl+minl)/2;
    ll out=0;
    for(int i=minl;i<=maxl;++i)
    {
        if(m%i==0)
            if(out<i)
            out=i;
    }
    printf("%lld\n",out);
}


Measured memory_bytes: 128
x = list(input())
s_cnt = [0] * (len(x)+1)

lost_pair = 0

for i in range(1, len(x)+1):
    if x[i-1] == 'S':
        s_cnt[i] = s_cnt[i-1] + 1
    else:
        if s_cnt[i-1] > 0:
            s_cnt[i] = s_cnt[i-1] - 1
            lost_pair += 1

print(len(x) - 2*lost_pair)

Measured memory_bytes: 12580
#include <stdio.h>
#include <math.h>

int func(double x){
	double x1;
	x1 = x* x * x;
	return x1;
}
int main(){
	double x,x1;
	scanf("%lf",&x);
	x1 = func(x);
	printf("%.0f\n",x1);
	return 0;
}

Measured memory_bytes: 2692
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Char8 as BSC8
import qualified Data.Maybe            as Maybe

main :: IO ()
main = do
  -- s :: BSC8.ByteString
  s <- BSC8.getLine
  BSC8.putStrLn $ solve s (BSC8.length s)

solve :: BSC8.ByteString -> Int -> BSC8.ByteString
solve bs n = if a == b then "Yes" else "No"
  where
    a = BSC8.take m       bs
    b = BSC8.drop (m + 1) bs
    m = n `div` 2

Measured memory_bytes: 3684
from collections import defaultdict

h, w, m = map(int, input().split())

cnt_h = [0] * h
cnt_w = [0] * w
dic = defaultdict(int)

for _ in range(m):
    h_m, w_m = map(int, input().split())
    cnt_h[h_m - 1] += 1
    cnt_w[w_m - 1] += 1
    dic[(h_m - 1, w_m - 1)] += 1

max_h = max(cnt_h)
max_w = max(cnt_w)

mh = []
mw = []

for i in range(h):
    if max_h == cnt_h[i]:
        mh.append(i)

for i in range(w):
    if max_w == cnt_w[i]:
        mw.append(i)

for i in mh:
    for j in mw:
        if dic[(i, j)] == 0:
            print(max_h + max_w)
            quit()

print(max_h + max_w - 1)

Measured memory_bytes: 85868
'''input
5 2
1 1 2 2 5
'''
n,k = map(int,raw_input().split())
arr = map(int,raw_input().split())
ind = [0]*(n+1)
for i in range(n):
	ind[arr[i]] += 1
ind.sort()
aa = 0
for i in range(n+1):
	if ind[i] > 0:
		aa += 1
if aa <= k:
	print "0"
else:
	ans = 0
	for i in range(n):
		if aa == k:
			break
		if ind[i] > 0:
			ans += ind[i]
			aa -= 1
	print ans







Measured memory_bytes: 51696
n = int(input())
V = E = 0
for d in range(1,n+1): V += d * (d + 1) // 2
for _ in range(n-1):
    a, b = map(int, input().split())
    if a > b: a, b = b, a
    E += a * (n - b + 1)
print(V - E)


Measured memory_bytes: 9132
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;

signed main() {
  int n;cin>>n;
  vector<string> v(n);
  rep(i,n){
    cin>>v[i];
    sort(v[i].begin(), v[i].end());
  }
  sort(v.begin(), v.end());
  int cnt = 1, ans = 0;
  repd(i,1,n){
    if(v[i] == v[i-1]){
      cnt++;
    }else{
      ans += (cnt*(cnt-1))/2;
      cnt = 1;
    }
    //cout << ans << endl;
  }
  ans += (cnt*(cnt-1))/2;
  cout << ans << endl;
}



Measured memory_bytes: 7296
#pragma GCC optimize ("Ofast")
#include <iostream>
#include <algorithm>
#include <vector>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define ll long long
using namespace std;

ll ab(ll a)
{
	if(a<0) return -a;
	return a;
}

int main()
{
	ll n,t,nowx=0,nowy=0,nowt=0,x,y;
	cin >> n;
	while(n--)
	{
		cin >> t >> x >> y;
		if(ab(x-nowx)+ab(y-nowy)>t-nowt) return cout << "No\n",0;
		else if((t-nowt-(ab(x-nowx)+ab(y-nowy)))%2) return cout << "No\n",0;
		nowt=t,nowx=x,nowy=y;
	}
	cout << "Yes\n";
}

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

int main(){
  int h1,h2,k1,k2,a,b,c,d;
  cin >> h1 >> h2;
  cin >> k1 >> k2;
  cin >> a >> b >> c >> d;
  cout << ((h1*a+h2*b+h1/10*c+h2/20*d > k1*a+k2*b+k1/10*c+k2/20*d)?"hiroshi":(h1*a+h2*b+h1/10*c+h2/20*d == k1*a+k2*b+k1/10*c+k2/20*d)?"even":"kenjiro") << endl;
}



Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int a[500000],b[500000];

signed main(){
	int n;scanf("%d",&n);
	string s;cin>>s;
	int cnt=0;
	rep(i,s.size()){
		a[i+1]=a[i];
		b[i+1]=b[i];
		if(s[i]=='W')a[i+1]=a[i]+1;
		else b[i+1]=b[i]+1,cnt++;
	}
	int Min=INT_MAX;
	rep(i,s.size()){
		int c=a[i],d=cnt-b[i+1];
		Min=min(Min,c+d);
	}
	cout<<Min;
}

Measured memory_bytes: 3076
#include<stdio.h>
int main()
{
  int n;
  long long int ans;
  ans=1;
  scanf("%d",&n);
  long long int a[100005];
  for(int i=0;i<n;i++)
  {
      scanf("%lld",&a[i]);
      if(!a[i])
      {
          printf("0\n");
          return 0;
      }
  }
 for(int i=0;i<n;i++)
  {
    long long int temp;
    temp=ans*a[i];
    if(ans>temp||temp>1000000000000000000)
    {  printf("-1\n"); return 0;}
    ans=temp;
  }
  printf("%lld",ans);
  return 0;
}


Measured memory_bytes: 2504
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;
typedef long long LL;

const LL MOD = 1000000007;
const size_t MAX_N = 1000001;

struct modll {
	long long x;
	modll() { }
	modll(int _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(int y) { return (x + y + MOD) % MOD; }
	modll operator+=(int y) { x = (x + y + MOD) % MOD; return *this; }
	modll operator-(int y) { return (x - y + MOD) % MOD; }
	modll operator-=(int y) { x = (x - y + MOD) % MOD; return *this; }
	modll operator*(int y) { return (x * y) % MOD; }
	modll operator*=(int y) { x = (x * y) % MOD; return *this; }
	modll operator/(int y) { return (x * modpow(y, MOD - 2)) % MOD; }
	modll operator/=(int y) { x = (x * modpow(y, MOD - 2)) % MOD; return *this; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

modll fact[MAX_N + 1], inv[MAX_N + 1];

modll combination(LL n, LL r) {
	if (r > n) {
		return 0;
	}
	return (fact[n] * inv[r]) * inv[n - r];
}


LL solve(LL n, LL k, vector<LL> a) {
	LL zc = 0, cnt = 0;
	vector<LL> pos, neg;
	for (LL i = 0; i < n; ++i) {
		if (a[i] > 0) {
			pos.emplace_back(a[i]);
		} else if (a[i] == 0) {
			++zc;
		} else {
			neg.emplace_back(-a[i]);
		}
	}
	LL pc = pos.size() + zc;
	LL kk = k - (k % 2);
	LL ne = neg.size() - (neg.size() % 2);
	LL nc = min(kk, ne);
	modll ans = 0;
	if ((k % 2) != 0 && (nc + pc < k)) {
		if (zc) {
			ans = 0;
		} else {
			sort(neg.begin(), neg.end());
			ans = 1;
			for (LL i = 0; i < k && i < neg.size(); ++i) {
				++cnt;
				ans *= (int)(MOD - neg[i]);
			}
			for (LL i = 0; cnt < k && i < pos.size(); ++i) {
				++cnt;
				ans *= (int)pos[i];
			}
		}
	} else if (pos.size() + ne < k) {
		if (zc) {
			ans = 0;
		} else {
			ans = 1;
			for (auto x : pos) {
				ans *= (int)x;
			}
			for (auto x : neg) {
				ans *= (int)(MOD - x);
			}
		}
	} else {
		sort(pos.rbegin(), pos.rend());
		sort(neg.rbegin(), neg.rend());
		int pi = 0, ni = 0, pr = pos.size(), nr = neg.size();
		LL r = k;
		ans = 1;
		while (r > 0) {
			LL pp = pr >= 2 ? pos[pi] * pos[pi + 1] : 0;
			LL nn = nr >= 2 ? neg[ni] * neg[ni + 1] : 0;
			if (r >= 2 && nn > pp) {
				r -= 2;
				nr -= 2;
				ans *= (int)(MOD - neg[ni++]);
				ans *= (int)(MOD - neg[ni++]);
			} else if (pr >= 1) {
				--r;
				--pr;
				ans *= (int)pos[pi++];
			} else {
				ans = 0;
				break;
			}
		}
	}
	return ans;
}

int main(int argc, char* argv[]) {
	cout.precision(20);
#ifdef _MSC_VER
	while (true)
#endif
	{
		LL n = -1, k = -1;
		cin >> n >> k;
		if (n < 0) return 0;
		vector<LL> a(n);
		for (LL i = 0; i < n; ++i) {
			cin >> a[i];
		}
		LL ans = solve(n, k, a);
		cout << ans << endl;
	}
	return 0;
}


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

int main()
{
	int a,b,c,k,sum=0;
	cin>>a>>b>>c>>k;
	if(a<=k)
	{
		sum+=a;
		k-=a;
	}
	else
	{
		sum+=k;
		k=0;
	}
	if(b<=k)
		k-=b;
	else
		k=0;
	if(c<=k)
	{
		sum-=c;
		k-=c;
	}
	else
	{
		sum-=k;
		k=0;
	}
	cout<<sum<<endl;
	return 0;
}


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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

#ifdef DEBUG
#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }

// DEGUG
template <class T>
void _dump(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void _dump(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  _dump(s, forward<Tail>(tail)...);
}
// }}} End

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

  VAR(int, N);

  vector<i64> h(N);
  rep(i, N) {
    IN(h[i]);
  }
  h.emplace_back(LINF);

  i64 maxv = 0;
  i64 norm = 0;
  rep(i, N) {
    if (h[i] >= h[i+1]) norm++;
    else {
      chmax(maxv, norm);
      norm = 0;
    }
  }

  OUTL(maxv);

  return 0;
}


Measured memory_bytes: 1792