akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
    int k,s;
    cin>>k>>s;
    int cnt=0;
    for(int i=0;i<=k;i++){
    	for(int j=0;j<=k;j++){
    		int pp= s-i-j;
    		if(pp>=0 and pp<=k)cnt++;
    	}
    }
    cout<<cnt;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

int getMinCost(const std::vector<int> heights) {
  std::vector<int> dp(heights.size() + 10, 0);
  dp[0] = 0;
  dp[1] = std::abs(heights[1] - heights[0]);

  for (int i = 2; i < static_cast<int>(heights.size()); ++i) {
    const int h1 = std::abs(heights[i] - heights[i - 1]);
    const int h2 = std::abs(heights[i] - heights[i - 2]);
    dp[i] = std::min(dp[i - 1] + h1, dp[i - 2] + h2);
  }
  return dp[heights.size() - 1];
}

int main() {
  int n;
  std::cin >> n;
  std::vector<int> heights(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> heights[i];
  }
  std::cout << getMinCost(heights) << std::endl;
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int tree[2 * 40005];
template <class T>
struct Segtree {
  // vector<T> tree;
  int n;
  Segtree() = default;
  Segtree(int N) {
    n = N;
    memset(tree, 0, sizeof(int) * 2 * n);
  }
  void update(int i, T val) {
    int p = i + n;
    const T diff = val - tree[p];
    while (p) {
      tree[p] += diff;
      p /= 2;
    }
  }

  T query(int start, int end) {
    int l = n + start;
    int r = n + end - 1;
    T ret = 0;
    while (l <= r) {
      if (l & 1) {
        ret += tree[l];
        l++;
      }

      if ((r & 1) == 0) {
        ret += tree[r];
        r--;
      }
      l /= 2;
      r /= 2;
    }
    return ret;
  }
};
constexpr double eps = numeric_limits<double>::epsilon();
int gcd(int a, int b) {
  while (b) {
    int tmp = b;
    b = a % b;
    a = tmp;
  }
  return a < 0 ? -a : a;
}

int N;
int A[40005];
int B[40005];
int C[40005];
int rank2[40005];
int rank3[40005];

pair<double, int> kp[40005];
pair<double, int> xp[40005];

int countRev() {
  Segtree<int> st = Segtree<int>(N);
  int ret = 0;
  int *v = rank3;
  for (int i = 0; i < N; ++i) {
    const int c = v[i];
    st.update(c, 1);
    ret += st.query(c + 1, N);
  }

  return ret;
}
int countSmall(double x) {
  // calc point
  for (int i = 0; i < N; ++i) {
    xp[i].first = (C[i] - double(A[i]) * x) / B[i];
    xp[i].second = i;
  }

  sort(xp, xp + N);
  for (int i = 0; i < N; ++i) {
    rank2[xp[i].second] = i;
  }

  for (int i = 0; i < N; ++i) {
    rank3[rank2[kp[i].second]] = i;
  }

  return countRev();
}

double sol() {
  for (int i = 0; i < N; ++i) {
    kp[i].first = 1.0 * A[i] / B[i];
    kp[i].second = i;
  }

  // cout << endl;
  sort(kp, kp + N);
  double l = -1E9;
  double r = 1E9;
  double ret = r;
  const int k = (N * (N - 1) / 2 + 1) / 2;
  while (1) {
    double x = l + (r - l) / 2;
    // cout << "x: " << x << "  =========" << endl;
    if (countSmall(x) >= k) {
      ret = x;
      r = x - eps;
    } else {
      l = x + eps;
    }

    double diff = r - l;
    if (diff < 1E-9 || abs(diff / l) < 1E-9) break;
  }
  return ret;
}
int main() {
  // // cout << countRev({4, 3, 2, 1, 0}) << endl;
  ios::sync_with_stdio(false);
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> A[i] >> B[i] >> C[i];
    int g = gcd(A[i], B[i]);
    if (C[i]) g = gcd(g, C[i]);
    A[i] /= g;
    B[i] /= g;
    C[i] /= g;
  }
  double x = sol();
  for (int i = 0; i < N; ++i) {
    swap(A[i], B[i]);
  }
  double y = sol();
  cout << setprecision(11) << fixed << x << ' ' << setprecision(11) << fixed
       << y << endl;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    
    vector<bool> A(N, false);
    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;
        for (int i = 0; i < d; i++) {
            int k;
            cin >> k;
            k--;
            A[k] = true;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++)
        if (!A[i])
            ans++;
    cout << ans;
}

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

using namespace std;

#define INF 1001001001  //int32_t
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n;
    map<int,int> m;
    cin >>n;

    for (int i = 0; i < n; i++){
        int a;
        cin >>a;

        ++m[a];
        m[a] %= 2;
    }

    for(auto p : m){
        if(p.second == 1)ans++;
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 4992
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    static String INPUT = "";

    public static void main(String[] args) {
        InputStream is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());

        Scanner scanner = new Scanner(is);

        final int n = scanner.nextInt();

        List<Schedule> scheduleList = new ArrayList<>();
        for (int i = 0; i < n - 1; i++) {
            scheduleList.add(
                    new Schedule(
                            scanner.nextInt(),
                            scanner.nextInt(),
                            scanner.nextInt()
                    )
            );
        }
        List<Integer> result = solve(scheduleList);
        for (Integer time : result) {
            System.out.println(time);
        }
    }

    static List<Integer> solve(List<Schedule> schedules) {
        List<Integer> ret = new ArrayList<>();
        for (int i = 0; i < schedules.size(); i++) {
            ret.add(solve(schedules, i));
        }
        ret.add(0);
        return ret;
    }

    static int solve(List<Schedule> schedules, int i) {
        if (i == schedules.size()) {
            return 0;
        }
        // freq : 2
        // time :0 => 0
        // time :1 => 1
        // time :2 => 0
        // freq : 5
        // time :0 => 0
        // time :1 => 4
        // time :2 => 3
        // time :3 => 2
        // time :4 => 1
        // time :5 => 0

        int currentTime = 0;
        for (int j = i; j < schedules.size(); j++) {
            Schedule schedule = schedules.get(j);
            if (schedule.startTime > currentTime) {
                currentTime = schedule.startTime + schedule.duration;
            } else {
                int mod = currentTime % schedule.frequency;
                if (mod > 0) {
                    currentTime += schedule.frequency - mod;
                }
                currentTime += schedule.duration;
            }
        }
        return currentTime;
    }

    static class Schedule {
        int duration;
        int startTime;
        int frequency;

        Schedule(int duration, int startTime, int frequency) {
            this.duration = duration;
            this.startTime = startTime;
            this.frequency = frequency;
        }
    }
}


Measured memory_bytes: 26400
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void puts_all(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void puts_all(const T &value, const Args&... args){std::cout << value << " ";puts_all(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int h, n;
  while(cin >> h >> n){
    vector<int> a(n); cin >> a;

    int s = accumulate(ALL(a), 0);

    cout << (h <= s ? "Yes" : "No") << endl;
  }


  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)
 
using namespace std;
#define ll long long
 
int main(){
  int N;
  ll K;
  cin >> N >> K;
  vector<int> digitK(40, 0);
  ll tmpK = K+1;
  for(int d=0; d<40; d++) {
    digitK[d] = tmpK % 2;
    tmpK /= 2;
    if(tmpK == 0)
      break;
  }
  vector<int> digits(40, 0);
  vector<ll> A(N);
  for(int i=0; i<N; i++) {
    cin >> A[i];
    ll tmpA = A[i];
    for(int d=0; d<40; d++) {
      digits[d] += tmpA % 2;
      tmpA /= 2;
      if(tmpA == 0)
	break;
    }
  }
  ll tmp = (K+1) & ~(1); // 0ビット目に0
  ll ans = 0;
  for(int d=0; d<40; d++) {
    if(digitK[d] == 1 && tmp <= K) {
      ll fx = 0;
      for(int i=0; i<N; i++)
	fx += tmp ^ A[i];
      ans = max(ans, fx);
    }
    if(digits[d] <= N - digits[d])
      tmp |= (1LL << d); // dビット目に1
    tmp &= ~(1LL << (d+1)); // d+1ビット目に0
  }
  cout << ans << endl;
  return 0;
}

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

template<typename T>
istream& operator >> (istream& istr, vector<T>& v){
    for(T& x: v) istr >> x;
    return istr;
}

template<typename T, typename U>
istream& operator >> (istream& istr, pair<T,U>& p){
    istr >> p.first >> p.second;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            // ostr << *itr;
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    // ostr << p.first << p.second;
    // ostr << p.first << ", " << p.second;
    ostr << "(" << p.first << ", " << p.second << ")";
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll v(n); v[i]=x;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll v(m,vll(n)); v[i][j]=x;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll v(n); v[i]=make_pair(x,y); v[i].first/second;
// v.front() : v[0]
// v.back()  : v[v.size()-1]

#define PI 3.1415926535897932
#define EPS 1e-12
#define INF ((ll)1e+12)
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<=(b); i++)
#define FORR(i,a,b) for(ll i=(b); i>=(a); i--)
#define fix(x) cout << fixed << setprecision(x)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()

template<typename T> T sum(vector<T>& v){return accumulate(all(v), (T)0);}
template<typename T> inline void sort(vector<T>& v){sort(all(v));}
template<typename T> inline void rsort(vector<T>& v){sort(all(v), greater<T>());}
template<typename T> inline void chmin(T& a, T b){if(a>b) a=b;}
template<typename T> inline void chmax(T& a, T b){if(a<b) a=b;}

int main(){
    string s;
    cin >> s;
    if(s=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}


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

int main() {
    int a, b, c, ans;
    cin >> a >> b >> c;
    ans = 0;
    for (int i = a; i <= b; ++i) {
        if (c % i == 0) {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define uii             unordered_map<int,int>
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
void S_K_S()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int32_t main()
{
	S_K_S();
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	int n;
	cin>>n;
	int a[n],b[n];
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	int m1=INT_MIN,m2=INT_MAX,m3=INT_MIN,m4=INT_MAX;
	for(int i=0;i<n;i++){
		int t1=a[i]+b[i];
		// cout<<t1<<endl;
		m1=max(t1,m1);
		m2=min(t1,m2);
		int t2=a[i]-b[i];
		m3=max(t2,m3);
		m4=min(t2,m4);
	}
	// cout<<m1<<endl;
	// cout<<m2<<endl;
	int opt1=m1-m2;
	int opt2=m2-m1;
	int opt3=m3-m4;
	int opt4=m4-m3;
	cout<<max(max(opt1,opt2),max(opt3,opt4));
}


Measured memory_bytes: 6712
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int min = sc.nextInt();
		int max = sc.nextInt();
		int a [] = new int[n];
		int sum = 0;
		for(int i = 0; i < n; i++) {
			a[i] = i+1;
			int e = a[i];
			int dig = 0;
			while(e != 0) {
				dig += e %10;
				e /= 10;
			}
			if(min <= dig && dig <= max) {
				sum += a[i];
			}
		}
		System.out.println(sum);
	}
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

#define OUT(a) { cout << int(a) << "\n"; exit(0); }

int main() {
  int d, n; cin >> d >> n;
  if (n < 100) OUT(n * pow(100, d));
  if (n == 100) OUT(pow(100, d) * 101);
}


Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
#include<bitset>
#include<string>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
using namespace std;


int main()
{
    int n;
    cin>>n;
    vector<int> a(n),b(n),c(n-1);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<n;i++) cin>>b[i];
    for(int i=0;i<n-1;i++) cin>>c[i];
    
    int ans=b[a[0]-1];
    for(int i=1;i<n;i++){
        ans+=b[a[i]-1];
        if(a[i]-a[i-1]==1) ans+=c[a[i-1]-1];
    }
    
    cout<<ans<<endl;
    return 0;
}


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

string encode(int i){
    string num=to_string(i);
    while(num.size()<6){
        num='0'+num;
    }
    return num;
}

int main(){

    int n,m;
    cin >> n>> m;
    vector<pair<int,int> > s(m);
    vector<int> p[n+1];

    rep(i,m){
        cin >> s[i].first >> s[i].second;
        p[s[i].first].push_back(s[i].second);
    }
    rep(i,n+1){
        sort(p[i].begin(),p[i].end());
    }
    for(int i=0;i<m;i++){
        auto it=lower_bound(p[s[i].first].begin(),p[s[i].first].end(),s[i].second);
        int t=distance(p[s[i].first].begin(),it);
        string ans = encode(s[i].first)+encode(t+1);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 7808
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
#include <set>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

const int MAX = 1000000 + 1000;

int main(){
  const int n = getInt();
  const int x = getInt();

  vector<int> d(n);
  vector<int> c(n);
  REP(i,n){
    d[i] = getInt();
    c[i] = getInt();
  }

  const int inf = 1 << 30;
  vector<int> dp(MAX, inf);

  typedef pair<int, int> data;
  priority_queue<data, vector<data>, greater<data> > pq;

  pq.push(data(0, 0));

  while(pq.size()){
    const data dt = pq.top(); pq.pop();
    const int pos = dt.second;
    const int cost = dt.first;

    if(dp[pos] < cost) continue;
    dp[pos] = cost;

    if(pos == x) break;

    REP(i,n){
      REP(j,2){
        const int next = pos + (j ? 1 : -1) * d[i];
        const int cc = cost + c[i];

        if(0 <= next && next < MAX && dp[next] > cc){
          dp[next] = cc;
          pq.push(data(cc, next));
        }
      }
    }
  }

  printf("%d\n", dp[x] == inf ? -1 : dp[x]);

  return 0;
}


Measured memory_bytes: 10208
#include<bits/stdc++.h>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;

int id[N],Sz[N],to[N << 1],nex[N << 1],beg[N];
ll D[N],Sum = 0;
int e;
struct node {
	int x,y;
}G[N];
map <ll,int> Map,Id;

inline void dfs(int x,int fa,int dis) {
	Sum += dis;
	for(int i = beg[x];i;i = nex[i]) {
		if(to[i] == fa) continue;
		dfs(to[i],x,dis + 1);
	}
}

inline ll read() {
	ll x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

inline void add(int x,int y) {
	to[++e] = y,nex[e] = beg[x],beg[x] = e;
}

int main() {

	int n = read(),rt = 0;
	For(i,1,n) Map[D[i] = read()] = i,Sz[i] = 1;
	sort(D + 1,D + n + 1,greater<ll>());
	For(i,1,n) Id[D[i]] = i;

	For(i,1,n - 1) {
		ll Pre = D[i] + Sz[i] * 2 - n,val = Id[Pre];
		if(!val || Pre >= D[i]) return puts("-1"),0;
		Sz[val] += Sz[i];
		G[i] = (node){Map[D[i]],Map[D[val]]};
		rt = Map[D[val]];
	}

	For(i,1,n - 1) add(G[i].x,G[i].y),add(G[i].y,G[i].x);
	
	dfs(rt,0,0);

	if(Sum != D[n]) return puts("-1"),0;

	For(i,1,n - 1) printf("%d %d\n",G[i].x,G[i].y);

	return 0;
}

Measured memory_bytes: 19200
#include<iostream>
using namespace std;
int a,b,c,sum5=0,sum7=0;
int main()
{
    cin>>a>>b>>c;
    if(a==5)sum5++;
    if(b==5)sum5++;
    if(c==5)sum5++;
    if(a==7)sum7++;
    if(b==7)sum7++;
    if(c==7)sum7++;
    if(sum5==2&&sum7==1)cout<<"YES";
    else cout<<"NO";
}

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    string s[3]; REPI(i, 3) cin >> s[i];
    cout << "A" << s[1][0] << "C";
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
using int64 = long long;

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> X(M);
  for (int i = 0; i < M; i++) {
    cin >> X[i];
  }
  if (M == 1 || N >= M) {
    cout << 0 << endl;
    return 0;
  }
  sort(X.begin(), X.end());
  vector<int> diff_store(M - 1);
  for (int i = 0; i < M - 1; i++) {
    diff_store[i] = X[i + 1] - X[i];
  }
  for (int &x : diff_store) {
    x = abs(x);
  }
  sort(diff_store.begin(), diff_store.end(), greater<int>());
  int skip_sum = 0;
  for (int i = 0; i < N - 1; i++) {
    skip_sum += diff_store[i];
  }
  cout << X[M - 1] - X[0] - skip_sum << endl;
  return 0;
}

Measured memory_bytes: 1024
# 行数を取得
num_lines = int(input())
li = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}

# 1行ずつ取り出し
for _ in range(num_lines):
    s = input()
    for key, value in li.items():
      if s.count(key) > 0 :
        li[key] = int(value) + 1

for key, value in li.items():
  print('{} x {}'.format(key, value))

Measured memory_bytes: 9140
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		int m = 1;
		
		int n = sc.nextInt();
		int [] a = new int[n];
		
		for(int i=0 ; i<n ; i++) {
			a[i] = sc.nextInt();
		}
		
		for(int j=n-1;j>0;j--) {
			for(int k=0;k<j;k++) {
				if(a[k]<a[k+1]) {
					int temp = a[k];
					a[k] = a[k+1];
					a[k+1] = temp;
				}
			}
		}
		
		for(int i=0 ; i<n-1 ; i++) {
			if(a[i]>a[i+1]) {
				m+=1;
			}
		}
		
		System.out.printf("%d\n",m);
	}
}


Measured memory_bytes: 21716
import copy

def dfs(ar, num, cnt):
  ar.append(num)
  if cnt < n-1:
    ans = 0
    for i in range(num, m+1):
      rep = dfs(copy.deepcopy(ar), i, cnt+1)
      ans = max([ans, rep])
    return ans
  else:
    ans = 0
    for i in range(q):
      if ar[abcd[i][1]-1] - ar[abcd[i][0]-1] == abcd[i][2]:
        ans += abcd[i][3]
    return ans

n,m,q = map(int, input().split())
abcd = [list(map(int, input().split())) for i in range(q)]

ans = 0
for i in range(1,m+1):
  a = []
  rep = dfs(copy.deepcopy(a), i, 0)
  ans = max([ans, rep])
print(ans)

Measured memory_bytes: 9288
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

struct comp {
	bool operator()(const pii &a, const pii &b) const{
		if(a.second >= 0 && b.second >= 0){
			return a.first < b.first;
		}
		else if(a.second >= 0 && b.second < 0){
			return 1;	
		}
		else if(a.second < 0 && b.second >= 0){
			return 0;	
		}
		else{
			return a.first + a.second > b.first + b.second;
		}
	}
};

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<pii> v(n);
	rep(i,0,n){
		string s;
		cin >> s;
		int m = 0, d = 0;
		for(char c:s){
			d += c == '('?1:-1;
			gmin(m,d);
		}
		m=-m;
		v[i] = {m,d};
	}
	sort(all(v),comp());
	int cur = 0;
	bool val = true;
	rep(i,0,n){
		if(cur < v[i].first){
			val = false;
			break;
		}
		else{
			cur += v[i].second;
		}
	}
	val &= cur == 0;
	cout << (val?"Yes":"No") << '\n';
}


Measured memory_bytes: 11032
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;

const int maxn = 200020;

ll n,ans,cntw;
string s;

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

int main(){
	ans=0,cntw=0;
	cin>>s;
	n = s.size();
	
	for(ll i = 0;i < n;i++){
		if(s[i]=='W'){
			++cntw;
			ans+=i;
		}
	}
	ans-=(cntw-1ll)*cntw/2; 
	printf("%lld\n",ans);
	
	return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=100100100;
const ll  INF=1000000000000000100;//10の18乗
const int mod=(int)1e9+7;

int n,q;
vector<vector<int>>g;
vector<ll>c;
void dfs(int pa,int i){
    for(auto ch:g.at(i)){
        if(ch==pa)continue;
        c.at(ch)+=c.at(i);
        dfs(i,ch);
    }
}
int main(){
    cin>>n>>q;
    g.resize(n);
    c.resize(n);
    rep(i,0,n-1){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        g.at(a).push_back(b);
        g.at(b).push_back(a);
    }
    rep(i,0,q){
        int p,x;
        cin>>p>>x;
        p--;
        c.at(p)+=x;
    }
    dfs(0,0);
    rep(i,0,n){
        cout<<c.at(i)<<endl;
    }
return 0;
}

Measured memory_bytes: 27392
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    int n;
    string s;
    cin >> n;
    cin >> s;
    vector<int> wcount(n, 0);
    vector<int> ecount(n, 0);
    if(s.front() == 'W')
    {
        wcount[0] = 1;
    }else{
        ecount[0] = 1;
    }
    for(int i = 1; i < n; i++)
    {
        if(s[i] == 'W')
        {
            wcount[i] = wcount[i - 1] + 1;
        }else{
            wcount[i] = wcount[i - 1];
        }
        if(s[i] == 'E')
        {
            ecount[i] = ecount[i - 1] + 1;
        }else{
            ecount[i] = ecount[i - 1];
        }
    }
    int max_count = n;
    if(s.front() == 'W')
    {
        max_count = ecount.back();
    }else{
        max_count = wcount.back();
    }
    for(int i = 1; i < n; i++)
    {
        int temp = wcount[i - 1] + (ecount[n - 1] - ecount[i]);
        max_count = min(temp, max_count);
    }
    cout << max_count << endl;
    return 0;
}


Measured memory_bytes: 3076
def make_divisors(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if(n%i==0):
            divisors.append(i)
            divisors.append(n//i)
    return divisors
    
def factorization(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct
    
def main():
    n=int(input())
    ans=1
    cnt={}
    for i in range(1,n+1):
        fact=factorization(i)
        for s in fact:
            if s not in cnt:
                cnt[s]=1
            else:
                cnt[s]+=1
    for value in cnt.values():
        ans=ans*(value+1)%(10**9+7)
    print(ans)
main()
    
    

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

using namespace std;

int main()
{
    string a,b;
    cin>>a>>b;
    int len=a.size();
    int ans=0;
    for(int i=0;i<len;i++)
    {
        if(a[i]!=b[i])
            ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3916
#include<iostream>
#include<cstdio>
#include<map>
#include<set>
#include<queue>
using namespace std;
const int N=100001;
int n;
map<pair<int,int>,int> book;
set<int> e[N];
queue<pair<int,int> >q;
int f[N];
int find(int v)
{
	if(v==f[v]) return v;
	f[v]=find(f[v]);
	return f[v];
}
pair<int,int> make(int x,int y)
{
    if(x>y) swap(x,y);
    return make_pair(x,y);
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    	f[i]=i;
    for(int i=1;i<=(n-1)*2;i++)
	{
        int x,y;
        scanf("%d%d",&x,&y);
        e[x].insert(y);
		e[y].insert(x);
        pair<int,int> t=make(x,y);
        book[t]++;
        if(book[t]==2) q.push(t);
        if(book[t]>2)
        {
        	printf("NO");
        	return 0;
		}
    }
    for(int i=1;i<n;i++)
	{
        if(q.empty())
        {
        	printf("NO");
        	return 0;
		}
        int x=0,y=0;
        while(x==y)
        {
        	x=find(q.front().first),y=find(q.front().second);
        	q.pop();
		}
        if(e[x].size()>e[y].size()) swap(x,y);
        f[x]=y;
        for(set<int>::iterator it=e[x].begin();it!=e[x].end();it++)
		{
            int v=find(*it);
            e[v].erase(e[v].find(x));
            if(v==y) continue;
            e[v].insert(y),e[y].insert(v);
            pair<int,int> t=make(v,y);
            book[t]++;
            if(book[t]==2) q.push(t);
        }
        e[x].clear();
    }
    printf("YES");
    return 0;
}

Measured memory_bytes: 40832
# 2**nの繰り返し二乗法によるあまり計算
def mpow(a,n,mod):
  if n == 0:
    return 1
  elif n == 1:
    return a
  elif n%2==0:
    return (pow(a,n//2,mod))**2%mod
  else:
    return a*pow(a,n-1,mod)%mod
# 2項係数のあまり計算
def mfac(l,r,mod):
  ans = l
  for i in reversed(range(r,l)):
    ans *= i
    ans %= mod
  return ans
def mcomb(n,k,mod):
  A = mfac(n,n-k+1,mod)
  B = mfac(k,1,mod)
  B = mpow(B,mod-2,mod)
  return A*B%mod
 
def main():
  mod = 10**9+7
  n,a,b = map(int,input().split(" "))
  ans = mpow(2,n,mod)-1-mcomb(n,a,mod)-mcomb(n,b,mod)
  ans %= mod
  print(ans)
 
if __name__ == "__main__":
  main()

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

#define FOR(i,S,E) for(int i=S; i<E; i++)
#define ri(x) scanf("%d", &x)
#define fst first
#define snd second

const int MAXK = 1e5+10;
int K, vis[MAXK];
int main() {
    ri(K);
    deque<ii> dq;
    dq.push_back({1, 0});
    while(dq.size()) {
        ii u = dq.front();
        dq.pop_front();
        if (u.fst == 0) {
            printf("%d\n", u.snd+1);
            return 0;
        }
        vis[u.fst] = true;
        if (!vis[(u.fst+1)%K])
            dq.push_back({(u.fst+1)%K, u.snd+1});
        if (!vis[(u.fst*10)%K])
            dq.push_front({(u.fst*10)%K, u.snd});
    }
}


Measured memory_bytes: 1152
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline
H,W = map(int,input().split())
a=[[0] for f in range(H)]
ans=[]
for i in range(H):
 a[i]=list(map(int,input().split()))
for i in range(H):
 for j in range(W-1):
  if a[i][j]%2==1 :
   ans.append([i+1,j+1,i+1,j+2])
   a[i][j+1]+=1
for i in range(H-1):
 if a[i][W-1]%2==1 :
  ans.append([i+1,W,i+2,W])
  a[i+1][W-1]+=1
print(len(ans))
for i in ans:
 print(*i) 


Measured memory_bytes: 69596
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <stack>
#include <queue>
#include <array>
#include <random>
#include <chrono>

using namespace std;
#define rep(i, a, n) for (int i = a; i < n; ++i)
#define per(i, a, n) for (int i = n - 1; i >= a; --i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef int64_t i64;
typedef uint64_t ui64;
typedef pair<int, int> pi;

struct custom_hash {
    static ui64 splitmix64(ui64 x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(ui64 x) const {
        static const ui64 FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template <class T, class U>
inline ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << p.first << ' ' << p.second;
    return os;
}
template <class T, class U>
inline istream& operator>>(istream& os, pair<T, U>& p) {
    os >> p.first >> p.second;
    return os;
}
template <class T>
inline ostream& operator<<(ostream& os, const vector<T>& v) {
    if (v.empty())
        return os;
    if (v.begin() != v.end())
        os << v.front();
    for (auto it = ++v.begin(); it != v.end(); ++it)
        os << ' ' << *it;
    return os;
}
template <class T>
inline istream& operator>>(istream& is, vector<T>& v) {
    for (auto& i : v)
        is >> i;
    return is;
}

template <class T, size_t N>
inline istream& operator>>(istream& is, array<T, N>& a) {
    for (auto& i : a)
        is >> i;
    return is;
}

inline void Solve(istream& is, ostream& os) {
    i64 n, x;
    is >> n >> x;
    vector<i64> input(n);
    is >> input;

    i64 ans = 0;
    rep(i, 0, n) {
        i64 diff = ((i ? input[i - 1] : 0) + input[i]) - x;
        if (diff <= 0) {
            continue;
        }
        input[i] -= diff;
        ans += diff;
    }
    os << ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << setprecision(20) << fixed;
    Solve(cin, cout);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
	string S,T;
	cin>>S>>T;
	if((S.at(2)==T.at(0))&&(S.at(0)==T.at(2))&&(S.at(1)==T.at(1))){
		cout<<"YES"<<endl;
	}
	else{cout<<"NO"<<endl;}
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

p = int(input())
A = tuple(map(int, input().split()))
B = [0]*p
U = p-1
MOD = p
 
fact = [1]*(U+1)
fact_inv = [1]*(U+1)
 
for i in range(1,U+1):
    fact[i] = (fact[i-1]*i)%MOD
fact_inv[U] = pow(fact[U], MOD-2, MOD)
 
for i in range(U,0,-1):
    fact_inv[i-1] = (fact_inv[i]*i)%MOD

def comb(n, k):
    if k < 0 or k > n:
        return 0
    z = fact[n]
    z *= fact_inv[k]
    z %= MOD
    z *= fact_inv[n-k]
    z %= MOD
    return z

for j, a in enumerate(A):
  if a:
    B[0] += 1
    temp = 1
    for i in range(p-1, -1, -1):
      B[i] -= (-1)**(i%2) * temp * comb(p-1, i)
      temp *= j
      temp %= p
      B[i] %= p
print(*B)

Measured memory_bytes: 74908
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

ll dp[60][60][3000];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,a;
    cin >> n >> a;
    vi x(n);
    cin >> x;
    dp[0][0][0] = 1;
    rep(i,n) rep(j,60) rep(k,3000) {
        dp[i+1][j][k] += dp[i][j][k];
        if(k >= x[i] && j > 0) dp[i+1][j][k] += dp[i][j-1][k-x[i]];
    }
    ll ans = 0;
    rep2(i,1,60) ans += dp[n][i][a*i];
    cout << ans << endl;
}


Measured memory_bytes: 72576
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int A, B, C, D; cin >> A >> B >> C >> D;
	int x = 0;
	while (A > 0 && C > 0) {
		if (x % 2 == 0) {
			C -= B;
			x++;
		}
		else {
			A -= D;
			x++;
		}
	}
	cout << (A > 0 ? "Yes" : "No") << "\n";

	return 0;
}

Measured memory_bytes: 3604
from collections import defaultdict
h, w, m = map(int, input().split())
target = []
point = defaultdict(int)
count_target_of_y = defaultdict(int)
count_target_of_x = defaultdict(int)
for i in range(m):
    x, y = map(int, input().split())
    count_target_of_y[y] += 1
    count_target_of_x[x] += 1
    point[(x,y)] += 1
max_x_count = max(list(count_target_of_x.items()), key=lambda x:x[1])[1]
max_y_count = max(list(count_target_of_y.items()), key=lambda x:x[1])[1]
max_x_count_list = [i for i in count_target_of_x.items() if i[1] == max_x_count]
max_y_count_list = [i for i in count_target_of_y.items() if i[1] == max_y_count]
for x in max_x_count_list:
    for y in max_y_count_list:
        if point[(x[0], y[0])] == 0:
            print(max_x_count + max_y_count)
            exit()
print(max_x_count + max_y_count - 1)


Measured memory_bytes: 240692
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(pair<int, int> a, pair<int, int> b) {
	return a < b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	int n;
	cin >> n;
	vint a(n);
	rep(i, n) {
		cin >> a[i];
	}
	bool ans = true;
	int now = a[0];
	rep(i, n) {
		now = max(a[i], now);
		if (now - 2 >= a[i]) {
			ans = false;
			break;
		}
	}
	Yes(ans);
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int solve(int,int,int,int * );

int main(){
  int i,n,A[2001],m,q;

  scanf("%d",&n);

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

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&m);

    if(solve(0,m,n,A)) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

int solve(int i,int m,int n,int A[]){
  int res;
  if(m==0) return 1;
  if(i>=n) return 0;

  res = solve(i+1,m,n,A) || solve(i+1,m-A[i],n,A);
  return res;
}



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

int main() {
  int A, B, X;
  cin >> A >> B >> X;
  bool ok = X <= A + B && A <= X;

  if (ok) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = [int(i) for i in input().split()]


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors


lst = make_divisors(sum(A))

for l in lst:
    cnt_m, cnt_p = 0, 0
    ml = sorted([i % l for i in A])
    for m in ml:
        if cnt_m <= K-m:
            cnt_m += m
        else:
            cnt_p += l-m
    if cnt_m <= K and cnt_p <= K:
        print(l)
        exit()
print(1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>  // ver2.3.1
#define int long long
#define endl "\n"
#define ALL(v) (v).begin(),(v).end()
#define COUNT(a,k) upper_bound(ALL(a),k)-lower_bound(ALL(a),k)
#define BIGGER(a,k) a.end()-upper_bound(ALL(a),k)
#define SMALLER(a,k) lower_bound(ALL(a),k)-a.begin()
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Pii pair<int,int>
#define VPii vector<Pii>
#define Tiii tuple<int,int,int>
#define PQi priority_queue<int>
#define PQir priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define itos to_string
#define stoi stoll
#define FI first
#define SE second
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define cyes cout<<"yes"<<endl
#define cno cout<<"no"<<endl
#define _ <<' '<<
#define sortr(v) sort(v,greater<>())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define dem(a,b) ((a+b-1)/(b))
#define Vin(a) rep(iI,0,a.size())cin>>a[iI]
#define Vout(a) rep(lZ,0,a.size()-1)cout<<a[lZ]<<' ';cout<<a.back()<<endl
#define VVout(a) rep(lY,0,a.size()){if(!a[lY].empty()){Vout(a[lY]);}else cout<<endl;}
#define VPout(a) rep(lX,0,a.size())cout<<a[lX].FI<<' '<<a[lX].SE<<endl
#define Verr(a) rep(iZ,0,a.size()-1)cerr<<a[iZ]<<' ';cerr<<a.back()<<endl
#define VVerr(a) rep(J,0,a.size()){if(!a[J].empty()){Verr(a[J]);}else cerr<<'.'<<endl;}
#define VPerr(a) rep(iX,0,a.size())cerr<<a[iX].FI<<' '<<a[iX].SE<<endl
#define INF 3000000000000000000  //  3.0*10^18(MAXの1/3くらい)
#define MAX LLONG_MAX
#define PI 3.141592653589793238462
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm
int mypow(int x, int n, int m){  //  累乗x^n(mod m)  O(log(n))
if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int scomb(int n, int r){if((n-r)<r)r=n-r;  //  nCr (小さい場合)
int a=1;for(int i=n;i>n-r;--i){a=a*i;}for(int i=1;i<r+1;++i){a=a/i;}return a;}
int comb(int n, int r){if((n-r)<r)r=n-r;  //  nCr (%MOD)
int a=1;for(int i=n;i>n-r;--i){a=a*i%MOD;}for(int i=1;
i<r+1;++i){a=a*mypow(i,MOD-2,MOD)%MOD;}return a%MOD;}
int stpow(int n){  //  階乗(%MOD)
if(n==0)return 1;int a=1;rep(i,1,n+1)a=a*i%MOD;return a;}
Vi stpowV(){Vi a(100001);  //  階乗配列(%MOD)
a[0]=1;repeq(i,1,100000)a[i]=a[i-1]*i%MOD;return a;}
void press(auto &v){v.erase(unique(ALL(v)),v.end());}  //  圧縮



signed main() {
  cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(12);
  int m;
  int ans = 0;
  cin >> m;
  int keta = 0,digisum = 0;
  
  ans--;
  int qw,er;
  
  rep(i,0,m){
    cin >> qw >> er;
    ans += er;
    digisum += qw*er;
    
    if((digisum%9)==0){
      ans += (digisum/9)-1;
      digisum = 9;
    }
    
    else {
      ans += digisum/9;
      digisum %= 9;
    }
    
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

struct Point {
	int x, y;
};

int point_length(Point p1, Point p2) {
	return abs(p1.x - p2.x) + abs(p1.y - p2.y);
}

int main() {
	int time, x, y;
	Point current_p, next_p;
	current_p.x = 0;
	current_p.y = 0;

	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> time >> next_p.x >> next_p.y;
		int len = point_length(next_p, current_p);
		if (time < len) {
			cout << "No" << endl;
			return 0;
		}
		else {
			if ((time - len) % 2 != 0) {
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;
}


Measured memory_bytes: 256
import sys
from itertools import combinations_with_replacement
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


N, M, Q = readnums()
num_list = [list(readnums()) for _ in range(Q)]

ans = 0
for v in combinations_with_replacement(range(1, M + 1), N):
    val = 0
    for n in num_list:
        if v[n[1] - 1] - v[n[0] - 1] == n[2]:
            val += n[3]
    ans = max(ans, val)

print(ans)


Measured memory_bytes: 9152
N = int(input())
H = list(map(int, input().split()))

# 各山のたかさを１個ずつみて
# その時点の最大値より高い山が出るたびにカウントアップ
cnt = 1  # H1は必ず1なので
maxHeight = H[0]
for i in range(1, N):
   if H[i] >= maxHeight :
       cnt += 1
       maxHeight = H[i]

print(cnt)

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

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

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	cout<<n*n*n<<endl;
}

Measured memory_bytes: 256