akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<vector<int> > ame(2, vector<int>(N,0));
    for(int i=0;i<2;i++){
        for(int j=0;j<N;j++){
            int tmp;
            cin >> tmp;
            ame[i][j] = tmp;
        }
    }

    int max_ame = 0;
    for(int i=0;i<N;i++){
        int total_ame = 0;
        for(int j=0;j<N;j++){
            if(j<i)
                total_ame += ame[0][j];
            else if(j > i)
                total_ame += ame[1][j];
            else if(j == i){
                total_ame += ame[0][j];
                total_ame += ame[1][j];
            }
        }

        if(max_ame < total_ame) max_ame = total_ame;
    }
    cout << max_ame << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k;
	cin>>k;
	string s;
	cin>>s;
	int x=s.size();
	
	if(x<=k)
	cout<<s;
	else
	{
		for(int i=0;i<k;i++)
		{
			cout<<s[i];
		}
		cout<<"...";
	}
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#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__)


int main(){
    ll n,m;
    cin>>n>>m;
    ll x[n],y[n],z[n];
    rep(i,n) cin>>x[i]>>y[i]>>z[i];
    ll ans=0;
    rep(i,8){

        ll w[n];
        rep(j,n) w[j]=((i&1?x[j]:(-x[j]))+(i&2?y[j]:(-y[j]))+(i&4?z[j]:(-z[j])));
        sort(w,w+n,greater<ll>());
        ll tmp=0;
        rep(j,m) tmp+=w[j];
        chmax(ans,tmp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import numpy as np

if __name__ == '__main__':
    c = np.array([list(map(int, input().split())) for _ in range(3)])
    comb = [(0, 1), (1, 2), (2, 0)]
    # row
    for yc in comb:
        total = np.sum(c[:, yc[0]]) - np.sum(c[:, yc[1]])
        if total % 3 != 0:
            print("No")
            exit(0)

    # column
    for xc in comb:
        total = np.sum(c[xc[0], :]) - np.sum(c[xc[1], :])
        if total % 3 != 0:
            print("No")
            exit(0)

    print("Yes")


Measured memory_bytes: 12508
S = input()
divide = ['dream', 'dreamer', 'erase', 'eraser']
line = ['','','','']

for i in range(4):
    char = divide[i][::-1]
    line[i] = char
s_str = S[::-1]
char = ''
for i in range(len(s_str)):
    char += s_str[i]
    if char in line:
        char = ''
if char == '':
    print('YES')
else:
    print('NO')

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

int main(){
	while(1){
		int n,r;
		cin>>n>>r;
		if(n==0&&r==0) break;
		int a[50],b[50];
		lp(i,50){
			a[i]=i+1;
			b[i]=-1;
		}
		lp(i,r){
			int p,c;
			cin>>p>>c;
			lp(j,p){
				b[n-p-c+1+j]=a[n-p+1+j];
			}
			lp(j,c){
				b[n-c+j]=a[n-p-c+1+j];
			}
			lp(j,n){
				if(b[j]!=-1){
					a[j]=b[j];
				}
			}
			lp(j,50){
				b[j]=-1;
			}
		}
		cout<<a[n-1]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3092
n = int(input())
seen = set()
ans = 0
for i in range(1,n):
    if (min(i,n-i),max(i,n-i)) not in seen and min(i,n-i) != max(i,n-i):
        ans += 1
        seen.add((min(i,n-i),max(i,n-i)))
print(ans)

Measured memory_bytes: 80724
while True:
    try:
        n = int(input())
        count = 0
        for a in range(0,10):
            for b in range(0,10):
                for c in range(0,10):
                    for d in range(0,10):
                        if a+b+c+d==n:
                            count+=1
        print(count)
    except:
        break

Measured memory_bytes: 6724
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#include <utility>
#include <cctype>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#define LL long long
#define LB long double
#define x first
#define y second
#define Pair pair<int,int>
#define pb push_back
#define pf push_front
#define mp make_pair
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=1e9+7;
const LL LINF=2e16;
const int INF=2e9;
const int magic=348;
const double eps=1e-10;
const double pi=acos(-1);

inline int getint()
{
    char ch;int res;bool f;
    while (!isdigit(ch=getchar()) && ch!='-') {}
    if (ch=='-') f=false,res=0; else f=true,res=ch-'0';
    while (isdigit(ch=getchar())) res=res*10+ch-'0';
    return f?res:-res;
}

int n;
int a[4248][4248];
LL dp[4248][4248];
const int BASE=2008;
LL fac[100048],inv[100048],finv[100048];

inline void init_inv()
{
	fac[0]=fac[1]=1;inv[0]=inv[1]=1;finv[0]=finv[1]=1;
	for (register int i=2;i<=100000;i++)
	{
		inv[i]=MOD-((long long)(MOD/i)*inv[MOD%i])%MOD;
		fac[i]=(fac[i-1]*i)%MOD;
		finv[i]=(finv[i-1]*inv[i])%MOD;
	}
}

inline LL C(int x,int y)
{
	if (x<y) return 0ll;
	return ((fac[x]*finv[y])%MOD*finv[x-y])%MOD;
}

int main ()
{
	int i,j,x,y;
	init_inv();
	n=getint();
	for (i=1;i<=n;i++)
	{
		x=getint();y=getint();
		a[BASE+x][BASE+y]++;
		a[BASE-x][BASE-y]++;
	}
	for (i=1;i<=BASE;i++)
		for (j=1;j<=BASE;j++)
			dp[i][j]=a[i][j];
	for (i=1;i<=BASE*2;i++)
		for (j=1;j<=BASE*2;j++)
			dp[i][j]=(dp[i][j]+dp[i-1][j]+dp[i][j-1])%MOD;
	LL ans=0;
	for (i=BASE+1;i<=BASE*2;i++)
		for (j=BASE+1;j<=BASE*2;j++)
			ans=(ans+(dp[i][j]*a[i][j])%MOD)%MOD;
	for (i=BASE+1;i<=BASE*2;i++)
		for (j=BASE+1;j<=BASE*2;j++)
			ans=((ans-((long long)a[i][j]*C((i-BASE+j-BASE)*2,j-BASE+j-BASE))%MOD)%MOD+MOD)%MOD;
	ans=(ans*finv[2])%MOD;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 205056
#include<bits/stdc++.h>
using namespace std;
 
int Rank[1000005];
int Tmp[1000005];
int kc,len;
 
bool compare_sa(int i,int j){
  return
    Rank[i]!=Rank[j]?
    Rank[i]<Rank[j]:
    (i+kc<=len?Rank[i+kc]:-1)<(j+kc<=len?Rank[j+kc]:-1);
}
 
void construct_sa(char* S,int *sa){
  len=strlen(S);
  for(int i=0;i<=len;i++){
    sa[i]=i;
    Rank[i]=i<len?S[i]:-1;
  }
  for(kc=1;kc<=len;kc*=2){
    sort(sa,sa+len+1,compare_sa);
    Tmp[sa[0]]=0;
    for(int i=1;i<=len;i++){
      Tmp[sa[i]]=Tmp[sa[i-1]]+compare_sa(sa[i-1],sa[i]);
    }
    for(int i=0;i<=len;i++)Rank[i]=Tmp[i];
  }
}
 
 
int n,m;
char str[1000005];
char t[1000005];
int sa[1000005];
 
int main(){
  scanf("%s",str);
  n=strlen(str);
  construct_sa(str,sa);
  scanf("%d",&m);
  while(m--){
    scanf("%s",t);
    int k=strlen(t);
    int l=0,r=n+1,m;
    while(l+1<r){
      m=(l+r)/2;
      if(strncmp(str+sa[m],t,k)<=0)l=m;
      else r=m;
    }
    printf("%d\n",(strncmp(str+sa[l],t,k)==0));
  }
  return 0;
}

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

#define MOD 1000000007

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

int n,m;
string Mat[1002];
int pd[1002][1002];
inline bool check(int x,int y){
	if(x>=n or x<0 or y>=m or y<0 or Mat[x][y]=='#')
		return false;
	return true;
}
int dp(int x,int y){
	if(x==(n-1) and y==(m-1))
		return 1;
	if(pd[x][y]!=-1) return pd[x][y];
	int ans=0;
	for(int i = 0;i<2;i++)
		if(check(x+dx[i],y+dy[i]))
			ans = (ans+dp(x+dx[i],y+dy[i]))%MOD;
	return pd[x][y] = ans;
}

int32_t main(){
	memset(pd,-1,sizeof pd);
	cin >> n >> m;
	for(int i=0;i<n;i++)
		cin >> Mat[i];
	cout << dp(0,0) << '\n';
	
}

Measured memory_bytes: 5376
n,l = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
ans = false
for i in 1..n-1
  if a[i-1]+a[i] >= l
    ans = true
    last = i
    break
  end
end
puts ans ? "Possible" : "Impossible"
exit if !ans
puts (1..i-1).to_a,(i..n-1).to_a.reverse

Measured memory_bytes: 12932
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n,w;
    cin>>n>>w;
    long long int wt[n+1],vl[n+1];
    for(int i=1;i<=n;i++){
        cin>>wt[i]>>vl[i];
    }
   // cout<<w<<endl;
    long long ans[100001]={0};
    for(int i=1;i<=100000;i++)
        ans[i]=1e12;
    for(long long int i=1;i<=n;i++){
        for(long long int j=100000;j>=vl[i];j--){
            ans[j]=min(ans[j],wt[i]+ans[j-vl[i]]);
        }
    }
    //cout<<ans[100000]<<" "<<w<<endl;

    for(int i=100000;i>=0;i--){
    if(ans[i]<=w){cout<<i;
    return 0;}}
    return 0;
}


Measured memory_bytes: 1024
#pragma comment (linker, "/STACK:256000000")
 
#define _USE_MATH_DEFINES
#define _CRT_NO_DEPRECEATE
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <memory.h>
#include <sstream>
#include <cassert>
#include <ctime>
#include <complex>
 
//#include <random>
 
using namespace std;
 
 
double PI = 3.1415926535897932384626433832795;
long double EPS = 1e-12;
 
typedef unsigned int uint32;
typedef long long int64;
typedef unsigned long long uint64;
const int MOD = 1e9 + 7;
const int BASE = 1327; 
typedef pair<int, int> pii;
const int MAXN = 100100;

int b, a;
int mas[MAXN];
int was[MAXN];
int n, m;
int l;
inline void show(int x)
{
	cout << "Possible\n";
	for(int i = 0; i < x; ++i)
		cout << i + 1 << '\n';
	for(int i = n - 2; i > x; --i)
		cout << i + 1 << '\n';
	cout << x + 1;
}

void solve()
{
	cin >> n >> l;
	for(int i = 0; i < n; ++i)
		cin >> mas[i];
	for(int i = 0; i < n - 1; ++i)
	{
		if (mas[i] + mas[i + 1] >= l)
		{
			show(i);
			return;
		}
	}
	cout << "Impossible";
}

 
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _MY_DEBUG
    freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
#else
    //freopen(TASK ".in", "rt", stdin); freopen(TASK ".out", "wt", stdout);
#endif
    srand(1313);
	
	int t = 1;
	//cin >> t;
	
	
		solve();
	
	
    return 0;
}   

Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;

using namespace std;

int main(){
	
	string s,t;
	cin>>s>>t;
	for(int i=0;i<s.size();i++){
		string s2=s.substr(0,s.size()-1);
		s=s[s.size()-1]+s2;
		if(s==t){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll N; cin >> N;
	vll arr (N);
	F0R(i, N) cin >> arr[i];

	ll Z = 0;
	FOR(i, 2, N) Z ^= arr[i];

	ll X = arr[0], Y = arr[1];

	if (X + Y - Z % 2 == 1) {
		print(-1); return 0;
	}

	if ((X ^ Y) == Z) {
		print(0); return 0;
	}

	ll REQ = (X + Y - Z) / 2;
	ll SUM = X + Y; SUM -= REQ * 2;
	ll NEWX = REQ;

	if (NEWX > X)  {
		print(-1); return 0;
	}
	
	for (int bit = 50; bit >= 0; --bit) {
		if (SUM & (1LL << bit)) {
			if ((REQ & (1LL << bit))) {print(-1); return 0;}
			if (NEWX + (1LL << bit) <= X) {
				NEWX += (1LL << bit);
			}
		}
	}
	print((NEWX && ((NEWX ^ (Y + X - NEWX)) == Z)) ? (X - NEWX) : -1);
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795L
#ifndef DEBUG
#define debug(args...)
#else
#include "debug.h"
#endif
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
#ifdef DEBUG
  freopen("inp.txt", "r", stdin);
#endif
  ld a, b, h, m;
  cin>>a>>b>>h>>m;
  ld p1=2.0l*PI*(h*60.0l+m)/720.0l, p2=2.0l*PI*m/60.0l;
  cout<<setprecision(30)<<sqrtl(a*a+b*b-2.0l*a*b*cosl(p1-p2))<<'\n';
  return 0;
}


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


int main(){
  string S;
  cin>>S;
  string ans ="AC";
  if(S.at(0)!='A'){
    ans = "WA";
  }else{
    string tmp=S;
    int c_count = 0;
     transform(S.begin(), S.end(), S.begin(), ::toupper);
     for(int i = 1;i<S.size();i++){
       if(tmp.at(i)=='C'){
         if(i<2||i>S.size()-2){ans = "WA";break;}
         c_count++;
         if(c_count>1){ans = "WA";break;}
       }else if(S.at(i)==tmp.at(i)){ans ="WA";break;}
     }
     if(c_count==0)ans ="WA";
  }


  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <unordered_set>

using namespace std;

int A[3][3];
int C[8]{};

int main() {
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> A[i][j];
    }
  }
  int N;
  unordered_set<int> B;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    int b;
    cin >> b;
    B.insert(b);
  }
  for (auto &b : B) {
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 3; ++j) {
        if (A[i][j] == b) {
          ++C[i];
          ++C[j + 3];
          C[6] += i + j == 2;
          C[7] += i == j;
          for (int k = 0; k < 8; ++k) {
            if (C[k] >= 3) {
              printf("Yes\n");
              return 0;
            }
          }
        }
      }
    }
  }
  printf("No\n");
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

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

    vector<int> h(N);
    int zero_cnt = 0;
    for(auto& e : h){
        cin >> e;
        if(e == 0){
            zero_cnt++;
        }
    }

    int ans = 0;
    while(zero_cnt < N){
        for(int i=0;i<N;i++){
            if(h[i] > 0 && (i == 0 || h[i - 1] == 0)){
                ans++;
            }
        }
        zero_cnt = 0;
        for(int i=0;i<N;i++){
            if(h[i] > 0){
                h[i]--;
            }else{
                zero_cnt++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
    long long N, K;
    cin >> N >> K;
    long long ans = 0;

    long long n;

    n = 0;
    for(int i=1;i<=N;i++){
        if(i%K==0)
            n++;
    }
    ans += n*n*n;

    if(K%2 == 0){
        n = 0;
        for(int i=1;i<=N;i++){
            if(i%K==K/2)
                n++;
        }
        ans += n*n*n;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 int64_t n,k,i,x=0,h=1,c=0,r=0;
 cin>>n>>k;
 vector<int64_t> v(n);
 for (i=0;i<n;i++) cin >> v[i];
 for (i=60;i>=0;i--,c=0){
  for(auto a:v)c+=a>>i&1;
  if(c*2>n){if(k>>i&1)h=0;
  }else if(!h||k>>i&1)x|=1ll<<i;
 }
 for(auto a:v)r+=a^x;
 cout<<r<<endl;
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n,m,ans,cnt;
int low[60],vis[60];
vector<int>G[60];
void dfs(int x,int pr){
	vis[x]=low[x]=++cnt;
	for(auto to:G[x])if(to!=pr){
		if(vis[to])low[x]=min(low[x],vis[to]);
		else{
			dfs(to,x);
			low[x]=min(low[x],low[to]);
		}
	}
	if(low[x]==vis[x]&&pr!=-1)ans++;
}
int main(){
	cin>>n>>m;
	for(int i=1,x,y;i<=m;i++){
		cin>>x>>y;
		G[x].pb(y);
		G[y].pb(x);
	}
	dfs(1,-1);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3176
import math
 
A, B, H, M = map(int, input().split())
 
angle_A = 6*M
angle_B = 30*(H+M/60)
angle_C = abs(angle_A-angle_B)
 
rad_C = math.radians(angle_C)
 
C = math.sqrt(A**2+B**2-2*A*B*math.cos(rad_C))
 
print(C)

Measured memory_bytes: 9212
# Rem of sum is Num
# Reviewing problem


from collections import defaultdict


def cnt_func(X):
    res = 0
    right = 0
    L = len(X)
    for i in range(L):
        while right+1 < L and X[right+1] < K+X[i]:
            right += 1
        res += right-i
    return res


N, K = map(int, input().split())

A = list(map(int, input().split()))
A.insert(0, 0)
for i in range(1, N+1):
    A[i] += A[i-1]
B = [0 for i in range(N+1)]
for i in range(N+1):
    B[i] = (A[i]-i) % K
ans = 0
Mod = defaultdict(list)
for i in range(N+1):
    Mod[B[i]].append(i)
for X in Mod.values():
    ans += cnt_func(X)
print(ans)

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

int main(){
    int N;
    cin >> N;
    vector<int64_t> ryu(N+1);
    ryu.at(0) = 2;
    ryu.at(1) = 1;
    for (int i=2; i<N+1; i++){
        ryu.at(i) = ryu.at(i-1) + ryu.at(i-2);
    }
    cout << ryu.at(N) << endl;

    return 0;

}

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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int L = a + b;
	int R = c + d;
	if (L == R) {
		cout << "Balanced";
	}
	else if (L > R) {
		cout << "Left";
	}
	else {
		cout << "Right";
	}
}

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

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int[] D = new int[N + 1];
    for (int i = 1; i <= N; i++) D[i] = scanner.nextInt();
    Arrays.sort(D);
    for (int i = 0; i <= N; i++) {
      if (i + 2 <= N && D[i] == D[i + 1] && D[i] == D[i + 2]) {
        System.out.println(0);
        return;
      }
    }

    for (int i = 2; i <= N; i += 2) D[i] = 24 - D[i];
    Arrays.sort(D);

    int min = Integer.MAX_VALUE;
    for (int i = 1; i <= N; i++) min = Math.min(min, D[i] - D[i - 1]);
    min = Math.min(min, 24 - D[N]);
    System.out.println(min);
  }
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
typedef long long           ll;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << " | "; __f(comma + 1, args...);
}
ll max(ll a, ll b) {return (a > b ? a : b);}
ll min(ll a, ll b) {return (a < b ? a : b);}
#define all(x) (x).begin(), (x).end()

void solve() {
  ll ans = 0;
  ll h, w, bombs;
  cin >> h >> w >> bombs;
  ll u, v;
  map<ll, ll> x_axis, y_axis;
  set<pair<ll, ll>> points;
  for (ll i = 0; i < bombs; i++) {

    cin >> u >> v;
    points.insert({u, v});
    x_axis[u]++, y_axis[v]++;
  }
  ll mx = -1, row, col;

  for (auto i : x_axis) {
    u = i.second;
    if (u > mx)
    {
      mx = u;
      row = i.first;
    }
  }
  vector<ll> rows, colums;
  for (auto i : x_axis) {
    u = i.second;
    if (u == mx) {
      rows.push_back(i.first);
    }
  }
  mx = -1;
  for (auto i : y_axis) {
    u = i.second;
    if (u > mx) {
      mx = u;
    }

  }
  for (auto i : y_axis) {
    u = i.second;
    if (u == mx) colums.push_back(i.first);
  }
  ll n = rows.size(), m = colums.size();
  ans = -1;
  ans = x_axis[rows[0]] + y_axis[colums[0]];
  for (ll i = 0; i < n; i++)
    for (ll j = 0; j < m; j++) {
      u = x_axis[rows[i]] + y_axis[colums[j]];
      if (points.find({rows[i], colums[j]}) == points.end())
      {
        cout << u;
        return;
      }
      else u--;

    }


  cout << ans - 1 << "\n";

}
int main()
{
  cin.sync_with_stdio(0);
  cin.tie(0);
  ll t;
// cin >> t;
  solve();
  return 0;
}


Measured memory_bytes: 67784
#include <bits/stdc++.h>
using namespace std;
string s;
int k; 
int main()
{
	int mas[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	cin >> k;
	cout << mas[k-1];
	
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////
ll Gcd(ll x, ll y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return Gcd(y, x%y);
}
ll lcm(ll a, ll b) {
	ll g = Gcd(a, b);
	return a / g * b;
}
int N;
ll T[110];
int main() {
    cin >> N;
	ll ans = 1;
	for (int i = 0; i < N; ++i) {
		ll T;
		cin >> T;
		ans = lcm(ans, T);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
 
#define mod(cans) cans%10**9+7
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(unsigned i=0;i<n;i++)
#define repr(i,n) for(unsigned i=n-1;i>=0;i--)
#define rep1(i,n) for(unsigned i=1;i<=n;i++)
#define cin_pl(n,x) rep(i,n){cin>>x[i];}
#define cins(s,n) rep(i,n)cin>>s.at[i];
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define prians(Answer) cout<<Answer<<"\n"
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int> > matrix;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef greater<int> gi;
typedef vector<unsigned> vu;


ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
bool is_prime(const unsigned n){
    switch(n){
        case 0:
        case 1: return false;
        case 2: return true;
    }
 
 
    for(unsigned i=2;i<n;++i){
        if(n%i == 0) return false;
    }
 
    return true;
}
int Digits(unsigned x)
{
    int ans=0;
    while(x!=0)
    {
        x/=10;
        ans++;
    }
    return ans;
}
unsigned GetDigit(unsigned num){
    return to_string(num).length();
}


int main()
{
    cin.tie(0);
ios::sync_with_stdio(false);
ll n,p;cin>>n;
for(ll i=sqrt(n)+1;i>0;i--)
{
    if(n%i==0)
    {
       p=GetDigit(n/i);break;
    }
}
cout<<p;


}

Measured memory_bytes: 256
#include <iostream>
    #include <algorithm>
    #include <vector>
    #include <cmath>
     
    using namespace std;
     
    int main(){
     
      int a, b, c, k;
     
      cin >> a >> b >> c >>k;
     
      int d = max({a, b, c});
     
      int sum = a + b + c + int(pow(2, k)) * d - d;
     
      cout << sum << endl;
     
      return 0;
    }

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    long long n,r,b,s,k=0,cat,rest;
    cin>>n>>b>>r;
    s=b+r;
    cat=n/s;
    k=cat*b;
    rest=n%s;
    if(rest>b){
        k+=b;
    }
    else{
        k+=rest;
    }
    cout<<k;
  
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
#define int long long int
#define double long double
using namespace std;
#define INT_MAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

signed main()
{
int n;
std::cin >> n;
if(n == 3 || n == 5 || n == 7){
    std::cout << "YES" << std::endl;
} else {
    cout << "NO" << std::endl;
}
return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int>         vi;
const int mod = 1000000007;






int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k,change;
    cin>>n>>k;
    map<int,int>m;
    vi arr;
    for(int i =0;i<n;i++){
        int no;
        cin>>no;
        m[no]++;
    }
    if(k>=m.size()){
        cout<<0<<endl;
        return 0;
    }
    else{
        change  = m.size()-k;
        auto it = m.begin();
        for(int i =0;it!=m.end() && i <n;i++,it++){
                arr.pb(it->second);
        }
    }
    sort(all(arr));
    int ans=0;
    for(int i =0;i < change;i++){
        ans = ans + arr[i];
    }
    cout<<ans<<endl;








}






























































Measured memory_bytes: 14964
N,W = list(map(int,input().split()))
w = [0]*N
v = [0]*N

for i in range(N):
	w[i],v[i] = list(map(int,input().split()))

dp = [[0]*(W+1) for i in range(N)]
dp[0][w[0]] = v[0]

for i in range(1,N):
	for s in range(W+1):
		if s-w[i] >= 0:
			dp[i][s] = max(dp[i-1][s], dp[i-1][s-w[i]]+v[i])
		else:
			dp[i][s] = dp[i-1][s]
print(max(dp[N-1]))


Measured memory_bytes: 119772
// GeT AC

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int main() {
    int n, q;
    string s;    
    cin >> n >> q;
    cin >> s;


    // 8 3
    //  ACACTACG
    // [01122233]

    // 2 6 => 2
    // 1 2 => 0
    // 0 7 => 3


    int ac_count = 0;
    vector <int> memo(n, 0);
    for (int i = 1; i < n; i++) {
        if (s[i - 1] == 'A' && s[i] == 'C') {
            ac_count++;
        }
        memo[i] = ac_count;
    }
    memo[0] = 0;

    // for (int i = 0; i < n; i++) {
    //     cout << memo[i] << " ";
    // }
    // cout << endl;

    int l[n], r[n];
    int l_i, r_i;
    for (int i = 0; i < q; i++) {
        cin >> l_i >> r_i;
        l_i--;
        r_i--;
        l[i] = l_i;
        r[i] = r_i;
    }

    for (int i = 0; i < q; i++) {
        l_i = l[i];
        r_i = r[i];
        cout << memo[r_i] - memo[l_i] << endl;
    }

    return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int diff = 0;
  int size = s.size();
  rep(i, size) {
  	if(s.at(i) != t.at(i)) diff++; 
  }
  cout << diff << endl;
  return 0;
}

Measured memory_bytes: 3864
#include "bits/stdc++.h"

using namespace std;

//typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)



signed main(){

	int N, a[123456];
	cin >> N;

	for (int i = 0; i < N; i++)
		cin >> a[i];

	int ans = 0;
	for (int i = 0; i < N; i++){
		int j = i;
		while (j < N - 1 && a[j] <= a[j + 1]) j++;
		int k = i;
		while (k < N - 1 && a[k] >= a[k + 1]) k++;

		i = max(j, k);
		ans++;
	}
	cout << ans << endl;

	return 0;
}


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

int main() {
  int N; cin >> N;
  vector<ll> A(N);
  rep(i,N) cin >> A.at(i);

  ll sump=0; 
  ll ansp=0;
  ll summ=0;
  ll ansm=0;
  rep(i,N){
    sump += A.at(i);
    if(i%2==0 && sump<=0){
      ansp += -sump+1;
      sump = 1;
    }
    if(i%2==1 && sump>=0){
      ansp += sump+1;
      sump = -1;
    }
  }
  
  rep(i,N){
    summ += A.at(i);
    if(i%2==1 && summ<=0){
      ansm += -summ+1;
      summ = 1;
    }
    if(i%2==0 && summ>=0){
      ansm += summ+1;
      summ = -1;
    }
  }
  cout << min(ansp, ansm) << endl; 
  return 0;
}


Measured memory_bytes: 4020
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    int64_t n, d;
    cin >> n >> d;

    int64_t ans = 0;
    vector<vector<int64_t>> v(n, vector<int64_t>(d));
    for (auto i : irange(0L, n)) {
        for (auto j : irange(0L, d)) {
            cin >> v[i][j];
        }

        for (auto j : irange(0L, i)) {
            int64_t dist2 = 0;
            for (auto k : irange(0L, d)) {
                dist2 += (v[i][k] - v[j][k]) * (v[i][k] - v[j][k]);
            }

            int64_t dist = sqrt(dist2);
            if (dist * dist == dist2 || (dist + 1) * (dist + 1) == dist2) {
                ++ans;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int my_ceil(int a, int b){
    return (a+b-1)/b;
}

int main(){
    int n;
    cin >> n;
    cout << fixed << setprecision(10);
    cout << (double)my_ceil(n,2)/(double)n << endl;

}

Measured memory_bytes: 3764
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<sstream>
using namespace std;
#define MOD 1000000007
#define ll long long
const long long INF = 1LL << 60;

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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};


int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

long long dp[110][100010];
int main() {
	int N;
	cin >> N;
	int co[2][101];
	ll h[101];
	for (int i = 0; i < N; i++) {
		cin >> co[0][i] >> co[1][i] >> h[i];
	}
	int flag = 0;
	for (int i = 0; i < 101; i++) {
		for (int j = 0; j < 101; j++) {
			int temp;
			for (int k = 0; k < N; k++) {
				if (h[k] > 0) {
					temp= abs(i - co[0][k]) + abs(j - co[1][k]) + h[k];
					break;
				}
			}
			
			for (int k = 0; k < N; k++) {
				int temp2 = temp - abs(i - co[0][k]) - abs(j - co[1][k]);
				if (temp2 < 0)temp2 = 0;
				if (temp2 != h[k]) {
					flag = 1;
					break;
				}
			}
			if (flag == 0) {
				cout << i << ' ' << j << ' ' << temp;
				return 0;
			}
			else {
				flag = 0;
			}

		}
	}


	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

//#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

signed main()
{
	vector<int> v;

	int N;
	cin >> N;

	REP(i, N)
	{
		int A;
		cin >> A;

		auto it = lower_bound(v.begin(), v.end(), A);

		if (it == v.end())
		{
			v.insert(it, A);
		}
		else
		{
			if (*it == A)
			{
				v.erase(it);
			}
			else
			{
				v.insert(it, A);
			}
		}
	}

	cout << v.size() << endl;
}

Measured memory_bytes: 892
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

int main()
{
	ll a, b;
	cin >> a >> b;

	ll cnt = 0;

	if (a == b)
	{
		cnt = 0;
	}
	else if (a == 0)
	{

		if (b < 0)
		{
			cnt++;
		}
		cnt += abs(b);
	}
	else if (b == 0)
	{
		if (a > 0)
		{
			cnt++;
		}
		cnt += abs(a);

	}
	else if (a > 0 && b > 0)
	{
		if (a <= b)
		{
			cnt = b - a;
		}
		else
		{
			cnt = a + b;
			//cnt++;
		}
	}
	else if (a > 0 && b < 0)
	{
		b *= -1;
		if (a <= b)
		{
			cnt = b - a;
		}
		else
		{
			cnt = a - b;
		}
		cnt++;
	}
	else if (a < 0 && b > 0)
	{
		a *= -1;
		if (a <= b)
		{
			cnt = b - a;
		}
		else
		{
			cnt = a - b;
		}
		cnt++;
	}
	else
	{
		a *= -1;
		b *= -1;
		if (a <= b)
		{
			cnt = b - a;
			cnt += 2;
		}
		else
		{
			cnt = a - b;
		}
	}

	cout << cnt << endl;
}

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

using namespace std;

int main() {
    string str;
    cin >> str;
    int ans=0;
    bool flag=true;
    vector<string> vec;
    vec.push_back("eraser"); vec.push_back("erase"); vec.push_back("dreamer"); vec.push_back("dream");
    for(int i=str.size()-1; i>=0; i--) {
        if(str[i]=='r') {
            if(i-1>0 && str[i-1]=='e') {
                if(i-2>0) {
                    if(str[i-2]=='s') {
                        if(i-5>=0) {
                            for(int j=i-3; j>=i-5; j--) {
                                if(vec[0][j-i+5]!=str[j]) {
                                    flag=false;
                                    break;
                                }
                            }
                            if(!flag) {
                                break;
                            }
                            i -= 5;
                        } else {
                            flag=false;
                            break;
                        }
                    } else if(str[i-2]=='m') {
                        if(i-6>=0) {
                            for(int j=i-3; j>=i-6; j--) {
                                if(vec[2][j-i+6]!=str[j]) {
                                    flag=false;
                                    break;
                                }
                            }
                            if(!flag) {
                                break;
                            }
                            i -= 6;
                        } else {
                            flag=false;
                            break;
                        }
                    } else {
                        flag=false;
                        break;
                    }
                } else {
                    flag=false;
                    break;
                }
            } else {
                flag=false;
                break;
            }
        } else if(str[i]=='e') {
            if(i-4>=0) {
                for(int j=i-1; j>=i-4; j--) {
                    if(vec[1][j-i+4]!=str[j]) {
                        flag=false;
                        break;
                    }
                }
                if(!flag) {
                    break;
                }
                i -= 4;
            } else {
                flag=false;
                break;
            }
        } else if(str[i]=='m') {
            if(i-4>=0) {
                for(int j=i-1; j>=i-4; j--) {
                    if(vec[3][j-i+4]!=str[j]) {
                        flag=false;
                        break;
                    }
                }
                if(!flag) {
                    break;
                }
                i -= 4;
            } else {
                flag=false;
                break;
            }
        }
    }

    if(flag) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }


    return 0;
    
}

Measured memory_bytes: 512
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, M = read_ints()
    # M = a*b b >= N
    i = 1
    max_gcd = 1
    while i*i <= M:
        if M%i == 0:
            if M//i >= N:
                max_gcd = max(max_gcd, i)
            if i >= N:
                max_gcd = max(max_gcd, M//i)
        i += 1
    return max_gcd


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 63412
v[50],p,n,c;f(X){for(n=0;n<X;n+=v[p++]);c+=n;}main(s){for(;n=atoi(gets(v));printf("%d\n",s)){for(c=p=s=0;p<n;v[++p]=strlen(gets(v+n)));for(;c-31;)c=0,p=++s,f(5),f(7),f(5),f(7),f(7);}}

Measured memory_bytes: 532
#include <bits/stdc++.h>
using namespace std;
typedef tuple<int, int, int> T;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q;
    cin >> N >> Q;
    vector<T> v(N);
    for (int i = 0; i < N; i++) {
        int s, t, x;
        cin >> s >> t >> x;
        v[i] = T(x, s, t);
    }
    sort(v.begin(), v.end());
    vector<int> D(Q);
    set<int> se;
    se.insert(2e9);
    for (int i = 0; i < Q; i++) {
        cin >> D[i];
        se.insert(D[i]);
    }
    map<int, int> ma;
    for (int i = 0; i < N; i++) {
        int x = get<0>(v[i]), s = get<1>(v[i]), t = get<2>(v[i]);
        int l = s - x;
        int r = t - x;
        while (1) {
            auto itr = se.lower_bound(l);
            if (*itr >= r) break;
            ma[*itr] = x;
            se.erase(*itr);
        }
    }
    for (int i = 0; i < Q; i++) {
        int p = ma[D[i]];
        cout << (p ? p : -1) << endl;
    }
}


Measured memory_bytes: 22784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  int n = s.size();
  vi v(n + 1, 0);
  rep(i, n) if(s[i] == 'L') v[i] = 1;
  vi ans;
  int r, k = 0;
  rep(i, n) {
    int d = v[i + 1] - v[i];
    if(d == 1) r = i;
    if(d == -1) {
      int m = i - k + 1;
      vi now(m, 0);
      int j = r - k;
      if(j % 2) {
        now[j] = m / 2;
        now[j + 1] = (m + 1) / 2;
      } else {
        now[j] = (m + 1) / 2;
        now[j + 1] = m / 2;
      }
      rep(j, m) ans.push_back(now[j]);
      k = i + 1;
    }
  }
  for(int u : ans) cout << u << ' ';
  cout << endl;
}

Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N,M;
	cin>>N>>M;
	vector<int> dp(N+1,0);
	rep(i,M){
		int t;
		cin>>t;
		dp[t] = -1;
	}
	dp[0] = 1; dp[1] = ((dp[1]==-1)?0:1);
	for(int i = 2; i<=N ; ++i){
		if(dp[i] == -1)continue;
		int b1 = ((dp[i-1] == -1)?0:dp[i-1]);
		int b2 = ((dp[i-2] == -1)?0:dp[i-2]);
		dp[i] = b1 + b2;
		dp[i] %= MOD;
	}
	cout<<dp[N]<<endl;
	return 0;
}

Measured memory_bytes: 640
n=int(input())
List=list(map(int,input().split()))
num=0
cnt=0
for i in List:
    if i%2==0:
        num+=1
        if i%3==0 or i%5==0:
            cnt+=1
if num==cnt:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3060
import java.util.*;

// ARC 86-D
// https://beta.atcoder.jp/contests/arc086/tasks/arc086_b

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int A = in.nextInt();
		int B = in.nextInt();
		String s = in.next();
		
		boolean isValid = true;
		if (s.length() != A + B + 1) {
			isValid = false;
		}
		if (s.charAt(A) != '-') {
			isValid = false;
		}
		for (int i = 0; i < s.length(); i++) {
			if (i != A && !('0' <= s.charAt(i) && s.charAt(i) <= '9')) {
				isValid = false;
			}
		}
		System.out.println(isValid ? "Yes" : "No");
	}
}


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

int main(){
  string s;cin>>s;
  char a;
  int ans=0;
  sort(s.begin(),s.end());
  a=s[0];
  for(char c:s){
    if(c != a){
      ++ans;
      a=c;
      }
  }
  if(ans>1 || ans==0) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;

  return 0;
}

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

constexpr int MAXN = 5 + 1e5;
constexpr ll INF = 1e18;

ll mul(ll a, ll b) {
  if (a == -1) return -1;
  ll mina = (INF+b-1)/b;
  if (a > INF/b) return -1;
  /*cout << a << "*" << b << "=" << a*b << endl;
  cout << a << " " << mina << endl;
  cout << "--------\n";*/
  return a*b;
}

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  int n; cin >> n;
  ll ans = 1;
  while (n--) {
    ll x; cin >> x;
    if (x == 0) {
      ans = 0;
      break;
    }
    ans = mul(ans, x);
  }
  cout << ans << '\n';
  return 0;
}


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

int n;
char buf[11451419];

int main() {
  while (1) {
    fgets(buf, sizeof(buf), stdin);
    if (buf[0] == '.') return 0;

    stack<char> q;
    bool ans = true;

    n = strlen(buf);
    for (int i=0; i<n; i++) {
      char c = buf[i];
      if (c == '(' || c == '[') {
        q.push(c);
      } else if (c == ')') {
        if (q.empty()) ans = false;
        else {
          if (q.top() != '(') ans = false;
          q.pop();
        }
      } else if (c == ']') {
        if (q.empty()) ans = false;
        else {
          if (q.top() != '[') ans = false;
          q.pop();
        }
      }
    }

    if (!q.empty()) ans = false;

    if (!ans) puts("no");
    else puts("yes");
  }
}

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



int main() 
{
  ll N,M; cin>>N>>M;
  vector<ll> kaidan(N+1,-1);//{-1,-1,-1,-1,........,-1}
  rep(i,M)
  {
    ll a; cin>>a;
    kaidan.at(a)=0;
  }
  rep(i,N+1)
  {
    if(i==0)
    {
      if(kaidan.at(0)!=0)
      {
        kaidan.at(0)=1;
        continue;
      }
    }
    if(i==1)
    {
      if(kaidan.at(1)!=0)
      {
        kaidan.at(1)=1;
        continue;
      }
    }
    if(kaidan.at(i)==-1)
    {
      ll &b=kaidan.at(i);
      b=kaidan.at(i-1)+kaidan.at(i-2);
      b%=1000000007;
    }  
  }
  cout<<kaidan.at(N)<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <functional>
#include <cstdio>
#include <queue>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
typedef long long ll; 
std::priority_queue<ll> quel;
std::priority_queue<ll, std::vector<ll>, std::greater<ll> > quer; 
int l[100005], r[100005]; 
int main()
{
	// freopen("ARC070-E.in", "r", stdin); 
	int n; 
	scanf("%d", &n); 
	ll ans = 0, st_l = 0, st_r = 0; 
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", l + i, r + i); 
		if (!i)
		{
			quel.push(l[i]); 
			quer.push(l[i]); 
			continue; 
		}
		st_l -= r[i] - l[i]; 
		st_r += r[i - 1] - l[i - 1]; 
		ll x = quel.top() + st_l, y = quer.top() + st_r; 
		if (l[i] < x)
		{
			ans += my_abs(x - l[i]); 
			quer.push(x - st_r); 
			quel.push(l[i] - st_l); 
			quel.push(l[i] - st_l); 
			quel.pop(); 
		}
		else if (l[i] > y)
		{
			ans += my_abs(y - l[i]); 
			quel.push(y - st_l); 
			quer.push(l[i] - st_r); 
			quer.push(l[i] - st_r); 
			quer.pop(); 
		}
		else
		{
			quel.push(l[i] - st_l); 
			quer.push(l[i] - st_r); 
		}
	}
	printf("%lld\n", ans);
	return 0; 
}


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

int main() {
	char s[3];
	string ans = "No";

	rep(i,3) {
		cin >> s[i];
	}

	if(s[0] != s[1] || s[0] != s[2] || s[1] != s[2]) ans = "Yes";
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <list> 
#define F(i,x,y) for(int i=x;i<=y;++i)
using namespace std;
list<char>l;
bool flag=false;
char s[100005],C;
int Q,T,F;
int main(){
	scanf("%s%d",s,&Q);
	F(i,0,strlen(s)-1){
		l.push_back(s[i]);
	}
	F(i,1,Q){
		scanf("%d",&T); 
		if(T==1)flag=!flag;
		else{
			scanf("%d",&F);
			getchar();
			C=getchar();
			--F;
			if(!(((int)flag+F)&1))l.push_front(C);
			if(((int)flag+F)&1)l.push_back(C);
		}
	}
	if(flag)l.reverse();
	for(list<char>::iterator it=l.begin();it!=l.end();++it){
		printf("%c",*it);
	}
	printf("\n");
	return 0;
}


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

using namespace std;

#ifdef LOCAL
#define DBG_MACRO_NO_WARNING
#include <dbg.h>
#else
#define dbg(...) 0
#endif

using ll = long long;
using ull = unsigned long long;

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

#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  int x;
  cin >> x;

  cout << x*x << endl;

  return 0;
}

Measured memory_bytes: 3656
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int catCnt = sc.nextInt();
        int animalCnt = sc.nextInt();
        int requiredNumber = sc.nextInt();
        int remaining = requiredNumber - catCnt;
        if(animalCnt >= remaining && remaining >= 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

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

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

    int ans = 0;

    while(n > 0) {
        n -= (2 * d + 1);
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256