akhauriyash/Code-Regression huggingface dataset:
s=input()
ans=1
i=0
while 1:
  if i>=len(s):
    break
  if s[i:i+5]=="dream":
    i+=5
  elif s[i:i+5]=="erase":
    if s[i:i+6]=="eraser":
      i+=6
    else:
      i+=5
  elif s[i-5:i+2]=="dreamer":
    i+=2
  else:
    ans=0
    break
if ans:
  print("YES")
else:
  print("NO")

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

string solve(string s){
    int n = 1<<10;
    vector<int> dp(n, 0);
    int curr = 0;
    for(char c: s){
        if(c == 'u'){
            curr = 0;
        }else{
            dp[curr] |= 1<<(c-'0');
            curr |= 1<<(c-'0');
        }
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<i; j++){
            if(!(i&j) and (dp[j]&i)){
                dp[i|j] |= dp[i];
            }
        }
    }
    for(int i=0; i<n; i++){
        if(dp[i]&i){
            return "UNSAFE";
        }
    }
    return "SAFE";
}

int main(){
    while(1){
        int n;
        cin >> n;
        if(n == 0) break;

        string s;
        cin >> s;
        cout << solve(s) << endl;
    }
    return 0;
}



Measured memory_bytes: 3220
A, B, K = [int(_) for _ in input().split()]
if 2*K <= B-A:
    print("\n".join([str(_) for _ in list(range(A,A+K)) + list(range(B-K+1,B+1))]))
else:
    print("\n".join([str(_) for _ in list(range(A,B+1))]))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ms(x, n) memset(x,n,sizeof(x));
typedef  long long LL;
const int INF = 1 << 30;
const int MAXN = 1e4+10;

int n, a[MAXN];
bool cmp(int x, int y){return x > y;}
int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> a[i];
    sort(a+1, a+1+n, cmp);
    int ans = 0;
    for(int i = 1; i <= n; ++i)
        for(int j = i+1; j <= n; ++j){
            int t = lower_bound(a+1+j, a+n+1, a[i]-a[j], greater<int>())-a-1;
            if(t-j > 0) ans += t-j;
        }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fl(n)             for(long long int i=0;i<n;i++)
#define sz(a)             int((a).size())
#define tr(c,i)           for(auto i = (c).begin(); i != (c).end(); i++)
#define trr(c,i)          for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define present(c,x)      ((c).find(x) != (c).end())
#define cpresent(c,x)     (find(all(c),x) != (c).end())
#define vi                vector <int>
#define vvi               vector < vi >
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define ll                long long
#define fr                first
#define sc                second
#define vc                vector
#define pii               pair<int,int>
#define msi               map<string,int> 
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define M                 1000000007


int solve()
{
	string s,t;
	cin>>s>>t;

	int mn=sz(s),szs=sz(s),szt=sz(t);
	for(int i=0;i<=szs-szt;i++)
	{
		int tmn=0;
		for(int j=0;j<szt;j++)
		{
			if(t[j]!=s[i+j])
				tmn++;
		}
		if(tmn<mn)
			mn=tmn;
	}
	cout<<mn<<"\n";


  return 0;
}


int main() {
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
  
  int t=1;
  //cin>>t;
  while(t--)
  {
    solve();
  }
  return 0;
}

 

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

int main() {
  vector<int> A(6);
  for (int i = 0; i < 6; i++) {
    cin >> A.at(i);
  }

  map<int, int> cnt;
  for (int x : A) {
    if (cnt.count(x)) {
      // 既に含まれているならインクリメント
      cnt.at(x)++;
    } else {
      // 含まれていないなら、1を追加
      cnt[x] = 1;
    }
  }

  bool ans = true;
  for (auto p : cnt) {
    auto value = p.second;
    if (value == 0 or value == 3) {
      ans = false;
    }
  }
  if (ans) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int i,num=0,num2=0;
  	string ch;
  	cin>>ch;
  	for(i=0;i<ch.size();i++){
    	if(ch[i]=='A')num++;
      	else num2++;
    }
  if(num>0 &&num2>0)cout<<"Yes";
  else cout<<"No";
  return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()


def main():
    S = input()
    ans = set()
    for c in S: ans.add(c)
    if ans == {'a', 'b', 'c'}:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 61868
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#include<deque>
#define rep(i,rept)	for(int i = 0; i<(int)rept;++i)
typedef long long ll;
using namespace std;


int main() {
	//17日目 
	//尺取り法

	cin.tie(0); ios::sync_with_stdio(false);


	int sx, sy, tx, ty;
		
	cin >> sx >> sy >> tx >> ty;

	int disx = 0, disy = 0;
	disx = tx - sx;
	disy = ty - sy;

	cout << string(disy, 'U') << string(disx, 'R');
	
	cout << string(disy, 'D') << string(disx, 'L');
	
	cout << 'L' << string(disy + 1, 'U') << string(disx + 1, 'R') << 'D';

	cout << 'R' << string(disy + 1, 'D') << string(disx + 1, 'L') << 'U';

	cout << endl;
	return 0;
}


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

using namespace std;

long long ans,n,m,x,y,i,banyak;
vector<int> edge[100007];
long long flag[100007];

bool DFS(int pos, int nyan) {
	bool ret = 1;
	
	int i;
	for (i=0 ; i<edge[pos].size() ; i++) {
		if (flag[edge[pos][i]] == 0) {
			flag[edge[pos][i]] = 3 - nyan;
			//printf("--- %lld %lld\n",edge[pos][i],3-nyan);
			banyak++;
			ret &= DFS(edge[pos][i], 3 - nyan);
		} else if (flag[edge[pos][i]] == nyan) {
			//printf("%lld %lld %d\n",pos,edge[pos][i],nyan);
			ret = false;
		}
	}
	
	return ret;
}

int main() {
	scanf("%lld%lld",&n,&m);
	for (i=0 ; i<m ; i++) {
		scanf("%lld%lld",&x,&y);
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	
	for (i=1 ; i<=n ; i++) if (flag[i] == 0) {
		flag[i] = 1;
		banyak = 1;
		bool bin = DFS(i,1);
		assert(banyak == n);
		//printf("%lld %lld\n",bin,banyak);
		if (bin) {
			long long x = 0;
			for (i=1 ; i<=n ; i++) if (flag[i] == 1) x++;
			ans += x * (n-x);
		} else {
			ans += (banyak) * (banyak-1) / 2;
			
		}
	}
	
	printf("%lld\n",ans-m);
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{

    int N,M;
    cin >> N >> M;
    map<ll,ll> A;
    rep(i,N){
        ll a;
        cin >> a;
        A[-a]++;
    }
    
    rep(i,M){
        ll b,c;
        cin >> b >> c;
        A[-c] += b;
    }
    
    ll ans = 0;
    ll num = (ll)N;
    
    for (auto P : A) {
        if(P.se <= num){
            ans += P.fi*P.se;
            num -= P.se;
        }else{
            ans += P.fi*num;
            num = 0;
        }
        
        
        if(num == 0){
            cout << -ans << endl;
            return 0;
        }
    }
    
    
    
    

    return 0;
}


Measured memory_bytes: 12800
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
	int n;
	while(cin>>n,n){
		int a[19][19]={0};
		int x=n/2+1;
		int y=n/2;
		
		a[x][y]=1;
		for(int i=2;i<=n*n;i++){
			x++;y++;
			if(n==x&&n==y){
				int k;
				//cout<<x<<" "<<y<<" "<<i<<endl;
				for(k=0;a[k][n-1]!=0;k++);
				x=k;y=n-1;
				//cout<<x<<" "<<y<<" "<<i<<endl;
				a[x][y]=i;continue;
			}
			if(a[x][y]!=0){
				x++;
				y--;			
			}
			//はみ出したら
			if(x>=n)x=0;
			if(y>=n)y=0;
			a[x][y]=i;
			//cout<<x<<" "<<y<<" "<<i<<endl;
		}
		
	//	a[0][n-1]=100;
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				printf("%4d",a[i][j]);
			}
			cout<<endl;
		}
	}
	
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int A, B, C; cin >> A >> B >> C;
  int X, Y; cin >> X >> Y;
  int a, b;
  ll ans = 1000000000000000000;
  for(int i = 0; i <= max(X, Y); ++i) {
    a = i; b = i;
    int tmp_a = 0; int tmp_b = 0;
    if(X > a) tmp_a = X - a;
    if(Y > b) tmp_b = Y - b;
    ll tmp = C * i * 2 + A * tmp_a + B * tmp_b;
    if(ans > tmp) ans = tmp;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
N = input()
a = int(N[0])
b = int(N[1])
c = int(N[2])
d = int(N[3])
A = N[0]
B = N[1]
C = N[2]
D = N[3]

if a + b + c + d == 7:
    print(A + "+" + B + "+" + C + "+" + D + "=" + "7")
elif a + b + c - d == 7:
    print(A + "+" + B + "+" + C + "-" + D + "=" + "7")
elif a + b - c + d == 7:
    print(A + "+" + B + "-" + C + "+" + D + "=" + "7")
elif a - b + c + d == 7:
    print(A + "-" + B + "+" + C + "+" + D + "=" + "7")
elif a + b - c - d == 7:
    print(A + "+" + B + "-" + C + "-" + D + "=" + "7")
elif a - b + c - d == 7:
    print(A + "-" + B + "+" + C + "-" + D + "=" + "7")
elif a - b - c + d == 7:
    print(A + "-" + B + "-" + C + "+" + D + "=" + "7")
elif a - b - c - d == 7:
    print(A + "-" + B + "-" + C + "-" + D + "=" + "7")


Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s1 = sc.next();
		String s2 = sc.next();
		String s3 = sc.next();
		if(s1.endsWith(s2.substring(0, 1)) && s2.endsWith(s3.substring(0,1))) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m;i >= n;--i)
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(begin(v), end(v))
#define REV(v) reverse(begin(v), end(v))
#define VI vector<int>
#define PB(x) push_back(x)
#define SZ(x) end(x) - begin(x)
#define DEBUG(x) cerr << __LINE__ << ":" << #x << ": " << x << "\n";
//#define int long long
using namespace std;
using lint = long long;
struct Fast{Fast(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};} fast;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
inline void CO(auto &a) {REP(i, SZ(a)) cout << i << ": " << a[i] << "\n";}
//if (IO > 1e5){lint a;	scanf(%lld, &a);	printf("%lld\n", a);}

signed main(){
	int a,b;
	cin >> a >> b;
	if (a == b){
		cout << a+b << endl;
	}else if (a >= b){
		cout << a+a-1 << endl;
	}else{
		cout << b+b-1 << endl;
	}
return 0;
}


Measured memory_bytes: 256
using DataStructures
p()=parse.(Int,split(readline()))
function main()
  n,q=p()
  f=FenwickTree(p())
  for i=1:q
    b,l,r=p()
    if Bool(b)
      println(prefixsum(f,r)-(l>0 ? prefixsum(f,l) : 0))
    else
      inc!(f,l+1,r)
    end
  end
end
main()


Measured memory_bytes: 263080
/* ***************************************
Author        :Scau.ion
Created Time  :2016/11/06 19:55:36 UTC+8
File Name     :ion.cpp
*************************************** */

#include <bits/stdc++.h>

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

using namespace std;

const int maxn=100010;

char s[maxn];

int main()
{
    scanf("%s",s);
    int n=strlen(s);
    int ans=0;
    for (int j=1;j<n;++j)
        if (s[j]!=s[j-1]) ++ans;
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
# coding: utf-8
# Your code here!
s=list(input())
s1=s[0::2]
s2=s[1::2]
flg=0

for i in s1:
    if i=="L":
        flg=1
for i in s2:
    if i=="R":
        flg=1
        
if flg==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import numpy as np
N = input()
A = np.array(map(int, raw_input().split()))


A = np.append(np.append([0], A), [0])
total_sum = 0
for i in range(0, len(A) - 1):
    total_sum += np.abs(A[i + 1] - A[i])

for i in range(1, len(A) - 1):
    partial_sum = total_sum - np.abs(A[i + 1] - A[i]) - np.abs(A[i] - A[i - 1]) + np.abs(A[i + 1] - A[i - 1])
    print partial_sum



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

int main(){
	int n;
	cin>>n;
	vector<int>v(2e5+1);

	vector<int>ans(n+1);
	for(int i=1;i<=n-1;++i){
		int a; cin>>a;
		ans[a]++;
	}
	for(int i=1;i<=n;++i)
		printf("%d\n",ans[i]);
}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  vi A(5);
  rep(i,5) cin >> A[i];
  int ans = 0;
  int mn = 11;
  int mnIdx = -1;
  rep(i,5) {
    int m = A[i]%10;
    if (m == 0) m = 10;
    if (m < mn) {
      mn = m;
      mnIdx = i;
    }
  }
  rep(i,5) {
    if (i == mnIdx) {
      ans += A[i];
      continue;
    }
    ans += A[i];
    ans += (10 - (A[i] % 10))%10;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

x_max = max(x)
y_min = min(y)

if True in [x_max < z <= y_min for z in range(X+1, Y+1)]:
    print('No War')
else:
    print('War')

Measured memory_bytes: 3064
using System;

namespace AGC006
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            var t = Console.ReadLine();

            var c = 0;
            var end = false;
            for (var i = 0; i < N; i++)
            {
                for (var j = 0; j < N; j++)
                {
                    if (t[j] == s[i] && N - i <= N - j)
                    {
                        c = 1;
                        for (var k = 1; k < N - Math.Max(i, j); k++)
                        {
                            if (s[i + k] != t[j + k]) break;
                            c++;
                            if (i + k == N - 1) end = true;
                        }

                        if (end) break;
                    }
                }

                if (end) break;
            }

            var result = s.Length + t.Length - c;

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 2648
#include <bits/stdc++.h> 
using namespace std; 
#define int long long
# define pii pair<int,int>
const int maxn=1e6+5;
signed main() { 
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    vector<string> a(n),b(m);
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<m;i++)
        cin>>b[i];
    bool exist=false;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(i+m-1>=n || j+m-1>=n)continue;
            bool flag=true;
            for(int k=0;k<m;k++)
            {
                for(int l=0;l<m;l++)
                {
                    if(a[i+k][j+l]!=b[k][l])
                    {
                        flag=false;
                    }
                }
            }
            if(flag)
            {
                exist=true;
            }
        }
    }
    if(exist)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string str;
	
	while(1){
		getline(cin, str);
		if(str == "END OF INPUT"){
			break;
		}
		int l = str.size();
		int c;
		for(int i = 0; i < l; i++){
			c = 1;
			i++;
			for(; i < l; i++){
				if(str[i] != ' '){
					c++;
				} else {
					cout << c;
					while(str[++i] == ' '){
						cout << 0;
					}
					break;
				}
			}
			i--;
		}
		cout << c << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.AtCoder_Begginer_Contest_162
{
    class A
    {
        static void Main(string[] args)
        {
            string input1 = Console.ReadLine();
            
            foreach(var c in input1)
            {
                if (c == '7')
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }
    }
}


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

struct UnionFind {
    UnionFind(int n) : p(n, -1) {}
    int root(int u) {
        return p[u] < 0 ? u : p[u] = root(p[u]);
    }
    int size(int u) {
        return -p[root(u)];
    }
    bool same(int u, int v) {
        return root(u) == root(v);
    }
    void unite(int u, int v) {
        u = root(u);
        v = root(v);
        if (u == v) return;
        if (p[u] > p[v]) swap(u, v);
        p[u] += p[v];
        p[v] = u;
    }
    vector<int> p;
};

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

    int n, m;
    cin >> n >> m;

    UnionFind uf(n);
    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        x--; y--;

        uf.unite(x, y);
    }

    vector<int> a(n, 0);
    for (int i = 0; i < n; i++) {
        a[uf.root(i)] = 1;
    }

    int r = 0;
    for (int i = 0; i < n; i++) {
        r += a[i];
    }

    cout << r << endl;

    return 0;
}

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> cnt(M, 0);
	for (int i = 0; i < N; ++i) {
		int k;
		cin >> k;
		for (int j = 0; j < k; ++j) {
			int a;
			cin >> a;
			--a;
			++cnt[a];
		}
	}
	int ans = 0;
	for (int i = 0; i < M; ++i) {
		if (cnt[i] == N) {
			++ans;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

#include <bits/stdc++.h>
using namespace std;

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

int main() {
    LL n = read(), ans = n - 1;
    for (LL i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            ans = min(ans, i - 1 + n / i - 1);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
N,W=map(int,input().split())
lwv=[]
for i in range(N):
    lwv.append(list(map(int,input().split())))
ldp=[[0 for j in range(W+1)] for i in range(N)]
for j in range(W+1):
    if lwv[0][0]<=j:
        ldp[0][j]=lwv[0][1]
for i in range(1,N):
    for j in range(W+1):
        if j-lwv[i][0]>=0:
            ldp[i][j]=max(ldp[i-1][j],ldp[i-1][j-lwv[i][0]]+lwv[i][1])
        else:
            ldp[i][j]=ldp[i-1][j]
print(ldp[N-1][W])


Measured memory_bytes: 171656
/*
	  Chase
	   Your
	  Legend

	英雄志逐传奇
*/

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <math.h>
#include <stdio.h>

#define rep(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}


int main() {
	int n;
	cin >> n;
	vector<int>vec(n + 2);
	vec[0] = 0;
	vec[n + 1] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> vec[i];
	}

	int sum = 0;
	rep(i, n + 1) {
		sum = abs(vec[i] - vec[i + 1]) + sum;
	}
	
	vector<int>ans(n + 2);
	for (int i = 1; i <= n; i++) {
		ans[i - 1] = sum + abs(vec[i - 1] - vec[i + 1]) - (abs(vec[i - 1] - vec[i]) + abs(vec[i] - vec[i + 1]));
	}


	rep(i, n) {
		cout << ans[i] << endl;
	}
}


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

int main() {
  int K,S,N;
  cin>>K>>S;
  	for(int i=0;i<K+1;i++){
      for(int j=0;j<K+1;j++){
        if(S-i-j<K+1&&0<=S-i-j){
        N++;
        }
      }
    }
  cout<<N<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
using namespace std;
ll n,a,b,x,y,ans;
int main(){
	cin>>n>>a>>b;
	if(a%2==b%2)
	{
		cout<<(b-a)/2<<endl;
	}
	else
	{
		x=a,y=b;
		y-=(x-1);
		y--;
		x=1;
		ans=a+(y-x)/2;
		x=a,y=b;
		x+=n-y+1;
		y=n;
		ans=min(ans,n-b+1+(y-x)/2);
		cout<<ans<<endl;
	}
	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long     ll;
using namespace std;
ll mp[100005]={0};
int main()
{
    ll n,sum=0,x,y;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        mp[x]++;
        sum+=x;
    }
    int q;
    cin>>q;
    for(int i=0;i<q;i++)
    {
        cin>>x>>y;
        mp[y]+=mp[x];
        sum-=(mp[x]*x);
        sum+=(mp[x]*y);
        mp[x]=0;
        cout << sum << endl;
    }
}


Measured memory_bytes: 4372
n,k=map(int,input().split())
mo=1000000007
x=max(n-k,k)
dp=[[0 for i in range(k+2)] for j in range(x+1)]
dp[0][0]=1
for i in range(1,x+1):
    for  j in  range(1,k+2):
        dp[i][j]=(dp[i-1][j]+dp[i-1][j-1])%mo
for i in range(1,k+1):
    ans=dp[k][i]*(dp[n-k][i-1]+dp[n-k][i]*2+dp[n-k][i+1])
    print(int(ans%mo))

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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> c(n-1), s(n-1), f(n-1);
  for(int i=0;i<n-1;i++)
    cin >> c[i] >> s[i] >> f[i];
  
  for(int i=0;i<n;i++){
    int now = i;
    int now_time = 0;
    while(now < n-1){
      if(now_time < s[now])
        now_time = s[now] + c[now];
      else
        now_time = (now_time + f[now] - 1) / f[now] * f[now] + c[now];
      now++;
    }
    cout << now_time << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
    int n,t[101],m,p[101],x[101],sum=0,i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&t[i]);
    scanf("%d",&m);
    for(i=0;i<m;i++)
    {
        scanf("%d %d",&p[i],&x[i]);
    }
    for(i=0;i<m;i++)
    {
        for(j=0;j<n;j++)
        {
            if(p[i]-1 == j)
                sum+=x[i];
            else
                sum+=t[j];
        }
        printf("%d\n",sum);
        sum=0;
    }
    return 0;

}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  string S;
  cin >> S;
  if(S == "Sunny"){
    cout << "Cloudy" << endl;
  }else if(S == "Cloudy"){
    cout << "Rainy" << endl;
  }else{
    cout << "Sunny" << endl;
  }

  return 0;
}


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

int main() {
  string s;
  cin >> s;
  
  if ((s.at(0) == s.at(1) && s.at(1) == s.at(2)) || (s.at(1) == s.at(2) && s.at(2) == s.at(3))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}

Measured memory_bytes: 256
#include <stdio.h>
int a,b,c,ans;
int main() {
 scanf("%d %d %d",&a,&b,&c);
 ans=b/a;
 if(ans>c)
  {printf("%d",c);} 
 else
  {printf("%d",ans);}
  
  
  
  
  
  
  
  return 0;
}

Measured memory_bytes: 2152
def main():
    A, B, C = map(int, input().split())
    if (A == B) and (B == C) and (A == C):
        print("No")
    elif (A != B) and (B != C) and (A != C):
        print("No")
    else:
        print("Yes")
    return 0

if __name__ == '__main__':
    main()

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	vector<int> arr(n);
	for(int i=0; i<n; ++i){ cin>>arr[i]; }
	vector<int> to_left(n), to_right(n);
	// max left to me.
	to_left[0] = -1;
	for(int i=1; i<n; ++i){
		to_left[i] = max(to_left[i-1],arr[i-1]);
	}
	to_right[n-1] = -1;
	for(int i=n-2; i>=0; --i){
		to_right[i] = max(to_right[i+1], arr[i+1]);
	}
	for(int i=0; i<n; ++i){
		cout<<max(to_left[i],to_right[i])<<'\n';
	}

	return 0;
}


Measured memory_bytes: 3968
import collections
n=int(input())
v=list(map(int,input().split()))
v1=v[0::2]
v2=v[1::2]
c1=collections.Counter(v1)
c2=collections.Counter(v2)
arr1=c1.most_common()[1:]
arr2=c2.most_common()[1:]
arr21=c1.most_common()[:1]+c1.most_common()[2:]
arr22=c2.most_common()[:1]+c2.most_common()[2:]
arr1n=sum([a[1] for a in arr1])
arr2n=sum([a[1] for a in arr2])
arr21n=sum([a[1] for a in arr21])
arr22n=sum([a[1] for a in arr22])
if c1.most_common()[0][0]==c2.most_common()[0][0]:
  if arr21n<=arr22n:
    print(arr21n+arr2n)
  else:
    print(arr22n+arr1n)
else:
  print(arr1n+arr2n)

Measured memory_bytes: 32696
#include<stdio.h>
#include<string.h>
int main()
{
	char a[1000],b[1000],c[1000];
	int m,n,k;
	scanf("%s %s %s",a,b,c);
	m=strlen(a);
	n=strlen(b);
	k=strlen(c);
	if((a[m-1]==b[0])&&(b[n-1]==c[0]))
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main() {
  int h,w;
  string mt;
  vector<string> m;

  cin >>h>>w;
  for (int i = 0; i < h; ++i) {
    cin >> mt;
    m.push_back(mt);
      
  }
  // for (auto l : m) {
  //   cout << l <<endl;
  // }
  bool flag=true;

  for (int i=0; i < h; ++i) {
    for (int j=0; j < w; ++j) {
      if(m[i][j]!='#')
        continue;

      bool noblack=true;
      
      if(i>0)
        if(m[i-1][j]=='#')
          noblack=false;
      if(i<h-1)
        if(m[i+1][j]=='#')
          noblack=false;
      if(j>0)
        if(m[i][j-1]=='#')
          noblack=false;
      if(j<w-1)
        if(m[i][j+1]=='#')
          noblack=false;
      
      if(noblack)
        flag=false;
    }
  }


  // int minn = *min_element(p.begin(), p.end());
  if(flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

}


Measured memory_bytes: 256
x,y,z,k = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

ab = []
for a_ in a:
    for b_ in b:
        ab.append(a_+b_)

res = []
for ab_ in sorted(ab, reverse=True)[:k]:
    for c_ in sorted(c, reverse=True)[:k]:
        res.append(ab_+c_)

for x in sorted(res, reverse=True)[:k]:
    print(x)

Measured memory_bytes: 157140
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 100000;
int n, m;
int h[MAX_N];
vi g[MAX_N];

int main() {
    fastio();

    cin >> n >> m;
    forn(i, n) {
        cin >> h[i];
    }

    forn(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int ans = 0;
    forn(i, n) {
        bool ok = true;
        for (int j : g[i]) {
            ok &= h[j] < h[i];
        }

        if (ok) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9152
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long d = in.nextInt();
        long d2 = d * d;
        int count = 0;
        for(int i=0; i<n; i++) {
            long x = in.nextLong();
            long y = in.nextLong();
            if(d2 >= x*x + y*y) {
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 59244
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) < (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n) - 1; (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll fac(ll n){
    ll t = 1;
    rep1(i, n + 1)t *= i;
    return t;
}

int main()
{
    vector<ll> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(all(a));
    if ((a[2] - a[0] + a[2] - a[1]) % 2 == 0) {
        cout << (a[2] - a[0] + a[2] - a[1]) / 2 << endl;
    }else{
        cout << (a[2] - a[0] + a[2] - a[1] + 3) / 2 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  
	int H,W;
	cin>>H>>W;
	while(H!=0||W!=0){
		for(int i=1;i<=H;i++){
			for(int a=1;a<=W-1;a++){
				cout<<"#";
			}
				cout<<"#"<<endl;
		}
		cout<<endl;
		cin>>H>>W;
	}
		
		
		
		
	return 0;
}

Measured memory_bytes: 1156
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define PI 3.141592654
#define deb1(x) cout << #x <<"="<< x <<endl;
#define deb2(x,y) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<endl;
#define deb3(x,y,z) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<<endl;
#define deb4(x,y,z,a) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<< ", "<<#a <<"="<<a << endl;
#define debarr(x) cout << #x<<endl;for(int i : x){cout << i <<" ";} cout <<endl;

const int N = 100010;
int dp[100010][2];
int n,k;
double pi;
vector<int> arr;


bool solve(int s, int t){

    //if(dp[s][t]!=-1){
    //    return dp[s][t];
    //}

    bool lose = true;
    for(int i=0;i<n;i++){
        if(s >= arr[i])
            lose=false;
    }
    if(lose){
        if(t==0){
            dp[s][t] = 0;
            return false;
        }
        else{
            dp[s][t] = 1;
            return true;
        }
    }

    bool who;
    for(int i=0;i<n;i++){
        if(s >= arr[i]){
            int nn = t^1;
            who = solve(s-arr[i],nn);
            if(t==0 && who==true){
                dp[s][t] = 1;
                return true;
            }
            if(t==1 && who == false){
                dp[s][t] = 0;
                return false;
            }
        }

    }
    if(t==0){
        dp[s][t] = 0;
        return false;
    }else{
        dp[s][t] = 1;
        return true;
    }

}



void mymain(){
  cin >> n >> k;
  arr.resize(n);
  for(int i=0;i<n;i++)
    cin >> arr[i];
  /*bool ans = solve(k,0);
  for(int i=0;i<N;i++){
    for(int j=0;j<2;j++){
        dp[i][j] =-1;
    }
  }*/

  vector<bool> win(k+1,false);

  for(int i=1;i<=k;i++){
    for(int s : arr){
        if(i >= s){
            if(win[i-s] == false)
                win[i] = true;
        }
    }
  }

  cout << (win[k]?"First":"Second") << endl;

}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
//cin>>t;

for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}
/*

*/


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a, b, c, d, area1, area2;
    
    scanf( "%d %d %d %d", &a, &b, &c, &d );
    area1 = a * b;
    area2 = c * d;

    if( area1 > area2 ) 
        printf( "%d", area1 );
    else if (area1 < area2)
        printf("%d", area2);
    else
        printf("%d", area1);
    return 0;
}

Measured memory_bytes: 128
def gcd(x, y):
    while x > 0:
        x, y = y % x, x
    return y


nx = list(map(int, input().split()))
n = nx[0]
X = nx[1]
x = list(map(int, input().split()))
for i in range(n):
    x[i] = abs(x[i] - X)
ans = x[0]
for i in range(1, n):
    ans = gcd(ans, x[i])
print(ans)

Measured memory_bytes: 14480
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))

ok = True
for a in A:
    if a %2 == 0:
        if not ( a % 3 == 0 or a % 5 == 0):
            ok = False
if ok:
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 24172
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
    int n;
    cin>>n;
    int a[110];
    rep(i,n){
        cin>>a[i];
        }
    sort(a,a+n);
    cout<<abs(a[n-1]-a[0])<<endl;

}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
class Main{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String[] str = br.readLine().split(" ");
        int w = Integer.parseInt(str[0]);
        int h = Integer.parseInt(str[1]);
        int x = Integer.parseInt(str[2]);
        int y = Integer.parseInt(str[3]);
        int r = Integer.parseInt(str[4]);
        //System.out.println(w+" "+h+" "+x+" "+y+" "+r);
        if((x>=-100 && x<=100 && y>=-100 && y<=100) && (w>0 && h>0 && r>0 && w<=100 && h<=100 && r<=100)){
            if((x-r<0 || x+r>w) || (y-r<0 || y+r>h)){
                System.out.println("No");
            }else if((x-r>=0 && x+r<=w) || (y-r>=0 && y+r<=h)){
                System.out.println("Yes");
            }
        }
    }
}

Measured memory_bytes: 17088
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,m;
    cin >> a >> b >> m;
    vector<int> veca(a);
    vector<int> vecb(b);
    for(int i=0;i<a;i++){
        cin >> veca[i];
    }
    for(int i=0;i<b;i++){
        cin >> vecb[i];
    }
    vector<int> x(m);
    vector<int> y(m);
    vector<int> c(m);
    int mn;
    int tmp;
    int mna,mnb;
    mna = *min_element(veca.begin(),veca.end());
    mnb = *min_element(vecb.begin(),vecb.end());
    mn = mna+mnb;
    tmp = mn;
    for(int i=0;i<m;i++){
        cin >> x[i] >> y[i] >> c[i];
        tmp = veca[x[i]-1]+vecb[y[i]-1]-c[i];
        if(tmp>=0) mn = min(mn,tmp);
    }
    cout << mn << endl;
}




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

int main(void){
  int x,y,r;
  cin>>x;
  cin>>y;




  if (x < y){
    swap(x, y);
  }
  while (y > 0){
    r = x % y;
    x = y;
    y = r;
  }


    cout<<x<<endl;;


  return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
bool acc[100005];
int wa[100005];
int main()
{
    int n, m, ac = 0, pa = 0;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int q;
        string s;
        cin >> q >> s;
        if (!acc[q - 1])
        {
            if (s == "AC")
            {
                pa += wa[q - 1];
                acc[q - 1] = true;
                ac += 1;
            }
            else
            {
                wa[q - 1]++;
            }
        }
    }
    cout << ac << " " << pa;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	string s;
	cin >> s;
	int n = s.size();
	ll cnt = 0;
	ll ans = 0;
	for (int i = 0; i < n;) {
		if (s[i] == 'A') {
			cnt++;
			i++;
		}
		else if (s[i] == 'B' && s[i + 1] == 'C') {
			ans += cnt;
			i += 2;
		}
		else cnt = 0, i++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)

using namespace std;

int main(void) {
	int k;
	int n;
	cin >> k >> n;
	
	int ans = 0;
	int temp;
	for (int i = 0; i < k; i++) {
	cin >> temp;
		if (temp >= n) {
			ans++;
		}
	}
	
	cout << ans;

}




Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] divisorList = new int[N];
        int mod = (int) (Math.pow(10, 9) + 7);
        double result = 1;
        for (int i = N; i >= 2; i--) {
            calcNumOfDivisor(i, divisorList);
        }
        for (int i = 0; i < divisorList.length; i++) {
            result = result * (divisorList[i] + 1) % mod;
        }

        System.out.println((int)result);
    }
    public static void calcNumOfDivisor(int num, int[]divisorList) {
        for (int i = 2; i <= num; i++) {
            while (num % i == 0) {
                divisorList[i - 1]++;
                num /= i;
            }
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

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

    vector<string> a(h);

    for (int i = 0; i < h; i++) {
        cin >> a[i];
    }

    using ll = long long;
    const ll mod = 1'000'000'007;

    vector<vector<int>> dp(h, vector<int>(w));

    dp[0][0] = 1;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (a[i][j] == '.') {
                if (i + 1 < h) 
                    dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % mod;
                
                if (j + 1 < w)
                    dp[i][j + 1] = (dp[i][j + 1] + dp[i][j]) % mod;
            }
        }
    }

    cout << dp[h - 1][w - 1] << endl;
}


Measured memory_bytes: 5760
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

def main():
    X = int(input())
    ans = 1
    for b in range(X, 0, -1):
        for p in range(10, 1, -1):
            if b ** p <= X:
                ans = max(ans, b ** p)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
vi removal[(int)3e5];
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int n, m;cin >> n >> m;
    vi vals(n);
    FOR(i, n)cin >> vals[i];
    int cost = 0;
    vi updates(2*m);
    int begin = 0;
    FOR(i, n - 1){
        int nex = vals[i+1];
        int cur = vals[i];
        if(cur <= nex){
            if(nex- cur == 0)continue;
            cost += nex -cur;
            updates[cur+2]++;
            updates[nex + 1]--;
            removal[nex +1].pb(nex- cur- 1);
        }else{
            cost += (m - cur) + (nex - 1) + 1; 
            // no need to remove this last update
            // it will last till the end
            updates[cur+2]++;
            updates[1]++;
            begin += (m - cur) - 1;
            updates[nex + 1]--;
            removal[nex + 1].pb((m - cur) + (nex - 1) +1 -1);
        }

    }
    begin = -begin;
    int points = 0;
    int mn = 0;
    FOR1(i, m){
        points += updates[i]; 
        for(int r: removal[i])begin += r;
        begin -= points;
        mn = min(begin, mn);
    }
    cout<< cost +  mn << endl;
}




Measured memory_bytes: 12032
#include<stdio.h>
int main(void)
{
	int w,h,x,y,r;
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	if((0<=(x-r))&&((x+r)<=w)&&(0<=(y-r))&&((y+r)<=h)) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 998244353
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

bool prime(ll n)
{
	if(n<=1)return false;
	if(n<=3)return true;
	if(n%2==0||n%3==0)return false;
	for(ll i=5;i*i<=n;i+=6)
	{
		if(n%i==0||n%(i+2)==0)return false;
	}
	return true;
}

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
		if(b&1)
		    r=(r*a)%m;
		b>>1;
		a=(a*a)%m;
	}
	return r%m;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	string s; cin>>s;
	ll n = s.size();
	bool flag= true;
	for(ll i =0;i<n/2;i++)
    {
        if(s[i]!=s[n-1-i])flag = false;
        if(s[i]!=s[n/2-1-i])flag = false;
        if(s[n/2+1+i]!=s[n-i-1])flag = false;
    }
    if(flag)cout<<"Yes\n";
    else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256