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

template <typename InputIterator>
typename InputIterator::value_type
summation(InputIterator first, InputIterator last) {
  using T = typename InputIterator::value_type;
  T *p = new T();
  const auto sum = std::accumulate(first, last, *p);
  delete p;
  return sum;
}
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream& operator>> (std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream& operator>> (std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}
template <typename T>
std::vector<T> prime(const T max) {
  std::vector<bool> sieve(max - 1, true);
  const auto lim = std::floor(std::sqrt(max));

  if (max < 2) {
    return {};
  }

  T var = 2;
  while (var <= lim) {
    for (T i = 2; i * var <= max; i++) {
      sieve[i * var - 2] = false;
    }
    do {
      var++;
    } while (!sieve[var - 2] && var <= lim);
  }

  std::vector<T> ans;
  ans.reserve(std::count(sieve.cbegin(), sieve.cend(), true));
  for (T i = 0; i < max - 1; i++) {
    if (sieve[i]) {
      ans.push_back(i + 2);
    }
  }

  return ans;
}


int main() {
  int64_t n;
  std::cin >> n;
  int64_t i = 1;

  const auto p = prime(n);
  for (const auto j : p) {
    auto k = j;
    int64_t m = 0;
    while (k <= n) {
      m += n / k;
      k *= j;
    }
    m++;
    m %= 1000000007;
    i *= m;
    i %= 1000000007;
  }

  std::cout << i << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
int main(){
    cin>>N;
    string S;
    if(N==0){
        cout<<0;
        return 0;
    }
    ll n=2;
    for(ll i=0;N!=0;i++){
        if(N%n!=0){
            S+='1';
            N-= pow(-2,i);
        }else{
            S+='0';
        }
        n*=2;
    }
    reverse(S.begin(),S.end());
    cout<<S<<endl;
    return 0;
}

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

int main(){
  int N, m, s;
  string str;
  cin >> N >> str;
  m=s=0;
  
  for(int i=0 ; i<N ; i++)
    if(str[i]=='D')
      s--;
    else
      m=max(m, ++s);
  
  cout << m << endl;
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
void chmin(int& x, int y){
  if(x > y) x = y;
}
void chmax(int& x, int y){
  if(x < y) x = y;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  PII x, y;
  cin >> x.SS >> y.SS >> N;
  REP(i,N){
	int a,b,c; cin >> a >> b >> c;
	switch(c){
	  case 1:
		chmax(x.FF, a);
		break;
	  case 2:
		chmin(x.SS, a);
		break;
	  case 3:
		chmax(y.FF, b);
		break;
	  case 4:
		chmin(y.SS, b);
		break;
	}
  }

  cout << max(0, x.SS - x.FF) * max(0, y.SS - y.FF) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int n,k;
	scanf("%d %d",&n,&k);
	long long int score[n];
	for (int i = 0; i < n; i++)
	{
		scanf("%lld",&score[i]);
	}
	for (int i = 0, j = k; i < n-k; i++,j++)
	{
		if (score[j-k] < score[j])
		{
			printf("Yes\n");
		}
		else if (score[j-k] >= score[j])
		{
			printf("No\n");
		}
	}
	return 0;
}

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

typedef struct water{
  double t;
  int v;
} node;

void run(void){
  int n,l;
  scanf("%d%d",&n,&l);
  node *q=(node *)calloc(n,sizeof(node));
  int front=0;
  int last=0;
  double t;
  int v;
  scanf("%lf%d",&t,&v);
  printf("%.7f\n",t);
  q[last++]=(node){t,v};
  double qtv=t*v;
  int i;
  for(i=1;i<n;i++){
    node in;
    scanf("%lf%d",&in.t,&in.v);
    int sum=0;
    node p=q[front];
    while(sum+p.v<=in.v){
      qtv-=p.v*p.t;
      sum+=p.v;
      front++;
      p=q[front];
    }
    if(sum<in.v){
      qtv-=q[front].t*(in.v-sum);
      q[front].v-=in.v-sum;
    }
    qtv+=in.t*in.v;
    while(front<last && q[last-1].t>in.t){
      last--;
      p=q[last];
      in=(node){(in.t*in.v+p.t*p.v)/(in.v+p.v),in.v+p.v};
    }
    q[last++]=in;
    printf("%.7f\n",qtv/l);
  }
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 16768
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}


int main(int argc, char const *argv[]) {
    double r; cin>>r;
    cout << 2*r*3.141592 << '\n';
    return 0;
}

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

string X;
string Y;

int calc(int x, int y, vector<vector<int> >& Memo){
    if (X[x] == '\0' || Y[y] == '\0') return 0;
    if (Memo[x][y] != -1) return Memo[x][y];

    int unuse = calc(x + 1, y, Memo);
    int use = 0;
    int y_target = Y.find(X[x], y);
    if (y_target == string::npos) {
        use = 0;
    } else {
        use = calc(x + 1, y_target + 1, Memo) + 1;
    }
    return Memo[x][y] = max(unuse, use);
}

int main(){
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> X;
        cin >> Y;
        vector<int> tmp(Y.size(), -1);
        vector<vector<int> > Memo(X.size(), tmp);
        cout << calc(0, 0, Memo) << endl;
    }

    return 0;
}

Measured memory_bytes: 6788
#include <bits/stdc++.h>
int main() {
    int n;
    std::cin>>n;
    std::vector<int> costs;
    std::vector<int> values;
    std::vector<int> c_v;
    for(int i=0;i<n;i++){
        int t;
        std::cin>>t;
        values.push_back(t);
    }
    for(int i=0;i<n;i++){
        int t;
        std::cin>>t;
        costs.push_back(t);
    }
    for(int i=0;i<n;i++){
        int t;
        t = values[i]-costs[i];
        c_v.push_back(t);
    }
    int pr=0;
    for(int i =0; i<n;i++){
        if(c_v[i]>0){
            pr = pr + c_v[i];
        }
    }
    std::cout<<pr<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define M 11

int main(void){
  int i,num,j,k;
  int n[N];
  int mtrx[N][M][M];
  
  for(i=0;;i++){
    scanf("%d",&n[i]);
    if(n[i]==0){
      break;
    }
    for(j=0;j<=n[i];j++){
      for(k=0;k<=n[i];k++){
        mtrx[i][j][k]=0;
      }
    }
    for(j=0;j<n[i];j++){
      for(k=0;k<n[i];k++){
        scanf("%d",&mtrx[i][j][k]);
      }
    }
    for(j=0;j<n[i];j++){
      for(k=0;k<n[i];k++){
        mtrx[i][j][n[i]]+=mtrx[i][j][k];
        mtrx[i][n[i]][j]+=mtrx[i][k][j];
      }
    }
    for(j=0;j<n[i];j++){
      mtrx[i][n[i]][n[i]]+=mtrx[i][j][n[i]];
    }
  }
  num=i;
  for(i=0;i<num;i++){
    for(j=0;j<=n[i];j++){
      for(k=0;k<=n[i];k++){
        printf("%5d",mtrx[i][j][k]);
      }
      printf("\n");
    }
  }
  return 0;
}

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

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

    int n, a, b;
    string s;
    cin >> n >> a >> b >> s;

    int japanese = 0, overseas = 0;
    for(int i = 0; i < n; ++i) {
        if (s[i] == 'c') {
            cout << "No\n";
        } else if (s[i] == 'a') {
            if (a + b > japanese) {
                cout << "Yes\n";
                ++japanese;
            } else {
                cout << "No\n";
            }
        } else {
            ++overseas;
            if (a + b > japanese && overseas <= b) {
                cout << "Yes\n";
                ++japanese;
            } else {
				cout << "No\n";
			}
        }
    }

    return 0;
}


Measured memory_bytes: 848
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b; cin >> a >> b;
    if(a>=1 && a<=9) {
        if(b>=1 && b<=9) {
            cout << a*b << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define dunk(a) cout << (a) << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;

int main() {
	int n; cin >> n;
	map<string, int> mp;
	rep(i, n) {
		string s;
		cin >> s;
		mp[s]++;
	}

	int mx = 0;
	for (auto p : mp) mx = max(mx, p.second);

	for (auto p : mp) if (p.second == mx) dunk(p.first);

	return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

const ll mod = 1000000000 + 7;
int main(){
    ll n;
    cin >> n;
    VL a(n), acc(n+1, 0);
    rep(i, 0, n) cin >> a[i];
    for(ll i = n-1; i>=0; i--) acc[i] = (acc[i+1] + a[i]) % mod;
    ll ans = 0;
    rep(i, 0, n) {
        ans += (acc[i+1] * a[i]) % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6424
#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() {
    string S, T;
    cin >> S >> T;
    reverse(S.begin(), S.end());
    reverse(T.begin(), T.end());
    rep(i,S.size()-T.size()+1) {
        bool ok = true;
        rep(j,T.size()) {
            if (S.at(i + j) != '?' && S.at(i + j) != T.at(j)) {
                ok = false;
                break;
            }
        }
        if (ok) {
            rep(j,T.size()) S.at(i + j) = T.at(j);
            rep(j,S.size()) if (S.at(j) == '?') S.at(j) = 'a';
            reverse(S.begin(), S.end());
            cout << S << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
}



Measured memory_bytes: 3636
function Main(input) {
  a = input.split(' ')[0] * 1
  b = input.split(' ')[1] * 1
  ans = 0
  if (a >= 13) {
      ans = b 
  } else if (a >= 6) {
      ans = b / 2
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

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

  int cnt1 = 0; // s[0] == '0'
  for (int i=0; i<s.length(); i++) {
    if (i % 2 == 0) {
      if (s[i] == '0') {
      } else {
        cnt1++;
      }
    } else {
      if (s[i] == '0') {
        cnt1++;
      } else {
      }
    }
  }
  int cnt2 = 0; // s[0] == '1'
  for (int i=0; i<s.length(); i++) {
    if (i % 2 == 0) {
      if (s[i] == '0') {
        cnt2++;
      } else {
      }
    } else {
      if (s[i] == '0') {
      } else {
        cnt2++;
      }
    }
  }

  cout << min(cnt1, cnt2) << endl;

  return 0;
}


Measured memory_bytes: 512
IDENTIFICATION DIVISION.
       PROGRAM-ID. test1.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 INP PIC X(100).
       01 A PIC 99999.
       01 B PIC 99999.
       01 temp1 PIC 9999.
       01 temp2 PIC 9999.
       01 N PIC 9999.
       01 RE PIC 9.
       PROCEDURE DIVISION.
       MAIN.
      	MOVE 0 TO RE.
       	ACCEPT INP.
      	PERFORM VARYING N FROM 1 BY 1 UNTIL N = 4
      		MOVE INP(N:1) TO A
      		IF A = 1 THEN
      			ADD 1 TO RE
      		END-IF
      	END-PERFORM.
      	DISPLAY RE.
        STOP RUN.




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

// next_permutation版

int main(){
    string S, T; cin >> S >> T;

    cout << T+S << endl;


    return 0;
}

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

int main() {
  int N, M;
  int s[N];
  int c[N];
  int out = 0;
  int d[N] = {};
  for(int i=0;i<N;i++){
    d[i] = 0;
  }

  cin >> N >> M;
  for(int i=0;i<M;i++){
    cin >> s[i] >> c[i];

    if(s[i] == 1 && c[i] == 0 && N != 1){
      out = -1;
    }
  }

  for(int i=0;i<M;i++){
    for(int j=0;j<M;j++){
      if(i != j){
        if(s[i] == s[j] && c[i] != c[j]){
          out = -1;
        }
      }
    }
  }

  if(out == -1){
    cout << -1;
  }else{
    for(int i=0;i<M;i++){
      d[s[i] - 1] = pow(10, (N-s[i])) * c[i];
    }
    if(d[0] == 0 && N > 1){
      d[0] = pow(10, N-1);
    }
    cout << d[0] + d[1] + d[2];
  }


}

Measured memory_bytes: 28928
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
struct node{
	int a,b;
	inline bool operator < (node x)const{
		return a<x.a;
	}
};
int main(){
	int n,m;
	cin>>n>>m;
	node a[n];
	for(int i=0;i<n;++i)
		cin>>a[i].a>>a[i].b;
	sort(a,a+n);
	int j=0;
	int sum=0;
	priority_queue<int>q;
	for(int i=1;i<=m;++i){
		while(a[j].a==i){
			q.push(a[j].b);
			++j;
		}
		if(!q.empty()){
			sum+=q.top();
			q.pop();
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1660
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
signed main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	printf("%d",((!(a-b))?(c):(((!(a-c))?(b):(a)))));
	return putchar(10),0;
}

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

int main(){
    string s;
    cin >> s;
    int num[26] = {0};
    for(int i = 0;i<s.size();i++){
        num[s[i]-'a']++;
    }
    for(int i = 0;i < 26;i++){
        if(!num[i]){
            char c = i + 'a';
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

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

#define FastRead        ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl            "\n"
#define sq(x)           ((x)*(x))
#define pi              acos(-1.0)
#define NUM             1000005

typedef long long ll;

int main()
{

    FastRead

    ll d,s,t;

    cin>>d>>s>>t;

    if(t*s>=d)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


Measured memory_bytes: 3532
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;

typedef long long int ll;

int main(){
    int N, Count=0;
    cin >> N;
    vector<int> L(N), V(10*10*10+1);
    for(int i=0; i<N; i++){
        cin >> L[i];
        for(int k=L[i]; k<V.size()+1; k++){
            V[k]++;
            }
        }
    sort(L.begin(), L.end());
    for(int i=0; i<N; i++){
        for(int k=i+2; k<N; k++){
            int c;
            c = L[k] - L[i];
            for(int l=i+1; l<k; l++){
                if(L[l]>c){
                    Count++;
                    }
                }

            }

        }
    cout << Count;
//    for(int i=0; i<V.size(); i++){
//            cout << V[i] << ", ";
//        }


}

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

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int N,t[10010],dp[2][2][5010];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>N;
	rep2(i,1,N)cin>>t[i];
	rep(i,2)rep(j,2)rep(k,N/2+1)dp[i][j][k]=INF;
	dp[0][0][0]=0;
	int cur=1,pre=0;
	rep(i,N){
		dp[cur][0][0]=INF;
		rep2(k,1,min(N/2,i+1)+1){
			dp[cur][0][k]=min(dp[pre][0][k-1],dp[pre][1][k-1]+t[i]);
		}
		rep(k,min(N/2,i)+1){
			dp[cur][1][k]=min(dp[pre][0][k]+t[i],dp[pre][1][k]);
		}
		cur^=1,pre^=1;
	}
	cout<<min(dp[pre][0][N/2],dp[pre][1][N/2])<<endl;
}

Measured memory_bytes: 1312
use std::io::BufRead;

fn main() {
    let stdin = std::io::stdin();
    let n = stdin.lock().gets().parse::<u32>().unwrap();
    println!("{}", n * (n + 1) / 2);
}

trait Gets { fn gets(&mut self) -> String; }
impl<T: std::io::BufRead> Gets for T {
    fn gets(&mut self) -> String { self.lines().next().unwrap().unwrap() } }


Measured memory_bytes: 4352
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
dp = [0] * (n + 1)
for i in range(m):
    dp[a[i]] = -1
#dp
mod = 10 ** 9 + 7
dp[0] = 1
if dp[1] != -1:
    dp[1] = 1
for i in range(2, n + 1):
    if dp[i - 1] == -1 and dp[i - 2] == -1:
        print(0)
        quit()
    if dp[i] == -1:
        continue
    if dp[i - 1] == -1:
        dp[i] = dp[i - 2]
    elif dp[i - 2] == -1:
        dp[i] = dp[i - 1]
    #dp[i] = max(dp[i - 1], dp[i - 2])
    else:
        dp[i] = dp[i - 1] + dp[i - 2]
    dp[i] %= mod 
    #dp[i] %= mod
#dp[n]
if dp[n] == -1:
    print(0)
else:
    print(dp[n])

Measured memory_bytes: 7848
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int h,w,n,a[SZ],x[233][233];
pii ps[SZ]; int g=0;
int main()
{
	scanf("%d%d%d",&h,&w,&n);
	for(int i=1;i<=n;++i)
		scanf("%d",a+i);
	for(int i=1;i<=h;++i)
	{
		if(i&1)
			for(int j=1;j<=w;++j) ps[++g]=pii(i,j);
		else
			for(int j=w;j>=1;--j) ps[++g]=pii(i,j);
	}
	int s=1;
	for(int i=1;i<=n;++i)
	{
		while(a[i]--)
		{
		pii w=ps[s++];
		x[w.fi][w.se]=i;
		}
	}
	for(int i=1;i<=h;++i,puts(""))
		for(int j=1;j<=w;++j) printf("%d ",x[i][j]);
}


Measured memory_bytes: 2432
import sys

input = sys.stdin.readline
N, Q = map(int, input().split())

s = input()

input = sys.stdin.readline
Query = [input().split() for i in range(Q)]

left, right = 0, N - 1

for t, d in reversed(Query):
    if d == "L":
        if t == s[left]:
            left += 1
        if right < N - 1 and t == s[right + 1]:
            right = min(right + 1, N - 1)
    else:
        if left > 0 and t == s[left - 1]:
            left = max(left - 1, 0)
        if t == s[right]:
            right -= 1
print(max(right - left + 1, 0))


Measured memory_bytes: 39348
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for (int i = 0; i < n; i++) { cin >> h[i]; }
    vector<int> g(n, 0);

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        if (g[a] < h[b]) { g[a] = h[b]; }
        if (g[b] < h[a]) { g[b] = h[a]; }
    }

    int ans = 0;

    for (int i = 0; i < n; i++) {
        if (g[i] == 0 || g[i] < h[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define int long long
int mod = 1e9+7;

signed main(){
    int N; cin >> N;
    vector<int> a(N), sum(N, 0);
    for(int i = 0; i < N; i++) cin >> a[i];
    int ans = 1;
    for(int i = 0; i < N; i++){
        if(a[i] != 0) ans *= (sum[a[i] - 1] - sum[a[i]]);
        if(a[i] == 0) ans *= (3 - sum[a[i]]);
        ans %= mod;
        sum[a[i]]++;
    }
    cout << ans << endl;
}

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

int main() {
  int N, A, B, X, Y;
  cin >> N >> A >> B;
  X = N * A;
  Y = B;
    if(X > Y)
      cout << Y << endl;
    if(X < Y)
      cout << X << endl;
    if(X == Y)
      cout << X << endl;
}

Measured memory_bytes: 256
from time import time
start_time = time()
D = int(input())
C = list(map(int,input().split()))
S = [list(map(int,input().split())) for i in range(D)]

INF = float('inf')
DF = 5000
last = [0] * 26
cur_ans = []
nexts = []
for i,s in enumerate(S):
    best_k = -1
    best_score = -INF
    scores = []
    for k,s in enumerate(s):
        score = s
        for j,c in enumerate(C):
            if j==k: continue
            score -= c * (i+1 - last[j])
        if score > best_score:
            best_score = score
            best_k = k
        scores.append((score,k))
    last[best_k] = i+1
    cur_ans.append(best_k + 1)
    for sc,k in scores:
        if k==best_k: continue
        if sc < best_score - DF: continue
        nexts.append((best_score-sc, i,k))
nexts.sort(key=lambda x:x[0])

def evaluate(ans):
    last = [0] * 26
    score = 0
    for i,(s,a) in enumerate(zip(S,ans)):
        score += s[a-1]
        last[a-1] = i+1
        for j,c in enumerate(C):
            score -= c * (i+1 - last[j])
    return score + 10**6

cur_score = evaluate(cur_ans)
selects = [-1] * D
for _,ni,nk in nexts:
    if selects[ni] >= 0: continue
    last = [0] * 26
    ans = []
    for i,s in enumerate(S):
        if selects[i] >= 0:
            last[selects[i]] = i+1
            ans.append(selects[i] + 1)
            continue
        if i==ni:
            last[nk] = i+1
            ans.append(nk + 1)
            continue
        best_k = -1
        best_score = -INF
        for k,s in enumerate(s):
            score = s
            for j,c in enumerate(C):
                if j==k: continue
                score -= c * (i+1 - last[j])
            if score > best_score:
                best_score = score
                best_k = k
        last[best_k] = i+1
        ans.append(best_k + 1)
    sc = evaluate(ans)
    if sc > cur_score:
        cur_score = sc
        cur_ans = ans
        selects[ni] = nk
    if time() - start_time > 1.8:
        break

print(*cur_ans, sep='\n')

Measured memory_bytes: 71616
import java.io.*;
import java.math.BigInteger;
import java.util.Arrays;

public class Main implements Runnable {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }

    public void run() {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        int n = in.nextInt();
        int odd = 0;
        int even = 0;
        int ev4 = 0;
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            if (a % 4 == 0) ev4++;
            else if (a % 2 == 0) even++;
            else odd++;
        }
        if (odd == 0) {
            System.out.println("Yes");
            return;
        }
        if (even == 0) {
            if (odd <= ev4 + 1) System.out.println("Yes");
            else System.out.println("No");
            return;
        }
        if (odd <= ev4) System.out.println("Yes");
        else System.out.println("No");
    }
}

class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException {super(System.out);}
}
class ContestScanner implements Closeable {
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}

Measured memory_bytes: 40052
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
puts a[gets.to_i-1]

Measured memory_bytes: 14364
S = int(input())


def cmb(n, r, p):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = 1
    for i in range(n, n - r, -1):
        over = over * i % p
    under = 1
    for i in range(1, r + 1):
        under = under * i % p
    inv = pow(under, p - 2, p)
    return over * inv % p


M = 10 ** 9 + 7
ans = 0
for i in range(1, S):
    if S - 3 * i < 0:
        break
    ans += cmb(S - 3 * i + i - 1, i - 1, M)
    ans %= M
print(ans)


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

int main() {
	int n, m;
	cin >> n >> m;
	
	cout << (n-1) * (m-1) << endl;
	return 0;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

def min(a,b)
  return a>b ? b : a
end
class LazySegTree
  attr_accessor:node,:lazy,:lazyF,:n
  def initialize(n)
    @n=1
    @n*=2 while @n<n
    @node=array(2*@n-1,1,0)
    @lazy=array(2*@n-1,1,0)
  end

  def lazy_eval(i,l,r)
    unless @lazy[i].zero?
      @node[i]+=@lazy[i]
      if r-l>1
        @lazy[i*2+1]+=@lazy[i]
        @lazy[i*2+2]+=@lazy[i]
      end
      @lazy[i]=0
    end
  end
  def add(s,t,x,i,l,r)
    lazy_eval(i,l,r)
    return if r<=s or t<=l
    if s<=l and r<=t
      @lazy[i]=x
      lazy_eval(i,l,r)
    else
      mid=(l+r)/2
      add(s,t,x,i*2+1,l,mid)
      add(s,t,x,i*2+2,mid,r)
      @node[i]=min(@node[i*2+1],@node[i*2+2])
    end
  end

  def find(s,t,i,l,r)
    return 2**31-1 if r<=s or t<=l
    lazy_eval(i,l,r)
    return @node[i] if s<=l and r<=t
    mid=(l+r)/2
    leaf_l=find(s,t,i*2+1,l,mid)
    leaf_r=find(s,t,i*2+2,mid,r)
    return min(leaf_l,leaf_r)
  end
end

n,q=get_i
lst=LazySegTree.new(n)
q.times do
  query=get_i
  if query[0].zero?
    lst.add(query[1],query[2]+1,query[3],0,0,lst.n)
  else
    puts lst.find(query[1],query[2]+1,0,0,lst.n)
  end
end


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

int main(){
    string s, u, v;
    int q;
    cin >> s >> q;
    int rev = 0;
    for(int i = 0; i < q; i++){
        int t, f;
        char c;
        cin >> t;
        if(t == 1){
            rev = (rev+1)%2;
        }
        else{
            cin >> f >> c;
            if( (f == 1 && rev%2 == 0) || (f == 2 && rev%2 == 1) ){
                u = c + u;
            }
            else{
                v += c;
            }
        }
    }
    s = u + s + v;
    if(rev%2 == 1){
        reverse(s.begin(), s.end());
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 1360
N = int(input())
H = list(map(int, input().split()))
old = H[0]
ans = 0
a = 0
for i in range(1,N):
  if H[i] <= old:
    a += 1
  else:
    if a > ans:
      ans = a
    a = 0
  old = H[i]
if a > ans:
  ans = a
print(ans)
    

Measured memory_bytes: 20448
#include<iostream>
#include<bits/stdc++.h>
#define ll long long int
using namespace std;

int main()
{
	int n;
  cin>>n;
  int arr[n],a;
  ll min=1000000005,sum=0;
  int val=0;
  for(int i=0;i<n;i++)
  {
    cin>>a;
    if(a<0){
      val=1-val;
      a=-a;     
    }
      
    arr[i]=a;
    if(min>arr[i])min=arr[i];
    sum+=(ll)arr[i];
    //cout<<sum<<" ";
  }
  //cout<<endl;
  //cout<<min<<endl;
  if(val==0)
    cout<<sum<<endl;
  else
    cout<<(sum-2*min)<<endl;
  return 0;
}
  
  

Measured memory_bytes: 640
a = []
for i in range(3):
    a+=list(map(int,input().split()))
n = int(input())
b = [int(input()) for i in range(n)]
n_a = [0 for i in range(9)]
for i in b:
    for j in a:
        if i == j:
            n_a[a.index(j)]+=1


if n_a[0] !=0 and n_a[3] !=0 and n_a[6] !=0:
    print("Yes")
elif n_a[1] !=0 and n_a[4] !=0 and n_a[7] !=0:
    print("Yes")
elif n_a[2] !=0 and n_a[5] !=0 and n_a[8] !=0:
    print("Yes")
elif n_a[0] !=0 and n_a[1] !=0 and n_a[2] !=0:
    print("Yes")
elif n_a[3] !=0 and n_a[4] !=0 and n_a[5] !=0:
    print("Yes")
elif n_a[6] !=0 and n_a[7] !=0 and n_a[8] !=0:
    print("Yes")
elif n_a[0] !=0 and n_a[4] !=0 and n_a[8] !=0:
    print("Yes")
elif n_a[2] !=0 and n_a[4] !=0 and n_a[6] !=0:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
using namespace std;

class node{
public:
  int p = -1, l, r;
};


vector<node> t(100);
vector<int> s(100), c(100);

void pr(vector<node>& t, int i){
  if(i == -1) return;
  cout << " " << i;
  pr(t, t[i].l);
  pr(t, t[i].r);
  return;
}
void in(vector<node>& t, int i){
  if(i == -1) return;
  in(t, t[i].l);
  cout << " " << i;
  in(t, t[i].r);
  return;
}
void po(vector<node>& t, int i){
  if(i == -1) return;
  po(t, t[i].l);
  po(t, t[i].r);
  cout << " " << i;
  return;
}

int num = 0;
vector<int> ans;
void func(int l, int r){
  if(l >= r) return;
  int p = s[num];
  num++;
  for(int i = l; i < r; i++){
    if(p == c[i]){
      func(l, i);
      func(i + 1, r);
      ans.push_back(p);
    }
  }
  return;
}

void solve(){
  int n; cin >> n;
  for(int i = 0; i < n; i++){
    cin >> s[i];
  }
  for(int i = 0; i < n; i++){
    cin >> c[i];
  }
  func(0, n);
  for(int i = 0; i < ans.size() - 1; i++){
    cout << ans[i] << " ";
  }
  cout << ans[n - 1] << endl;
  return;
}

int main(){
  solve();
  return 0;
}



Measured memory_bytes: 3176
n, m = map(int, input().split())
e = []
for i in range(m):
  e.append(list(map(int, input().split())))

e.sort(key=lambda x:x[1])
ret = 0

l = 0
for i in range(m):
  if e[i][0] < l:
    continue
  else:
    l = e[i][1]
    ret += 1
    
print(ret)

Measured memory_bytes: 29072
package main

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

var scanner *bufio.Scanner

func printIt() {
	for {
		a := nextInt()
		op := nextString()
		b := nextInt()

		ans := 0

		if op == "+" {
			ans = a + b
		} else if op == "-" {
			ans = a - b
		} else if op == "*" {
			ans = a * b
		} else if op == "/" {
			ans = a / b
		} else {
			break
		}

		fmt.Println(ans)
	}
}

func nextInt() int {
	scanner.Scan()
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(1)
	}
	return num
}

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	printIt()
}



Measured memory_bytes: 1096
#include <stdio.h>

int main(int argc, char *argv[])
{
  int i, j, k, l;
  int sumlist[1000];

  for (i = 0; ; i++) {
    int n, x;
    scanf("%d %d", &n, &x);

    if (n == 0 && x == 0)
      break;
    
    sumlist[i] = 0;

    for (j = 0; j < n; j++) {
      for (k = j+1; k < n; k++) {
	if (j == k) 
	  continue;
	for (l = k+1; l < n ;l++) {
	  if (l == k || l == j)
	    continue;
	  
	  if (j + k + l + 3 == x)
	    sumlist[i] +=1;
	}
      }
    }
  }

  for (j = 0; j < i; j++)
    printf("%d\n", sumlist[j]);

  return 0;
}

Measured memory_bytes: 604
#include <stdio.h>
int main(){

  int n,num,amo,resnum=0,resamo=-1,i;

  scanf("%d",&n);

  for(i = 0; i < n; i++){

    scanf("%d %d",&num,&amo);

    if(amo > resamo){

      resamo=amo;
      resnum=num;

    } else if(amo == resamo && num < resnum){

      resnum=num;

    }

  }

  printf("%d %d\n",resnum,resamo);

  return 0;

}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ll i,j,n;
    string s,t;
    cin>>s>>t;
    n = s.length();
    ll m = t.length();
    ll ans = 1e18;
    for(i=0;i<n;i++)
    {
        if(i+m-1<n)
        {
            j = 0;
            ll k = i;
            ll val = 0;
            while(j<m)
            {
             if(s[k]!=t[j]) val++;
             k++;
             j++;
            }
            ans = min(ans,val);
        }
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3624
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
   int a,b;cin>>a>>b;
   cout<<(a+b+1)/2;
}



Measured memory_bytes: 256
_ = input()
t, desire = map(int, input().split())
places_h = map(int, input().split())

def desire_delta(place_h, t, desire):
  avg_tmp = t - place_h * 0.006
  return max(desire - avg_tmp, avg_tmp - desire)

res = [(idx, desire_delta(h, t, desire)) for idx, h in enumerate(places_h)]

sorted_res = sorted(res, key=lambda place: place[1])

print(sorted_res[0][0] + 1)

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9

int main(){
  ll N, A, B;
  cin >> N >> A >> B;
  if(abs(A-B) % 2 == 0){
    cout << abs(A-B) /2 << endl;
  }
  else{
    ll ans = min(max(A, B)-1, N-min(A,B));
    if(A > B){
      swap(A,B);
    }
    ans = min(ans, (B-A)/2+A);
    ans = min(ans, (B-A)/2+N-B+1);
    cout << ans << endl;
  }
  return 0;
}


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

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    int c = scan.nextInt();
    int x = scan.nextInt();
    int y = scan.nextInt();

    long ans = Long.MAX_VALUE;

//x,y<=10^5なので、最悪k=2*10^5
    for(int k = 0; k <= 100000; k++){
      long sum = c*2*k + a*Math.max(x-k, 0) + b*Math.max(y-k, 0);
      ans = Math.min(ans, sum);
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
 
 
auto solve(std::string O, std::string E){
    stringstream ss;
    for(int i = 0; i < E.size(); ++i) {
        ss << O[i] << E[i];
    }
    if(E.size() < O.size()) {
        ss << O[O.size()-1];
    }
    return ss.str();
}
 
int main(){
    string O;
    cin >> O;
    string E;
    cin >> E;
    auto result = solve(O, E);
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

int main() {
    LL N;
    scanf("%lld", &N);
    LL sum = 0;
    for (LL i = 1; i * i <= N; i++) {
        if (N % i == 0) {
           LL d1 = i - 1;
           LL d2 = (N / i) - 1;
           LL r1 = 0, r2 = 0;
           LL x1 = 0, x2 = 0;
           if (d1) r1 = N % d1, x1 = N / d1;
           if (d2) r2 = N % d2, x2 = N / d2;
           if (x1 == r1) sum += d1;
           if (x2 == r2) sum += d2;
        }
    }
    printf("%lld\n", sum);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main(){
  int n;
  string s;
  cin >> n >> s;

  vector<int> r,g,b;
  for(int i=0;i<n;i++){
    if(s[i] == 'R')
      r.emplace_back(i);
    if(s[i] == 'G')
      g.emplace_back(i);
    if(s[i] == 'B')
      b.emplace_back(i);
  }

  ll cnt = 0;
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      if(s[i] == s[j]) continue;

      bool isr = false,isb = false,isg = false;
      if(s[i] == 'R' || s[j] == 'R') isr = true;
      if(s[i] == 'G' || s[j] == 'G') isg = true;
      if(s[i] == 'B' || s[j] == 'B') isb = true;

      if(isr == true && isg == true){
        int x = lower_bound(b.begin(),b.end(),j) - b.begin();
        cnt += b.size()-x;
      }else if(isr == true && isb == true){
        int x = lower_bound(g.begin(),g.end(),j) - g.begin();
        cnt += g.size()-x;
      }else if(isg == true && isb == true){
        int x = lower_bound(r.begin(),r.end(),j) - r.begin();
        cnt += r.size()-x;
      }else{
        continue;
      }
      if(j+j-i < n){
        if(s[i]!=s[j+j-i] && s[j]!=s[j+j-i]){
          cnt--;
        }
      }
    }
  }

  cout << cnt << endl;
}


Measured memory_bytes: 3632
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[,] dist = new int[N, N];
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                dist[i, j] = cin.nextInt();
            }
        }

        long ans = 0;

        for (int i = 0; i < N; i++)
        {
            if (dist[i, i] != 0)
            {
                Console.WriteLine("-1");
                return;
            }
            for (int j = i + 1; j < N; j++)
            {
                if(dist[i,j] != dist[j, i])
                {
                    Console.WriteLine("-1");
                    return;
                }
                int minDist = int.MaxValue;

                for (int k = 0; k < N; k++)
                {
                    if (k == i || k == j) continue;
                    minDist = Math.Min(minDist, dist[i, k] + dist[k, j]);
                }

                if(minDist < dist[i, j])
                {
                    Console.WriteLine("-1");
                    return;
                }
                else if(minDist == dist[i, j])
                {
                    continue;
                }
                else
                {
                    ans += dist[i, j];
                }
            }
        }
        Console.WriteLine(ans);
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 19032
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

const int M = 1000005;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	vector<int> cnt(M);
	for (int x: a) {
		if (cnt[x] != 0) {
			cnt[x] = 2;
			continue;
		}
		for (int i = x; i < M; i+=x) cnt[i]++;
	}
    int ans = 0;
	for (int x : a) {
		if (cnt[x]==1) ans++;
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 7884
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
import copy
import numpy as np
import sys
INF = float('inf')
mod = 10**9+7


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

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    n, x, y = LI()
    d = [0]*n
    for i in range(1, n):
        for j in range(i + 1, n + 1):
            d[min(j - i, abs(x - i) + 1 + abs(j - y),
                  abs(y - i) + 1 + abs(j - x)) - 1] += 1
    for k in range(n-1):
        print(d[k])


if __name__ == "__main__":
    main()


Measured memory_bytes: 27384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    char c;
    cin >> c;

    cout << char(c + 1) << endl;

    return 0;
}

Measured memory_bytes: 256