akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
    
#define ll long long int
#define pb push_back
#define rep(i , j , n) for(ll i = j ; i < n ; i++)
#define pre(i , j , n) for(ll i = j ; i >= n ; i--)
#define all(x) x.begin(), x.end()
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vll;
typedef vector<char>	vc;
typedef vector<bool>	vb;
#define br "\n"
#define MAX  1000001
#define ff first
#define ss second
ll mod = 1e9 + 7;

void solve(){
    string s;
    cin >> s;
    ll ans = 0;
    rep(i,0,s.length()){
        ans += (s[i] - '0');
    }
    if(ans % 9 == 0) cout <<  "Yes";
    else cout << "No";
}
	
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif  
 
    ll t = 1;
    // cin >> t;
    rep(i,0,t){
        solve();
    }
 
}	

Measured memory_bytes: 3708
#include<bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
 
#ifdef _WIN32
    #define gx getchar
    #define px putchar
    #define ps putchar(' ')
    #define pn putchar('\n')
    #define DEBUG 1
#else
    #define gx getchar_unlocked
    #define px putchar_unlocked
    #define ps putchar_unlocked(' ')
    #define pn putchar_unlocked('\n')
    #define DEBUG 0
#endif
 
#define rep(i,j,k) for(ll i=0;i<j;i+=k)
//input
void scan(int &n)
{
    int sign = 1;
    n = 0;
    char c = gx();
    while( c < '0' || c > '9' )
    {
        if( c == '-' ) sign = -1;
        c = gx();
    }
    while( c >= '0' && c <= '9' ) n = (n<<3) + (n<<1) + c - '0', c = gx();  n = n * sign;
}
void lscan(ll &n)
{
    int sign = 1;
    n = 0;
    char c = gx();
    while( c < '0' || c > '9' )
    {
        if( c == '-' )
        sign = -1;
        c = gx();
    }
    while( c >= '0' && c <= '9' ) n = (n<<3) + (n<<1) + c - '0', c = gx();  n = n * (ll)(sign);
}
int sscan(char a[])
{
    char c = gx();
    while(c==' ' || c=='\n') c=gx();
    int i=0;
    while(c!='\n')a[i++] = c,c=gx();
    a[i]=0;
    return i;
}
int wscan(char a[])
{
    char c = gx();
    while(c==' ' || c=='\n') c=gx();
    int i=0;
    while(c!='\n' && c!=' ')a[i++] = c,c=gx();
    a[i]=0;
    return i;
}
 
//output
void print(int n)
{
    if(n<0)
    {
        n=-n;
        px('-');
    }
    int i=10;
    char o[10];
    do{o[--i] = (n%10) + '0'; n/=10;}while(n);
    do{px(o[i]);}while(++i<10);
}
void lprint(ll n)
{
    if(n<0LL)
    {
        n=-n;
        px('-');
    }
    int i=21;
    char o[21];
    do{o[--i] = (n%10LL) + '0'; n/=10LL;}while(n);
    do{px(o[i]);}while(++i<21);
}
void sprint(const char a[])
{
    const char *p=a;
    while(*p)px(*p++);
}
 
 
ll po(ll a, ll b, ll m)
{
	ll x=1,y=a;
	while(b > 0)
	{
		if(b%2 == 1)
		{
			x=(x*y);
			if(x>m) x%=m;
		}
		y = (y*y);
		if(y>m) y%=m;
		b /= 2;
	}
	return x;
}
 
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int main()
{
	ll n,k;
	cin>>n>>k;
	unordered_map<int,vector<int> > m;
	ll ans = 0;
	for(ll i=1;i<=k;i++)
	{
		ll d;
		cin>>d;
		for(ll j=0;j<d;j++) {
			ll temp;
			cin>>temp;
			m[temp].push_back(i);
		}
	}
	for(ll i=1;i<=n;i++)
	{
		if(m[i].size()==0)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3580
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<iomanip>
#include<cstdint>
#include<bits/stdc++.h>
using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}


int atcoder(){
    int a,b,c,ans;
    cin>>a>>b>>c;
    if(a+b>=c) ans=b+c;
    else ans = min(a+2*b+1,b+c);
    cout <<ans<<ENT;
    return 0;
}


signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}



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

int main(){
  int N;
  cin >> N;
  int *V = new int[N];
  int *C = new int[N];
  
  for(int i=0;i<N;i++){
    cin >> V[i];
  }
  for(int i=0;i<N;i++){
    cin >> C[i];
  }
  int sum = 0;
  
  for(int i=0;i<N;i++){
    int T = V[i]-C[i];
    if(T>0){
      sum += T;
    }
  }
  
  cout << sum ;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// How to use 「map」
/*
  - 宣言
    map<{key_type}, {value_type}> salary;
  - 要素の挿入
    salary["Alice"] = 1000;
  - 要素の取得 O(logn)
    salary.at("Alice");
  - 要素の削除
    salary.erase("Alice");
  - キー検索
    salary.find("Alice"); -> true
    salary.find("Bob");   -> false
  - イテレーション
    for(auto& [key, value] : salary) {...}
 */
// -------------------------------------


// How to use 「lower_bound」, 「upper_bound」
/*
  vector<int> a = {1, 2, 3, 4, 5};
  auto iter1 = lower_bound(all(a), 3);  <- 第二引数「以上」の最小イテレータが返る
  auto iter2 = upper_bound(all(a), 3);  <- 第二引数「より大きい」最小のイテレータが返る
 */
// -------------------------------------


// How to use 「struct sort」
/*
  struct Person {
    string name;
    int age;

    Person(string _name, int _age) {
      name = _name;
      age = _age;
    }

    bool operator<(const Person &another) const {
      return age < another.age;
    }
  };

  vector<Person> people;
  people.pb(Person("Alice", 20));
  people.pb(Person("Bob", 19));
  people.pb(Person("John", 40));
  people.pb(Person("Chris", 30));
  sort(all(people));
 */
 // -------------------------------------

// -------------------------------------------------------------------------------------



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

  int ans = 0;
  rep1(i, n-1) {
    vector<int> _p(3);
    _p[0] = p[i-1];
    _p[1] = p[i];
    _p[2] = p[i+1];
    sort(all(_p));
    if(p[i] == _p[1]) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int INT_INF = 2147483647;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef pair<ll,ll> P;

int main(){
  int n;
  cin >> n;
  vector<P> v;
  rep(i,n){
    ll x,l;
    cin >> x >> l;
    v.push_back(P(x-l,x+l));
  }
  int res = 0;

  sort(v.begin(), v.end(), [](P a, P b) {return a.second < b.second;});

  ll edge= - 1001001001;
  rep(i,n){
    if(edge<=v[i].first){
      res++;
      edge = v[i].second;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3444
x = input()
n = len(x)-1

for bit in range(1 << n):
    f=x[0]
    for i in range(n):
        if bit & (1 << i):
            f+='+'
        else:
            f+='-'
        f += x[i + 1]
    if eval(f) == 7:
        print(f+"=7")
        break

Measured memory_bytes: 3060
S = list(input())
T = list(input())
if len(S) < len(T):
	print("UNRESTORABLE")
else:
	S = S[::-1]
	T = T[::-1]
	for i in range(len(S)-len(T)+1):
		if all (T[j] == S[i+j] or S[i+j] == '?' for j in range(len(T))):
			S[i:i+len(T)] = T
			S = S[::-1]
			print("".join(S).replace('?','a'))
			exit()
	print("UNRESTORABLE")

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <queue>
#include <math.h>
using namespace std;
#define lol long long



int main()
{
	double N, K;
	cin >> N >> K;
	double ans = 0.0;
	for (int i = 1; i <= N; i++) {
		int count = 0;
		if (i >= K) {
			ans += 1 / N;
		}
		else {
			for (int j = i; j < K; j *= 2) {
				count++;
			}
			ans += (1 / N) * pow(0.5, count);
			
		}
	}
	cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S min_L(S a,T b){
  return a<=b?a:b;
}
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(char &c){
  int i;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = my_getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
template<class T1, class T2, class T3> inline int DistinctE_L(T1 a, T2 b, T3 c){
  if(a==b){
    if(a==c){
      return 1;
    }
    return 2;
  }
  if(a==c || b==c){
    return 2;
  }
  return 3;
}
template<class T, class S> int arrCountVal(int N, T A[], S val){
  int i;
  int res = 0;
  for(i=(0);i<(N);i++){
    if(A[i]==val){
      res++;
    }
  }
  return res;
}
int N;
char S[4002];
int main(){
  int i;
  long long res;
  rd(N);
  rd(S);
  res = (long long) arrCountVal(N,S,'R') * arrCountVal(N,S,'G') * arrCountVal(N,S,'B');
  for(i=(0);i<(N);i++){
    int j;
    int len =min_L(i, N-i-1);
    for(j=(1);j<(len+1);j++){
      if(DistinctE_L(S[i-j], S[i], S[i+j])==3){
        res--;
      }
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200430-1

// --- original code ---
// int N;
// char S[4002];
// 
// {
//   ll res;
//   rd(N,S);
//   res = (ll) arrCountVal(N,S,'R') * arrCountVal(N,S,'G') * arrCountVal(N,S,'B');
//   rep(i,N){
//     int len = min(i, N-i-1);
//     rep(j,1,len+1) if(DistinctE(S[i-j], S[i], S[i+j])==3) res--;
//   }
//   wt(res);
// }


Measured memory_bytes: 3620
# 気づき
# ①+-+-+-..か-+-+-+...のふたつを試して小さい方
# ②満たさなくなったら帳尻を合わせる（いまみてるやつだけでいい)
# ③1<=i<=nに対して和が0でない -> a1≠0（これは①とかぶる）
# 累積和をとってインデックスの偶奇で判断

n = int(input())
arr = list(map(int, input().split()))
p, m = 0, 0  # 累積和
pn, mn = 0, 0  # （操作した回数の）カウント
for i in range(n):
    if i % 2 == 0:
        # pは正にしたい
        if p + arr[i] > 0:
            p += arr[i]
        else:
            # 少ない操作で和を大きくしたいので1との差を取る
            d = p + arr[i]  # 差
            pn += abs(1 - d)
            p = 1
    else:
        # pは負にしたい
        if p + arr[i] < 0:
            p += arr[i]
        else:
            # 少ない操作で和を小さくしたいので-1との差をとる
            d = p + arr[i]
            pn += abs(-1 - d)
            p = -1
for i in range(n):
    if i % 2 == 0:
        # mは負にしたい
        if m + arr[i] < 0:
            m += arr[i]
        else:
            # ry
            d = m + arr[i]
            mn += abs(-1 - d)
            m = -1
    else:
        # mは正にしたい
        if m + arr[i] > 0:
            m += arr[i]
        else:
            # ry
            d = m + arr[i]
            mn += abs(1 - d)
            m = 1

print(min(pn, mn))


Measured memory_bytes: 14468
#                         author:  kagemeka 
#                         created: 2019-11-08 15:54:47(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
import functools
# import operator
## from external libraries
# import scipy.special   # if use comb function on AtCoder, 
# import scipy.misc      # select scipy.misc.comb (old version) 
# import numpy as np

def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)


def main():
    n, *a = (int(x) for x in sys.stdin.read().split())

    m = functools.reduce(lcm, a)
    f = sum([(m - 1) % a[i] for i in range(n)])
    print(f)

if __name__ == "__main__":
    # execute only if run as a script
    main()


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

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

int main(){
    string s;
    cin>>s;
    int n=s.size();
    rep(i,n-1){
        if(s[i]=='B'&&s[i+1]=='C') s[i]='K',s[i+1]='D';
    }
    reverse(s.begin(),s.end());
    ll k=0,cnt=0;
    rep(i,n){
        if(s[i]=='K') k++;
        else if(s[i]=='A') cnt+=k;
        else if(s[i]!='D') k=0;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define INF 1e9
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll N, M, Q;
ll A[100001];
ll B[100001];
pair<ll, ll> AB[100001];
ll ans;
string S;
ll K;
map<ll, ll> m;
int main() {
	cin >> N >> M;
	rep(i, 0, M) {
		cin >> AB[i].second >> AB[i].first;
	}
	sort(AB, AB + M);
	ll nowpos = 0;
	rep(i, 0, M) {
		if (nowpos <= AB[i].second){
			ans++;
			nowpos = AB[i].first;
		}
	}
	cout << ans << endl;
	cin >> ans;
	return 0;
}

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

int main(){
	int n,L,R;
	int ans = 2020;
	cin >> L >> R;
	n = R-L;
	for (int i = L; i < L+min(2019,n); i++){
		for (int j = i+1; j <= min(R,i+2019); j++){
			ans = min(((i%2019)*(j%2019))%2019,ans);
		}
	}
	cout << ans << endl;
	return 0;
}

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


int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N){
        cin >> A[i];
    }
    int count = 0;
    for(int i = 0;i<N;i++){
     //同じならスキップ
     while(i+1<N && A[i] == A[i+1]) i++;

     //増加
     if(A[i] > A[i+1]){
         while(i+1<N && A[i] >= A[i+1]) i++;
     }
     //減少
     else if(A[i] < A[i+1]){
         while(i+1<N && A[i] <= A[i+1]) i++;
     }
    count++;
    }
   cout << count << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+3;
int h[maxn];
vector<int> g[maxn];
int vis[maxn];
int ans=0;
void dfs(int u){
	int flag=1;
	vis[u]=1;
	//printf("Now at %d\n",u);
	for(auto i:g[u]){
		if(h[i]>=h[u]) flag=0;
		if(vis[i]) continue;
		vis[i]=1;
		dfs(i);
		//vis[i]=0;
	}
	//printf("back to %d\n",u);
	if(flag==1) {
		ans++;
		//printf("ans++:%d\n",u);
	}
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&h[i]);
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for(int i=1;i<=n;i++){
		if(vis[i]) continue;
		dfs(i);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 11292
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct qq
{
	char name[100];
	int time;
}Que;

void enqueue(Que x);
Que dequeue();

Que Q[LEN];
int head, tail, n;

void enqueue(Que x)
{
	Q[tail] = x;
	tail = (tail +1) % LEN;

}

Que dequeue()
{
	Que x = Q[head];
	head = (head + 1)% LEN;
	return x;

}


int main(void)
{
	int t = 0;
	int n, q, i, b;
	Que a;
	char s[100];
	
	scanf("%d %d", &n, &q);
	
	for(i =1; i<= n; i++)
	{
		scanf("%s %d", Q[i].name, &Q[i].time);
		
	}
	
	head= 1;
	tail=n+1;
	
	while(head!=tail)
	{
		a = dequeue();
		
		if(q < a.time)
		{
			b=q;
		}
		else if(q >= a.time)
		{
			b=a.time;
		}
		
		a.time = a.time-b;
		t = t+b;
		
		if(a.time > 0)
		{
			enqueue(a);
		
		}
		else
		{
			printf("%s %d\n", a.name, t);
		}
	}
	
	return 0;
	
}





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

M, X, Xi = 0, 0, 1
for i, a in enumerate(A, start=1):
    if abs(a) > M:
        M = abs(a)
        X = a
        Xi = i

if X > 0:
    ans = []
    for i in range(N):
        A[i] += X
        ans.append((Xi, i + 1))

    for i in range(N - 1):
        A[i + 1] += A[i]
        ans.append((i + 1, i + 2))

    print(len(ans))
    for x, y in ans:
        print(x, y)

else:
    ans = []
    for i in range(N):
        A[i] += X
        ans.append((Xi, i + 1))

    for i in range(N - 1, 0, -1):
        A[i - 1] += A[i]
        ans.append((i + 1, i))

    print(len(ans))
    for x, y in ans:
        print(x, y)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <string>
using namespace std;

int main() {
  
  string s;  cin >> s;
  
  int l = s.size();
  int a[5];

  for(int i = 0; i < l; i++) {
    a[i] = s[i] - '0';
  }

  for(int bit = 0; bit < 1 << (l - 1); bit++) {
    
    int ans = a[0];

    for (int i = 1; i < l; i++) {
      if (bit & (1 << i - 1)) {
        ans += a[i];
      } else {
        ans -= a[i];
      }
    }
    
    if (ans == 7) {
      for (int i = 0; i < l; i++) {
        cout << a[i];
        if (i < l - 1) {
          if (bit & (1 << i)) {
            cout << "+";
          } else {
            cout << "-";
          }
        }
      }

      cout << "=7" << endl;

      return 0;
    }
  }

  cout << "NOTFOUND" << endl;

}

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

int main(){
  int n;cin>>n;
  for(double i=0.0;i<=46297.0;i+=1.0){
    if((int)(i*1.08)==n){
      cout<<(int)i<<endl;
      return 0;
    }
  }
  cout<<":("<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,res;	map<int,int> mp;
signed main(){
	cin>>n;
	for(int i=1,x;i<=n;i++){
		scanf("%lld",&x);	res+=mp[i-x];
		mp[i+x]++;
	}
	cout<<res;
	return 0;
}


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

int main() {
    string o, e;
    cin >> o >> e;
    for (int i = 0; i < o.size()+e.size(); i++) {
        char c;
        if (i%2 == 0) c = o[i/2];
        else c = e[i/2];
        cout << c;
    }
    cout << endl;
}

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

using namespace std;

int N, E;
vector<int> g[10000];
vector<int> out;
char col[10000];

void toposort(int s) {
    stack<int> chain;
    col[s] = 'g';
    chain.push(s);
    while(!chain.empty()) {
        int now = chain.top();
        int hasnext = false;
        for (int i = 0; i < g[now].size(); ++i) {
            if(col[g[now].at(i)] == 'w') {
                chain.push(g[now].at(i));
                col[g[now].at(i)] = 'g';
                hasnext = true;
                break;
            }
        }
        if(!hasnext) {
            col[now] = 'b';
            chain.pop();
            out.push_back(now);
        }

    }

}
int main() {
    cin >> N >> E;
    for (int i = 0; i < E; ++i) {
        int s, t ;
        cin >> s >> t;
        g[s].push_back(t);
//        g[s][t] = 1;
    }

    for (int j = 0; j < N; ++j) {
        col[j] = 'w';
    }
    for (int k = 0; k < N; ++k) {
        int sum = 0;
        sum = g[k].size();
        if(col[k] == 'w') {
            toposort(k);
        }
    }

    for (int l = N-1; l >=0; --l) {
        if(l != N-1) cout << " ";
        cout << out.at(l) ;
    }
    cout <<endl;

    return 0;
}



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

int N, M;
int X[100010];
int Y[100010];
int ans;

int main(){
  cin >> N >> M;
  rep(i, M) cin >> X[i];
  sort(X, X+M);

  rep(i, M-1) Y[i] = abs(X[i+1] - X[i]);
  sort(Y, Y+M-1);

  if (M <= N) cout << 0 << endl;
  else{
    rep(i, M-N) ans += Y[i];
    cout << ans << endl;
  }
}


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

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

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

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

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

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

fn main() {
    input! {
        s: String,
    }
    let mut ansvec: Vec<usize> = Vec::new();
    for i in 0..s.len() {
        let mut ans = 0;
        for j in i..s.len() {
            match s.chars().nth(j).unwrap() {
                'A' | 'T' | 'C' | 'G' => ans += 1,
                _ => break,
            }
        }
        ansvec.push(ans);
    }
    println!("{}", ansvec.iter().max().unwrap());
}


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

int main() {
 long long a,b,x;
 cin>>a>>b>>x;
 
 long long ans = b / x - a / x;
	if(a % x == 0)ans++;
	cout << ans << endl;
}

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

int main(){
    string b;
    cin >> b;
    if(b=="A")
        cout << "T" << endl;
    else if(b=="T")
        cout << "A" << endl;
    else if(b=="C")
        cout << "G" << endl;
    else
        cout << "C" << endl;

    return 0;
}

Measured memory_bytes: 256
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,*aaa = get_all_int()
memo = set()

for a in aaa:
    if a in memo:
        print("NO")
        exit()
    memo.add(a)
print("YES")

Measured memory_bytes: 98668
I=input
A,B,C,X,s=int(I()),int(I()),int(I()),int(I()),0
for i in range(A+1):
    for j in range(int(B)+1):
        for k in range(int(C)+1):
            if 500*i+100*j+50*k==int(X):s+=1
print(s)

Measured memory_bytes: 9164
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
#include <iomanip>
#include<set>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1844674407370955161
typedef long long int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007


int main()
{
    ll A,B,K;
    cin>>A>>B>>K;

    if(A>K){
        cout<<A-K<<" "<<B<<endl;
    }else if(K-A<B){
        cout<<0<<" "<<B-K+A<<endl;
    }else{
        cout<<0<<" "<<0<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){ 
  int n,flag=0;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++){
    for(int j=n-1;j>=1;j--){
      if(a[j]<a[j-1]){
	swap(a[j],a[j-1]);
	flag++;
      }
    }
  }
  for(int i=0;i<n;i++){
    if(i==n-1)cout<<a[i]<<endl;
    else cout<<a[i]<<" ";
  }
  cout<<flag<<endl;
  return 0;
}

Measured memory_bytes: 3104
def pin(type=int):
    return map(type,input().split())
    
#どっかで最悪計算量の入力データを用意する関数を作ろう？
"""
"""

#solution:
def dfs_search_2Dgrid(h,w):
    #if h,wが迷路の外->Noneを返す
    #if もう通った点->None
    #通った点のリスト？に記録
    #二次元グリッドなので4方向に進もうとしてみよう
    pass
#input
N,R=pin()
ans=0
k=10-N
k=0 if k<0 else k

print(R+100*k)

Measured memory_bytes: 38460
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int a[5];
int main(){
	int k;
	for(int i = 0; i < 5; i++){
		cin>>a[i];
	}
	cin>>k;
	int f = 0;
	for(int i = 0; i < 5 ; i++){
		for(int j = i+1; j < 5; j++){
			int shu = fabs(a[i] - a[j]);
			if(shu > k)
				f = 1;
		}
	}
	if(f == 0)
		cout<<"Yay!"<<endl;
	else 
		cout<<":("<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define REPA(x, v) for(auto&& x:v)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(v.rbegin(),v.rend())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];
    
    ll ans = 0;
    ll t = A[0];

    Rep(i, 1, N){
        if(A[i] < t){
            ans += t - A[i];
        }
        chmax(t, A[i]);
    }
    pr(ans);
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;  cin >> a >> b >> c;
    if (b - a == c - b) {
      cout << "YES" << '\n';
    } else {
      cout << "NO" << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n,y,a=0,b=0,c=0;
	
	scanf("%d %d",&n,&y);
	
	for(a=n;a>=0;a--){
		c=0;
		for(b=n-a;b>=0;b--){
			if(10000*a+5000*b+1000*c==y){
				printf("%d %d %d",a,b,c);
				return 0;
			}
			c++;
		}
	}
	printf("-1 -1 -1");
	return 0;
}

Measured memory_bytes: 128
n = int(input())
lst = list(map(int,input().split()))

cum_sum = [0]
acc = 0
for i in lst:
  acc += i
  cum_sum.append(acc)

dic = {}
for i in cum_sum:
  if i in dic:
    dic[i] += 1
  else:
    dic[i] = 1

ans = 0


for i in dic:
  v = dic[i]
  if v >= 2:
    ans += (v * (v - 1)) // 2
print(ans)


Measured memory_bytes: 41228
import java.util.Scanner;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        String s = sc.next();
        int a = s.length();
        int z = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'A') {
                if (i < a) {
                    a = i;
                }
            }
            if (s.charAt(i) == 'Z') {
                if (i > z) {
                    z = i;
                }
            }
        }
        System.out.println(z-a+1);
    }

}


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

using namespace std;

int main () {
    int N, A, B;
    cin >> N >> A >> B;

    if (A * N < B) {
        cout << A * N << endl;
    } else if (A * N > B) {
        cout << B << endl;
    } else {
        cout << B << endl;
    }
}

Measured memory_bytes: 3604
cnst :: [String] -> (String,[Int])
cnst [n,b,w] =
    let b' = read b :: Int
        w' = read w :: Int
    in
        (n, [w' - b' + 1, w'])

solv :: [(String,[Int])] -> Int -> String
solv t w =
    let f = filter (\ (n,[s,e]) -> (w >= s) && (e >= w) ) t
    in
        if f == []
        then "Unknown"
        else
           let (n,[ws,wl]) = head f
           in
                unwords [ n, show (w - ws + 1) ] 

ans :: [[String]] -> [[String]]
ans (["0","0"]:_) = []
ans ([n,q]:x) =
    let n'= read n :: Int
        q'= read q :: Int
        t = map cnst $ take n' x
        w = map (read . head) $ take q' $ drop n' x :: [Int]
        a = map (solv t) w
        r = drop (n'+q') x
    in
        a:(ans r)

main = do
    c <- getContents
    let i = map words $ lines c
        o = ans i
    mapM_ putStrLn $ concat o


Measured memory_bytes: 7548
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(int X = 0; X < N; X++)
#define pback push_back
#define mpair make_pair
#define MODN 1000000007

using namespace std;

int main(){

    int n;
    cin >> n;

    int maxn = 1;
    int secn = 1;

    vector<int> v;

    rep(i,n){
        int tmp;
        cin >> tmp;

        v.pback(tmp);

        if(maxn < tmp){
            secn = maxn;
            maxn = tmp;
        }else if(secn < tmp){
            secn = tmp;
        }
    }

    rep(i,n){
        cout << (v[i] == maxn ? secn : maxn) << endl;
    }

    
    return 0;
}

Measured memory_bytes: 2548
n = gets.chomp.to_i
h = gets.chomp.to_i
w = gets.chomp.to_i

count = 0
1.upto n do |height|
  if h+height-1 <= n
    1.upto n do |width|
      if w+width-1 <= n
        count += 1
      else
        break
      end
    end
  else
    break
  end
end

puts count


Measured memory_bytes: 1788
from collections import Counter
from itertools import product


from functools import reduce
import operator
nproduct = lambda it: reduce(operator.mul,it,1)

# 素因数分解
def prime_factors(n):
    i = 2
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            yield i
    if n > 1:
        yield n

def all_divisors(n):
    factors,counts = map(tuple,zip(*Counter(prime_factors(n)).items()))

    for p in product(*(range(c+1) for c in counts)):
        yield nproduct(v**k for v,k in zip(factors,p))

def num_divisors(n):
    return nproduct(c+1 for c in Counter(prime_factors(n)).values())


N = int(input())

cnt = num_divisors(N-1)
for d in all_divisors(N):
    if d == 1:
        continue
    x = N
    while x % d == 0:
        x //= d
    if x % d == 1:
        cnt += 1

print(cnt-1)

Measured memory_bytes: 3692
def BellmanFord(edges, num_v, source):
    #グラフの初期化
    inf = float("inf")
    dist = [inf for i in range(num_v)]
    dist[source-1] = 0

    #辺の和
    for i in range(num_v):
        for edge in edges:
            if dist[edge[0]-1] != inf and dist[edge[1]-1] > dist[edge[0]-1] + edge[2]:
                dist[edge[1]-1] = dist[edge[0]-1] + edge[2]
                #負閉経路かつそれがゴールを通るもの、がある
                #i == num_v-1だけだと、負閉経路の検出だけになる
                if i == num_v - 1 and edge[1] == num_v:
                    return -1

    return dist

num_v, num_e = map(int, input().split())
edges = []
for _ in range(num_e):
    a, b, c = map(int, input().split())
    edges.append((a, b, -c))

dist = BellmanFord(edges, num_v, 1)
if dist == -1:
    print("inf")
else:
    print(-dist[-1])


Measured memory_bytes: 3308
#d3と同一解法
n=int(input())
import sys
#再帰関数の再帰回数を変更
sys.setrecursionlimit(10**6)
s=[[] for _ in range(n)]

for i in range(n-1):
    a,b=map(int,input().split())
    s[a-1].append((b-1,i))
    s[b-1].append((a-1,i))

l=[0]*(n-1)

def dfs(node,pre_col,par):
    col=1
    for nei,i in s[node]:
        if nei==par:
            continue
        if col==pre_col:
            col+=1
        l[i]=col
        dfs(nei,col,node)
        col+=1
dfs(0,-1,-1)
print(max(l))
for i in l:
    print(i)


Measured memory_bytes: 74684
from collections import deque

S = deque(input())
Q = int(input())

flag = False
for _ in range(Q):
    q = input()
    if q[0] == '1':
        flag = not flag
    else:
        _, f, c = q.split()
        if flag:
            if f == '2':
                S.appendleft(c)
            else:
                S.append(c)
        else:
            if f == '1':
                S.appendleft(c)
            else:
                S.append(c)

if flag:
    S.reverse()
print(''.join(S))


Measured memory_bytes: 8436
#include <iostream>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

int main() {
    ll N, x, ans;
    cin >> N;

    vector<ll> a;

    for (int i = 0; i < 3*N; i++) {
        cin >> x;
        a.push_back(x);
    }

    sort(a.begin(), a.end(),std::greater<ll>());
    
    ans = 0;
    for (int i = 0; i < N; i++) {
        ans += a[2*i+1];
    }

    cout << ans << endl;
}


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

typedef pair<int, int> P;

int N, M;
vector<P> R[100001];

struct BIT {
  int n; vector<int> xs;
  BIT(int n) : n(n) {
    xs.resize(n+1);
  }

  void add(int x, int k) {
    for (int i=x+1; i<=n; i+=i&-i) xs[i] += k;
  }
  int sum(int x) {
    int s = 0;
    for (int i=x+1; i>0; i-=i&-i) s += xs[i];
    return s;
  }
};

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

  cin >> N >> M;
  BIT bit(M+1);
  for (int i=0; i<N; i++) {
    int l, r;
    cin >> l >> r;
    R[r-l+1].push_back(P(l, r));
  }

  int s = N;
  for (int d=1; d<=M; d++) {
    s -= R[d-1].size();
    for (auto &p : R[d-1]) {
      bit.add(p.first, 1);
      bit.add(p.second+1, -1);
    }
    int c = 0;
    for (int i=d; i<=M; i+=d) c += bit.sum(i);
    cout << s + c << "\n";
  }
  return 0;
}


Measured memory_bytes: 8064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	x := nextInt()
	a := nextInt()

	if x < a {
		fmt.Println(0)
	} else {
		fmt.Println(10)
	}

}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
from sys import stdin

n, x = [int(x) for x in stdin.readline().rstrip().split()]
an = list(map(int, input().split()))

pos = 0

ans = 0
while ans < n:
    ans += 1
    pos += an[ans-1]
    if x < pos:
        break

if pos <= x:
    ans += 1

print(ans)


Measured memory_bytes: 38256
// B - Guidebook
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n; cin>>n;
	vector<tuple<string,int,int>> sp;
	for(int i=0; i<n; ++i){
		string s; int p; cin>>s>>p;
		sp.push_back(make_tuple(s, -p, i+1));
	}
	sort(sp.begin(), sp.end());
	for(auto e:sp) cout<< get<2>(e) <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

int g[100100];
int main()
{
	int n, m;
	cin >> n >> m;
	vector<ll> h(n);
	rep(i,n){
		cin >> h[i];
	}

	rep(i,m){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		if (h[a] < h[b])
		{
			g[a] = 1;
		}
		else if (h[a] > h[b])
		{
			g[b] = 1;
		}
		else
		{
			g[a] = 1;
			g[b] = 1;
		}
	}
	int ans = 0;
	rep(i,n){
		if (!g[i])
			ans++;
	}
	cout << ans << endl;
}


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

using ll = long long int;
using P = std::pair<int, int>;

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

constexpr ll mod = 1e9 + 7;

class mint
{
    ll num = 0;

public:
    mint(ll x = 0) : num(x) {}

    mint operator+(const mint &rhs) const
    {
        return (num + rhs.num) % mod;
    }
    mint operator*(const mint &rhs) const
    {
        return num * rhs.num % mod;
    }
    mint operator-(const mint &rhs) const
    {
        return (num - rhs.num + mod) % mod;
    }
    mint operator+=(const mint &rhs)
    {
        return num = (num + rhs.num) % mod;
    }
    friend std::ostream &operator<<(std::ostream &os, const mint &rhs);
};

std::ostream &operator<<(std::ostream &os, const mint &rhs)
{

    os << rhs.num;

    return os;
}

template <class T>
T pow(T x, int m)
{

    T re = 1;

    for (int i = 0; i <= 30; ++i)
    {
        if (m & (1 << i))
            re = re * x;
        x = x * x;
    }

    return re;
}

template <class T>
T inv(T x)
{

    return pow(x, mod - 2);
}

int main()
{
    int n, k;

    std::cin >> n >> k;

    std::vector<ll> a(n);

    rep(i, n)
    {
        std::cin >> a[i];
    }

    std::sort(std::begin(a), std::end(a));

    std::vector<mint> fac(n + 1);

    fac[0] = 1;

    rep(i, n)
    {
        fac[i + 1] = (mint)(i + 1) * fac[i];
    }

    auto comb = [&](int x, int y) { return fac[x] * inv<mint>(fac[y]) * inv<mint>(fac[x - y]); };

    mint ans = 0;

    rep(i, n - k + 1)
    {
        ans = ans - (mint)a[i] * comb(n - i - 1, k - 1);
    }

    for (int i = k - 1; i < n; ++i)
    {
        ans = ans + (mint)a[i] * comb(i, k - 1);
    }

    std::cout << ans << std::endl;

    return 0;
}

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

int main()
{
    set<int> s;
    int n,i,sum=0;
    cin>>n;
    for(i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(s.count(x)==0)
            s.insert(x);
        else s.erase(x);
    }
    sum=s.size();
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 4864
#include<iostream>
using namespace std;
int main() {
	int h, w;
	cin >> h >> w;
	while (h != 0) {
		int i, j;
		for (i = 0; i < h; i++) {
			for (j = 0; j < w; j++) {
				if (i == 0 || i == h - 1 || j == 0 || j == w - 1)
					cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
		cin >> h >> w;
	}
	return(0);
}



Measured memory_bytes: 3076
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int L[200001], R[200001];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, k, c; string s; cin >> n >> k >> c >> s;
	int wd = 0, cd = 0;
	forl(i, 0, n) {
		if(cd) { cd--; continue; }
		if(s[i] != 'o') continue;
		L[wd++] = i; cd = c;
	}
	wd = k-1, cd = 0;
	ford(i, n-1, 0) {
		if(cd) { cd--; continue; }
		if(s[i] != 'o' or wd < 0) continue;
		R[wd--] = i; cd = c;
	}
	vector<int> ans;
	forl(i, 0, k) {
		if(R[i] == L[i]) ans.push_back(R[i]+1);
	}
	printe(ans);
}


Measured memory_bytes: 4236
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

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

int main() {
    int N;
    string A, B, C;
    cin >> N >> A >> B >> C;
    map<string, int> cnt;
    int ans = 0;
    REP(i, N) {
        cnt[to_string(i) + A[i]]++;
        cnt[to_string(i) + B[i]]++;
        cnt[to_string(i) + C[i]]++;
        if(A[i] != B[i] and B[i] != C[i] and C[i] != A[i]) {
            ans--;
        }
    }
    for(auto hoge : cnt) {
        if(hoge.second == 1) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back

int N,K;
int p[200005];
signed main(){
    scanf("%lld %lld",&N,&K);
    rep(i,N){
        scanf("%lld",&p[i]);
        p[i]++;
    }
    int ans=0;
    int now=0;
    rep(i,N){
        if(i<K){
            now+=p[i];
        }
        if(i==K-1){
            ans=now;
        }
        if(i>=K){
            now+=p[i]-p[i-K];
            if(now>ans){ans=now;}
        }
        //printf("%lld-",now);
        
    }
    printf("%lf\n",(double)ans/2.0);
    return 0;
}


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

#define J 0
#define O 1
#define I 2

int H, W, N;
string c = "JOI";
char s[1001][1001];
int mem[1001][1001][3];

int main()
{
  cin >> H >> W >> N;
  for(int i = 1; i <= H; i++)
    scanf("%s", s[i] + 1);

  for(int i = 0; i < 3; i++)
  {
    mem[1][1][i] = c[i] == s[1][1];
    for(int x = 2; x <= W; x++)
      mem[x][1][i] = mem[x - 1][1][i] + (s[1][x] == c[i] ? 1 : 0);
    for(int y = 2; y <= H; y++)
      mem[1][y][i] = mem[1][y - 1][i] + (s[y][1] == c[i] ? 1 : 0);
  }
  for(int i = 0; i < 3; i++)
    for(int x = 2; x <= W; x++)
      for(int y = 2; y <= H; y++)
        mem[x][y][i] = mem[x - 1][y][i] + mem[x][y - 1][i] - mem[x - 1][y - 1][i] + (s[y][x] == c[i] ? 1 : 0);
  for(int i = 0; i < N; i++)
  {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    for(int j = 0; j < 3; j++)
      cout << mem[d][c][j] + mem[b - 1][a - 1][j] - mem[b - 1][c][j] - mem[d][a - 1][j] << (j < 2 ? " " : "");
    cout << endl;
  }
}

Measured memory_bytes: 13944
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))//memset only use to initialize 0 or -1 no other number.
#define pii pair<int,int>
#define pll pair<ll,ll>
#define INF 1e9
#define INFL 1e18

//#define mod 998244353
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> os_pair;
ll mod;
ll power(ll x,ll n){ll res =1;while(n>0){if(n%2==1){res=res*x;}x=x*x;n=n/2;}return res;}
ll powm(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

//cout<< fixed << setprecision(10)

int main(){

    fast;
    ll k,i,j;
    cin>>k;
    
    if(k%7==0)
    k=k/7;
    if(k==1)
    {
    	cout<<1;
    	return 0;
	}
    k=k*9;
    mod=k;
    for(i=1;i<=1000000;i++)
    {
    	if(powm(10,i)==1)
    	{
    		cout<<i;
    		return 0;
		}
	}
	cout<<-1;
    
	
    

}

Measured memory_bytes: 3632
n,m = map(int,input().split())
stair = []
mod = int(1e9+7)
ans = 1
for i in range(m):
    stair.append(int(input()))
dp = [0] * (n+1)
dp[0] = dp[1] = 1
stair.append(int(1e10))
if n == 1:
    print(1)
    exit()
k = 0
for i in range(1, n+1):
    if i == stair[k]:
        dp[i] = 0
        k += 1
    elif i == 1:
        dp[1] = 1
    else:
        dp[i] = (dp[i-1] + dp[i-2])%mod
print(dp[-1])





Measured memory_bytes: 50136