akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int a[111111];
int main() {
	int n, q;
	string s;
	cin >> n >> q >> s;
	for (int i = 1; i < n; i++)
		a[i + 1] = a[i] + (s[i - 1] == 'A'&&s[i] == 'C');
	for (int i = 0; i < q; i++) {
		int l, r;
		scanf("%d%d", &l, &r);
		cout << a[r] - a[l] << '\n';
	}
	cout << flush;
	return 0;
}


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

void solve()
{
  int m1, d1, m2, d2;
  cin>>m1>>d1>>m2>>d2;
  if(d2==1) cout<<1<<endl;
  else cout<<0<<endl;
}

int main()
{
    int t;
    t=1;
    while(t--)
    {
        solve();

    }
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n;
	vector<pair<string,P> > vec;
	cin >> n;
	for(int i = 0;i < n;i++){
		string s;
		int t;
		cin >> s >> t;
		vec.pb(mp(s,mp(-t,i)));
	}
	sort(all(vec));
	for(int i = 0;i < n;i++) cout << vec[i].second.second + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define ill(_x)  ll _x;scanf("%lld",&_x);
#define idb(_x)  double _x;scanf("%lf",&_x);
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define sll set<ll>
#define vs vector<string>
#define in0(x, a, b)((x)>=a && (x)<=b    )
#define in1(x, a, b)((x)>a && (x)<b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const double pi = 3.14159265358979323846;
const int INF = 0x3f3f3f3f;
const int X10=1024,X11=2048,X12=4096,X13=8196,X14=16392,X15=32786,X16=65536,X17=131072,X18=262144,X19=524288,X20=1048576;

pair<int,int> f(int a1,int a2,int a3){
    return {a1-a2,a2-a3};
};
int A[3];
void _(){
    string s1 ,s2;
    cin >> s1 >> s2;
    int n = s1.size();
    if(s1==s2){cout << "Yes";return;}
    for (int i = 1; i < n; ++i) {
       if(s1.substr(0,i)==s2.substr(n-i) && s1.substr(i)==s2.substr(0,n-i)){
           cout << "Yes";return;
       }
    }
    cout <<"No";
}






int main() {
#ifdef Debug
    freopen("/home/joduskame/Desktop/cpp/IO/Input.txt", "r", stdin);
    freopen("/home/joduskame/Desktop/cpp/IO/Output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    _();
    return 0;

}








Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
  int k,a,b;
  scanf("%d%d%d", &k,&a,&b);
  for(int cnt=0;cnt < 1000;cnt++)
  {
  if(a<=cnt*k && cnt*k<=b){
      printf("OK"); return 0;
    }else if(cnt*k > b){
      printf("NG"); return 0;
    }
  }
}

Measured memory_bytes: 1704
#include <stdio.h>
int main(void){
    int N;
    char S[100],T[100];
    scanf("%d",&N);
    scanf("%s%s",S,T);
    int i;
    for(i=0;i<N;i++){
        printf("%c",S[i]);
        printf("%c",T[i]);
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,w[105],v[105],f[100005],ans;const ll inf=1e18;
int main()
{
    scanf("%lld%lld",&n,&m);
    for(int i=0;i<100001;i++) f[i]=inf;
    f[0]=0;
    for(int i=0;i<n;i++) scanf("%lld%lld",w+i,v+i);
    for(int i=0;i<n;i++)
    for(int j=100000;j>=v[i];j--)
    f[j]=min(f[j],f[j-v[i]]+w[i]);
    for(int i=0;i<=100000;i++) if(f[i]<=m) ans=i;
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF 2147483647
#define INFLL LLONG_MAX
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    int a, b, c;
    cin >> a >> b >> c;
    bool ans = true;

    if(a==b && b==c) ans = false;
    if(a!=b && b!=c && c!=a) ans = false;

    if(ans) Yes();
    else No();
}

Measured memory_bytes: 256
W,H,N = map(int,input().split())
X,Y,A = [],[],[]
for i in range(N):
    x,y,a = map(int,input().split())
    X.append(x)
    Y.append(y)
    A.append(a)
x0,x1,y0,y1 = 0,W,0,H
for i in range(N):
    if A[i]==1:
        x0 = max(x0,X[i])
    elif A[i]==2:
        x1 = min(x1,X[i])
    elif A[i]==3:
        y0 = max(y0,Y[i])
    else:
        y1 = min(y1,Y[i])

print(max(0,(x1-x0))*max(0,(y1-y0)))

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



int N;
int A[210];

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

  int res = 0;

  //操作が行える限り操作を繰り返す
  while (true) {
    bool exist_odd = false; // A[i]がすべて偶数か判定
    for (int i = 0; i < N; ++i) {
      if (A[i] % 2 != 0) exist_odd = true; //奇数があったらフラグ立てる
    }

    if (exist_odd) break;

    for (int i = 0; i < N; ++i) {
      A[i] /= 2;
    }
    ++res;
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n;
    V p, q;

    cin >> n;
    REP(i, n)
    {
        int b;
        cin >> b;
        p.push_back(b);
    }
    REP(i, n)
    {
        int b;
        cin >> b;
        q.push_back(b);
    }

    if (p == q)
    {
        cout << 0 << endl;
        return 0;
    }

    if (p > q)
        swap(p, q);

    V v(n);
    REP(i, n)
    v[i] = i + 1;

    int cnt = 1;

    do
    {
        if (p < v && v < q)
            cnt++;
    } while (next_permutation(v.begin(), v.end()));

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val nmInput  = scala.io.StdIn.readLine()
  val nmArray = nmInput.split(" ").map(_.toInt).toSeq
  val n = nmArray(0)
  val m = nmArray(1)

  var scArray = Vector.empty[(Int, Int)]
  (1 to m).foreach { _=>
    val scInput  = scala.io.StdIn.readLine()
    val scInputArray = scInput.split(" ").map(_.toInt)
    val scTuple = (scInputArray(0), scInputArray(1))
    if (scArray.find(sc => sc == scTuple).isEmpty) {
      scArray :+= scTuple
    }
  }
  scArray = scArray.sortBy(sc => sc._1)
  if(n == 1 && scArray.length == 1 && scArray.head._1 == 1 && scArray.head._2 == 0) {
    println(0)
  } else if (
    (scArray.length > 0 && scArray.head._1 == 1 && scArray.head._2 == 0) ||
    scArray.groupBy(sc => sc._1).map(sc => sc._2.size).find(sc => sc >= 2).isDefined
  ) {
    println(-1)
  } else if(scArray.length == 0) {
    if(n == 1) {
      println(0)
    } else {
      var result = ""
      (1 to n).foreach { i =>
        if(i == 1) {
          result = "1"
        } else {
          result = result + "0"
        }
      }
      println(result)
    }
  } else {
    var result = ""
    (1 to n).foreach { i =>
      val sc = scArray.find(sc => sc._1 == i)
      if (sc.isEmpty) {
        if(i == 1) {
          result = "1"
        } else {
          result = result + "0"
        }
      } else {
        result = result + sc.get._2.toString
      }
    }
    println(result)
  }

}


Measured memory_bytes: 27348
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define MAX 100010
#define aout(a) REP(i,sizeof(a)) cout << a[i] << " "; cout << endl;
#define vout(v) REP(i,v,size()) cout << v[i] << " "; cout << endl;
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main() {
  int x; cin>>x;
  if(x == 0) cout<<1;
  else cout<<0;
}

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

int main()
{    
   char c;
   cin >> c;
   char ans = c + 1;
   cout << ans <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k, x;
  x = 1;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    if (x * 2 > x + k){
      x += k;
    }
    else {
      x *= 2;
    }
   }
  cout << x << endl;
}

Measured memory_bytes: 256
import sys
for e in sys.stdin:
    cnt_j = 0
    cnt_i = 0
    for i in range(len(e)-2):
        if e[i:i+3] == 'JOI':
            cnt_j += 1
        elif e[i:i+3] == 'IOI':
            cnt_i += 1
    print(cnt_j)
    print(cnt_i)


Measured memory_bytes: 5572
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                int N = sc.nextInt();
                int data[][] = new int[N][3];
                for (int i = 0; i < N; i++) {
                        for (int j = 0; j < 3; j++) {
                                data[i][j] = sc.nextInt();
                        }
                }
                for (int i = 0; i < N; i++) {
                        int ans = 0;
                        for (int j = 0; j < 3; j++) {
                                boolean f = true;
                                for (int k = 0; k < N; k++) {
                                        if (i != k) {
                                                if (data[i][j] == data[k][j]) {
                                                        f = false;
                                                        break;
                                                }
                                        }
                                }
                                if (f) {
                                        ans += data[i][j];
                                }
                        }
                        System.out.println(ans);
                }
        }
}

Measured memory_bytes: 28820
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int r;
    cin >> r;
    cout << r * r << endl;
}


Measured memory_bytes: 256
#%%time
N = int(input())

isok=False
for h in range(1,3501):
    bunsi = 4*h - N
    bunbo = N*h
    if bunsi>0:
        n = (bunbo//bunsi) + 1
        bunsi = 4*h*n - N*(h+n)
        bunbo = N*h*n
        if bunsi>0 and bunbo%bunsi==0:
            w = bunbo//bunsi
            isok = True
            break
        
if isok:
    print(h,n,w)
else:
    print("ここ来たらマジでヤバいが")

Measured memory_bytes: 3064
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int long long i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll m[100001];

int main(){
    ll n;
    cin>>n;
    rep(i,100001){m[i]=0;}
    
    rep(i,n){
        ll x;
        cin>>x;
        m[x]++;
    }
    
    ll ans=0;
    
    for(int i=0;i<100001;i++){
        if(m[i]>=1){
            ans+=(m[i]-1);
        }
    }
    
    if(ans%2){
        ans++;
    }
    if(n-ans>=1){
    cout<<n-ans<<endl;
    }else{
        cout<<n-ans+1<<endl;
    }
    
    
return 0;
}


Measured memory_bytes: 1024
s = gets.to_i
arr = []
arr << s
i = 0
loop do
  if arr[i].even?
  	if arr.include?(arr[i]/2)
      puts i + 2
      exit
    end
    arr << arr[i]/2
  else
    if arr.include?(3 * arr[i] + 1)
      puts i + 2
      exit
  	end
    arr << 3 * arr[i] + 1
  end
  i += 1
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,ans=0;
    cin>>n;
    ll arr[n],c[n];
    vector<pair<ll,ll> > vect;
    for(i=0;i<n;i++)
        cin>>arr[i];
    for(i=0;i<n;i++){
        cin>>c[i];
        c[i]=arr[i]-c[i];
    }
    sort(c,c+n);
    for(i=0;i<n;i++){
        if(c[i]>0)
            ans+=c[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<utility>
#include<array>
#include<set>
#include <numeric>
#define EPS (1e-7)
using namespace std;


long long lcm(long long n, long long m) {
	long long r,x,tmp;
	x = m * n;
	/* 自然数 a > b を確認・入替 */
	if (n < m) {
		tmp = n;
		n = m;
		m = tmp;
	}

	/* ユークリッドの互除法 */
	r = n % m;
	while (r != 0) {
		n = m;
		m = r;
		r = n % m;
	}
	return x / m;

}



int main() {

	long long A, B, C, D;
	long long cdLcm;
	long long cn, dn, lcmn=0;
	long long ans = 0;
	cin >> A >> B >> C >> D;

	cdLcm = lcm(C, D);

	cn = B  / C - (A-1)/C;
	dn = B / D - (A - 1) / D;
	if(cdLcm <= B){lcmn = B / cdLcm - (A - 1) / cdLcm;}
	ans = (B-A + 1) -(cn + dn - lcmn);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{ 
   int T;
   cin>>T;
   int A,B;
   cin>>A>>B;
   int i,flag=0;
   for(int i=A;i<=B;i++)
   {
   	if(i%T==0)
   	{
   		flag=1;
	}
   }
   if(flag==1)
   {
   	cout<<"OK"<<endl;
   }
   else
   {
   	cout<<"NG"<<endl;
   }
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    vector<bitset<64>> sums;
    for (int i = 0; cin >> a[i]; i++) {
        long long sum = 0;
        for (int j = i; j >= 0; j--) {
            sum += a[j];
            sums.emplace_back(sum);
        }
    }
    for (int i = 63; i >= 0; i--) {
        vector<bitset<64>> next;
        for (auto& j : sums) {
            if (j[i]) {
                next.emplace_back(j);
            }
        }
        if (next.size() >= k) {
            sums = move(next);
        }
    }
    for (int i = 1; i < k; i++) {
        sums[i] &= sums[i - 1];
    }
    cout << sums[k - 1].to_ullong();
    return 0;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int main() {
    ll n,i;
    cin>>n;
    ll a[n];
    for(i=1;i<=n;i++)
        cin>>a[i];
    ll s=0;
    for(i=1;i<=n;i++)
        s=s+a[i];
    cout<<s-n;

    return 0;
}


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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 100 + 10;
const int MOD = 1e9 + 7;

int32_t main(){
    boost;

    //code
    
    int a , b , x;

    cin >> a >> b >> x;

    if(a%x == 0)
    	cout << (b/x) - (a/x) + 1;
    else
    	cout << (b/x) - (a/x);
    return 0;
}

Measured memory_bytes: 256
// BROWNIE TK
 
#include <bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
typedef long long ll;
 
#define pb push_back
#define popb pop_back
#define si size()
//#define be begin()
//#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
 
#define forz(i, n) for (int i = 0; i < n; i++)
#define bui(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define mui(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
 
using namespace std;
 
/*STD fucntions*/
 
void pairsort(int a[], int b[], int n)
{
    pair<int, int> pairt[n];
 
    // Storing the respective array
    // elements in pairs.
    for (int i = 0; i < n; i++)
    {
        pairt[i].first = a[i];
        pairt[i].second = b[i];
    }
 
    // Sorting the pair array.
    sort(pairt, pairt + n);
 
    // Modifying original arrays
    for (int i = 0; i < n; i++)
    {
        a[i] = pairt[i].first;
        b[i] = pairt[i].second;
    }
}

void pairsortlli(lli a[], lli b[], lli n)
{
    pair<lli, lli> pairt[n];
 
    // Storing the respective array
    // elements in pairs.
    for (lli i = 0; i < n; i++)
    {
        pairt[i].first = a[i];
        pairt[i].second = b[i];
    }
 
    // Sorting the pair array.
    sort(pairt, pairt + n);
 
    // Modifying original arrays
    for (lli i = 0; i < n; i++)
    {
        a[i] = pairt[i].first;
        b[i] = pairt[i].second;
    }
}
  lli binomialCoeff(lli n, lli k) 
{ 
    lli C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (lli i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (lli j = min(i, k); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%mod; 
    } 
    return C[k]; 
} 
lli power(lli x,lli y,lli p)
{
  lli res=1;
  x=x%p;
  while(y>0)
  {
    if(y&1)
      res=(res*x)%p;
    //y must be even now
    y=y>>1; //y=y/2
    x=(x*x)%p;
  }
  return res;
}
lli gcd(lli a, lli b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
lli lcm(lli a, lli b)
{ return a * b / gcd(a, b); }
lli max(lli a, lli b)
{
  if (a > b)
    return a;
  return b;
}
lli min(lli a, lli b)
{
  if (a < b)
    return a;
  return b;
}

  int main() 
  {
    kira;
    lli a,b;
    cin>>a>>b;
    if(a<=2*b)
    cout<<0<<endl;
    else
    {
      cout<<a-2*b<<endl;
    }
    
  }

Measured memory_bytes: 256
N = int(input())
ans = []

#普通の n進法 -> 10進法 の変換と同じ
#(ex)注意
#(-9)%(-2)  -> -1  //本当は1になってほしい *(-1)
#(-9)//(-2) -> 4   //本当は5になってほしい +1
# 5%(-2)    -> -1  //本当は1になってほしい *(-1)
# 5//(-2)   -> -3  //本当は-2になってほしい +1
while(1):
  if(N == 1):
    ans.append('1')
    break
  elif(N == 0):
    ans.append('0')
    break
  if(N%(-2) == -1): 
    ans.append('1')
    N = N//(-2) + 1
  else: 
    ans.append('0')
    N = N//(-2) 

ans.reverse()
ans_str = ''.join(ans)
print(ans_str)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main(int argc, char *argv[])
{
	char c;
	cin >> c;

	switch (c) {
	case 'a':
	case 'e':
	case 'i':
	case 'u':
	case 'o':
		cout << "vowel";
		break;
	default:
		cout << "consonant";
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
ansa, ansb = 0, 0
ls = [0]*n

for _ in range(m):
    a, b = map(int, input().split())
    ansa = h[a-1]
    ansb = h[b-1]

    if ansa > ansb:
        ls[b-1] += 1

    elif ansa == ansb:
        ls[a-1] += 1
        ls[b-1] += 1

    else:
        ls[a-1] += 1

print(ls.count(0))


Measured memory_bytes: 20124
#include<bits/stdc++.h>
using namespace std ; 
long long min(long long a,long long b){
	if(a>b)return b;
	return a;
} 
long long check(long long a,long long b,long long c){
	if(a<b+c && b<a+c && c<a+b){
		return 1; 

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

int main(){
	long long x, d,k; 
	cin>>x>>k>>d ; 
	long long c=ab(x) ; 

	long long div= c/d;
	if(div>= k){c-= k*d;c=ab(c);} 
	else  {c-=div*d;c=ab(c);
		k-=div ; 
		if(k%2){c=min(ab(c-d),ab(c+d));
		} 

	} 
	cout<<c;
}

Measured memory_bytes: 3620
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int a[] = new int[n];
		for(int i = 0; i < n; i++){
		    a[i] = stdIn.nextInt();
		}
		
		int m = stdIn.nextInt();
		int num[] = new int[n + m];
		for(int i = 0; i < n + m; i++){
		    if(i < n){
		        num[i] = a[i];
		    }else{
		        num[i] = stdIn.nextInt();
		    }
		}
		
		Arrays.sort(num);
		
        System.out.println(num[0]);
        
        for(int i = 1; i < n + m; i++){
            if(num[i - 1] != num[i]){
                System.out.println(num[i]);
            }
        }
        
		stdIn.close();
	}

}




Measured memory_bytes: 132096
a,b,c,d=map(int,raw_input().split())
x=c-a
y=d-b
print 'U'*y+'R'*x+'D'*y+'L'*x+'L'+'U'*y+'U'+'R'*x+'RD'+'R'+'D'*y+'D'+'L'*x+'LU'

Measured memory_bytes: 2568
import heapq

N, M = map(int, input().split())
A = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(A)

for _ in range(M):
    tmp = heapq.heappop(A)
    heapq.heappush(A, tmp/2)

A = map(lambda x: int(x)*(-1), A)

print(sum(A))

Measured memory_bytes: 92312
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<ctime>
#include<map>
#define R(i, n) for(int i = 0;i < n;i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", a + i)
#define SAL(i, n, a) R(i, n) scanf("%lld", a + i)
#define SC(a) scanf("%c", &a);
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;

ll X;

int main() {
	SL(X);
	ll a = 100;
	ll ans = 0;
	while (a < X) {
		a += a * 0.01;
		ans++;
	}
	PL(ans);
}



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

int main()
{
  	int a, b;
  	cin>>a>>b;
  	if(a % 3 == 0 || b %3 == 0 || (a+b)%3 == 0)
      	cout<<"Possible";
  	else
      	cout<<"Impossible";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include <math.h>
#include <stdlib.h>
#define MAX 10000


typedef struct{
  int p;
  int r;
  int l;
  int s;
} Node;
int flag;
int hfunc(Node *,int,int);
void pre(Node *,int);
void in(Node *,int);
void pos(Node *,int);

int main(){
  int n,i,j,degree,point,c1,c2,depth=0,sum=0,height,root=0;
 
  Node T[25];
  for(i=0;i<25;i++){
    T[i].p=T[i].r=T[i].l=T[i].s=-1;
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d%d",&point,&c1,&c2);
    if(c1!=-1)sum++;
    if(c2!=-1)sum++;
    T[point].l=c1;
    T[point].r=c2;
    if(c1!=-1){
    T[c1].s=c2;
    T[c1].p=point;
    }
    if(c2!=-1){
    T[c2].s=c1;
    T[c2].p=point;
    }
  }
  for(i=0;i<=sum;i++){
    if(T[i].p==-1){root=i; break;}
  }
  printf("Preorder\n");
  pre(T,root);
  printf("\nInorder\n");
  in(T,root);
  printf("\nPostorder\n");
  pos(T,root);
  printf("\n");
    

  

  return 0;
}
void pre(Node T[],int i){
  if(T[i].l==-1 && T[i].r==-1){
    printf(" %d",i);
    return;
  }
  printf(" %d",i);
  if(T[i].l!=-1)
  pre(T,T[i].l);
  if(T[i].r!=-1)
  pre(T,T[i].r);
}
void in(Node T[],int i){
  if(T[i].l==-1 && T[i].r==-1)
  {
    printf(" %d",i);
    return;
  }
  if(T[i].l!=-1)
  in(T,T[i].l);
  printf(" %d",i);
  if(T[i].r!=-1)
  in(T,T[i].r);
}
void pos(Node T[],int i){
  if(T[i].l==-1 && T[i].r==-1)
    {
      printf(" %d",i);
      return;
    }
  if(T[i].l!=-1)
  pos(T,T[i].l);
  if(T[i].r!=-1)
  pos(T,T[i].r);
  printf(" %d",i);
}    



Measured memory_bytes: 2084
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;

    int ans = 0;
    for(int i=0; i<3; ++i){
        if(s[i] == t[i])
            ++ ans;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int n;
  long x;
  cin >> n >> x;
  vector<long> a(n);
  rep(i,n) cin >> a.at(i);
  sort(a.begin(),a.end());
  long ans = 0;
  rep(i,n){
    if(x >= a.at(i)){
      ans++;
      x -= a.at(i);
    }else break;
  }
  if(n == ans && x != 0) ans--;
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.Math.*;

class Main{

    static int n;
    static int k;

    //static int[] mData = new int[100000];
    static ArrayList<Integer> mData = new ArrayList<Integer>();

    //dp[t] = 1 kaze da u situaciji kad je prvi na potezu, ostalo t kamencica, prvi ima pobjednicku
    //dp[t] = 2 drugi ima pobjednicku
    static int[] dp = new int[100001];

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in).useLocale(Locale.US);

        n = sc.nextInt();
        k = sc.nextInt();

        //mData.add(0);
        for(int i = 0; i < n; i++){
            mData.add( sc.nextInt() );            
            //mData[i] = sc.nextInt();
        }

        //if( mData.get(0) == 1 ) dp[1] = 1;
        //else dp[1] = 2;

        for(int i = 1; i < k+1; i++){
            int ind = Collections.binarySearch(mData, i);
            if(ind >= 0) dp[i] = 1;
            else{
                ind = -ind -1;
                int res = 2;
                for(int j = 0; j < ind; j++){
                    if( dp[i - mData.get(j)] == 2){
                        res = 1;
                        break;
                    }
                }
                dp[i] = res;
            }
        }
    /*
        for(int i = 1; i < 10; i++){
            System.out.print(dp[i] + "\t" );
        }
    */
        if( dp[k] == 1 ) System.out.println("First");
        else System.out.println("Second");
        

        sc.close();
    }
}















Measured memory_bytes: 26068
def modInverse(a, p):  # p prime
    assert a % p != 0
    return pow(a, p - 2, p)


MOD = 10 ** 9 + 7
N, M = [int(x) for x in input().split()]


MAX_N = M
# Precompute all factorials: i!
fact = [1]
for i in range(1, MAX_N + 1):
    fact.append((fact[-1] * i) % MOD)

# Precompute all inverse factorials: 1 / (i!)
invFact = [0] * (MAX_N + 1)
invFact[MAX_N] = modInverse(fact[MAX_N], MOD)
for i in range(MAX_N - 1, -1, -1):
    invFact[i] = (invFact[i + 1] * (i + 1)) % MOD
    assert fact[i] * invFact[i] % MOD == 1


def nCr(n, r):  # mod
    # Modulo binomial coefficients
    return (fact[n] * invFact[r] * invFact[n - r]) % MOD


# Principle of inclusion exclusion
ans = 0
for i in range(N + 1):
    ans += (
        ((-1) ** (i % 2))
        * nCr(N, i)  # Choose i positions
        * (nCr(M, i) * fact[i])  # Choose numbers for those positions
        * (nCr(M - i, N - i) * fact[N - i]) ** 2  # Choose remaining A and B
    )
    ans %= MOD

print(ans)



Measured memory_bytes: 122524
#include <stdio.h>
typedef struct{
  char c;
  int value;
}card;
int main(){
  char space;
  int i, j, n, min, flag;
  card a[36], b[36], x;
  scanf("%d\n",&n);
  for(i = 0; i < n; i++){
    scanf("%c%d%c", &a[i].c, &a[i].value, &space);
    b[i] = a[i]; }
  for(j = 0; j < n; j++){
    flag = 0;
    for(i= n-1; i > j; i--){
      if(a[i].value < a[i-1].value){
        x = a[i];
        a[i] = a[i-1];
        a[i-1] = x;
	flag = 1; }
    }
    if(flag == 0) break;
  }
  for(j = 0; j < n; j++){
    min = j;
    for(i = j; i < n; i++){
      if(b[i].value < b[min].value)
        min = i;
    }
    if(min != j){
      x = b[j];
      b[j] = b[min];
      b[min] = x;
    } }
  for(i = 0; i < n-1; i++){
    printf("%c%d ", a[i].c, a[i].value);
  }
  printf("%c%d\n", a[n-1].c, a[n-1].value);
  printf("Stable\n");
  for(i = 0; i < n-1; i++){
    printf("%c%d ", b[i].c, b[i].value);
    if(a[i].c != b[i].c){
      flag = 2; }
  }
  printf("%c%d\n", b[n-1].c, b[n-1].value);
  if(flag == 2){
    printf("Not stable\n");
  }
  else printf("Stable\n");
  return 0; }



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

using namespace std;

typedef long long ll;

const int MX = 5005;

template <typename T> void cmin(T &x, const T &y)
{
	if(y < x) x = y;
}

template <typename T> void cmax(T &x, const T &y)
{
	if(y > x) x = y;
}

template <typename T> void read(T &x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

int n, a, b;
int seq[MX];
ll f[MX];
int les[MX][MX], gre[MX][MX];

int main()
{
	read(n), read(a), read(b);
	for(int i=1; i<=n; i++) read(seq[i+1]);
	n += 2;
	seq[n] = n;
	seq[1] = 0;
	for(int i=1; i<=n; i++)
	{
		for(int l=1; l+i-1<=n; l++)
		{
			int r = l+i-1;
			les[l][r] = les[l][r-1] + (seq[r]<seq[l]);
			gre[l][r] = gre[l+1][r] + (seq[l]>seq[r]);
		}
	}
	memset(f, 0x3f, sizeof(f));
	f[1] = 0;
	for(int i=1; i<=n; i++)
		for(int j=1; j<i; j++)
			if(seq[j]<seq[i] && les[j][i]+gre[j][i]==i-j-1)
				cmin(f[i], f[j] + 1ll*les[j][i]*b + 1ll*gre[j][i]*a);
	printf("%lld\n", f[n]);
	return 0;
}

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

int main() {
	int n;
	std::cin >> n;
	 int ans = 0;
	for (int i = 1;i <= 100000;i++) {
		int b = i*i;
		if (b <= n) {
			ans = b;
		}
		if (b > n) {
			break;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}

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

using namespace std;

class PlayerData {
public:
	int num;
	double time;
};

PlayerData Player[24];


void show(int start) {
	cout << Player[start].num << " " << fixed << setprecision(2) << Player[start].time << endl;
	cout << Player[start + 1].num << " " << fixed << setprecision(2) << Player[start + 1].time << endl;
	Player[start].time = Player[start + 1].time = 101;
}

bool compere(const PlayerData& p1, const PlayerData& p2) {
	return p1.time < p2.time;
}

int main(void) {
	int start, end;

	for (int i = 0; i < 24; i++) {
		cin >> Player[i].num >> Player[i].time;

	}

	end = 0;
	for (int i = 0; i < 3; i++) {
		start = end;
		end += 8;
		sort(Player + start, Player + end, compere);
		show(start);
	}

	start = 0;
	sort(Player + start, Player + end, compere);
	show(start);


	return 0;
}


Measured memory_bytes: 3136
// AOJ 1018
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
	int n;
	while (cin >> n){
		if (cin.eof()) break;
		vector <int> data;
		int a;

		for (int i = 0; i < n; i++){
			cin >> a;
			data.push_back(a);
		}
		sort(data.begin(), data.end());
		int ret = 0, sum = 0;
		for (int i = 0; i < n; i++){
			sum += data[i];
			ret += sum;
		}
		cout << ret << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};

struct HashData {
	int h1, h2;
	bool operator==(const HashData& rhs) const {
		return h1 == rhs.h1 && h2 == rhs.h2;
	}
	bool operator!=(const HashData& rhs) const { return !(*this == rhs); }
};

class RollingHash {
	template<int B, int M>
	class RollingHashPart {
	private:
		size_t len;
		std::vector<int> pow_b, hash;
	public:
		RollingHashPart() {}
		template<typename T>
		RollingHashPart(const T& s) : len(s.size()), pow_b(s.size() + 1), hash(s.size() + 1) {
			pow_b[0] = 1;
			hash[0] = 0;
			for (int i = 0; i < len; i++) {
				pow_b[i + 1] = (ll)pow_b[i] * B % M;
				hash[i + 1] = ((ll)hash[i] * B + s[i]) % M;
			}
		}
		// [l, r)
		int get(int l, int r) const {
			int res = (hash[r] - (ll)hash[l] * pow_b[r - l]) % M;
			if (res < 0) res += M;
			return res;
		}
	};
public:
	RollingHashPart<1033, 1000000007> rh1;
	RollingHashPart<6037, 999999937> rh2;
 
	RollingHash() {}
	template<typename T> RollingHash(const T & s) : rh1(s), rh2(s) {}
	// [l, r)
	HashData get(int l, int r) const {
		return (HashData){ rh1.get(l, r), rh2.get(l, r) };
	}

	lpair getPair(int l, int r) const {
		return make_pair(rh1.get(l,r) , rh2.get(l, r));
	}
	// [l1, r1), [l2, r2)
	int lcp(const RollingHash & rhs, int l1, int r1, int l2, int r2) const {
		int lb = 0, ub = std::min(r1 - l1, r2 - l2) + 1;
		while (ub - lb > 1) {
			int md = (lb + ub) >> 1;
			(get(l1, l1 + md) == rhs.get(l2, l2 + md) ? lb : ub) = md;
		}
		return lb;
	}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    string S;
    cin >> S;
    RollingHash r(S);
    ll lv = 0, rv = N+1;
    while(rv - lv > 1){
        ll mid = (rv + lv) / 2;
        bool ok = false;
        rep(i,0,N){
            rep(j,i+1,N){
                if(j - i < mid) continue;
                if(j+mid-1 >= N) continue;
                if(r.getPair(i, i+mid) == r.getPair(j, j+mid)){
                    ok = true;
                    break;
                }
            }
            if(ok) break;
        }
        if(ok){
            lv = mid;
        }else{
            rv = mid;
        }
    }
    print(lv);


    
}


Measured memory_bytes: 384
import java.util.*;

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

        long min = sc.nextLong() - 1;
        long max = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();

        long lcm = LCM(c, d);
        long cnt = 0;

        cnt += devide(max, c);
        cnt += devide(max, d);
        cnt -= devide(max, lcm);

        cnt -= devide(min, c);
        cnt -= devide(min, d);
        cnt += devide(min, lcm);

        System.out.println(max - min - cnt);
    }

    public static long devide(long a, long b) {
        return a / b;
    }

    public static long GCD(long a, long b) {
        if (a < b) {
            return GCD(b, a);
        } else if (b == 0) {
            return a;
        } else {
            return GCD(b, a % b);
        }
    }

    public static long LCM(long a, long b) {
        return a * b / GCD(a, b);
    }
}


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

template <int32_t MOD>
struct mint {
    int64_t data;  // faster than int32_t a little
    mint() = default;  // data is not initialized
    mint(int64_t value) : data(value) {}  // assume value is in proper range
    inline mint<MOD> operator + (mint<MOD> other) const { int64_t c = this->data + other.data; return mint<MOD>(c >= MOD ? c - MOD : c); }
    inline mint<MOD> operator - (mint<MOD> other) const { int64_t c = this->data - other.data; return mint<MOD>(c <    0 ? c + MOD : c); }
    inline mint<MOD> operator * (mint<MOD> other) const { int64_t c = this->data * int64_t(other.data) % MOD; return mint<MOD>(c < 0 ? c + MOD : c); }
    inline mint<MOD> & operator += (mint<MOD> other) { this->data += other.data; if (this->data >= MOD) this->data -= MOD; return *this; }
    inline mint<MOD> & operator -= (mint<MOD> other) { this->data -= other.data; if (this->data <    0) this->data += MOD; return *this; }
    inline mint<MOD> & operator *= (mint<MOD> other) { this->data = this->data * int64_t(other.data) % MOD; if (this->data < 0) this->data += MOD; return *this; }
    inline mint<MOD> operator - () const { return mint<MOD>(this->data ? MOD - this->data : 0); }
    mint<MOD> pow(uint64_t k) const {
        mint<MOD> x = *this;
        mint<MOD> y = 1;
        for (uint64_t i = 1; i and (i <= k); i <<= 1) {
            if (k & i) y *= x;
            x *= x;
        }
        return y;
    }
    mint<MOD> inv() const {
        return pow(MOD - 2);
    }
};
template <int32_t MOD>
mint<MOD> fact(int n) {
    static vector<mint<MOD> > memo(1, 1);
    while (n >= memo.size()) {
        memo.push_back(memo.back() * mint<MOD>(memo.size()));
    }
    return memo[n];
}
template <int32_t PRIME>
mint<PRIME> inv_fact(int n) {
    static vector<mint<PRIME> > memo(1, 1);
    while (n >= memo.size()) {
        memo.push_back(memo.back() * mint<PRIME>(memo.size()).inv());
    }
    return memo[n];
}
template <int32_t MOD>
mint<MOD> choose(int n, int r) {
    assert (0 <= r and r <= n);
    return fact<MOD>(n) * inv_fact<MOD>(n - r) * inv_fact<MOD>(r);
}

constexpr int MOD = 998244353;
int solve(ll n, ll a, ll b, ll k) {
    mint<MOD> cnt = 0;
    REP (x, n + 1) {
        int y = (k - a * x) / b;
        if (a * x + b * y != k) continue;
        if (not (0 <= y and y <= n)) continue;
        cnt += choose<MOD>(n, x) * choose<MOD>(n, y);
    }
    return cnt.data;
}

int main() {
    ll n, a, b, k; cin >> n >> a >> b >> k;
    cout << solve(n, a, b, k) << endl;
    return 0;
}


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

int main(){
  string w;
  cin >>w;
  
  unordered_map<char,int> mp;
  
  int len = w.size();
  repeat(i,0,len) mp[w[i]]++;
  
  string ans = "Yes";
  repeat(i,0,len){
    if(mp[w[i]]%2!=0) ans = "No";
  }
  
  cout <<ans<< endl;
}

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

/* initialize */
int n, k, A[100000], c;
ll sum = 0;


int check(ll P){
    int x = 0;
    for (int i = 0; i < k; ++i) {
        ll s = 0;
        while (s + A[x] <= P){
            s += A[x];
            x++;
            if (x == n) return n;
        }
    }
    return x;
}
ll search(ll right){
    ll left = 0;
    while (right - left > 1){
        ll mid = (right + left)/2;
        if (check(mid) >= n) right = mid;
        else left = mid;
    }

    return right;
}

/* main */
int main() {
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &c);
        sum += c;
        A[i] = c;
    }
    ll ans = search(sum+1);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;

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; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}
/**
* @fn
* 指定した値との差の絶対値が最小のvectorの番号を返します。
*/
long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

//ここまでライブラリ
//ここから本文

long long int tpabsmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b) && a.at(i) >= b) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


int main() {
	string s;
	cin >> s;
	int sento = 0;
	int saigo = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s.at(i) == 'A') {
			sento = i;
			break;
		}
	}
	for (int i = s.size() - 1; i > 0; i--) {
		if (s.at(i) == 'Z') {
			saigo = i;
			break;
		}
	}
	cout << saigo - sento + 1 << endl;
}



Measured memory_bytes: 640
# 入力
N, K, Q = map(int, input().split())
A = list(map(int, input().split()))

INF = 10**20

# Y = A_1, .., A_N のときの X - Y の最小値を求める
# Y を決め打つと、 X - Y の最小値はO(NlogN)で求められる


def f(b):
    i = 0
    T = []
    while i < N:
        S = []
        while i < N and A[i] >= b:
            S.append(A[i])
            i += 1
        if len(S) >= K:
            T.extend(sorted(S)[:(len(S) - K + 1)])
        i += 1
    return (
        sorted(T)[Q - 1] if len(T) >= Q else
        INF
    )


ans = min(f(a) - a for a in A)

# 出力
print(ans)


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

int main() {
  int N;
  cin >> N;
  
  int i = 0;
  while (i < N){
    string C;
    cin >> C;
    
    if(C == "W"){
      i++;
    }
    if(C == "P"){
      i++;
    }
    if(C == "G"){
      i++;
    }
    if(C == "Y"){
      cout << "Four" << endl;
      break;
    }
    
    if(i == N-1){
      cout << "Three" << endl;
    }
  }
}

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

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

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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 ctoi(char c){return c - '0';}


// TODO: write
int main() { 
  int h,n;cin>>h>>n;
  vector<int> a(n),b(n);rep(i,n)cin>>a[i]>>b[i];
  vector<vector<ll>> dp(n+1,vector<ll>(h+1,INF));
  
  rep(i,n)dp[i][0] = 0;
  
  rep(i,n){
    rep(j,h+1){
      chmin(dp[i+1][j],dp[i][j]);
      chmin(dp[i+1][j],dp[i+1][max(j-a[i],0)]+b[i]);
    }
  }

  print(dp[n][h]);
  return 0;
}

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

int main() {
  int n;cin>>n;
  ll ans=1;
  ll a=1e9+7;
  for(int i=1;i<=n;i++){
    ans=(ans*i)%a;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include"bits/stdc++.h"
#define INFLL        1e18
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define DELNL        cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll=long long;using ull=unsigned long long;
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}

class mod_int{
private:
    static const ull _mod,_cnt_div;
    static const ull pow_mod(ull x,ull y){x%=_mod;return(y==0?1:y%2==0?pow_mod(x*x%_mod,y/2):x*pow_mod(x,y-1))%_mod;}
    ull _num;
public:
    static mod_int inv(ull arg){return mod_int(pow_mod(arg,_mod-_cnt_div));}
    static mod_int inv(const mod_int&mi){return inv(mi.num());}
    mod_int()=default;mod_int(ull num):_num(num%_mod){}
    ull num()const{return _num;}
    mod_int operator+ (ull arg)const{arg%=_mod;return mod_int(_num+arg);}
    mod_int operator- (ull arg)const{arg%=_mod;return mod_int(max(_num,arg)-min(_num,arg));}
    mod_int operator* (ull arg)const{arg%=_mod;return mod_int(_num*arg);}
    bool operator==(ull arg)const{return _num==arg;}
    bool operator!=(ull arg)const{return!operator==(arg);}
    mod_int&operator=(ull arg){_num=arg;return*this;}
    mod_int&operator+=(ull arg){_num=operator+(arg).num();return*this;}
    mod_int&operator-=(ull arg){_num=operator-(arg).num();return*this;}
    mod_int&operator*=(ull arg){_num=operator*(arg).num();return*this;}
    mod_int operator+ (const mod_int&mi)const{return operator+ (mi.num());}
    mod_int operator- (const mod_int&mi)const{return operator- (mi.num());}
    mod_int operator* (const mod_int&mi)const{return operator* (mi.num());}
    bool operator==(const mod_int&mi)const{return _num==mi.num();}
    bool operator!=(const mod_int&mi)const{return!operator==(mi);}
    mod_int&operator=(const mod_int&mi){return operator=(mi.num());}
    mod_int&operator+=(const mod_int&mi){return operator+=(mi.num());}
    mod_int&operator-=(const mod_int&mi){return operator-=(mi.num());}
    mod_int&operator*=(const mod_int&mi){return operator*=(mi.num());}
};

constexpr ull sz=200000,mod=1000000007;
const ull mod_int::_mod=mod;
const ull mod_int::_cnt_div=2;
vector<mod_int>fact_mod(sz);
vector<mod_int>fact_inv(sz);
mod_int stair_mod(ll n)
{
    mod_int ret=0;
    for(ll a=n,b=0;a>=0;a-=2,b+=1)ret+=fact_mod[a+b]*fact_inv[a]*fact_inv[b];
    return ret;
}
int main()
{
    ll n=in(),m=in();
    vector<ll>a(m);REP(i,m)a[i]=in();a.push_back(n+1);

    fact_mod[0]=1;REP(i,sz-1)fact_mod[i+1]=fact_mod[i]*(i+1);
    REP(i,sz)fact_inv[i]=mod_int::inv(fact_mod[i]);
    ll now=0;
    mod_int ans=1;
    REPC(ai,a){
        ans*=stair_mod(ai-now-1);
        now=ai+1;
    }
    cout<<ans.num()<<endl;
}

Measured memory_bytes: 4992