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

using namespace std;

int main(void){
    string S;
    string T;
    int N;

    cin >> S >> T;
    
    cin >> N;

    int s_s, s_e, t_s, t_e;

    int S_asum[100005];
    S_asum[0] = 0;
    for(int j=1;j<=S.length();j++){
        S_asum[j] = (S_asum[j-1] + S[j -1] - 'A' + 1) % 3;
    }
    int T_asum[100005];
    T_asum[0] = 0;
    for(int j=1;j<=T.length();j++){
        T_asum[j] = (T_asum[j-1] + T[j -1] - 'A' + 1) % 3;
    }

    for(int i=0;i<N;i++){

        /*cin >> s_s >> s_e >> t_s >> t_e;*/
        scanf("%d%d%d%d", &s_s, &s_e, &t_s, &t_e);

        int s_tmp = 0;
        int t_tmp = 0;

        s_tmp = S_asum[s_e] - S_asum[s_s-1] + 3;
        t_tmp = T_asum[t_e] - T_asum[t_s-1] + 3;

        /*string ans = "NO";*/
        if((s_tmp - t_tmp) % 3 == 0){
            /*ans = "YES";*/
            printf("YES\n");
        }
        else{printf("NO\n");}
        /*cout << ans << endl;*/
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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 k;
bool f(int st, vi a) {
  if(st == k) {
    if (a[0] < a[1] && a[1] < a[2]) return true;
    else return false;
  }
  bool res = false;
  REP(i, 3) {
    vi b = a;
    b[i] *= 2;
    res |= f(st+1, b);
  }
  return res;
}

int main() {
  vi a(3);
  REP(i, 3) cin>>a[i];
  cin>>k;
  bool res = f(0, a);
  if(res) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

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


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int A[n];
	int overall = 0;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		overall ^= A[i];
	}
	for (int i = 0; i < n; i++) {
		cout << (overall ^ A[i]) << " "; 
	}
	cout << endl;
}



Measured memory_bytes: 4356
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int min_comp(int min, int a)
{

}
int max_comp(int max, int a)
{
  if(max>a)    return max;
  else    return a;
}


int main()
{
  int K;
  int A,B,C;
  int A2,B2,C2;
  int max_flag;
  int min,max;
  int number;
  int debug_cnt;
//  long long N[101]={};
  int i;
  int cont;
//    int k=0;
  scanf("%d", &A);
  max=A;
  max_flag=1;
  
  scanf("%d", &B);
  if(max<B){
    max=B;
    max_flag=2;
  }
  scanf("%d", &C);
  if(max<C){
  max=C;
    max_flag=3;
  }
//    printf("%d %d %d %d\n", max_flag,A,B,C);
  
  while(1){
//    printf("%d   ", debug_cnt);
//    debug_cnt++;
//    if(debug_cnt==30) break;

    if((A==B)&&(B==C)&&(C==A)) break;
//    printf("%d\n", cont);
    
    if(max_flag==1){
      if(A-B>=2){
        B=B+2;
        cont++;
      }
      else if(A-C>=2){
        C=C+2;
        cont++;
      }
      else if(((A-B)==1) && ((A-C)==1) ){
        B++;
        C++;
        cont++;
      }
      else if(((A-B)==1)){
        A++;
        B++;
        cont++;
      }
      else if(((A-C)==1)){
        A++;
        C++;
        cont++;
      }
    }
    if(max_flag==2){
      if(B-A>=2){
        A=A+2;
        cont++;
      }
      else if(B-C>=2){
        C=C+2;
        cont++;
      }
      else if(((B-A)==1) && ((B-C)==1) ){
        A++;
        C++;
        cont++;
      }
      else if(((B-A)==1)){
        A++;
        B++;
        cont++;
      }
      else if(((A-C)==1)){
        B++;
        C++;
        cont++;
      }
  }
  if(max_flag==3){
      if(C-B>=2){
        B=B+2;
        cont++;
      }
      else if(C-A>=2){
        A=A+2;
        cont++;
      }
      else if(((C-B)==1) && ((C-A)==1) ){
        B++;
        A++;
        cont++;
      }
      else if(((C-B)==1)){
        C++;
        B++;
        cont++;
      }
      else if(((C-A)==1)){
        A++;
        C++;
        cont++;
      }
  }
    
  }
    printf("%d\n", cont);
//  else printf("No\n"); 
return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
 
int main(){
    int n,k;
    cin>>n>>k;
    int ans=0;
    int a;
    rep(i, n){
        cin >> a;
        if(a>=k) ans += 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n,k = readInts()
r,s,p = readInts()
t = list(input())

his = ["-1"]
ans = 0
for i in range(len(t)):
  if t[i]=="r":
    me = "p"
    point = p
  elif t[i]=="s":
    me = "r"
    point = r
  else:
    me = "s"
    point = s
  if his[max(0,i-k+1)]==me:
    his.append(i)
  else:
    ans+=point
    his.append(me)

print(ans)

Measured memory_bytes: 12228
n = int(input())
d = [list(input().split()) for _ in range(n)]

c = 0

for i in range(n):
    if d[i][0] == d[i][1]:
        c += 1
    else:
        c = 0
    if c == 3:
        break

if c == 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9208
S=input()
cond=0
for j in range(len(S)):
  if (j+1)%2==1 and S[j]=='L':
    cond=1
    break
  elif (j+1)%2==0 and S[j]=='R':
    cond=1
    break

if cond==0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

int main(){

    int N, K, Q;
    scanf("%d %d %d", &N, &K, &Q);

    int tokuten[N];   /* 参加者の得点配列 */
    int seikai[Q];   /* 正解者番号の配列 */

    /* 参加者の得点配列の初期化 */
    for( int j=0; j<N; j++ ){
        tokuten[j] = K-Q;
    }

    /* 正解者番号の配列への入力と、得点計算 */
    for( int i=0; i<Q; i++ ){
        
        /* 配列への入力 */
        scanf("%d", &seikai[i]);
        int seikaisya = seikai[i]-1;
        
        /* 正解者の得点を1増やす */
        tokuten[seikaisya] = tokuten[seikaisya] + 1;

    }

    for( int j=0; j<N; j++ ){

        if( tokuten[j] <= 0 ){
            printf("No\n");
        } else {
            printf("Yes\n");
        }
    }
    return 0;
}

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

int main(){
    ll N,D;
    cin >> N >> D;
    if((N%(2*D+1))==0){
        cout << N/(2*D+1) << endl;
    }else{
        cout << N/(2*D+1)+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template <class T> void out(const T &val) { cout << val << endl; }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    int a, b;
    sf(a, b);
    if (a > 9 || b > 9) puts("-1");
    else cout << a * b << endl;
    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 256
#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;

class Edge
{
public:
    int to, index;
    Edge(int to, int index){
        this->to = to;
        this->index = index;
    }
};

bool dfs(const vector<vector<Edge> >& edges, int curr, int prev, int goal, vector<bitset<64> >& bs, int index)
{
    if(curr == goal)
        return true;

    for(const auto& e : edges[curr]){
        int next = e.to;
        if(next == prev)
            continue;
        if(dfs(edges, next, curr, goal, bs, index)){
            bs[e.index][index] = true;
            return true;
        }
    }
    return false;
}

int main()
{
    int n;
    cin >> n;
    vector<vector<Edge> > edges(n, vector<Edge>());
    for(int i=0; i<n-1; ++i){
        int a, b;
        cin >> a >> b;
        -- a;
        -- b;
        edges[a].push_back(Edge(b, i));
        edges[b].push_back(Edge(a, i));
    }

    int m;
    cin >> m;
    vector<bitset<64> > bs(n-1);
    for(int i=0; i<m; ++i){
        int u, v;
        cin >> u >> v;
        -- u;
        -- v;
        dfs(edges, u, -1, v, bs, i);
    }

    vector<long long> dp(1<<m, 0);
    dp[0] = 1;
    for(int i=0; i<n-1; ++i){
        for(int j=(1<<m)-1; j>=0; --j){
            int k = j | bs[i].to_ulong();
            dp[k] += dp[j];
        }
    }
    cout << dp.back() << endl;

    return 0;
}


Measured memory_bytes: 8448
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
#include <set>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };
const double PI = 3.14159265358979323846;


int main() {

	int x;
	cin >> x;
	int five_hund = 0;
	int five = 0;

	five_hund = x / 500;
	five = (x % 500) / 5;

	cout << five_hund * 1000 + five * 5 << endl;


	return 0;

}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D;
  cin >>D;
    if(D==25) cout<<"Christmas";
    else if(D==24) cout<<"Christmas"<<" "<<"Eve";
    else if(D==23) cout<<"Christmas"<<" "<<"Eve"<<" "<<"Eve";
    else  cout<<"Christmas"<<" "<<"Eve"<<" "<<"Eve"<<" "<<"Eve";
}
  

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * TITLE : Next Alphabet
 * URL : https://atcoder.jp/contests/abc151/tasks/abc151_a
 */
public class Main {

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

		char[] c = C.toCharArray();
        System.out.println((char)(c[0] + 0x01));
		sc.close();
	}
}

Measured memory_bytes: 23124
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

#define MAX_V 10000
struct edge{
    int to;
    int cap;
    int cost;
    int rev;
    edge(){}
    edge(int to,int cap,int cost,int rev):to(to),cap(cap),cost(cost),rev(rev){}
};

int V;
vector<edge> G[MAX_V];
int h[MAX_V];
int dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];
void init_edge(){
    for(int i=0;i<V;i++)G[i].clear();
}
void add_edge(int from,int to,int cap,int cost){
    G[from].push_back(edge(to,cap,cost,(int)G[to].size()));
    G[to].push_back(edge(from,0,-cost,(int)G[from].size()-1));
}
int min_cost_flow(int s,int t,int f){
    int res = 0;
    fill(h,h+V,0);
    while(f>0){
        priority_queue< pii, vector<pii>, greater<pii> >  que;
        fill( dist, dist+V , INF );
        dist[s]=0;
        que.push(pii(0,s));
        while(!que.empty()){
            pii p = que.top(); que.pop();
            int v = p.second;
            if(dist[v]<p.first)continue;
            for(int i=0;i<(int)G[v].size();i++){
                edge &e = G[v][i];
                if(e.cap>0&&dist[e.to] > dist[v]+e.cost+h[v]-h[e.to]){
                    dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
                    prevv[e.to]=v;
                    preve[e.to]=i;
                    que.push(pii(dist[e.to],e.to));
                }
            }
        }
        
        if(dist[t]==INF){
            return -1;
        }
        for(int v=0;v<V;v++)h[v]+=dist[v];
        
        int d=f;
        for(int v=t;v!=s;v=prevv[v]){
            d=min(d,G[prevv[v]][preve[v]].cap);
        }
        f-=d;
        res+=d*h[t];
        for(int v=t;v!=s;v=prevv[v]){
            edge &e = G[prevv[v]][preve[v]];
            e.cap -= d;
            G[v][e.rev].cap += d;
        }
    }
    return res;
}
int main(){
    int E,F,a,b,c,d;
    cin>>V>>E>>F;
    while(E--){
        cin>>a>>b>>c>>d;
        add_edge(a,b,c,d);
    }
    cout<<min_cost_flow(0,V-1,F)<<endl;
    return 0;
}



Measured memory_bytes: 3424
def nCr(n,r,mod):
    p=1
    q=1
    
    # print(n,r)

    
    for i in range(r):
        
        q *= i+1
        q %= mod
        
        p *= n-i
        p %= mod

    # print(p,q)
    return (p * pow(q,mod-2,mod)) % mod

s=int(input())
mod = 10**9+7

ans = 0

for i in range(1,s//3+1):
    
    if i==1:
        h=1
        
    else:    
        h=nCr(s-3*i+i-1 ,i-1, mod)
        
    ans += h
    ans %= mod
    # print(h)

print(ans)

Measured memory_bytes: 9136
//#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int main() {
	int s, w;
	cin >> s >> w;
	cout << (s > w ? "safe" : "unsafe") << endl;
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)


#define SZ(x) ((int)(x).size())


typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
struct Vector{
    double x, y;
};

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;
}
using namespace std;

int main()
{
    int N;
   
    cin >> N;
    cout << (1000 - N % 1000)%1000 << endl;
    
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <cstdlib>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
#include <sstream>
#include <math.h>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecchar vector<char>
#define vecstr vector<string>
#define vecbool vector<bool>
#define vec2bool vector<vector<bool>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s >= 0;s--)

#define Pi 3.1415926535897932384626


int main()
{
	ll n,ans,a,b;
	string s;
	bool flag = true;

	cin >> a >> b;

	cout << a * b << "\n";
}


Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i += 2){
		cout << s[i];
	}
	cout << endl;
}

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

int main() {
    ll n, k;
    cin >> n >> k;
    map<ll, ll> mp;
    rep(i,n) {
        ll a, b;
        cin >> a >> b;
        mp[a]+=b;
    }
    for(auto x : mp) {
        if(k<=x.second) {
            cout << x.first << endl;
            return 0;
        }
        else k-=x.second;
    }
    return 0;
}

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

using namespace std;
using ll = long long;
#define MAX 3004

ll vls[MAX][MAX];
ll dp[MAX][MAX][4];
int n, m, k;

ll solve(int x, int y, int usd){
    if(dp[x][y][usd] != -1)
        return dp[x][y][usd];
    dp[x][y][usd] = usd < 3 ? vls[x][y] : 0;
    if(y + 1 < m && usd < 3)
        dp[x][y][usd] = max(dp[x][y][usd], solve(x, y + 1, usd + 1) + vls[x][y]);
    if(y + 1 < m)
        dp[x][y][usd] = max(dp[x][y][usd], solve(x, y + 1, usd));
    if(x + 1 < n)
        dp[x][y][usd] = max(dp[x][y][usd], solve(x + 1, y, 0) + (usd < 3 ? vls[x][y]: 0));
    return dp[x][y][usd];
}

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> k;
    ll x, y, vl;
    for(int i = 0; i < k; i++){
        cin >> x >> y >> vl;
        vls[x - 1][y - 1] = vl;
    }
    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0 , 0) << endl;

}

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

bool binarySearchJudge(const vector<int>& a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(const vector<int>& a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int n;
	cin >> n;
	vector<int> s(n);
	for (int i = 0; i < n; i++)
	{
		cin>>s[i];
	}
	
	int q;
	cin >> q;
	int ans = 0;
	for (int i = 0; i < q; i++)
	{
		int t;
		cin>>t;
		if (binarySearch(s, t)) ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
const ll mod = 1e9 + 7;

void solve() {
   int n;
   cin >> n;
   vector <ll> a(n + 1), cm(n + 1);
   for (int i = 0; i < n; i++) {
      cin >> a[i];
   }
   for (int i = n - 1; i >= 0; i--) {
      cm[i] = (cm[i + 1] + a[i]) % mod;
   }
   ll ans = 0;
   for (int i = 0; i < n; i++) {
      ans = (ans + (a[i] * cm[i + 1]) % mod) % mod;
   }
   cout << ans << '\n';
}

int main() {
#ifndef ONLINE_JUDGE
   freopen("inp.txt", "r", stdin);      freopen("outp.txt", "w", stdout);
#endif
   ios::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);

   solve();

   return 0;
}

Measured memory_bytes: 6296
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int w = sc.nextInt();
    int h = sc.nextInt();
    int n = sc.nextInt();
    int lx = 0;
    int rx = w;
    int by = 0;
    int uy = h;
    for(int i = 0; i < n; i++) {
      int x = sc.nextInt();
      int y = sc.nextInt();
      int a = sc.nextInt();
      if(a == 1) lx = Math.max(lx, x);
      if(a == 2) rx = Math.min(rx, x);
      if(a == 3) by = Math.max(by, y);
      if(a == 4) uy = Math.min(uy, y);  
    }
    System.out.println(Math.max(0, rx - lx) * Math.max(0, uy - by));
  }
}

Measured memory_bytes: 23124
#include<stdio.h>
int Partition(int[],int,int);

int main(){
  int n,i,j,A[100000];

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

  j=Partition(A,0,n-1);
  
  for(i=0; i<n; i++){
    if(i != 0)
      printf(" ");
    if(i==j)
      printf("[%d]",A[i]);
    else
      printf("%d",A[i]);
  }
  printf("\n");
  return 0;
}
  
int Partition(int B[],int p,int r){
  int temp,a,b,c;
  a=B[r];
  b=p-1;
  for(c=p; c<r; c++){
    if(B[c] <= a){
      b++;
      temp= B[c];
      B[c]= B[b];
      B[b]= temp;
    }
  }
  temp= B[r];
  B[r]= B[b+1];
  B[b+1]= temp;
  
  return b+1;
}

Measured memory_bytes: 992
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


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

    ll N , W;
    cin >> N >> W;
    vector<ll> w,v;
    rep(i,N){
        ll wi, vi;
        cin >> wi >> vi;
        w.pb(wi);
        v.pb(vi);
    }

    vector<ll> a[4];
    
    rep(i,N){
        ll num = w[i] - w[0];
        a[num].pb(v[i]);
    }

    rep(i,4) {
        sort(rall(a[i]));
        rep(j, a[i].size()){
            if(j == 0) continue;
            a[i][j] += a[i][j-1];
        }
        
    }

    ll ans = 0;
    rep(i, a[0].size()+1) rep(j, a[1].size()+1) rep(k, a[2].size()+1) {

        ll l = W;
        l -= (i * w[0] + j * (w[0]+1) + k * (w[0]+2) );
        if(l < 0) continue;
        l /= (w[0]+3);

        ll ret = 0;
        l = min(l, (ll)a[3].size());
        
        if(i != 0) ret += a[0][i-1];
        if(j != 0) ret += a[1][j-1];
        if(k != 0) ret += a[2][k-1];
        if(l != 0) ret += a[3][l-1];

        ans = max(ans, ret);
    }
    
    cout << ans << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] arr = new int[n][2];
		long sum = 0;
		for(int i = 0; i < n; i++) {
			arr[i][0] = sc.nextInt();
			arr[i][1] = sc.nextInt();
			sum += arr[i][0];
		}
		Arrays.sort(arr, new Comparator<int[]>() { //double[]でコンパレーターを実装する
			  public int compare(int[] a, int[] b) {
			    if(a[1] > b[1]) {
			      return 1;
			    }else if (a[1] == b[1]) {
			      return 0;
			    }else {
			      return -1;
			  }}});
		String ans = "Yes";
		if(arr[n-1][1] < sum) {
			ans = "No";
		}else {
			int task = 0;
			for(int i = 0; i < n; i++) {
				task += arr[i][0];
				if(task > arr[i][1]) {
					ans = "No";
					break;
				}
			}
		}
		
		System.out.println(ans);
		sc.close();
	}
	
}


Measured memory_bytes: 106016
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll mod=INF;


int main() {
    ll T;
    int n;
    cin >> T >> n;
    vector<ll> s(n),t(n);
    rep(i,n) cin >> s[i] >> t[i];
    s.push_back(INF);
    int r=1,m=0;
    ll u=0,ans=0;
    rep(i,n){
        while(true){
            if (r==1){
                if (s[i]+T<s[m]) break;
                u+=t[m]-s[m];
                m++;
                r=0;
            }
            else if (r==0){
                if (s[i]+T<t[m-1]) break;
                r=1;
            }
        }
        if (r==0) ans=max(ans,u-(t[m-1]-s[i]-T));
        else ans=max(ans,u);
        u-=t[i]-s[i];
    }
    cout << ans << endl;
}



Measured memory_bytes: 5276
N = int(input())
l = [[int(j) for j in input().split()] for i in range(N)]
l = sorted(l, key=lambda x:x[1])
s = 0
ans = 'Yes'
for a,b in l:
    s += a
    if s > b:
        ans = 'No'
        break

print(ans)

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

namespace Contest
{
    class Program
    {
        static int Main(string[] args)
        {
            new Program().Process();

            return 0;
        }

        private CommonInput cin;

        private void Process()
        {
            this.cin = new CommonInput();

            int x, y, tmp;

            while (true)
            {
                x = cin.GetInt();
                y = cin.GetInt();

                if (x == 0 && y == 0)
                    break;

                if (x > y)
                {
                    tmp = x;
                    x = y;
                    y = tmp;
                }

                Console.WriteLine("{0} {1}", x, y);
            }
        }
    }

    public class CommonInput
    {
        public CommonInput()
        {
            this._s = new string[0];
            this._i = 0;
        }

        private string[] _s;
        private int _i;
        private char[] _sep = { ' ' };

        public string GetLine()
        {
            if (this._i < this._s.Length)
                return this._s[this._i++];

            string line;
            this._i = 0;
            do
            {
                line = Console.ReadLine();
            } while (line == "");

            this._s = line.Split(this._sep, StringSplitOptions.RemoveEmptyEntries);

            return this._s[this._i++];
        }

        public int GetInt()
        {
            return int.Parse(this.GetLine());
        }

        public long GetLong()
        {
            return long.Parse(this.GetLine());
        }

        public double GetDouble()
        {
            return double.Parse(this.GetLine());
        }
    }
}

Measured memory_bytes: 5768
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		long[] a = new long[n];
		HashMap<Long, Integer> map = new HashMap<>();
		for(i=0;i<n;i++) {
			a[i] = parseLong(sc.next());
			map.put(a[i], map.containsKey(a[i])?map.get(a[i]) + 1:1);
		}
		sc.close();
		long ans=0;
		ArrayList<Long> keys = new ArrayList<Long>(map.keySet());
		Collections.sort(keys, Comparator.reverseOrder());
		ArrayList<Long> ab = new ArrayList<>();
		for(Long l:keys) {
			if(map.get(l)>=4) {
				ab.add(l);
				ab.add(l);
			} else if(map.get(l)>=2) {
				ab.add(l);
			}
			if(ab.size()>=2)break;
		}
		if(ab.size()<2) {
			ab.add(0L);
			ab.add(0L);
		}
		out.println(ab.get(0)*ab.get(1));
	}
}

Measured memory_bytes: 54168
#include<iostream>
#include<set>
using namespace std;
int main(){
    set<int>a,b,c;
    int n;
    cin>>n;
    int aa[n];
    for(int i=0; i<n; i++){
        int x;
        cin>>x;
        a.insert(x);
    }
    int m;
    cin>>m;
    for(int i=0; i<m; i++){
        int x;
        cin>>x;
        if(a.find(x)==a.end()){
            c.insert(x);
        }
        else{
            b.insert(x);
            a.erase(x);
        }
    }
    for(set<int>::iterator i=a.begin(); i!=a.end(); i++){
        if(b.find(*i)==b.end())
            c.insert(*i);
    }
    for(set<int>::iterator i=c.begin(); i!=c.end(); i++){
        cout<<*i<<endl;
    }
    return 0;
}


Measured memory_bytes: 31212
def main():
    num = int(input())
    suzi = list(map(int,input().split()))

    if 0 in suzi:
	    print(0)
	    return
    ans = 1
    for kazu in suzi:
        ans *= kazu
        if ans > 1000000000000000000:
            print(-1)
            return
    print(ans)


main()

Measured memory_bytes: 21556
#include<stdio.h>
#include<stdlib.h>

int main()
{
	char s[6];
	
	for(int i = 0; i < 6; i++)
	{
		scanf("%c", s + i);
	}
	if(s[2] == s[3] && s[4] == s[5]) printf("Yes");
	else printf("No");
	
}

Measured memory_bytes: 128
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;
#[derive(Clone, Debug, Default)]
struct Struct;


//#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
        p: [usize;n],
    }

    let mut sorted = BTreeSet::new();
    
    for i in 0..k {
        sorted.insert(p[i]);
    }
    let mut ans = 1;

    for i in 0..n-k {
        let mut r = sorted.range(0..n);
        let l = *r.next().unwrap();
        let h = *r.next_back().unwrap();
        if p[i] == l && p[i+k] >= h {
            // i..i+k のソート結果と i+1..i+1+k のソート結果が同じだ
        } else {
            ans += 1;
        }
        sorted.remove(&p[i]);
        sorted.insert(p[i+k]);
    }

    // ソートしても元の文字列と同じになる場合の重複を除く
    let mut sorted_len = 1;
    let mut ct = 0;
    for i in 1..n {
        if p[i-1] < p[i] {
            sorted_len += 1;
            if sorted_len == k {
                ct += 1;
            }
        } else {
            sorted_len = 1;
        }
    }
    //println!("{}", ct);

    if ct != 0 {
        ans -= ct-1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 8988
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    int a;
    cin >> a;
    if(a == 25) puts("Christmas");
    if(a == 24) puts("Christmas Eve");
    if(a == 23) puts("Christmas Eve Eve");
    if(a == 22) puts("Christmas Eve Eve Eve");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define FASTIO ios_base::sync_with_stdio(NULL); cin.tie(NULL);
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define MOD 1000000007

using namespace std;

void init(){
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin) ;
  freopen("output.txt", "w", stdout) ;
  #endif
}

// code from below
ll dp[101][(int)1e5 + 1];

void solve(){
	int n,maxWeight;
    cin>>n>>maxWeight;
    vi values(n+1),weights(n+1);
    for(int i=1;i<=n;i++)
        cin>>weights[i]>>values[i];

    for(int i=1;i<=n;i++){
        for(int j=1;j<=maxWeight;j++){
            if(j-weights[i]>=0)
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-weights[i]]+values[i]);
            else
                dp[i][j]=dp[i-1][j];
        }
    }

    // cout<<" dp array is \n";
    // for(int i=0;i<=n;i++,cout<<endl)
    //     for(int j=0;j<=maxWeight;j++)
    //         cout<<dp[i][j]<<" ";

    cout<<dp[n][maxWeight]<<endl;
}

int main(){
    int t=1;
    // cin>>t;
    // cin.ignore(numeric_limits<streamsize>::max(),'\n'); 
    while(t--)
        solve();
}

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

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

int main() {
  int w, h, x, y, r;
  cin >> w >> h >> x >> y >> r;
  if (0 <= x - r && x + r <= w && 0 <= y - r && y + r <= h) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

int N;
vector< vector< pair<int, int> > > A;

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

    cin >> N;
    A.resize(N);
    REP(i, N) {
        int a;
        cin >> a;
        REP(j, a) {
            int x, y;
            cin >> x >> y;
            x--;
            A[i].push_back(make_pair(x, y));
        }
    }

    int ans = 0;
    REP(cand, (1 << N)) {
        // cand のパターンが当てはまるかチェック
        bool isValid = true;
        REP(i, N) {
            if(cand & (1 << i)) {
                // i の証言をチェック
                for(auto& p : A[i]) {
                    if(p.second == 1) {
                        if(!(cand & (1 << p.first))) {
                            isValid = false;
                            break;
                        }
                    }
                    else {
                        if(cand & (1 << p.first)) {
                            isValid = false;
                            break;
                        }
                    }
                }
            }
            if(!isValid) { break; }
        }
        if(isValid) {
            ans = max(ans, (int)__builtin_popcountll(cand));
        }
    }

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

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 10000000000
#define ninf -10000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
bool compare(const pll l, const pll r)
{
    if(l.ss == r.ss)
        return l.ff < r.ff;
    return l.ss < r.ss;
}
int main()
{
    she_told_me_dont_worry
    vector< pll > co;
    ll n;
    cin>>n;
    ll pre[n+5], pos[n+5];
    pll ppre[n+5], ppos[n+5];
    int i;
    ll ans= 0;
    FOR0(i, n)
    {
        pll temp;
        cin>>temp.ff>>temp.ss;
        co.pb(temp);
        ans = MAX2(ans, temp.ss-temp.ff+1);
    }
    sort(co.begin(), co.end(), compare);
    ll l= ninf, r = inf;
    FOR0(i, n)
    {
        l = MAX2(l, co[i].ff);
        r = MIN2(r, co[i].ss);
        ppre[i].ff = l;
        ppre[i].ss = r;
        pre[i] = MAX2(0, r-l+1);
    }
    l= ninf, r = inf;
    FORD(i, n-1, 0)
    {
        l = MAX2(l, co[i].ff);
        r = MIN2(r, co[i].ss);
        ppos[i].ff = l;
        ppos[i].ss = r;
        pos[i] = MAX2(0, r-l+1);
    }
    FOR0(i, n-1)
    {
        ans = MAX2(ans, pre[i] + pos[i+1]);
        if( i > 0)
        {
            ll l = MAX2(ppre[i-1].ff, ppos[i+1].ff);
            ll r = MIN2(ppre[i-1].ss, ppos[i+1].ss);
            ll cur = co[i].ss - co[i].ff + 1;
            ans = MAX2(ans, cur + MAX2(0, r-l+1));
        }
    }
    cout<<ans<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}


Measured memory_bytes: 7028
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
/*
    vec1.size();
    str1.length();
    vec1.pop_back;
*/
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<pll> vplll;
#define rep(i,l,r) for (ll i = l; i < r; ++i)
#define reprev(i,l,r) for (ll i = r; i >= l; --i)
ll mod = 1e9+7;
ll expo_mod(ll x, ll y, ll p) 
{ 
    ll res = 1;
    x = x % p; 
    if (x == 0) 
        return 0; 
    while (y > 0) 
    {
        if (y%2==1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll arr[n+1];
    rep(i,0,n)
    {
        cin>>arr[i];
    }
    ll cost[n+1];
    ll val=1e6;
    memset(cost, val , (n+1)*sizeof(cost[0]));
    cost[0]=0;
    cost[1]=abs(arr[0]-arr[1]);
    rep(i,2,n)
    {
        rep(j,max(0LL,i-k),i)
        {
            cost[i]=min(cost[j] + abs(arr[i]-arr[j]),cost[i]);
        }
    }
    cout<<cost[n-1]<<"\n";
    return 0;
}

Measured memory_bytes: 1792
N,M,X = map(int,input().split())
A = list(map(int,input().split()))

first = X
last = N+1-X
first_count = 0
last_count = 0

for a in range(len(A)):
    if X < A[a]:
        first_count += 1
    else:
        last_count += 1

if first_count > last_count:
    ans = last_count
else :
    ans = first_count

print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdint>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <cassert>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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

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

template <LL MOD=1000000007> class MODLL {
public:
  LL x;
  MODLL(const LL _x) : x(_x % MOD) {};
  MODLL operator+(const MODLL rhs) const { return MODLL(*this) += rhs; }
  MODLL operator-(const MODLL rhs) const { return MODLL(*this) -= rhs; }
  MODLL operator*(const MODLL rhs) const { return MODLL(*this) *= rhs; }
  MODLL operator/(const MODLL rhs) const { return MODLL(*this) /= rhs; }
  MODLL& operator+=(const MODLL rhs) { x += rhs.x; x %= MOD; return *this; }
  MODLL& operator-=(const MODLL rhs) { x -= rhs.x; x %= MOD; if(x<0) x += MOD; return *this; }
  MODLL& operator*=(const MODLL rhs) { x *= rhs.x; x %= MOD; return *this; }
  MODLL inv() const {
    if(x == 0) { throw "does not have inverse"; }
    LL a = x, b = MOD, u = 1, v = 0;
    while (b) {
      long long t = a / b;
      a -= t * b; swap(a, b);
      u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return MODLL(u);
  }
  MODLL& operator/=(const MODLL rhs) { (*this) *= rhs.inv(); return *this; }
  MODLL pow(ULL n) const {
    MODLL res = 1;
    MODLL a = x;
    while (n > 0) {
      if (n & 1) res *= a;
      a = a * a;
      n >>= 1;
    }
    return res;
  }
};

typedef MODLL<> ML;

void test() {
  {
    ML x = 3;
    assert(x.pow(45).x == 644897553);
  }
  {
    for(int i=1; i<13; i++) {
      MODLL<13> x = i;
      assert( (x.inv().x * i) % 13 == 1 );
    }
  }
}


int main() {
  LL N,M;
  std::cin >> N >> M;

  std::vector<int> H(N,0);
  for(LL i=0; i<M; i++) {
    LL a;
    cin >> a;
    H[a] = 1;
  }

  std::vector<ML> dp(N+2,0);
  dp[N] = 1;
  for(LL i=N-1; i>=0; i--) {
    if(H[i]) { dp[i] = 0; continue; }
    dp[i] = dp[i+1] + dp[i+2];
  }

  std::cout << dp[0].x << std::endl;

  return 0;
}



Measured memory_bytes: 1408
#include<stdio.h>

  int i, A[50];

int fib(int n){
  
  A[0] = A[1] = 1;
  for(i = 2; i <= 50; i++)
    A[i] = A[i - 1] + A[i - 2];
  
  if(n == 0 || n == 1)
    return A[n];
  else
    return A[n];
}

int main(){
  int n;
  
  scanf("%d", &n);
  printf("%d\n",fib( n ));
  
  return 0;
}
 

Measured memory_bytes: 1808
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        mut n: usize,
        nums: [usize; n-1]
    }

    let mut cnt = vec![0;n];

    for i in nums.iter() {
        cnt[*i-1] += 1;
    }

    for i in cnt.iter() {
        println!("{}",i);
    }
}


Measured memory_bytes: 5528
import sys
import numpy as np
# from decimal import Decimal
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# ----------------------------------------
h, w = map(int, readline().split())

data = []
for _ in range(h):
    #d0 = input().replace('*','1').replace('.','0')
    d0 = str(input())
    print(d0)
    print(d0)


Measured memory_bytes: 27128
#include <bits/stdc++.h>
using namespace std;
#define retunr return
#define pb push_back
#define mp make_pair
#define null NULL
#define sc(x) scanf("%d", &x)
#define sc64(x) scanf("%I64d", &x)
#define pr(x) printf("%d", (x))
#define sp putchar(' ')
#define ln putchar('\n')
#define pr64(x) printf("%I64d", (x))
#define rep(i,l,r) for (int i = l, lim = r;i <= lim; ++i)
#define repr(i,l,r) for (int i = r, lim = l;i >= lim; --i)
#define fi first
#define se second
#define SET(__set, val) memset(__set, val, sizeof __set)
#define prf(x) printf("%.20f", x)
typedef unsigned int uint;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define N 100010
#define M 1024
#define MOD 1000000007
void _add(int &a, int b){a = (a+b)%MOD;}
void _sub(int &a, int b){a = (a+MOD-b)%MOD;}
void _mul(int &a, int b){a = (ll)a*b%MOD;}
void _max(int &a, int b){a = max(a,b);}
void _min(int &a, int b){a = min(a,b);}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b,a%b);}
ll pw(ll a, ll b){ll res(1);while(b){if(b&1)res=res*a%MOD;a=a*a%MOD;b>>=1;}return res;}
ll pwM(ll a, ll b, ll mod){ll res(1);while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

const int infi = 2147483647;
const ll infl = 9223372036854775807ll;
const db PI = 3.14159265358979323846;

/*
struct E{
	int v, w, n;
}G[N];
int cnt, point[N];
void adde(int u, int v, int w = 0){
	G[++cnt]=(E){v,w,point[u]},point[u]=cnt;
	G[++cnt]=(E){u,w,point[v]},point[v]=cnt;
}
void Ginit(){
	cnt = 0;
	SET(point,0);
}
*/
/*
struct hh{
	int a, b;
	bool operator < (const hh &x) const{
		if(a==x.a)return b<x.b;
		return a<x.a;
	}
}a[N];
*/
int n, m, k,q;
int main(){
//	freopen("1", "r", stdin);
	sc(n);
	if(n<1200){
		puts("ABC");
	}else
	if(n<2800){
		puts("ARC");
	}else{
		puts("AGC");
	}
/*
	int Case;
	sc(Case);
	rep(ca, 1, Case){
	    printf("Case #%d: ", ca);
	}
*/
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#ifdef DEBUG
#include<conio.h>
#endif // DEBUG

int main () {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif // DEBUG

    int num;

    scanf("%d", &num);

    int minn;
    scanf("%d", &minn);
    int maxn = minn;
    long long sum = minn;

    int tmp;
    for (size_t i = 1; i < num; i++)
    {
        scanf("%d", &tmp);
        if(minn > tmp) minn = tmp;
        if(maxn < tmp) maxn = tmp;
        sum += tmp;
    }

    printf("%d %d %lld\n", minn, maxn, sum);

#ifdef DEBUG
    getch();
#endif // DEBUG
    return 0;
}




Measured memory_bytes: 2072
#include<stdio.h>
#include<ctype.h>
typedef long long LL;
const int sz=2e5;
int A[sz]={0},here[sz]={0},town[sz]={0};
inline LL IN(void)
{
  LL x=0,f=1;char c=getchar();
  while(!isdigit(c)&&c!='-')c=getchar();
  if(c=='-')f=-f,c=getchar();
  while(isdigit(c))x=x*10+c-48,c=getchar();
  return f*x;
}
int main(void)
{
  int N,i,j,x;LL K;
  N=IN(),K=IN();
  for(i=0;i<N;i++)A[i]=IN(),here[i]=-1;
  for(i=0,j=0;;i=A[i]-1,j++)if(here[i]<0)here[i]=j,town[j]=i;else{x=here[i];break;}
  if(K>=j)K=(K-x)%(x-j)+x;
  return printf("%d\n",town[K]+1),0;
}

Measured memory_bytes: 3864
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(
            new InputStreamReader(System.in));
        br.readLine();
        final String[] data = br.readLine().split(" ");
        long min = Long.parseLong(data[0]);
        long max = Long.parseLong(data[0]);
        long sum = 0;
        long num = 0;
        for (String s : data) {
            num = Long.parseLong(s);
            if (max < num) {
                max = num;
            } else if (num < min) {
                min = num;
            }
            sum += num;
        }
        System.out.println(min + " " + max + " " + sum);
    }
}

Measured memory_bytes: 28344
#include<stdio.h>

int main()
{
    int a,b,sum,sub,mul;

    scanf("%d%d",&a,&b);

    sum=a+b;
    sub=a-b;
    mul=a*b;
    if(sum>=sub&&sum>=mul)
    {
        printf("%d\n",sum);
    }

        else if(sub>=mul&&sub>=sum)
    {
        printf("%d\n",sub);
    }

    else
    {
        printf("%d\n",mul);
    }


    return 0;
}

Measured memory_bytes: 128