akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main()
{
    int R,C;
    cin >> R >> C;

    char c[R][C];
    int cnt=0;
    REP(i,R){
        REP(j,C){
            cin >> c[i][j];
            if('#' == c[i][j])cnt++;
        }
    }

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

    vector<vint> dist(R,vint(C,-1));
    queue<pair<int,int>> que;

    dist[0][0] = 0;
    que.push(make_pair(0,0));

    while(!que.empty()){
        auto p = que.front();
        que.pop();
        int y,x;
        y = p.first;
        x = p.second;

        REP(dir,4){
            int ny = y + dy[dir];
            int nx = x + dx[dir];
            if(ny < 0 || nx < 0 || ny > R-1 || nx > C - 1)continue;
            if('#' == c[ny][nx])continue;
            if(dist[ny][nx] != -1)continue;
            dist[ny][nx] = dist[y][x] + 1;
            que.push(make_pair(ny,nx));
        }
    }

    if(dist[R-1][C-1] != -1){
        cout << (R*C - cnt - dist[R-1][C-1] - 1) << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
signed main(void) {
    int N, x;
    cin >> N >> x;
    int A[N];
    rep(i, N) cin >> A[i];
    int ans = INF;
    vector<int> Min(N, INF);
    for(int i = 0; i < N; i++)  //魔法の回数
    {
        int sum = x * i;
        rep(j, N) {
            Min[j] = min(Min[j], A[(j + i) % N]);
            sum += Min[j];
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> 
#include<ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define all(v) v.begin(),v.end() 
#define rev(v) v.rbegin(),v.rend()
#define ssd ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define inp 200005
#define en "\n"
using namespace std;
using namespace __gnu_pbds;

signed main() 
{
    ssd
    int i,j,k,n,m;
    cin>>n>>m;
    vector<string> v(n+5);
    for(i=1;i<=n;i++) {cin>>v[i]; v[i]="0"+v[i];}
    
    ll dp[n+5][m+5]={};
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(i==1 && j==1) {dp[i][j]=1; continue;}
            if(v[i][j]!='#')
            {
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
                dp[i][j] %= mod;
            }
        }
    }
    cout<<dp[n][m];
    return 0;             
}

Measured memory_bytes: 12572
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
using namespace std;

int main(){
    int N;cin>>N;
    vector<string> W(110);
    map<string,int> mp;
    bool b=true;
    cin>>W[0];
    mp[W[0]]++;
    for(int i=1;i<N;i++){
        cin>>W[i];
        mp[W[i]]++;
        if(W[i][0]!=W[i-1][W[i-1].size()-1])b=false;
        if(mp[W[i]]>1)b=false;
    }
    if(b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

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

    if (s[0] == 'S')
    {
        cout << "Cloudy" << endl;
    }
    else if (s[0] == 'C')
    {
        cout << "Rainy" << endl;
    }
    else
    {
        cout << "Sunny" << endl;
    }
    return 0;
}

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

using namespace std;

using ll = long long;
using Graph = vector< vector<int> >;

ll dfs(int cur, int par, const Graph& g, const vector<int>& c, vector<ll>& pena, vector<ll>& ans) {
    ll cnt = 0;
    ll prv_pena = pena[c[cur]];
    for (int nex : g[cur]) {
        if (nex == par) continue;
        pena[c[cur]] = 0;
        ll nex_cnt = dfs(nex, cur, g, c, pena, ans);
        ll tmp = nex_cnt - pena[c[cur]];
        ans[c[cur]] -= tmp * (tmp + 1) / 2;
        cnt += nex_cnt;
    }

    ++cnt;
    pena[c[cur]] = prv_pena + cnt;
    return cnt;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;

    vector<int> c(n);
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
        --c[i];
    }

    Graph g(n);
    for (int i = 1; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<ll> pena(n, 0);
    vector<ll> ans(n, (ll)n * (n + 1) / 2);
    ll cnt = dfs(0, -1, g, c, pena, ans);

    for (int i = 0; i < n; ++i) {
        ll tmp = cnt - pena[i];
        ans[i] -= tmp * (tmp + 1) / 2;
        cout << ans[i] << "\n";
    }
    return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	string st; cin >> st;
	int n = st.size();
	if (n&1) {
		cout << "No\n"; 
		return 0;
	}
	for (int i = 0; i < n; i++) {
		if ((i&1) && (st[i] != 'i')) {
			cout << "No\n"; 
			return 0;
		}
		if (!(i&1) && (st[i] != 'h')) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
}

Measured memory_bytes: 256
N, M = map(int, input().split())

abl1 = set()
abl2 = set()
for _ in range(M):
    ab = list(map(int,input().split()))
    if ab[0] == 1:
        abl1.add(ab[1])
    elif ab[1] == N:
        abl2.add(ab[0])


for i in abl1:
   if i in abl2:
       print("POSSIBLE")
       exit()
print("IMPOSSIBLE")

Measured memory_bytes: 18968
#include<bits/stdc++.h>
using namespace std;
int dp[105][100005],prefix[105][100005];
int n,k;
int arr[105];
const int MOD =1e9+7;



int main(){
    cin>>n>>k;

    for(int i=1;i<=n;i++)   cin>>arr[i];

    for(int i=0;i<=n;i++)
        dp[i][0]=prefix[i][0]=1;
    for(int i=0;i<=k;i++)
            prefix[0][i]=1;
    for(int i=1;i<=n;i++)
    for(int j=1;j<=k;j++){
        int first = (j - arr[i] - 1 >= 0)? prefix[i - 1][j - arr[i] - 1] : 0;
			int last = prefix[i - 1][j];
        dp[i][j]=(dp[i][j]+MOD+last-first)%MOD;
        prefix[i][j]=(prefix[i][j-1]+dp[i][j])%MOD;

    }
    cout<<dp[n][k];
}


Measured memory_bytes: 82176
using System;


    public static class Program
    {
        static void Main()
        {
        var j = 0;
            var data1 = int.Parse(Console.ReadLine().Trim());
        for (var i = 3; i <= data1; i++)
        {
            if (i % 3 == 0)
            {
                Console.Write(" " + i);
                
            }
            else if (i.ToString().Contains("3"))
            {
                Console.Write(" " + i);
               
            }

            


        }
        Console.WriteLine();
        

    }
        
        }


Measured memory_bytes: 17916
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
typedef long long ll;
const int MOD = 1000000007;
#define PI 3.141592653589
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (1) {
		c -= b;
		if (c <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
		a -= d;
		if (a <= 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<pair<ll, ll>> pll;
 
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}


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

  ll k, n;
  cin >> k >> n;
  vector<ll> a(n);
  for(ll i = 0; i < n; i++) cin >> a[i];

  vector<ll> dec(n);
  for(ll i = 0; i < n; i++) dec[i] = a[i] - k;

  ll maxlen = 0;
  for(ll i = 0; i < n-1; i++){
    maxlen = max(a[i+1] - a[i], maxlen);
  }
  maxlen = max(k - a[n-1] + a[0], maxlen);
  cout << k - maxlen << endl;
  return 0;
}

Measured memory_bytes: 3456
#include "bits/stdc++.h"
#include <random>

using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll D=365;
vi c(26);
vi last(26,-1);
vvi dat(D, vi(26));  // N * M の2次元配列
vvi AAlist(D, vi(D));  // N * M の2次元配列




ll calcscore(vi &Alist)
{
  for(ll i=0;i<26;i++){
    last[i]=-1;
  }
  

  ll sc=0;
  ll sct=0;
  ll l;
  ll id;
  ll factscore=0;
  for(ll i=0;i<D;i++){
    sc=-922337203685477580LL;
    for(ll j=0;j<26;j++){
      if (Alist[i]==j)continue;
      l=i-last[j];
      sct=l*c[j];
      factscore-=sct;
    }

    id=Alist[i];
    factscore+=dat[i][id];
    last[id]=i;
  }

  return factscore;
}



void makeseed(int xid,int startoffset)
{

  ll sc=0;
  ll sct=0;
  ll maxid=-1;
  ll factscore=0;
  
  for(ll i=0;i<26;i++){
    last[i]=startoffset-1;
  }

  for(ll i=startoffset;i<D;i++){
    sc=-922337203685477580LL;
    maxid=0;
    
    for(ll j=0;j<26;j++){
      ll l=i-last[j];
      l*=l;
      sct=l*c[j];
      factscore-=sct;
      sct=dat[i][j]+sct;
      if (sc<sct){
        sc=sct;
        maxid=j;
      }
    }
    factscore+=sc;
    last[maxid]=i;
    AAlist[startoffset][i]=maxid;
    //cout<<(maxid+1)<<endl;
  }


}





int main(){
  ll ans=0;
  cin>>ans;
  ll factscore=0;


  for(ll i=0;i<26;i++){
    cin>>c[i];
  }
  for(ll i=0;i<D;i++){
    for(ll j=0;j<26;j++){
      cin>>dat[i][j];
    }
  }


  for(ll i=0;i<D;i++){
    makeseed(0,i);
  }
  


  for(ll i=1;i<D;i++){
    for(ll j=0;j<i;j++){
      AAlist[i][j]=AAlist[i-1][j];
    }
  }
  
  ll score=-922337203685477580LL;
  ll ansid=0;
  for(ll i=0;i<D;i++){
    if (score<calcscore(AAlist[i])){
      ansid=i;
    }
    //cout<<calcscore(AAlist[i])<<endl;
  }



  for(ll i=0;i<D;i++){
    cout<<(AAlist[ansid][i]+1)<<endl;
  }

  


  return 0;
}

Measured memory_bytes: 4772
/**
 *    author:  tourist
 *    created: 08.10.2017 15:27:16       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  string s;
  cin >> s;
  cout << s.substr(0, s.length() - 8) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cassert>

#include <unordered_set>
#include <unordered_map>
#include <random>
#include <thread>
#include <chrono>

using namespace std;

#define all(c) c.begin(), c.end()
#define repeat(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x) 
#endif

typedef complex<double> point;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << "{";
    for(auto it = v.begin(); it != v.end(); ++it) {
        if(it != v.begin())
            os << ",";
        os << *it;
    }
    return os << "}";
}

using ll = int64_t;

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

    int a, b;
    cin >> a >> b;
    if (a+b == 15) {
        cout << "+" << endl;
    } else if(a*b == 15) {
        cout << "*" << endl;
    } else {
        cout << "x" << endl;
    }
    return 0;
}


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

ll solve(const int N, vector<pair<int, int>> v) {
  sort(v.begin(), v.end());
  v.emplace_back(N+1, 0);
  priority_queue<int, vector<int>, greater<>> q;
  int idx = 0;
  for (int i = 0; i <= N; i++) {
    while (v[idx].first == i) q.push(v[idx++].second);
    while (i < q.size()) q.pop();
  }
  ll res = 0;
  while (q.size()) {
    res += q.top();
    q.pop();
  }
  return res;
}

int main() {
  int T; cin >> T;
  while (T--) {
    ll res = 0;
    int N; cin >> N;
    vector<pair<int, int>> l, r;
    for (int i = 0; i < N; i++) {
      int K, L, R; cin >> K >> L >> R;
      res += min(L, R);
      if (L >= R) l.emplace_back(K, L - R);
      else r.emplace_back(N - K, R - L);
    }
    res += solve(N, l) + solve(N, r);
    cout << res << endl;
  }
}
      


Measured memory_bytes: 7288
#include <bits/stdc++.h>
#define ll long long int
#define pr pair<ll, ll>
#define tp tuple<ll, ll, ll>
using namespace std;
long long int mod = 1e9 + 7;

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

    ll x;
    cin >> x;
    ll ans = 0;
    ans += (x / 500) * 1000;
    x %= 500;
    x = x - x % 5;
    ans += x;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  string o,e;
  cin>>o;
  cin>>e;
  int n=e.size();
  rep(i,n)
    cout<<o[i]<<e[i];
  if(o.size()>e.size())
    cout<<o[o.size()-1];
  cout<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define MAXN 100
using namespace std;
int A[3][MAXN+5];
int dp[3][MAXN+5];
int N;
int main()
{
	scanf("%d",&N);
	for(int i=1;i<=2;i++)
		for(int j=1;j<=N;j++)
			scanf("%d",&A[i][j]);
	dp[1][1]=A[1][1];
	dp[2][1]=A[1][1]+A[2][1];
	for(int j=2;j<=N;j++)
	{
		dp[1][j]=dp[1][j-1]+A[1][j];
		dp[2][j]=max(dp[1][j]+A[2][j],dp[2][j-1]+A[2][j]);
	}
	printf("%d\n",dp[2][N]);
	return 0;
}

Measured memory_bytes: 128
n = int(input())

if n == 1:
    print(1)
    quit()
count = []
for i in range(2,n+1,2):
    c = 0
    while i % 2 == 0:
        i //= 2
        c += 1
    count.append(c)

ans = count.index(max(count))
print((ans+1)*2)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
void trace(int n, int arr[]){for(int i = 0; i < n; i++){cout << arr[i] << " ";} cout << endl << endl;}
const int N = 3005;
ll dp[N][N];
string s1, s2;
ll solve(int idx1, int idx2){
    if(idx1 >= s1.size() || idx2 >= s2.size())
        return 0;
    if(dp[idx1][idx2] != -1)
        return dp[idx1][idx2];
    ll mx = 0;
    if(s1[idx1] == s2[idx2])
        mx = solve(idx1 + 1, idx2 + 1) + 1;
    mx = max(mx, solve(idx1 + 1, idx2));
    mx = max(mx, solve(idx1, idx2 + 1));
    dp[idx1][idx2] = mx;
    return mx;
}
void print(int idx1, int idx2){
    if(idx1 >= s1.size() || idx2 >= s2.size())
        return;
    if(s1[idx1] == s2[idx2]){
        cout << s1[idx1];
        print(idx1 + 1, idx2 + 1);
    }
    else {
        if(dp[idx1][idx2] == solve(idx1 + 1, idx2))
            print(idx1 + 1, idx2);
        else
            print(idx1, idx2 + 1);
    }
}
int main()
{
    Hello
    memset(dp, -1, sizeof dp);
    cin >> s1 >> s2;
    solve(0, 0);
    print(0, 0);
    return 0;
}

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

class Dice {
private:
    int* face;
    int* relative;

public:
    Dice();
    ~Dice();
    void SetNumber(int index, int num);
    int ReturnRight(int top, int front);
};

Dice::Dice() {
    face = new int[6];
    relative = new int[55];
    relative[12] = relative[24] = relative[43] = relative[31] = 0;
    relative[3] = relative[35] = relative[52] = relative[20] = 1;
    relative[1] = relative[15] = relative[54] = relative[40] = 2;
    relative[4] = relative[45] = relative[51] = relative[10] = 3;
    relative[2] = relative[25] = relative[53] = relative[30] = 4;
    relative[13] = relative[34] = relative[42] = relative[21] = 5;
}

Dice::~Dice() {
    delete[] face;
    delete[] relative;
}

void Dice::SetNumber(int index, int num) {
    face[index] = num;
}

int Dice::ReturnRight(int top, int front) {
    int top_index, front_index;
    for (int i = 0; i < 6; ++i) {
        if (face[i] == top) top_index = i;
        if (face[i] == front) front_index = i;
    }
    return face[relative[top_index * 10 + front_index]];
}

int main() {
    Dice dice;
    int num;
    for (int i = 0; i < 6; ++i) {
        cin >> num;
        dice.SetNumber(i, num);
    }
    int time;
    cin >> time;
    int top, front;
    for (int i = 0; i < time; ++i) {
        cin >> top >> front;
        cout << dice.ReturnRight(top, front) << endl;
    }

    return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

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

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<double> v;
map<ll,ll> m;


int main()
{
	ll n;
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
	}

	int mem = 0;
	double min1 = INF;
	double min2 = INF;
	int sum = v.size();
	while (v.size() != 1) {
		min1 = INF;
		min2 = INF;
		for (int i = 0; i < v.size(); i++) {
			min1 = min(v[i], min1);
		}
		for (int i = 0; i < v.size(); i++) {
			if (v[i] == min1) {
				v.erase(v.begin() + i);
				break;
			}
		}
		
		for (int i = 0; i < v.size(); i++) {
			min2 = min(v[i], min2);
			mem = i;
		}
		for (int i = 0; i < v.size(); i++) {
			if (v[i] == min2) {
				v.erase(v.begin() + i);
				break;
			}
		}
		
		double tmp = (min1 + min2) / 2.0;

		v.push_back(tmp);
	}


	cout << v[0] << endl;

	return 0;
}





Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
#define MAX_N 100010
const ll R = 1e9 + 7;
 
int n, m, j = 0;
ll dp[MAX_N];

int main() {
    cin >> n >> m;
    int a[m + 1];
    for (int i = 0; i < m; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) {
        if (i <= 2) dp[i] = dp[i - 1] + 1;
        else dp[i] = (dp[i - 1] + dp[i - 2]) % R;
        if (i == a[j]) { dp[i] = 0; j++;}
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int h, w;
char field[100][100];
bool visit[100][100];
int dy[4] = {-1, 0, 1, 0};
int dx[4] = {0, 1, 0, -1};

void dfs(int y, int x, char c) {
  visit[y][x] = true;
  REP(i, 4) {
    int ny = y + dy[i];
    int nx = x + dx[i];
    if (0 <= ny && ny < h && 0 <= nx && nx < w && !visit[ny][nx] &&
        field[ny][nx] == c)
      dfs(ny, nx, c);
  }
}

int main() {
  while (true) {
    cin >> h >> w;
    if (h == 0 && w == 0) {
      return 0;
    }
    REP(i, h) REP(j, w) {
      cin >> field[i][j];
      visit[i][j] = false;
    }
    int ans = 0;
    REP(i, h) REP(j, w) {
      if (!visit[i][j]) {
        dfs(i, j, field[i][j]);
        ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3556
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	string s;
	cin >> s;
	vector<int>dp(1 << 26, MOD);
	dp[0] = 0;
	int cbit = 0;
	int ans = MOD;
	for (auto i : s) {
		ans = MOD;
		int box = i - 'a';
		cbit ^= (1 << box);
		for (int j = 0; j < 26; j++) {
			ans = min(ans, dp[cbit ^ (1 << j)] + 1);
		}
		ans = min(ans, dp[cbit] + 1);
		dp[cbit] = min(dp[cbit], ans);
		//cout << " ";
		//cout << ans << endl;
	}
	cout << ans << endl;
	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a;
  string s;
  cin >> a >> s;
  if (a >= 3200) {
    cout << s << endl;
  } else {
    cout << "red" << endl;
  }
  return 0;
}


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

class CTrump{

public:
    CTrump(char mark);
    virtual ~CTrump();
    char getMark(void);
    void setNumber(const unsigned int number);
    bool checkNumber(const unsigned int number);
private :
    CTrump(){};

    char m_mark;
    bool m_card[13];
};

CTrump::CTrump(char mark){
    m_mark = mark;
    for(int i = 0 ; i < 13 ; i++){
        m_card[i] = false;
    }
}

CTrump::~CTrump(){
    ;//???????????????
}

char CTrump::getMark(void){
    return m_mark;
}
void CTrump::setNumber(const unsigned int num){
    if((num > 0) && (num <= 13)){
        m_card[(num-1)] = true;
    }
}

bool CTrump::checkNumber(const unsigned int num){
    if((num > 0) && (num <= 13)){
        return m_card[(num-1)];
    }
    return false;
}

int main(void){
    
    CTrump card[4] = {'S','H','C','D'};

    int n = 0;
    cin >> n;
    for(int i = 0 ; i < n ; i++){
        char mark = 0;
        cin >> mark;
        
        int cardNum = -1;
        for(int j = 0 ; j < 4 ; j++){
            if(mark == card[j].getMark()){
                cardNum = j;
            }
        }       

        int number = 0;
        cin >> number;

        card[cardNum].setNumber(number);
    }
        
   for(int i = 0 ; i < 4 ; i++){
       for(int j = 1 ; j <= 13 ; j++){
           if(false == card[i].checkNumber(j)){
               cout << card[i].getMark() << ' ' << j << endl;
           }
       }
   }     

    return 0;
}

Measured memory_bytes: 1160
from collections import Counter
ans = 0
N = int(input())
Alist = list(map(int, input().split()))
A0 = Alist[0]
add = A0
res_ = []
for i in range(N):
    res_.append(Alist[i]+A0-i)
res = Counter(res_)
ans += res[0]
sbn = 0
for i in range(1, N):
    res[res_[i-1]] -= 1
    sbn += Alist[i] - Alist[i-1] + 1
    ans += res[-sbn]
print(ans)

Measured memory_bytes: 42728
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion


int32_t main() {
    make(int, n, x, y);
    if (x > y) {
        swap(x, y);
    }
    x--, y--;
    VI ans(n - 1);
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            ans[min(j - i, abs(i - x) + abs(j - y) + 1) - 1]++;
        }
    }
    for(int i = 0; i + 1 < n; ++i){
        cout << ans[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    MOD = 26
    ans = str()
    alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
    while N > 0:
        N -= 1
        ans = alpha[N % MOD] + ans
        N //= MOD
    print(ans)
        

if __name__ == '__main__':
    main()


Measured memory_bytes: 61832
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n; cin >> n; vector<int> v(1000);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    for(int j = n - 1; j > 0; j-- ){
        cout << v[j] << " " ;
    }
    cout << v[0] << endl;
}


Measured memory_bytes: 3084
#include<iostream>
int main(){
	while(1){
		int n,h[3]={0},i,a;
		std::cin>>n;
		if(!n)break;
		h[n-1]=1;
		for(i=1;i<5;i++){
			std::cin>>n;
			h[n-1]|=1<<i;
		}
		for(i=0;i<5;i++,a=0){
			for(n=0;!(h[n]&1<<i);n++);
			if(h[(n+1)%3])a+=1;
			if(h[(3+n-1)%3])a+=2;
			std::cout<<(a?a:3)<<'\n';
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

signed main(){
	int n, d;
	cin >> n >> d;

	vector<int> a(n);
	cin >> a;

	for(auto&i : a) i--;

	for(auto& i : a){
		i = i % (d + 1);;
	}


	int sum = 0;
	rep(i,n){
		sum = sum xor a[i];
	}



	if(sum == 0){
		cout << "Second" << endl;
	}else{
		cout << "First" << endl;
	}
}



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

const int MAX = 100;
const int SUM_MAX = 10001;
bool dp[SUM_MAX];

int main() {
  int n;
  cin >> n;
  fill(dp, dp+SUM_MAX, false);
  dp[0] = true;
  int ans = 0;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int s;
    cin >> s;
    sum += s;
    for (int j = SUM_MAX-s-1; j >= 0; j--) {
      if (dp[j] == true) {
	dp[j+s] = true;
      }
    }
  }
  for (int i = 0; i <= sum; i++) {
    if (dp[i] == true) {
      ans = max(ans, (i % 10 == 0 ? 0 : i));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 888
#include <cstdio>
#include <iostream>
#define LL long long
using namespace std;
int n,x;
int main(){
    cin>>n;
    cin>>x;
    int minx=x,maxx=x;
    for (int i=2;i<=n;i++){
        cin>>x;
        minx=min(x,minx);
        maxx=max(x,maxx);
    }
    cout<<maxx-minx<<endl;
    return 0;
}


Measured memory_bytes: 256
// OURL: 
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define RREP(i,a,n) for(int i=(a),i##_len=(n);i<i##_len;++i)
#define MAT1D(V,T,a) vector<T> V (a)
#define MAT2D(V,T,a,b) vector<vector<T>> V (a, vector<T>(b))
#define MAT3D(V,T,a,b,c) vector<vector<vector<T>>> V (a, vector<vector<T>>(b, vector<T>(c)))

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool>::reference b) { return to_string(bool(b)); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) { bool first = true; string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; }
template <typename A>
string to_string(vector<vector<A>> v) { string res; for(const auto &x : v) {res+="\n ";res += to_string(x);} return res;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << to_string(H); debug_out(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L" << to_string(__LINE__) << ":" <<#__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

ll combo(int n) {
  return ll(n) * ll(n-1) / 2;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;

  unordered_map<string, int> m;
  m.reserve(n);

  string s;
  REP(i,n) {
    cin >> s;
    sort(s.begin(),s.end());
    auto it = m.find(s);
    if (it == m.end()) {
      m[s] = 1;
    } else {
      m[s] += 1;
    }
  }

  ll c = 0;
  for(auto it : m) {
    debug(it.first, it.second);
    if (it.second > 1) {
      c += combo(it.second);
    }
  }
  cout << c << endl;
  return 0;
}



Measured memory_bytes: 10496
#include <cstring>
#include <string>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std;   

char s[1002];
int w,l;

int main()
{
	scanf("%s",s);
	scanf("%d",&w);
	l=strlen(s);
	for(int i=0;i<l;i+=w)
	{
		printf("%c",s[i]);
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main () {
  int N;
  cin >> N;
  int K;
  cin >> K;
  vector<char>A(N);
  for (int i = 0; i < N; i ++) {
    cin >> A[i];
    if (i == K - 1) {
      if (A[i] == 'A') A[i] = 'a';
      if (A[i] == 'B') A[i] = 'b';
      if (A[i] == 'C') A[i] = 'c';
    }
  }
  for (int i = 0; i < N; i ++) cout << A[i];
  cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
	int n;
	char in[5];
	scanf("%s", in);
	int count = 0;
	for(int i = 0; i < 3; i++){
		if(in[i] == 'R')count++;
	}
	if(strcmp(in, "RSR") == 0)count = 1;
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 2152
#include <iostream>
#include <stack>
#include <map>
#include <vector>
#include <algorithm>
#include <vector>
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)
typedef unsigned long long ull;

int const N = 1024*1024;

bool isp[N];
int c = 0;
void eratos(){
    rep(i, N)isp[i] = true;
    isp[0] = isp[1] = false;
    for (int i = 2; i < N; i++){
        if (!isp[i]) continue;
        for (int j = i + i; j < N; j += i){
            isp[j] = false;
        }
    }
}

int main(){
    eratos();
    int a, d, n;
    while (cin >> a >> d >> n && a | d | n){
        int len = 0;
        int last;
        for (int i = a; len < n; i += d){
            if (!isp[i]) continue;
            last = i;
            len++;
        }
        cout << last << endl;
    }
}

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

int main (void) {
    int loop_num, i, j;
    char mark;
    int num;
    char mark_box[4] = {'S', 'H', 'C', 'D'};

    bool all_card[4][13] = {};

    cin >> loop_num;
    for(i = 0; i < loop_num; i++) {
        cin >> mark;
        cin >> num;
        switch(mark) {
            case 'S' :
                all_card[0][num - 1] = true;
                break;
            case 'H' :
                all_card[1][num - 1] = true;
                break;
            case 'C' :
                all_card[2][num - 1] = true;
                break;
            case 'D' :
                all_card[3][num - 1] = true;
                break;
        }
    }

    for(i = 0; i < 4; i++) {
        for(j = 0; j < 13; j++) {
            if(all_card[i][j] == false) {
                cout << mark_box[i] << " " << j + 1 << endl;
            }
        }
    }
    return 0;
}

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

int n, k;
long h[100010], m;

int main(){
	cin >> n >> k;
	for (int i = 0; i < n; ++i) cin >> h[i];
	sort(h, h+n);
	m = 1e9;
	for (int i = 0; i <= n-k; ++i){
		if (h[i+k-1] - h[i] < m) m = h[i+k-1] - h[i];
	}
	cout << m;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<iostream>
using namespace std;
const int INF=500000;
long long a[INF*3+100];
struct node1 {
	long long ans,lazy;
	long long l,r;
} node[INF*3+100];
void pushdown(int k) {
	node[k<<1].lazy+=node[k].lazy;
	node[(k<<1)|1].lazy+=node[k].lazy;
	node[k<<1].ans+=(node[k<<1].r-node[k<<1].l+1)*node[k].lazy;
	node[(k<<1)|1].ans+=(node[(k<<1)|1].r-node[(k<<1)|1].l+1)*node[k].lazy;
	node[k].lazy=0;
}
long long pushup(long long y) {
	node[y].ans=node[y<<1].ans+node[(y<<1)|1].ans;
}
void update(long long k,long long head,long long tail,long long c) {
	if(tail<node[k].l||head>node[k].r)
		return;
	if(head<=node[k].l&&tail>=node[k].r) {
		node[k].lazy+=c;
		node[k].ans+=(node[k].r-node[k].l+1)*c;
		return ;
	}
	if(node[k].lazy!=0)
		pushdown(k);
	update(k<<1,head,tail,c);
	update((k<<1)|1,head,tail,c);
	pushup(k);
}
void build(long long k,long long head,long long tail) {
	node[k].lazy=0;
	node[k].l=head;
	node[k].r=tail;
	if(head==tail) {
		node[k].ans=a[tail];
		return ;
	}
	long long mid=(head+tail)>>1;
	build(k<<1,head,mid);
	build((k<<1)|1,mid+1,tail);
	pushup(k);
}
long long find(long long k,long long head,long long tail) {
	if(tail<node[k].l||head>node[k].r)
		return 0;
	if(head<=node[k].l&&tail>=node[k].r) {
		return node[k].ans;
	}
	if(node[k].lazy!=0)
		pushdown(k);
	long long mid=(node[k].l+node[k].r)>>1;
	if(head>mid)
		return find((k<<1)|1,head,tail);
	else  if(tail<=mid)
		return find(k<<1,head,tail);
	else  {
		return find((k<<1),head,mid)+find((k<<1)|1,mid+1,tail);
	}

}
int main() {
	long long n,m,x,y,ans=0;
	scanf("%lld%lld",&n,&m);
	int L,c;
	build(1,1,n); 
	for(long long i=1; i<=m; i++) {
		scanf("%lld%lld",&x,&y);
		update(1,x,y,1);
	}
	for(int i=1; i<=n; i++){
		if(find(1,i,i)==m)
			ans++;
		}
	cout<<ans;
}

Measured memory_bytes: 10496
#include<stdio.h>

int main() {
    //変数の宣言
    int a, b;
    int d, r;
    double f;
    
    //入力
    scanf("%d %d", &a, &b);
    
    //処理
    d = a / b;
    r = a % b;
    f = 1.0 * a / b;
    
    //出力
    printf("%d %d %f\n", d, r, f);
    
    
    return 0;
}



Measured memory_bytes: 2104
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back

using namespace std;
int n,k;
vector<ll>vec;
void input();

void solve(){
    for(int i=k;i<n;i++){
        if(vec[i-k]>=vec[i]){
            cout<<"No\n";
        }
        else{
            cout<<"Yes\n";
        }
    }
}

void Clear(){

}

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

    input();
    solve();
    Clear();
}

void input(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        vec.pb(x);
    }
}


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

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

	long long ans=0;
	string ss;
	if(s.length()<2)ans=0;


	else {
		for(int i=0;i<s.length();i++){
			if(s[i]=='B' && s[i+1]=='C'){
				ss += "D";
				i++;
			}
			else ss+= s[i];
		}
		// cout << ss<<endl;
		long long count =0;
		for(int i=0;i<ss.length();i++){
			if(ss[i]=='D'){
				ans+=count;
			}
			if(ss[i]=='C' || ss[i]=='B'){
				count =0;
			}
			if(ss[i]=='A'){
				count ++;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 776
#include <stdio.h>
#include <math.h>

int main(){
 int a,b,d,r;
 scanf("%d %d",&a,&b);
 double f;
 d=a/b;
 r=a%b;
 f=1.0*a/b;
 printf("%d %d %f\n",d,r,f);
}

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

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define INF 1e+18


signed main(){

  long long n,p,q,h,C=0,ret=-INF;
  cin >> n >> p >> q;
  vector<long long> c(n),ct(n),sum(n+1);
  rep(i,n){
    cin>>c[i];
    C += c[i];
    ct[i] = p*i+c[i];
  }
  sort(ct.begin(),ct.end());
  sum[0] = 0;
  rep(i,n)sum[i+1]=sum[i]+ct[i];
  rep(i,n+1){
    h = C+p*(i*i+(q-1)*i)-sum[i];
    if (h>ret) ret = h;
  }
  cout << ret << endl;

  return 0;
}



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

int main() {
  int n;
  cin>>n;
  string s;
  cin>>s;
  vector<int> a[10];
  for (int i=0; i<n; i++) {
    int j = s[i] - '0';
    a[j].push_back(i);
  }
  int cnt = 0;
  for (int i=0; i<10; i++) {
    if (a[i].size() == 0) {
      continue;
    }
    for (int j=0; j<10; j++) {
      if (a[j].size() == 0) {
        continue;
      }
      int x = a[i][0];
      auto it = upper_bound(a[j].begin(), a[j].end(), x);
      if (it == a[j].end()) {
        continue;
      }
      int y = *it;
      for (int k=0; k<10; k++) {
        if (a[k].size() == 0) {
          continue;
        }
        it = upper_bound(a[k].begin(), a[k].end(), y);
        if (it == a[k].end()) {
          continue;
        }
        ++cnt;
      }
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll (i)=0;(i)<(ll) (n);(i)++)
int main(void){
    ll i=0,j,p,h[1000010],k,n,a,b,c,d,e,m;
    cin >> n >> a >> b >> c >> d >> e;
    m=min({a,b,c,d,e});
    if(m<n)
    {
        if(n%m!=0)
        {
            m=n/m+5;
        }
        else
        {
            m=n/m+4;
        }
    }
    else
    {
        cout << '5' << endl;
        return 0;
    }
    cout << m << endl;
    
    return 0;

}


Measured memory_bytes: 3632
#include<stdio.h>
int main(void){
	int H,W,a,b;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 && W==0){
			break;
		}
		for(a=0;a<H;a++){
			for(b=0;b<W;b++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  int X,Y,Z;
  int count=0;
  cin>>A>>B>>C;
  if(A==B && B==C && A%2==0){
    cout<<-1<<endl;
    return 0;
  }
  while(A%2==0 && B%2==0 && C%2==0){
    A/=2;
    B/=2;
    C/=2;
    X=A; Y=B; Z=C;
    A=Y+Z; B=X+Z; C=X+Y;
    count++;
  }
  cout<<count<<endl;
  return 0;
}

    


Measured memory_bytes: 256
from collections import deque
n = int(input())
s = input()
A = deque([])
l = 0
r = 0
for i in range(n):
  if s[i]=='(':
    A.append(s[i])
    l += 1
  else:
    if l!=0:
      A.append(s[i])
      l -=1
    else:
      A.appendleft("(")
      A.append(s[i])

for j in range(l):
  A.append(")")
  
print("".join(A))

Measured memory_bytes: 9460
N, = list(map(int, input().split()))
d = {}
for i in range(N):
  ai,bi = list(map(int, input().split()))
  if bi in d:
    d[bi].append(ai)
  else:
    d[bi] = [ai]
B = list(d.keys())
B.sort()
ret = 'Yes'
s = 0
for b in B:
  s += sum(d[b])
  if s>b:
    ret = 'No'
print(ret)

Measured memory_bytes: 48644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod1=1000000007,mod2=1000000009,MAX=200005,INF=1<<30;

ll rui(ll a,ll b,ll mo){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%mo;
        a=a*a%mo;
        b/=2;
    }
    return ans;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    srand((unsigned int)time(NULL));
    
    int N;cin>>N;
    vector<ll> A(N),B(N),Adiff(N),Bdiff(N);
    
    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;i++) Adiff[i]=A[i]^A[(i+1)%N];
    for(int i=0;i<N;i++) Bdiff[i]=B[i]^B[(i+1)%N];
    
    ll ha1=rand(),ha2=rand();
    ll base1=0,base2=0,now1=0,now2=0;
    
    for(int i=0;i<N;i++){
        
        base1*=ha1;
        base2*=ha2;
        
        base1+=Bdiff[i];
        base2+=Bdiff[i];
        
        base1%=mod1;
        base2%=mod2;
        
        now1*=ha1;
        now2*=ha2;
        
        now1+=Adiff[i];
        now2+=Adiff[i];
        
        now1%=mod1;
        now2%=mod2;
    }
    
    for(int k=0;k<N;k++){
        if(now1==base1&&now2==base2){
            cout<<k<<" "<<ll(A[k]^B[0])<<endl;
        }
        
        now1+=mod1-Adiff[k]*rui(ha1,N-1,mod1)%mod1;
        now1*=ha1;
        now1+=Adiff[k];
        now1%=mod1;
        
        now2+=mod2-Adiff[k]*rui(ha2,N-1,mod2)%mod2;
        now2*=ha2;
        now2+=Adiff[k];
        now2%=mod2;
    }
    
}



Measured memory_bytes: 9728
from numba import njit
import numpy as np
@njit("i8(i8,i8,i8[:])")

def f(n,ans,l):
    for i in range(2,n+1):
        for j in range(i,n+1,i):
            l[j] += 1

        ans += (l[i]*i)
    return ans

n = int(input())
l = [1]*(n+1)
l[0] = 0
ans = l[1]
l_np = np.array(l,dtype="i8")

print(f(n,ans,l_np))


Measured memory_bytes: 265952
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    ll W, H, x, y;
    cin >> W >> H >> x >> y;
    ll div = 0;
    if (W == 2 * x && H == 2 * y)
    {
        div = 1;
    }
    cout << ((double)(W * H)) / 2 << " " << div << endl;
}

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


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>

#define ll long long
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug(Head head,Tail... tail){
    cerr<<" "<<to_string(head);
    debug(tail...);
}

int main(){
    int N,Q;
    cin>>N>>Q;
    string S;
    cin>>S;
    vector<int> list(N,0);
    FORIN(i,1,N){
        list[i]=list[i-1];
        if(S[i-1]=='A'&&S[i]=='C'){
            list[i]++;
        }
    }
    FOR(i,Q){
        int l,r;
        cin>>l>>r;
        cout<<(list[r-1]-list[l-1])<<endl;
    }
    debug(list);
    return 0;
}

Measured memory_bytes: 3392
n,m=map(int,input().split())
s=[]
c=[]
for i in range(m):
    st,ct=map(int,input().split())
    s.append(st)
    c.append(ct)
ans=[[0,0] for i in range(n)]
for i in range(m):
    if s[i]==1 and c[i]==0 and n>=2:
        print(-1)
        exit()
    if ans[s[i]-1][1]==0:
        ans[s[i]-1][0]=c[i]
        ans[s[i]-1][1]=1
    else:
        if ans[s[i]-1][0] != c[i]:
            print(-1)
            exit()
if ans[0][0]==0 and n>=2:
    ans[0][0]=1
ansn=0
for i in range(n):
    ansn+=ans[i][0]*10**(n-i-1)
print(ansn)
        
        

Measured memory_bytes: 38384