akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
#define enl "\n";
using namespace std;
using ll=long long;
using ld=long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class CMinimization {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n, k;
	    in >> n >> k;
	    vector<int> a(n);
	    for(int i=0; i<n; i++){
	        in >> a[i];
	    }

	    int res = 0;
	    int cur = 0;
	    while(cur < n){
	        if(!cur) cur += k;
	        else cur += k-1;
	        res++;
	    }

	    out << res << endl;
	}
};


int main() {
	CMinimization solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 640
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;

bool is_AGC(int a,int b,int c){
    if(a==1&&b==2&&c==3) return 1;
    else return 0;
}

bool four_ok(int a,int b,int c,int d){
    int m[4]={a,b,c,d};
    if(is_AGC(m[0],m[1],m[2])||is_AGC(m[1],m[2],m[3])) return 0;
    for(int i=0;i<3;i++){
        swap(m[i],m[i+1]);
        if(is_AGC(m[0],m[1],m[2])||is_AGC(m[1],m[2],m[3])) return 0;
        swap(m[i],m[i+1]);
    }
    return 1;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    ll dp[110][4][4][4]={0};
    cin>>n;
    
    dp[0][0][0][0]=1;
    ll mo=1e9+7;
    for(int i=0;i<n;i++){
        for(int a=0;a<4;a++){
            for(int b=0;b<4;b++){
                for(int c=0;c<4;c++){
                    for(int d=0;d<4;d++){
                        if(four_ok(a,b,c,d)){
                            dp[i+1][b][c][d]=(dp[i+1][b][c][d]+dp[i][a][b][c])%mo;
                        }
                    }
                }
            }
        }
    }
    ll ans=0;
    for(int a=0;a<4;a++){
        for(int b=0;b<4;b++){
            for(int c=0;c<4;c++){
                ans+=(dp[n][a][b][c]);
                ans%=mo;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
// glory be to the sky
#include<bits/stdc++.h> 


using namespace std;
	
typedef long long ll;  

int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);
	int R, C;
	string gr[105];
	cin >> R >> C;
	for (int i = 1; i <= R; i++) cin >> gr[i];
	for (int i = 1; i <= 2 * R; i++) {
		for (int j = 0; j < C; j++) cout << gr[(i + 1) / 2][j];
		cout << endl;
	}
	return 0;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    vector<string> N(3);
    rep(i, 0, 3) cin >> N.at(i);
    vector<int> n(3, -1);
    int st = 0;
    while (true){
        n.at(st)++;
        if (n.at(st) == N.at(st).size()){
            char ans = 'A';
            ans += st;
            cout << ans << endl;
            break;
        }
        if ((N.at(st).at(n.at(st))) == 'a') st = 0;
        else if ((N.at(st).at(n.at(st))) == 'b') st = 1;
        else if ((N.at(st).at(n.at(st))) == 'c') st = 2;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>  // std::accumulate(m.begin(), m.end(), 0LL);
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int N; std::cin >> N;
  std::vector<std::string> L(N);
  for(int i=0; i<N; i++) std::cin >> L[i];

  std::set<std::string> K;
  for(int i=0; i<N; i++) K.insert(L[i]);

  if ( K.size() == 3 ) std::cout << "Three" << std::endl;
  else std::cout << "Four" << std::endl;

  return 0;
}


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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}



//vc alp ={'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'};
//vc Alp ={'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'};
//cout<<""<<endl;
int main(){
  int H,W;cin>>H>>W;vs S(H);rep(i,H)cin>>S[i];
  vvi L(H,vector<int>(W));
  vvi R(H,vector<int>(W));
  vvi U(H,vector<int>(W));
  vvi D(H,vector<int>(W));
  
  rep(i,H){
    for(int j=0;j<W;j++){
      if(S[i][j]=='#')L[i][j]==0;
      else if(j==0&&S[i][j]!='#')L[i][j]=1;
      else if(j>0&&S[i][j]!='#')L[i][j]=L[i][j-1]+1;
    }
    for(int j=W-1 ;j>=0 ;j--){
      if(S[i][j]=='#')R[i][j]==0;
      else if(j==W-1&&S[i][j]!='#')R[i][j]=1;
      else if(j<W-1&&S[i][j]!='#')R[i][j]=R[i][j+1]+1;
    }
  }
  rep(i,W){
    rep(j,H){
      if(S[j][i]=='#')U[j][i]==0;
      else if(j==0&&S[j][i]!='#')U[j][i]=1;
      else if(j>0&&S[j][i]!='#')U[j][i]=U[j-1][i]+1;
    }
    for(int j=H-1;j>=0;j--){
      if(S[j][i]=='#')D[j][i]==0;
      else if(j==H-1&&S[j][i]!='#')D[j][i]=1;
      else if(j<H-1&&S[j][i]!='#')D[j][i]=D[j+1][i]+1;
    }
  }
  int ans=0;
  rep(i,H){
    rep(j,W){
      ans =max(ans,L[i][j]+U[i][j]+R[i][j]+D[i][j]-3);
    }
  }
  cout<<ans<<endl;
  

}







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



struct node{
  int lc;
  int rc;
  int key;
  void init(int a){
    lc=rc=-1;
    key=a;
  }
};

#define bstN 600000
struct bst{

  int size;
  node t[bstN];

  void init(){
    size=0;
  }
  
  void insert(int v){
    int i=0;
    while(i<size){
      int& child=(v<t[i].key?t[i].lc:t[i].rc);
      if(child==-1)child=size;
      i=child; 
    }
    t[size++].init(v);
  }

  void preord(int pos,vector<int> &vec){
    if(pos==-1||pos==size)return;
    preord(t[pos].lc,vec);
    vec.push_back(t[pos].key);
    preord(t[pos].rc,vec);
  }
  
  void inord(int pos,vector<int> &vec){
    if(pos==-1||pos==size)return;
    vec.push_back(t[pos].key);
    inord(t[pos].lc,vec);    
    inord(t[pos].rc,vec);
  }
};


bst T;

int main(){
  T.init();
  int n,a;
  char str[100];
  scanf("%d",&n);
  
  while(n--){
    scanf("%s",str);
    if(str[0]=='i'){
      scanf("%d",&a);
      T.insert(a);
    }else{
      vector<int> ans,ans2;
      
      T.preord(0,ans);
      for(int i:ans)cout<<' '<<i;
      cout<<endl;
      
      T.inord(0,ans2);
      for(int i:ans2)cout<<' '<<i;
      cout<<endl;
    }
  }

  return 0;
}

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

using namespace std;

typedef long long ll;
#define N 100005

int n, p, a[N];

ll m, v;

bool cmp(int x, int y)
{
	return x > y;
}

bool check(int x)
{
	if(x <= p) return 1;
	if(a[x] + m < a[p]) return 0;
	int rv = v - (p - 1) - (n - x + 1);
	if(rv < 0) return 1;
	ll rs = 1ll * rv * m;
	for(int i = p; i <= x - 1; i++)
		rs -= a[x] + m - a[i];
	return (rs <= 0);
}

int main()
{
	scanf("%d%lld%lld%d", &n, &m, &v, &p);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	sort(a + 1, a + n + 1, cmp);
	int l = 1, r = n, ans = 0;
	while(l <= r)
	{
		int mid = l + r >> 1;
		if(check(mid)) l = mid + 1, ans = mid;
		else r = mid - 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
 
int main() {
	int n;
	std::cin >> n;
	std::string a, s;
	std::vector<std::string> str;
	for (int i = 0; i < n; i++) {
		std::cin >> a;
		str.emplace_back(a);
	}
	for (int i = 'a'; i <= 'z'; i++) {
		int cmin = 1000;
		for (int j = 0; j < n; j++) {
			int calphabet = 0;
			for (int o = 0; o < str[j].size(); o++) {
				if (str[j][o] == i) {
					calphabet++;
				}
			}
			if (calphabet <= cmin) {
				cmin = calphabet;
			}
		}
		for (int j = 0; j < cmin; j++) {
			s += i;
		}
	}
	std::cout << s << std::endl;
}

Measured memory_bytes: 256
import bisect

n=int(input())
x=list(map(int, input().split(" ")))
x=sorted(x)

v1=x[-1]
del x[-1]

ins = bisect.bisect_left(x,v1/2)

if len(x)<=1:
    v2=0
elif abs(x[ins]-v1/2) > abs(x[ins-1]-v1/2):
    v2=x[ins-1]
else:
    v2=x[ins]

print(v1,v2)


Measured memory_bytes: 14428
open Batteries

let xs = Array.make 26 false

let main () =
  let n, s = Scanf.scanf "%d\n%s" (fun x y -> x, y) in
  let ans = ref 0 in
  for i = 1 to n - 2 do
    let x = String.slice ~first:0 ~last:(i+1) s in
    let y = String.slice ~first:(i+1) ~last:n s in
    for i = 0 to 25 do
      let c = Char.chr (i+97) in
      xs.(i) <- String.contains x c && String.contains y c
    done;
    ans := max !ans (Array.fold_left (fun acc x -> if x then acc + 1 else acc) 0 xs);
    Array.fill xs 0 25 false;
  done;
  Printf.printf "%d\n" !ans

let _ = main ()


Measured memory_bytes: 1152
//0510:   Score

#include <iostream>
using namespace std;

#define NUM 1000

int main(){
  int s[NUM];
  int t[NUM];
  int sums = 0;
  int sumt = 0;
  int i;

  for (i = 0; i < 4; i++){
    cin >> s[i];
    sums += s[i];
  }

  for (i = 0; i < 4; i++){
    cin >> t[i];
    sumt += t[i];
  }

  if (sums > sumt){
    cout << sums << '\n';
  }
  else {
    cout << sumt <<'\n';
  }
return 0;
}

Measured memory_bytes: 1168
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer a = sc.nextInt();
        Integer b = sc.nextInt();
        System.out.println(Math.max(a,b) + Math.max(Math.max(a, b)-1, Math.min(a,b)));
    }
}


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

int main()
{
  int a, b;
  cin >> a >> b;
  int sum = 0;
  for (int i = 0; i < 2; ++i) {
    if (a > b) {
      sum += a;
      a--;
    }
    else {
      sum += b;
      b--;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 10

int main(void){
  int i,j,tmp;
  int high[N];
  
  for(i=0;i<N;i++){
    scanf("%d",&high[i]);
  }
  
  for(i=0;i<N;i++){
    for(j=0;j<N-1;j++){
      if(high[j]<high[j+1]){
	tmp=high[j];
	high[j]=high[j+1];
	high[j+1]=tmp;
      }
    }
  }
  
  printf("%d\n%d\n%d\n",high[0],high[1],high[2]);
  
  return 0;
}

Measured memory_bytes: 600
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n, m;
  cin >> n >> m;
  if(n == 1 && m == 1) cout << 1 << endl;
  else if(n == 1) cout << max(0LL, m-2) << endl;
  else if(m == 1) cout << max(0LL, n-2) << endl;
  else if(n == 2 || m == 2) cout << 0 << endl;
  else cout << (n-2)*(m-2) << endl;

  return 0;
}


Measured memory_bytes: 256
import fractions
from collections import deque
import numbers as np


def main():
    N = int(input())
    d = list(map(int, input().split()))
    d.sort()
    bi_m = d[(N-1)//2]
    bi_p = d[(N-1)//2 + 1]
    print(bi_p - bi_m)


if __name__ == "__main__":
    main()


Measured memory_bytes: 16100
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define mod 1000000007
#define vll vector<ll>

ll ti[100001];


ll n,a[100001];

ll func(ll pre)
{
   if(pre<0) return 1e16;
   if(pre==0) return 0;
   if(ti[pre]!=-1) return ti[pre];


   return ti[pre]=min(abs(a[pre-2]-a[pre])+func(pre-2),abs(a[pre-1]-a[pre])+func(pre-1));
}


int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    memset(ti,-1,sizeof ti);
	//ll n;
	cin>>n;

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

      cout<<func(n-1)<<endl;;

	return 0;
}



Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
ll pow4(int N){
	ll a = 1;
	while(N > 0){
		a *= 4;
		N--;
	}
	// cout << "pow4" << a<< endl;
	return a;
}

ll powm2(int N){
	ll a = 1;
	while(N > 0){
		a *= -2;
		N--;
	}
		// cout << "powm2" << a<< endl;

	return a;
}

int main(){
	int N;
	int flag = 0;
	cin >> N;
	if (N == 0){
		cout << 0;
	}
	for (int i = 1000;i > 0;i--){
		if (((N < 2*(1 - pow4(floor(float(i - 1)/2.0)))/3) && (N  >= 2*(1 - pow4(floor(float(i)/2.0)))/3)) 
		|| (N > (pow4(ceil(float(i-1)/2.0)) - 1)/3) && (N <= (pow4(ceil(float(i)/2.0)) - 1)/3)){
			cout << 1;
			N -= powm2(i - 1);
			if(flag == 0){
				flag = 1;
			}
		}
		else{
			if (flag == 1){
				cout << 0;
			}
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<ll, ll> P;

void make_lunlun(vector<ll>& res, int k){
    int count = 0;
    vector<ll> tmp;
    for(int i = 1; i < 10; i++){
        tmp.push_back(i);
        res.push_back(i);
        count++;
    }

    while(count < k + 10){
        vector<ll> new_tmp;
        for(auto x: tmp){
            if(x % 10 == 9){
                ll newX = x * 10 + 8;
                res.push_back(newX);
                new_tmp.push_back(newX);
                count++;

                newX = x * 10 + 9;
                res.push_back(newX);
                new_tmp.push_back(newX);
                count++;
            }
            else if(x % 10 == 0){
                ll newX = x * 10;
                res.push_back(newX);
                new_tmp.push_back(newX);
                count++;

                newX = x * 10 + 1;
                res.push_back(newX);
                new_tmp.push_back(newX);
                count++;
            }
            else{
                for(int i = -1; i <= 1; i++){
                    ll newX = x * 10 + x % 10 + i;
                    res.push_back(newX);
                    new_tmp.push_back(newX);
                    count++;
                }
            }
            if(count >= k + 10){
                break;
            }
        }
        tmp.clear();
        for(auto x: new_tmp){
            tmp.push_back(x);
        }
    }
}


int main(){
    int x, y, z;    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z << endl;

    return 0;
}

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

int main(void) {
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for (int i = 0; i < N - 2; i++) {
    if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') ans++;
  }
  cout << ans << endl;
  return 0;
}

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

#define MAX_N 100
#define MOD 1000000007

int A, B, C, D, N;
int dp1[MAX_N];
string S, U[MAX_N];
vector<string>T[MAX_N];
vector<string>W[MAX_N];
int X[200][4]; char DNA[5] = "ATGC";
int dp[216][54][54][54];

int solve() {
	for (int i = N - 1; i >= 0; i--) {
		for (int j = 0; j < T[i].size(); j++) {
			if (T[i][j][0] - 'A' >= 26) {
				for (int k = 0; k < N; k++) {
					if (T[i][j] == U[k]) {
						for (int l = 0; l < W[k].size(); l++) {
							W[i].push_back(W[k][l]);
						}
					}
				}
			}
			else {
				W[i].push_back(T[i][j]);
			}
		}
	}
	for (int i = 0; i < W[0].size(); i++) {
		for (int j = 0; j < W[0][i].size(); j++) {
			for(int k = 0; k < 4; k++) {
				if (DNA[k] == W[0][i][j]) {
					X[i][k] = 1;
				}
			}
		}
	}
	dp[0][0][0][0] = 1;
	for (int i = 0; i < W[0].size(); i++) {
		for (int j = 0; j <= A; j++) {
			for (int k = 0; k <= B; k++) {
				for (int l = 0; l <= C; l++) {
					if (X[i][0] == 1) {
						dp[i + 1][j + 1][k][l] += dp[i][j][k][l];
						dp[i + 1][j + 1][k][l] %= MOD;
					}
					if (X[i][1] == 1) {
						dp[i + 1][j][k + 1][l] += dp[i][j][k][l];
						dp[i + 1][j][k + 1][l] %= MOD;
					}
					if (X[i][2] == 1) {
						dp[i + 1][j][k][l + 1] += dp[i][j][k][l];
						dp[i + 1][j][k][l + 1] %= MOD;
					}
					if (X[i][3] == 1) {
						dp[i + 1][j][k][l] += dp[i][j][k][l];
						dp[i + 1][j][k][l] %= MOD;
					}
				}
			}
		}
	}
	return dp[W[0].size()][A][B][C];
}

int main() {
	cin >> A >> B >> C >> D >> N;
	for (int i = 0; i < N; i++) {
		S = "";
		while (S == "") {
			getline(cin, S);
		}
		S += ' '; string V = "";
		for (int j = 0; j < S.size(); j++) {
			if (S[j] == ':') {
				U[i] = V;
				V = "";
				j++;
			}
			else if (S[j] == ']' || S[j] == ' ') {
				if (S[j - 1] != ']') {
					T[i].push_back(V);
					V = "";
				}
			}
			else if (S[j] != '[') {
				V += S[j];
			}
		}
	}
	for (int i = N - 1; i >= 0; i--) {
		int score = 0;
		for (int j = 0; j < T[i].size(); j++) {
			if (T[i][j][0] - 'A' >= 26) {
				for (int k = 0; k < N; k++) {
					if (T[i][j] == U[k]) {
						score += dp1[k];
					}
				}
			}
			else {
				score += 1;
			}
		}
		if (score >= 2000) {
			dp1[0] = 2000;
			break;
		}
		dp1[i] = score;
	}
	if (dp1[0] != A + B + C + D) {
		cout << "0" << endl;
		goto E;
	}
	cout << solve() << endl;
E:;
	return 0;
}

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

#define ramen 700

int main(){

    char s[3];
    int price; // 合計金額

    for(int i=0;i<3;i++){
        cin >> s[i];
        if(s[i] == 'o') price += 100;
    }

    cout << price + ramen ;
}

Measured memory_bytes: 256
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)

fun main(args: Array<String>) {
    val k = readInt()
    var res = 0
    for (i in 1..k) {
        for (j in 1..k) {
            for (l in 1..k) {
                res += gcd(gcd(i, j), l)
            }
        }
    }
    println(res)
}


Measured memory_bytes: 34664
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
#include <ctype.h>
using namespace std;

#define PI acos(-1.0)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second

#define eps 1e-8
#define mod 998244353

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<vector<int>> vvi;

struct Matrix {
    vvi data;
    int r, c;
    Matrix(int row, int col, bool identity = false) : r(row), c(col) {
        data.assign(row, vector<int>(col, 0));
        if (identity) {
            for (int i = 0; i < r; ++i) {
                data[i][i] = 1;
            }
        }
    }
    Matrix operator * (Matrix& other) {
        int m = r, n = c, p = other.c;
        Matrix res(m, p);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < p; ++j) {
                for (int k = 0; k < n; ++k) {
                    res.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return res;
    }
};

// 扩展欧几里得算法 res[1] * a + res[2] * b = res[0] = gcd(a, b)
vector<int> extendGcd(int a, int b) {
    if (b == 0) {
        return {a, 1, 0};
    } else {
        vector<int> tmp = extendGcd(b, a % b);
        return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
    }
}

// 矩阵快速幂
Matrix matrix_power(Matrix base, ll exp) {
    int n = base.r;
    Matrix res(n, n, true);
    while (exp) {
        if (exp & 1) {
            res = res * base;
        }
        base = base * base;
        exp >>= 1;
    }
    return res;
}

// 带模快速幂
ll power_mod(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

// 快速幂
ll power(ll base, int exp) {
    ll res = 1;
    while (exp) {
        if (exp & 1) res *= base;
        base *= base;
        exp >>= 1;
    }
    return res;
}

// 求逆元
ll inv(ll a) {
    return power_mod(a, mod - 2);
}

#define MAXFAC 100010

ll fac[MAXFAC];

void initFac() {
    fac[0] = 1;
    for (int i = 1; i < MAXFAC; ++i) {
        fac[i] = i * fac[i - 1] % mod;
    }
}

ll Combine(ll a, ll b) {
    return (fac[a] * inv(fac[b]) % mod) * inv(fac[a - b]) % mod;
}

/******************************** template ********************************/
#define MAXN 100010
int n;
int a[MAXN];

unordered_map<int, int> cnt;

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        scanf("%d", a + i);
        ++cnt[a[i] - 1];
        ++cnt[a[i]];
        ++cnt[a[i] + 1];
    }

    int res = INT_MIN;
    for (auto i : cnt) res = max(res, i.second);

    cout << res;

    return 0;
}

Measured memory_bytes: 4644
#include<bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main(){
    string s;
    cin >> s;
    int a = 0, b = 0, c = 0;
    rep(i, s.length()){
        if(s[i] == 'a') a++;
        else if(s[i] == 'b') b++;
        else c++;
    }
    if(abs(a - b) <= 1 && abs(a - c) <= 1 && abs(b - c) <= 1) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3728
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    cout<<(1000-(n%1000))%1000;
}

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

int main() {
	int a,b;
	char op;
	while(cin>>a>>op>>b,op!='?') {
		switch(op) {
			case '+':
				cout<<a+b<<endl;
				break;
			case '-':
				cout<<a-b<<endl;
				break;
			case '*':
				cout<<a*b<<endl;
				break;
			default:
				cout<<a/b<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
def gcd(c, d):
  if c <= d:
    c, d = d, c
  while c % d:
    c, d = d, c % d
  return d
def lcm(c, d):
  return (c * d) // gcd(c, d)

A, B, C, D = map(int, input().split())
c_or_d = ((B // C) - ((A - 1) // C)) + ((B // D) - ((A - 1) // D)) - ((B // lcm(C, D)) - ((A - 1) // lcm(C, D)))
print(B - A + 1 - c_or_d)


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
char op1,op2,op3 ;
int a,b,c,d;
void slove()
{
	if(a+b+c+d==7){op1='+';op2='+';op3='+';return;}
	if(a+b+c-d==7){op1='+';op2='+';op3='-';return;}
	if(a+b-c+d==7){op1='+';op2='-';op3='+';return;}
	if(a+b-c-d==7){op1='+';op2='-';op3='-';return;}
	if(a-b+c+d==7){op1='-';op2='+';op3='+';return;}
	if(a-b+c-d==7){op1='-';op2='+';op3='-';return;}
	if(a-b-c+d==7){op1='-';op2='-';op3='+';return;}
	if(a-b-c-d==7){op1='-';op2='-';op3='-';return;}
}

int main()
{
int s;
	while(cin>>s)
	{   
		d=s%10;
		c=s/10%10;
		b=s/100%10;
		a=s/1000%10;
		slove();
		cout<<a<<op1<<b<<op2<<c<<op3<<d<<'='<<'7';
		
	}
	
	
	return 0;
 } 

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<vll> vvll;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define FU(i, a, b) for (int i = a; i < b; ++i)
#define fu(i, b) FU(i, 0, b)
#define all(V) (V).begin(), (V).end()
#define sz(V) ((int)V.size())
#define FD(i, a, b) for (int i = b - 1; i >= a; --i)
#define fd(i, b) FD(i, 0, b)

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  string s;
  cin >> s;
  unordered_map<char, int> m;
  
  for(auto ch : s) m[ch] += 1;
  
  for(auto k : m) {
    if (k.S % 2 != 0) { cout << "No" << "\n";  return 0; }
  }
  
  cout << "Yes" << "\n";
  return 0;

}


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

using namespace std;

int main() {
  array<int, 5> a;
  for (int& i : a) cin >> i;
  sort(a.begin(), a.end(), greater<int>());
  for (int i = 0; i < int(a.size()); ++i) {
    cout << a[i];
    if (i != int(a.size()) - 1) cout << " ";
    else cout << endl;
  }
}

Measured memory_bytes: 1172
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
const int M=100;
int A[M+5][M+5];
int x[M+5],y[M+5],h[M+5];
bool check_h(int wh,int n,int a,int b)
{
	for(int i=0;i<n;i++)
	{
		if(h[i]&&(abs(x[i]-a)+abs(y[i]-b)+h[i]!=wh)) return 0;
		if(!h[i]&&(abs(x[i]-a)+abs(y[i]-b)<wh)) return 0;
	}
	return 1;
}
int main()
{
	int n;
	cin>>n;
	int f=0;
	for(int i=0;i<n;i++)
	{
		cin>>x[i]>>y[i]>>h[i];
		if(h[i]!=0) f=i;
	}
	for(int i=0;i<101;i++)
	{
		for(int j=0;j<101;j++)
		{
			int new_h=h[f]+abs(x[f]-i)+abs(y[f]-j);
			if(check_h(new_h,n,i,j))
			{
				cout<<i<<' '<<j<<' '<<new_h<<endl;
				return 0;
			}
		}
	}
	return 0;
}


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

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


ll N, A, B;
vector<ll> h;

bool solve(ll n ){
    ll cnt = 0;
    rep(i,h.size()){
        if(h[i] <= B*n) continue;
        cnt += ((h[i]- n*B)/ (A-B));
        if((h[i]-n*B)%(A-B) != 0) cnt ++;
    }
    if(cnt > n) return false;
    else return true;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N >> A >> B;
    rep(i,N){
        ll inp; cin >> inp;
        h.pb(inp);
    }
    
    ll l = 0;
    ll r = 1e9;
    
    while(l+1 < r){
        ll m = (l+r)/2;
        if(solve(m)) r = m;
        else l = m;
    }
    
    cout << r << endl;
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 1400
#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;
using ll = long long;

int main() {
    string s;
    cin >> s;
    if (s[s.size() - 1] == 's') s += "es";
else
    s += "s";
cout << s << endl;
return 0;
}
/*
g++ -std=c++17 -Wall -Wextra -g -O0 -fsanitize=undefined,address main.cpp && oj t
*/

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

using namespace std;

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

    vector<int> v(100005, 0);
    vector<int> w(100005, 0);
    for (int i = 0; i < n / 2; i++) {
        int a, b;
        cin >> a >> b;
        v[a]++, w[b]++;
    }

    auto vidx1 = distance(v.begin(), max_element(v.begin(), v.end()));
    auto widx1 = distance(w.begin(), max_element(w.begin(), w.end()));
    auto ans = n - v[vidx1] - w[widx1];
    if (vidx1 == widx1) {
        //最大値を保存
        auto vmax = v[vidx1];
        auto wmax = w[widx1];
        //2番目に大きな値を探す
        v[vidx1] = 0;
        w[widx1] = 0;
        auto vidx2 = distance(v.begin(), max_element(v.begin(), v.end()));
        auto widx2 = distance(w.begin(), max_element(w.begin(), w.end()));
        ans = n - max(v[vidx2] + wmax, vmax + w[widx2]);
    }

    cout << ans << endl;
    return 0;
}


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

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

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

    queue<int> q;
    rep(i, 1, 10) q.push(i);

    int c = 0;
    while(1){
        int v = q.front(); q.pop();
        c++;
        if (c==k){
            cout << v << endl;
            return 0;
        }

        int ln = v % 10;
        if (ln>0) q.push(v*10 + ln - 1);
        q.push(v*10 + ln);
        if (ln<9) q.push(v*10 + ln + 1);
    }


    return 0;
}


Measured memory_bytes: 1792
n,C = map(int, input().split())
d = [list(map(int, input().split())) for _ in range(C)]
c = [[0]*C for _ in range(3)]
for i in range(n):
  for j,x in enumerate(map(int, input().split())):
    c[(i+j)%3][x-1]+=1
res = 10**10
for i in range(C):
  for j in range(C):
    if i!=j:
      for k in range(C):
        if i!=k and j!=k:
          t = 0
          for l in range(C): t+=d[l][i]*c[0][l]
          for l in range(C): t+=d[l][j]*c[1][l]
          for l in range(C): t+=d[l][k]*c[2][l]
          if t<res: res=t
print(res)

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

using namespace std;

int main()

{
    int r, d, x, s, i;

    cin>>r>>d>>x;

    cout<<r*x-d<<endl;

    s=r*x-d;

    for(i=2; i<=10; i++) {
        cout<<r*s-d<<endl;
        s=r*s-d;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int n , a[10000] , sum ;
int main()
{
 //   freopen ("B.inp","r",stdin) ;
 //   freopen ("B.out","w",stdout) ;
    sum = 0  ;
    cin >> n  ;
    for (int i=1 ; i <= n ; i++)
    {
        cin >> a[i] ;
    }
    for (int i=1 ; i <= n ; i++)
    {
        for (int j=i-1 ; j >= 1  ; j-- )
              sum +=a[i]*a[j] ;
    }
    cout << sum <<endl  ;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, a, b; cin >> n >> a >> b;
	
	if(a + b > n + 1 || (ll)a * b < n){
		cout << -1 << endl;
		return 0;
	}
	vi v, u(n);
	rep(i, n) v.pb(i % a);
	int cnt = 0;
	for(int i = n - 1, p = 0; i >= 0; i--){
		if(v[i] == 0){
			u[i] += p;
			p = n - i;
			cnt++;
		}
		else u[i] += p;
	}
	cnt = b - cnt;
	//dbg(v); dbg(u); dbg(cnt);
	
	for(int i = (n - 1) / a * a; i >= 0; i -= a){
		int r = min(i + a, n);
		
		if(cnt >= r - i - 1){
			reverse(v.begin() + i, v.begin() + r);
			cnt -= r - i - 1;
		}
		else{
			reverse(v.begin() + i, v.begin() + i + cnt);
			rotate(v.begin() + i, v.begin() + i + cnt, v.begin() + r);
			break;
		}
	}
	//dbg(v); dbg(u);
	
	rep(i, n) cout << v[i] + u[i] + 1 << (i==n-1?"\n":" ");
	
	return 0;
}

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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second

ll a[2000005] , b[1000005];

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

    ll n,k;
    cin >> n;

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

    ll ans=0;
    for(int i=1; i<n; i++)
    {
        cin >> b[i];
        ll tmp = min(b[i] , a[i]);
        a[i] -= tmp;
        b[i] -= tmp;
        ans += tmp;

        tmp = min(b[i] , a[i+1]);
        a[i+1] -= tmp;
        b[i] -= tmp;
        ans += tmp;

    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define _GLIBCXX_DEBUG
#define V vector<ll>
using namespace std;
using ll = long long;

int main() {
   int n; cin>>n;
   V a(n);
   rep(i,0,n) cin>>a[i];
   sort(a.begin(),a.end());
   int A=0,B=0;
   for(int i=0; i<n; i+=2) A+=a[i];
   for(int i=1; i<n; i+=2) B+=a[i];
   cout<<abs(A-B)<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

// edit

void solve() {
    string S;
    cin >> S;
    
    cout << (S == "ARC" ? "ABC" : "ARC") << endl;

}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cctype>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <deque>
#include <map>
#include <bitset>
#include <functional>
#include <cmath>

#define INF 1000000000
using namespace std;
const long MOD = 1000000007;

int main(){
    long long n, m;
    cin >> n >> m;
    vector<long long> a(n+1);

    long long i;
    for(i = 0; i <= n; i++){
        a[i] = 1;
    }

    for(i = 0; i < m; i++){
        long long p;
        cin >> p;
        a[p] = 0;
    }

    long long dp[n+2];
    for(i = 0; i < n+2; i++) dp[i] = 0;
    dp[0] = 1;
    if(a[1] == 0) dp[1] = 0;
    else dp[1] = 1;

    for(i = 2; i <= n; i++){
        if(a[i] == 0) continue;
        dp[i] += ((dp[i-1] + dp[i-2]) % MOD);
        dp[i] %= MOD;
    }

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

Measured memory_bytes: 4840
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

void solve(long long N){
    long long sum = 0;
    REP(i, N + 1)
        if (i % 15 && i % 5 && i % 3) sum += i;
    cout << sum << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3792
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int i=1;
  while(++i<=n){
    int x=i;
    if(x%3==0){
      cout << " " << i;
      continue;
    }
    while(x){
      if(x%10==3){
	cout << " " << i;
	break;
      }
      x/=10;
    }
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int n;
long long dp[21][21];
char s[101];
int main()
{
	cin>>n>>s;
	long long ans=0;
	for(int i=0;i<(1<<n);i++)
	{
		vector<int> red,blue;
		for(int j=0;j<n;j++)
			if(i&(1<<j))red.push_back(j);
			else blue.push_back(j);
		memset(dp,0,sizeof dp);
		int bluecnt=__builtin_popcount(i),redcnt=n-bluecnt;
		dp[0][0]=1;
		for(int j=0;j<n;j++)
			for(int k=0;k<=j&&k<=bluecnt;k++)
			{
				if(j-k<redcnt&&s[2*n-j-1]==s[blue[j-k]])dp[j+1][k]+=dp[j][k];
				if(k<bluecnt&&s[2*n-j-1]==s[red[k]])dp[j+1][k+1]+=dp[j][k];
			}
		ans+=dp[n][bluecnt];
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

int main () {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int> > v;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    v.push_back(make_pair(a, b));
  }

  sort(v.begin(), v.end());

  priority_queue<int> pq;

  int index = 0;
  int ans = 0;
  for (int day = 1; day <= M; day++) {
    while (index < v.size() && v[index].first <= day) {
      pq.push(v[index].second);
      index++;
    }

    if (pq.size() > 0) {
      int p = pq.top();
      ans += p;
      pq.pop();
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1908
N, M = map(int, input().split())
a = [1] + [1] + [0 for i in range(max(N-1, 0))]

mod = 10 ** 9 + 7
for i in range(M):
    a1 = int(input())
    a[a1] = -1
    
for i in range(2,N+1):
    if a[i] == -1:
        continue
    else:
        a[i] = (max(a[i-1], 0) + max(a[i-2], 0)) % mod
        
print(a[N])

Measured memory_bytes: 7048
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <tuple>

using namespace std;

int main()
{  
    int N;
    cin >> N;
    double ans = 0;
    for(int i = 0; i < N; i++){
        double num;
        string s;
        cin >> num >> s;
        if(s == "BTC")num *= 380000;
        ans += num;
    }
    cout << ans << endl;
} 

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

const int MAXN = 100010;

int n;
int a[MAXN];

int main()
{
	
	int N, M, n, m;
	cin >> N >> M >> n >> m;
	if (N%n == 0 && M%m == 0)
		puts("No");
	else
	{
		puts("Yes");
		int c = 999999999;
		for (int i = 0; i < N; ++ i)
		{
			for (int j = 0; j < M; ++ j)
			{
				if (j) putchar(' ');
				if (i%n == n-1 && j%m == m-1)
					printf("%d", -(c+1));
				else if (i%n == 0 && j%m == 0)
					printf("%d", c);
				else
					printf("0");
			}
			puts("");
		}
	}
	
	return 0;
}


Measured memory_bytes: 2944