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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
void sort2array(double *a,long *b,long n){
    for(int i=0;i<n;i++){
        b[i]=i;
    }
    sort(b,b+n,[a](long i,long j)->bool {return a[i]<a[j];} );
}
//bを何回足せばaを超えるか
int wtover(int a,int b){
    if(a%b>0)return (a/b)+1;
    else return a/b;
}
const int INF=100000001,ID_MAX=20;
int bi_e[ID_MAX]={0};
//2進数表示したときの最高桁
int bi_max(long n){
    int m=0;
    for(m;pow(2,m)<=n;m++);m=m-1;
    return m;
}
//bi_eに二進数表示したやつを代入
void bi_exs(long n){
    rep(i,ID_MAX){
        bi_e[i]=0;
    }
    if(n<pow(2,ID_MAX)){
        int m=bi_max(n);
        long l;
        for(m;m>-1;m--){
            l=pow(2,m);
            bi_e[m]=n/l;
            n=n%l;
        }
    }
}
//x^n mod m (nが負の時は０)
long myPow(long x, long n, long m){
  if(n<0)return 0;
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}


int main(){
    int i,n,k,x;
    //入力
    cin>>n>>k;
    int a[n],d;
    memset(a,0,sizeof(a));
    rep(i,k){
        cin>>d;
        rep(j,d){
            cin>>x;
            a[x-1]=a[x-1]+1;
        }
    }
    //処理
    int cou=0;
    rep(i,n){
        if(a[i]==0)cou++;
    }
    //出力
    cout<<cou<<endl;

}

Measured memory_bytes: 3688
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    n = int(readline())
    a = list(map(int, readline().split()))
    a.sort()
    ans = 1
    for aa in a:
        ans *= aa
        if ans > 10 ** 18:
            print(-1)
            break
    else:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20176
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define INF 999999999
typedef long long ll;
using namespace std;
int main() {
    int N;
    cin >> N;
    int H[N];
    REP(i, N) cin >> H[i];
    int ocean = 0;
    int high = 0;
    REP(i, N) {
        if(high <= H[i]) {
            high = H[i];
            ocean++;
        }
    }
    cout << ocean << "\n";
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

class Main {

  static final int INF = Integer.MAX_VALUE / 4;

  static int cntAC(ArrayList<Integer> list, int l, int r) {
    int idx_l;
    int idx_r;
    // FOR LEFT lの右のindexを求める
    int ok = list.size();
    int ng = 0;
    int mid = (ok + ng) / 2;
    while (ok - ng > 1) {
      if (list.get(mid) < l) {
        ng = mid;
      } else {
        ok = mid;
      }
      mid = (ok + ng) / 2;
    }
    idx_l = ok;
    // FOR RIGHT rの左のindexを求める
    ok = 0;
    ng = list.size();
    mid = (ok + ng) / 2;
    while (ng - ok > 1) {
      if (list.get(mid) <= r) {
        ok = mid;
      } else {
        ng = mid;
      }
      mid = (ok + ng) / 2;
    }
    idx_r = ok;
    if (idx_r - idx_l < 0) {
      return 0;
    }
    return idx_r - idx_l + 1;
  }

  static ArrayList<Integer> searchAC(String s) {
    ArrayList<Integer> list = new ArrayList<Integer>();
    list.add(-INF);
    for (int i = 0; i < s.length() - 1;) {
      if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
        list.add(i);
        i = i + 2;
      } else {
        i = i + 1;
      }
    }
    list.add(INF);
    return list;
  }

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = Integer.parseInt(scanner.next());
    int Q = Integer.parseInt(scanner.next());
    String s = scanner.next();
    int[] l = new int[Q];
    int[] r = new int[Q];
    for (int i = 0; i < Q; i++) {
      l[i] = Integer.parseInt(scanner.next());
      r[i] = Integer.parseInt(scanner.next());
    }
    scanner.close();
    ArrayList<Integer> list = new ArrayList<Integer>();
    list = searchAC(s);

    //System.out.println(list);

    for (int i = 0; i < Q; i++) {
      System.out.println(cntAC(list, l[i] - 1, r[i] - 2));
    }

  }

}


Measured memory_bytes: 61912
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<climits>
#include<map>
#include<set>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<30
using namespace std;
typedef pair<double,int> P;
typedef pair<int,P> PP;

int main(){
  int n;
  int a,c;
  double b;
  unsigned long long Max;
  cin >> n;
  while(n-- > 0){
    Max = 0;
    unsigned long long mon;
    int year,num;
    vector<PP> va;


    cin >> mon >> year >> num;
    rep(i,num){
      cin >> a >> b >> c; 
   
      unsigned long long B,A,C;
      A = mon;
      C = 0;
      rep(i,year){
	B = A * b;
	if(a == 0){ // TAN
	  C = C + A * b;
	  A = A - c;
	}else if(a == 1){ // HUCK
	  A = A + B - c;
	}
      }
      if(a == 0)A = A + C;
      Max = max(Max,A);
    }


    cout << Max << endl;


  }
return 0;
}

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

#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair

#define forn(i,s,n) for(i=s;i<n;i++)
#define all(c)  c.begin(),c.end()
#define boost ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(0);srand(time(NULL));
#define tc(t) ll t;cin >> t; while(t--)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>



#define pii pair<long long,long long>
#define vii vector<pii>
#define vvi vector<vector <long long> >

#define ff first
#define ss second

#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vector<int> , greater<int> >

#define deb1(x) cout<<#x<<" : "<<x<<endl;
#define deb2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define deb3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
#define deba(a,n) for(ll i=0;i<n;++i) {  cout<<a[i]<<" "; };cout<<"\n"

#define MOD 1000000007
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN




int main()
{
 boost;
  int n,a,b;
  cin >> n >> a >> b;
  int c=n*a;
  cout << min(c,b);


}





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

using namespace std;

int A, B, C;
int K;
int m;
int res;

int main()
{
  cin >> A >> B >> C >> K;
  m = max(A, max(B, C));
  int temp = m;
  for (int i = 0; i < K; i++)
  {
    m *= 2;
  }
  res += A + B + C - temp + m;
  cout << res << endl;
  return 0;
}

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

int main(){
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    for(int i=0; i<X; i++) cin >> A[i];
    for(int i=0; i<Y; i++) cin >> B[i];
    for(int i=0; i<Z; i++) cin >> C[i];

    vector<ll> AB(X*Y);
    for(int i=0; i<X; i++) for(int j=0; j<Y; j++){
        AB[i + j*X] = A[i] + B[j];
    }
    sort(AB.begin(), AB.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());
    vector<ll> ans;
    int N = min(K, (int)AB.size());
    for(int i=0; i<N; i++){
        for(int j=0; j<Z; j++){
            ans.push_back(AB[i]+C[j]);
        }
    }
    sort(ans.begin(), ans.end(), greater<ll>());
    for(int i=0; i<K; i++){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 42984
lines = $stdin.read
array = lines.split("\n")
A,B = array[0].split(" ").map(&:to_i)
N = "#{A}#{B}".to_i

# p Math.sqrt(N).to_s
# p Math.sqrt(N).to_s.gsub(/.*\./,'')

if Math.sqrt(N).to_s.gsub(/.*\./,'').to_i > 0
  puts "No"
else
  puts "Yes"
end

Measured memory_bytes: 1788
#include<iostream>

using namespace std;

int main() {
	int N;
	cin >> N;
	int MSB = 0;//0-idx
	while (N >= (1 << MSB))MSB++;
	MSB--;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			for (int k = 0; k <= MSB; k++) {
				if ((i & (1 << k)) != (j & (1 << k))) {
					cout << k + 1 << " ";
					break;
				}
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstring>
using namespace std;
char a[6]={'0','C','F'}; 
int main(){
	string s;
	cin>>s;
	int len=s.length();
	int i,sum=0;
	for(i=0;i<len;i++){
		if(s[i]=='C'&&sum==0)	sum++;
		if(s[i]=='F'&&sum==1){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define p1 0
#define p2 1
#define p3 2

int prim();
int n,A[100][100];

int main()
{
  int i,j,sum;

  scanf("%d",&n);
  for(i = 0;i < n;i++)
    {
      for(j = 0;j < n;j++)
	{
	  A[i][j] = 0;
	  scanf("%d",&A[i][j]);
	  if(A[i][j] == -1) A[i][j] = 2500;
	}
    }
  printf("%d\n",prim());
  
  return 0;
}
int prim()
{
  int a,i,min,sum = 0;
  int d[100],p[100],c[100];

  for(i = 0;i < n;i++)
    {
      c[i] = p1;
      d[i] = 2500;
      p[i] = -1;
    }
  d[0] = 0;
  

  while(1)
    {
      min = 2500;
      a = -1;
      for(i = 0;i < n;i++)
	{
	  if(min > d[i] && c[i] != p3)
	    {
	      a = i;
	      min = d[i];
	    }
	}
      if(a == -1) break;

      c[a] = p3;
      for(i = 0;i < n;i++)
	{
	  if(c[i] != p3 && A[a][i] != 2500)
	    {
	      if(A[a][i] < d[i])
		{
		  d[i] = A[a][i];
		  p[i] = a;
		  c[i] = p2;
		}
	    }
	}
    }
  for(i = 0;i < n;i++)
    {
      if(p[i] != -1) sum += A[i][p[i]];
    }
  return sum;
}
  
  
  
  
  
 



Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

ll gcd(ll m, ll n){
  ll temp;
  while(m%n != 0){
    temp = n;
    n = m%n;
    m = temp;
  }
  return n;
}

int main(){
  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  ll lcmCD = C * D /gcd(C,D);
  ll ansC = (B-A+1) - (B/C - (A-1)/C);
  ll ansD = (B-A+1) - (B/D - (A-1)/D);
  ll ansCD = (B-A+1) - (B/lcmCD - (A-1)/lcmCD);


  ll answer = ansC + ansD - ansCD;

  cout << answer << endl;

  return 0;
}



Measured memory_bytes: 500
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int R;
	cin >> R;

	if (R < 1200)
	{
		cout << "ABC" << endl;
	}
	else if (R < 2800)
	{
		cout << "ARC" << endl;
	}
	else
	{
		cout << "AGC" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	long long k,x,d;
	cin>>x>>k>>d;
	if(x>0){
		if(x/d>=k){
			cout<<abs(x-k*d)<<endl;
		}
		else {
			long long ans=x-x/d*d;
			long long ans1=x-x/d*d-d;
			if((k-x/d)%2==1){
				cout<<abs(ans1)<<endl;
			}
			else {
				cout<<abs(ans)<<endl;
			}
		}
	}
	else {
		if(-x/d>=k){
			cout<<abs(x+k*d)<<endl;
		}
		else{
		
				long long ans=x+(-x)/d*d;
			long long ans1=x+(-x)/d*d+d;
			if((k-x/d)%2==1){
				cout<<abs(ans1)<<endl;
			}
			else {
				cout<<abs(ans)<<endl;
			}
		}
	
	}
}

Measured memory_bytes: 3168
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

int n, x;
vector<long double> v;

int main() {
  init_ios();
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    v.PB((long double)x);
  }
  sort(v.begin(), v.end());
  while (v.size() > 1) {
    auto v1 = v[0];
    auto v2 = v[1];
    v.erase(v.begin());
    v.erase(v.begin());
    v.PB((v1+v2)/2);
    sort(v.begin(), v.end());
  }
  cout<<fixed<<setprecision(10)<<v[0]<<"\n";
}

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

using namespace std;

#define ar array
#define ll long long

const int MAX_N = 1e5 + 1;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;



void solve() {
    int n, q; cin >> n >> q;
    vector<int> a(n + 1, n), b(n + 1, n);
    ll ans = (ll)(n - 2) * (n - 2);
    int h = n, w = n;
    while (q--) {
        int t, x; cin >> t >> x;
        if (t == 1) {
            if (x < w) {
                for (int i = x; i < w; i++) b[i] = h;
                w = x;
            }
            ans -= b[x] - 2;
        }
        else {
            if (x < h) {
                for (int i = x; i < h; i++) a[i] = w;
                h = x;
            }
            ans -= a[x] - 2;
        }
    }
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int tc; tc = 1;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        solve();
    }
}

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



long long int max(int a, int b) 
{ 
	return (a > b) ? a : b; 
} 

long long int knapSack(int W, int wt[], int val[], int n) 
{ 
	int i, w; 
	long long int K[n + 1][W + 1]; 

	for (i = 0; i <= n; i++) { 
		for (w = 0; w <= W; w++) { 
			if (i == 0 || w == 0) 
				K[i][w] = 0; 
			else if (wt[i - 1] <= w) 
				K[i][w] = max( 
					val[i - 1] + K[i - 1][w - wt[i - 1]], 
					K[i - 1][w]); 
			else
				K[i][w] = K[i - 1][w]; 
		} 
	} 

	return K[n][W]; 
} 

int main() 
{ 
    int n,w;
    cin>>n>>w;
    int val[n],wt[n];
    for(int i=0;i<n;i++)
      cin>>wt[i]>>val[i];
    
	cout<<(knapSack(w, wt, val, n)); 
	return 0; 
} 



Measured memory_bytes: 79104
#include<iostream>
using namespace std;
int main(void){
	int i,N,M,A[1000],B[1000],hcnt=0,cnt=0,money=0;
	cin>>N>>M;
	for(i=0;i<M;i++){
		cin>>A[i]>>B[i];
		if(A[i]>N){
			hcnt++;
			//cnt++;
		}
	}
	if(hcnt>=M-1){
		cout<<0<<endl;
		return 0;
	}
	i=0;
	while(hcnt<=M-1){//for(i=0;<M-1;i++){
		if(A[i]==N){
			hcnt++;
			i++;
		}
		else if(A[i]>N){
			i++;
		}
		else if(A[i]<N){
			if(cnt<N-A[i]){//今までの最大でかかるお金より多ければ
			money+=cnt;
			cnt=(N-A[i]);
			}
			else{
				money+=(N-A[i]);
			}
			hcnt++;
			i++;
		}
	}
	cout<<money<<endl;
	return 0;
}















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

namespace ITP1_4D
{
    class Program
    {
        static void Main(string[] args)
        {
            string inputText = Console.ReadLine();
            int n = int.Parse(inputText);

            inputText = Console.ReadLine();
            string[] words = inputText.Split(' ');

            if (words.Length < n)
            {
                return;
            }

            int[] intArray = new int[n];
            for (int i = 0; i < n; ++i)
            {
                intArray[i] = int.Parse(words[i]);
            }

            int minIndex = 0;
            int maxIndex = 0;
            long sum = 0;
            for (int i = 0; i < intArray.Length; ++i)
            {
                sum += intArray[i];
                if (intArray[i] < intArray[minIndex])
                {
                    minIndex = i;
                }
                if (intArray[maxIndex] < intArray[i])
                {
                    maxIndex = i;
                }
            }

            Console.WriteLine("{0} {1} {2}", intArray[minIndex], intArray[maxIndex], sum);
        }
    }
}

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

int main() {
  string s,sr="",sl="",ans = "Yes";
  int n,i;

  cin >> n;
  cin >> s;

  for(i=0;i<s.length();i++) {
    if(i<=(s.length()/2)-1) {sl+=s[i];}
    else if(i>(s.length()/2)-1) {sr+=s[i];}
  }

  if(sl==sr) {ans="Yes";}
  else if(sl!=sr) {ans="No";}
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>

char s[10][1001];
int cum[11][1001];
int main()
{
	int h, w, k;
	scanf("%d%d%d", &h, &w, &k);
	for (int i = 0; i < h; ++i)
	{
		scanf("%s", s[i]);
		for (int j = 0; j < w; ++j)
		{
			cum[i + 1][j + 1] = cum[i + 1][j] + (s[i][j] - '0');
		}
	}
	for (int j = 1; j <= w; ++j)
	{
		for (int i = 0; i < h; ++i)
		{
			cum[i + 1][j] += cum[i][j];
		}
	}

	int ans = 1e9;

	for (int part = 0; part < (1 << (h - 1)); ++part)
	{
		using pair = std::pair<short, short>;
		std::vector<pair> vec;
		for (int y = 0; y < h;)
		{
			int ys = y;
			int ye = y + 1;

			while (ye < h)
			{
				if ((part >> (ye - 1)) & 1) break;
				else ye++;
			}
			vec.emplace_back(pair{ys, ye});
			y = ye;
		}
		bool ng = false;
		int xcut = 0;
		for (int x = 0; x < w;)
		{
			int xs = x;
			int xe = xs;
			while (xe < w)
			{
				bool all = true;
				for (auto& p : vec)
				{
					int&& ys = p.first;
					int&& ye = p.second;
					if (cum[ye][xe + 1] - cum[ye][xs] - cum[ys][xe + 1] + cum[ys][xs] <= k)
					{
					}
					else
					{
						all = false;
					}
				}
				if (all)
				{
					++xe;
				}
				else
				{
					break;
				}
			}
			if (xe == xs)
			{
				ng = true;
				break;
			}
			if (xe != w)
			{
				++xcut;
			}
			x = xe;
		}
		if (!ng)
		{
			ans = std::min(ans, __builtin_popcount(part) + xcut);
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
[x,y,z] = input().split(" ")

a = int(x)
b = int(y)
c = int(z)

if a > b : 
    tmp = a
    a = b
    b = tmp
    
if b > c :
    tmp = b
    b = c
    c = tmp
    
if a > b : 
    tmp = a
    a = b
    b = tmp
    
    
print(a,b,c)
    



Measured memory_bytes: 5596
// Goods things are coming, just keep believing 
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define okay cout << "okay" << endl
// #define hey cout << "hey" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
// #define mpp make_pair
#define endl '\n'
#define ff first 
#define int long long
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 #define ld long double
#define INF 1000000000;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
 
 
 
const int N = 2e5 + 5;
const int LG = 20;
const int mod = 1e9 + 7;

int arr[N];
int pos[N];
vector<int> v[N];

int n;

void solve()
{
	int n;
	cin >> n;
	string input;
	cin >> input;
	int cnt = 0;
	for(int i = 0; i <= n - 3; i++)
	{
		string temp;
		temp.push_back(input[i]);
		temp.push_back(input[i + 1]);
		temp.push_back(input[i + 2]);
		if(temp == "ABC")
		{
			cnt++;
		}
	}
	cout << cnt << endl;
}
 
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int t = 1;
	// cin >> t;
	while(t--)
	{
		solve();
	}
}

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

int main() {
  int n; cin >> n;
  int a, cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a%2 == 1) cnt++;
  }
  cout << (cnt%2 == 0 ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
int a,b;
cin>>a;
cin>>b;


int ans=0;
for(int i=0;i<a;i=i+b)
{


        if ((b-a)<a)
    ans++;

    
}
if (ans ==0)
cout<< "1"<<endl;
else
cout<< ans<<endl;




return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
//#define sort(x) sort(x.begin(), x.end())
//sort(a,a+n,greater<ll>())
#define MAX 1000005
#define mod 1000000007


int main()
{
 //O_O ;
   ll n;
   cin>>n;ll s=0;
   for(ll i=1;i<=n;i++)
       for(ll j=1;j<=n;j++)
          for(ll k=1;k<=n;k++)
            s+=gcd(i,gcd(j,k));

    cout<<s<<nn;



    return 0;
}


Measured memory_bytes: 3600
N,K = map(int,input().split())
H = list(map(int,input().split()))
H = [H[0]]*K + H

INF = 10**18
dp = [INF for i in range(K+N)]
#dp = [INF]*(K+N)
dp[0] = 0

for i in range(K,N+K):
  h = H[i]
  costs = [x + abs(y - h) for x,y in zip(dp[i-K:i],H[i-K:i])]
  #print(costs)
  dp[i] = min(costs)

#print(dp)
print(dp[-1])



Measured memory_bytes: 13980
mod=10**9+7
def gcd(x,y):
    if x<y:
        x,y=y,x
    #x>y
    if x%y==0:
        return y
    else:
        return gcd(y,x%y)
def egcd(a, b):
    (x,lastx)=(0,1)
    (y,lasty)=(1,0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
def inv(x):
    return egcd(x,mod)[0]%mod
N=2*10**5+10
B,W=map(int,input().split())
Blist=[0 for i in range(N+1)]
Wlist=[0 for i in range(N+1)]
Fact=[0 for i in range(N+1)]
Finv=[0 for i in range(N+1)]
Exp2=[0 for i in range(N+1)]
Fact[0]=1;Finv[0]=1
Exp2[0]=1
for i in range(N):
    Exp2[i+1]=(Exp2[i]*2)%mod
for i in range(N):
    Fact[i+1]=(Fact[i]*(i+1))%mod
    Finv[i+1]=inv(Fact[i+1])
def C(n,k):
    if k<0 or n<k:
        return 0
    else:
        return (Finv[k]*(Fact[n]*Finv[n-k])%mod)%mod
Blist[0]=1;Wlist[0]=1
for i in range(N):
    Blist[i+1]=(2*Blist[i]-C(i,B-1))%mod
    Wlist[i+1]=(2*Wlist[i]-C(i,W-1))%mod
#print(Blist[:B+W])
#print(Wlist[:B+W])
ans=[0 for i in range(B+W)]
for i in range(B+W):
    ans[i]=(Blist[i]-Wlist[i]+Exp2[i])%mod
    ans[i]=(ans[i]*inv(Exp2[i+1]))%mod
for line in ans:
    print(line)


Measured memory_bytes: 102468
a=list(map(int,input().split()))
out=abs(a[1]-a[0])+abs(a[2]-a[1])
for i in range(3):
    if i ==0:
        b=a[1]
        c=a[2]
    elif i==1:
        b=a[0]
        c=a[2]
    else:
        b=a[0]
        c=a[1]
    if ((abs(b-a[i])+abs(c-b))<out):
        out=abs(b-a[i])+abs(c-b)
    if ((abs(c-a[i])+abs(b-c))<out):
        out=abs(c-a[i])+abs(b-c)
print(out)

Measured memory_bytes: 3064
#include <stdio.h>
#define H 251

typedef struct{
  int b;
  int c;
  int d;
  int e; 
}n;



n a[H];



int left(int i){return 2*i;}
int right(int i){return 2*i+1;}





int main(){
  int n,i;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&a[i].b);
  }
   for(i=1;i<=n;i++){
     if(i/2>=1)a[i].e=a[i/2].b;
    if(left(i)<=n)a[i].c=a[left(i)].b;
    if(right(i)<=n)a[i].d=a[right(i)].b;
    printf("node %d: key = %d, ",i,a[i].b);

    if(a[i].e)
     printf("parent key = %d, ",a[i].e);
    if(a[i].c)
      printf("left key = %d, ",a[i].c);
    if(a[i].d)
      printf("right key = %d, ",a[i].d);

    printf("\n");
   }
   
  
  return 0;
}



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

using namespace std;

int main() {

	int q, h, s, d;
	cin >> q >> h >> s >> d;
	long long n;
	cin >> n;
	n *= 8;

	vector<pair<int, int>> tanka(4);

	tanka[0] = make_pair( q * 8,2);
	tanka[1] = make_pair( h * 4,4);
	tanka[2] = make_pair( s * 2,8);
	tanka[3] = make_pair( d * 1,16);

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

	long long res=0;

	for (int i = 0; i < 4; i++) {
		res += n / tanka[i].second*tanka[i].first/(16/tanka[i].second);
		n = n % tanka[i].second;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 3604
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		long count = 5404;
		Map<Long, Long> map = new HashMap<>();
		List<Long> list = new ArrayList<>();
		for (int i = 0; i < count * 2 + 1; i++) {
			long hoge = (long) Math.pow(count - i, 5);
			list.add(hoge);
			map.put(hoge, count - i);
		}
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		for (int i = 0; i < list.size(); i++) {
			long a = list.get(i);
			for (int j = 0; j < list.size(); j++) {
				long b = list.get(j);
				if (a - b == n) {
					System.out.println(map.get(a) + " " + map.get(b));
					return;
				}
			}
		}
	}
}


Measured memory_bytes: 29384
#include <iostream>


#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
#include <list>
using namespace std;
#include <stdio.h>
#include <vector> 
#include <map> 
#include <algorithm>
#include <functional>
#include <algorithm>
#include <functional>
#include <array>
#include <iostream>

#include<iostream>
using namespace std;


int main()
{
	int N, K;
	std::string S;
	cin >> N >> K;

	int c = 0;
	for (int i = 0; i < N; ++i) {
		int h;
		cin >> h;
		if (h >= K) ++c;
	}

	printf("%d\n", c);

	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include <random>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  ll n;
  cin >> n;
  ll ans = n/11*2;
  n %= 11;
  if (n) ++ans, n -= 6;
  if (n > 0) ++ans;
  cout<<ans<<endl;
  return 0;
}































Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int top,S[100];
 
void push(int x){
  S[++top] = x;
}
 
int pop(){
  top--;
  return S[top+1];
}
 
int main(){
  int a,b;
  top = 0;
  char s[100];
 
  while( scanf("%s",s) != EOF){
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a + b);
    }
    else if(s[0] == '-'){
      b = pop();
      a = pop();
      push(a - b);
    }
    else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a * b);
    }
    else{
      push(atoi(s));
    }
  }
 
  printf("%d\n",pop());
 
  return 0;
 
}


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

int		count_equal(string a, string b)
{
	vector<bool> A(26, false);
	vector<bool> B(26, false);
	
	for (int i = 0; a[i]; i++)
		A[a[i] -'a'] = true;
	for (int i = 0; b[i]; i++)
		B[b[i] -'a'] = true;
	int ans = 0;

	for (int i = 0; i < 26; i++)
	{
		if (A[i] && B[i])
			ans++;
	}
	return (ans);
}

int		main(void)
{
	int n;
	string s;

	cin >> n;
	cin >> s;
	int ans = 0;

	for (int i = 1; i < n; i++)
	{
		int tmp;
		
		tmp = count_equal(s.substr(0, i), s.substr(i));
		ans = max(ans, tmp);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.insert(0,0)
a.insert(n+1,0)
sum_a=0
for i in range(n+1):
    sum_a+=abs(a[i]-a[i+1])
for i in range(1,n+1):
    print(sum_a-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]))

Measured memory_bytes: 14044
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piiii pair<pii,pii>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define logg2 0.30102999566398119521373889472449L
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e6+5;


vector<int> adj2[maxn+1];
int nex_node[maxn+1];


void solve(){
    ll a,b;cin>>a>>b;
    if(a<=0 && b>=0) cout<<"Zero";
    else if(a>0) cout<<"Positive";
    else{
        b=min(b,(ll)0);
        if((b-a+1)%2) cout<<"Negative";
        else cout<<"Positive";
    }
    return;
}
int main(){
    IO

    //TEST
    solve();
    return(0);
}


Measured memory_bytes: 27036
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
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 long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int a;
    cin>>a;
    cout<<a+pow(a,3)+pow(a,2)<<endl;
}


Measured memory_bytes: 4228
def solve():
    x, y = map(int, input().split())
    a = [1, 3, 5, 7, 8, 10, 12]
    b = [4, 6, 9, 11]
    c = [2]

    if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    solve()


Measured memory_bytes: 8980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
ll dp[101][101][500];
int main() {
  int n, W;
  cin >> n >> W;
  vector<ll> w(n), v(n);
  rep(i, n) cin >> w[i] >> v[i];
  int d = w[0];
  rep(i, n) {
    w[i] -= d;
  }
  rep(i,n)rep(j,n)rep(k,500) {
    ll ni = i + 1;
    ll nj = j + 1;
    ll nk = k + w[i];
    
    dp[ni][j][k] = max(dp[ni][j][k], dp[i][j][k]);
    if(nk + (nj * d) > W) continue;
    if(dp[ni][nj][nk] < dp[i][j][k] + v[i]) {
      dp[ni][nj][nk] = dp[i][j][k] + v[i];
    }
  }
  ll ans = 0;
  rep(i, n + 1) rep(j, 500){
    ans = max(ans, dp[n][i][j]);
  }
  cout << ans << endl;

}

Measured memory_bytes: 39680
import java.io.IOException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);

		while(true) {
			int H = sc.nextInt();
			int W = sc.nextInt();

			if(H==0&&W==0) {
				break;
			}

			for(int i=0;i<H;i++) {
				for(int j=0;j<W;j++) {
					if(i==0 || i==H-1 || j==0 || j==W-1) {
						System.out.print("#");
					}else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}

		sc.close();
	}
}


Measured memory_bytes: 34372
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

void solve()
{
    int n, K;
    scanf("%d%d", &n, &K);
    vector<int> a(n);
    int i;
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    long double l = 0, r = 1000000005.1;
    int k;
    for (k = 0; k < 60; k++) {
        long double m = (l + r) / 2;
        int cnt = 0;
        for (i = 0; i < n; i++) {
            int tmp=(int)((long double)a[i]/ m);
            cnt += tmp;
        }
        if (cnt > K) {
            l = m;
        }
        else {
            r = m;
        }
    }
    printf("%d\n", (int)(r+1-1e-9));

    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 3492
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,n) for(i=0;i<n;i++)in(v[i]);
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define cf(n) printf("%I64d\n",n)
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define N 100005
int x[N],y[N];
int main()
{
    int i,n,a,b,c,d;
    in(n);
    for(i=0;i<n;i++)
    {
        in(a);
        if(i&1)
            y[a]++;
        else
            x[a]++;
    }
    a=0,b=0;
    for(i=0;i<N;i++)
        if(x[i]>x[a])a=i;
    for(i=0;i<N;i++)
        if(y[i]>y[b])b=i;
    if(a!=b)
        n-=(x[a]+y[b]);
    else
    {
        c=0;
        for(i=0;i<N;i++)
            if(i!=a)c=max(c,y[i]);
        d=(x[a]+c);
        c=0;
        for(i=0;i<N;i++)
            if(i!=b)c=max(c,x[i]);
        d=max(d,c+y[b]);
        n-=d;
    }
    out(n);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    string ans;
    while(true){
        if(c-b <= 0){
            ans = "Yes";
            break;
        }
        c -= b;
        if(a-d <= 0){
            ans = "No";
            break;
        }
        a -= d;
    }

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}


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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    string s;
    int ans=0;
    cin >> s;
    REP(i,s.size()){
        if(s[i] == '1'){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define int long long

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int N, M;
vector<int> G[100100];

int color[100100];

bool dfs(int v, int c) {
    color[v] = c;
    for(auto u : G[v]) {
        if(color[u] == c) return false;
        if(color[u] == -1 && !dfs(u, 1 - c)) return false;
    }
    return true;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    cin >> N >> M;
    rep(i, M) {
        int a, b; cin >> a >> b;
        a --; b --;
        G[a].pb(b); G[b].pb(a);
    }
    memset(color, -1, sizeof(color));
    if(!dfs(0, 1)) {
        cout << N * (N - 1) / 2 - M << endl;
        return 0;
    } else {
        int cnt0 = 0, cnt1 = 0;
        rep(i, N) {
            if(color[i] == 0) cnt0 ++;
            else if(color[i] == 1) cnt1 ++;
        }
        cout << cnt1 * cnt0 - M << endl;
    }
	return 0;
}

Measured memory_bytes: 7424
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  ll N;
  cin >> N;
  string s;
  s = to_string(N);
  int divi = 0;
  rep(i,(int)s.size()){
    divi += (s[i]-'0');
  }
  if(N%divi==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	int MOD = 998244353;

	int n, a, b;
	long k;

	void run() {

		n = sc.nextInt();
		a = sc.nextInt();
		b = sc.nextInt();
		k = sc.nextLong();
		Arrays.fill(m, -1);
		m[0] = 1;
		p2(312345);
//		System.out.println(m[12]+" "+m[5]+" "+m[7]+" "+comb(12,7));
		long res = 0;
		for (long r = 0; r <= n; r++) {
			long bb = k - r * a;
			if (bb >= 0 && bb % b == 0 && bb / b <= n ) {
//				System.out.println(" "+r+" "+bb/b);
				res += pat((int)r, (int) (bb / b)) % MOD;
				res = res % MOD;
			}
		}

		System.out.println(res);

	}

	int[] m = new int[312345];

	void p2(int x) {

		for (int i = 1; i < x; i++) {
			m[i] = (int)((long)m[i - 1] * i % MOD);
		}

	}

	long div(long a, long b){
	    return (((a%MOD) * ( pow(b, MOD-2)))%MOD);
	}
	
	long pow(long x, long y) {
		if (y == 0) {
			return 1;
		}
		if (y == 1) {
			return x % MOD;
		}
		if (y % 2 == 0) {
			long p2 = pow(x, y / 2)  % MOD;
			return (p2*p2 %MOD);
		}
		long p2 = pow(x, y / 2)  % MOD;
		return ((((p2*p2)%MOD) * x) % MOD);
	}

	long comb(int n,int r){
		return div(div(m[n],m[r]),m[n-r])%MOD;
	}
	
	long pat(int rr, int bb) {
		return comb(n,rr)*comb(n,bb);
	}

}


Measured memory_bytes: 24532
#! usr/bin/env python
# -*- coding: utf-8 -*-

from collections import deque
import heapq
import math
import bisect


def main():
    N = int(input())
    A = list(map(int, input().split()))
    dp = [[-1]*2 for i in range(N+1)]

    dp[0][0] = A[0]
    dp[0][1] = -A[0]
    for i in range(N-1):
        dp[i+1][0] = max(dp[i][0]+A[i+1], dp[i][1]-A[i+1])
        dp[i+1][1] = max(dp[i][0]-A[i+1], dp[i][1]+A[i+1])

    print(dp[N-1][0])


if __name__ == '__main__':
    main()


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

int main(){
    int h,w,n;
    cin >> h >> w >> n;

    int ans;
    if (n % max(h,w) == 0) ans = n / max(h,w);
    else ans = n / max(h,w) + 1;

    cout << ans << endl;
}

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

int main(){
	int n;
	string s;
	cin >> n >> s;
	int ans = 1;
	char key = (char)s[0];
	for(int i=1;i<n;i++) {
		if(key != s[i]) {
			ans++;
			key = s[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
class Dice
  attr_reader :top, :front, :right, :left, :back, :bottom
  def initialize(pips)
    @top, @front, @right, @left, @back, @bottom = pips.split.map(&:to_i)
  end

  def rotate(dir)
    case dir
    when 'E'; tmp = @top; @top = @left; @left = @bottom; @bottom = @right; @right = tmp
    when 'W'; tmp = @top; @top = @right; @right = @bottom; @bottom = @left; @left = tmp
    when 'S'; tmp = @top; @top = @back; @back = @bottom; @bottom = @front; @front = tmp
    when 'N'; tmp = @top; @top = @front; @front = @bottom; @bottom = @back; @back = tmp
    when 'Z'; tmp = @front; @front = @right; @right = @back; @back = @left; @left = tmp
    end
  end

  def pips
    [
      {dir: 'top', pip: top},
      {dir: 'front', pip: front},
      {dir: 'right', pip: right},
      {dir: 'left', pip: left},
      {dir: 'back', pip: back},
      {dir: 'bottom', pip: bottom}
    ]
  end
end

d1 = Dice.new gets
d2 = Dice.new gets

d2.pips.each do |item|
  if d1.top == item[:pip]
    _d2 = d2.clone
    case item[:dir]
    when 'top'
    when 'bottom'; _d2.rotate('N'); _d2.rotate('N')
    when 'front'; _d2.rotate('N')
    when 'back'; _d2.rotate('S')
    when 'left'; _d2.rotate('E')
    when 'right'; _d2.rotate('W')
    end

    4.times do
      if d1.bottom == _d2.bottom &&
        d1.front == _d2.front && d1.back == _d2.back &&
        d1.left == _d2.left && d1.right == _d2.right
        puts 'Yes'
        exit
      end
      _d2.rotate('Z')
    end
  end
end

puts 'No'

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

int main() {
  int R, L, A, B, C, D;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  
  if (L > R) {
    cout << "Left" << endl;
  }
  
  if (L == R) {
    cout << "Balanced" << endl;
  }
  
  if (L < R) {
    cout << "Right" << endl;
  }
}

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

typedef long long ll;

int main() {
    int n;cin>>n;
    ll a[n];
    vector<ll>b;

    rep(i,n){
        cin>>a[i];
        if(a[i]-(i+1)<0)b.push_back(-a[i]+(i+1));
        a[i]+=(i+1);
    }
    sort(a,a+n);
    sort(b.begin(),b.end());
    int m = b.size();
    
    ll ans=0;
    ll tmp=0;
    ll cc=0;
    rep(i,n){
        if(i>=1 && a[i]==a[i-1])ans += cc;
        else{
            cc=0;
            for(int j=tmp;j<m;++j){
                if(b[j]==a[i])cc++;
                else if(b[j]<a[i])tmp=j+1;
                else break;
            }
            ans += cc;            
        }
    }

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

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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 1000000000
#define MOD 1000000007

int main(){

    ll k,n;
    cin >> k >> n;

    ll i,a1;

    vector<ll> a;

    for(i=0;i<n;i++){
        cin >> a1;
        a.push_back(a1);
    }

    ll maxa = 0;

    for(i=1;i<n;i++){
        maxa = max(maxa,(a[i]-a[i-1]));
    }

    maxa = max(maxa,min(a[n-1]-a[0],k-a[n-1]+a[0]));

    cout << k-maxa << endl;

}







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

 int main()
{

 string s,b;

 cin >> s >> b;
  int n = s.size(), ans = 0;
 for( int i = 0; i < n; ++i){
 if(s[i] != b[i]) ++ans;
 }
cout << ans << endl;
return 0;
}


Measured memory_bytes: 3896