akhauriyash/Code-Regression huggingface dataset:
//====== begin of bisma c++ template===========
#include<bits/stdc++.h>
#include <assert.h>
using namespace std;
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define ll long long 
#define sum(a,b) a=a+b
#define mem(a, b) memset(a, (b), sizeof(a))
#define MEM(a, b) memset(a, (b), sizeof(a))


//=======binarysearch===========
int bsr(vector<int>&a,int que){
 auto it=lower_bound(a.begin(),a.end(),que);
 if(*it==que){
    return it-a.begin();
 }
 return -1;
}
//========binarysearch=========



//=======SUBSET WITH BRUTEFORCE=============
void subsets(int S[], int n) {
     int nSub = 1<<n; 
     for(int i=0; i<nSub; i++){
          cout<<"{ ";//optional
          for(int k=0; k<n; k++){
               //if the k-th bit is set
               if( (1<<k) & i){
                    cout<<S[k]<<" ";
               } 
          }
          cout<<"}\n"; //optional
     }
}
//======SUBSET WITH BRUTE FORCE================


//======permuatate all ==================
void permutate(){
int n,x;
cin>>n;

vector<int> permutation;
for (int i = 0; i < n; i++) {
    cin>>x;
permutation.push_back(x);
}
do {
 rep(i,0,n-1) cout<<permutation[i];
 cout<<endl;
} while (next_permutation(permutation.begin(),permutation.end()));

}
//====permuatate all======================



//======= the end of bisma c++ template ============


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

if(n<=999){
  cout<<"ABC";
}else if(n>=1000 && n<=1998){
  cout<<"ABD";
}


  return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e15;

vector<ll> divisor(ll n) {
  vector<ll> res;
  for(ll i=1;i*i<=n;i++) {
    if(n%i==0) {
      res.push_back(i);
      if(i!=n/i) {
        res.push_back(n/i);
      }
    }
  }
  return res;
}

int main() {
  ll n;
  cin >> n;
  if(n==2) {
    cout << 1 << endl;
    return 0;
  }
  vec ans1=divisor(n-1);
  ll ans=0;
  for(ll i=2;i*i<=n;i++) {
    if(n%i) continue;
    ll tmp=n;
    while(tmp%i==0) {
      tmp/=i;
    }
    ans+=(tmp%i==1);
  }
  cout << ans1.size()+ans << endl;
}

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

struct FFT {
  struct CP {
    double x, y;

    CP() : x(0), y(0) {}

    CP(double x, double y) : x(x), y(y) {}

    inline CP operator+(const CP &c) const { return CP(x + c.x, y + c.y); }

    inline CP operator-(const CP &c) const { return CP(x - c.x, y - c.y); }

    inline CP operator*(const CP &c) const {
      return CP(x * c.x - y * c.y, x * c.y + y * c.x);
    }
    CP &operator*=(const CP &p) {
      *this = CP(*this) * p;
      return *this;
    }
    CP &operator/=(const double &p) {
      x /= p, y /= p;
      return *this;
    }

    inline CP conj() const { return CP(x, -y); }
  };
  const double PI = acos(-1);
  int base = 1;
  vector<CP> roots{CP(0, 0), CP(1, 0)};
  vector<int> rv{0, 1};
  FFT() {}
  void ensure_base(int nb) {
    if (nb <= base) return;
    rv.resize(1 << nb);
    roots.resize(1 << nb);
    for (int i = 0; i < (1 << nb); ++i)
      rv[i] = (rv[i >> 1] >> 1) + ((i & 1) << (nb - 1));
    while (base < nb) {
      double arg = PI * 2.0 / (1 << (base + 1));
      for (int i = 1 << (base - 1); i < (1 << base); ++i) {
        roots[i << 1] = roots[i];
        double narg = arg * (2 * i + 1 - (1 << base));
        roots[(i << 1) + 1] = CP(cos(narg), sin(narg));
      }
      ++base;
    }
  }
  void fft(vector<CP> &a, int n, bool sg = 0) {
    assert((n & (n - 1)) == 0);
    for (int i = 0; i < n; ++i)
      if (i < rv[i]) swap(a[i], a[rv[i]]);
    for (int k = 1; k < n; k <<= 1)
      for (int i = 0; i < n; i += 2 * k)
        for (int j = 0; j < k; ++j) {
          CP z = a[i + j + k] * (sg ? roots[j + k] : roots[j + k].conj());
          a[i + j + k] = a[i + j] - z;
          a[i + j] = a[i + j] + z;
        }
    if (sg)
      for (int i = 0; i < n; ++i) a[i] /= n;
  }
  vector<long long> mul(const vector<int> &a, const vector<int> &b) {
    int need = a.size() + b.size() - 1;
    int nb = 1;
    while ((1 << nb) < need) ++nb;
    ensure_base(nb);
    int sz = 1 << nb;
    vector<CP> fa(sz), fb(sz);
    for (int i = 0; i < sz; ++i) {
      if (i < a.size()) fa[i] = CP(a[i], 0);
      if (i < b.size()) fb[i] = CP(b[i], 0);
    }
    fft(fa, sz);
    fft(fb, sz);
    for (int i = 0; i < sz; ++i) fa[i] *= fb[i];
    fft(fa, sz, 1);
    vector<long long> res(need);
    for (int i = 0; i < need; ++i) res[i] = llround(fa[i].x);
    return res;
  }
};

const int p = 200003;
int n;
vector<long long> cnt;

long long solve();

int main() {
  cin >> n;
  cnt.resize(p);
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    ++cnt[a];
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  vector<int> memo(1, 1), tmp(p);
  int now = 2;
  for (int i = 1; i < p; ++i) {
    tmp[i] = cnt[now];
    memo.push_back(now);
    (now <<= 1) %= p;
  }
  for (int i = 0; i < p; ++i) {
    memo.push_back(now);
    (now <<= 1) %= p;
  }
  FFT fft;
  auto v = fft.mul(tmp, tmp);
  long long res = 0;
  for (long long i = 0; i < 2 * p; ++i) {
    res += v[i] * memo[i];
    if (i < p) res -= cnt[i] * (i * i % p);
  }
  return res / 2;
}


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

import sys


def get_answer(param):
    answer = []
    for i in xrange(param.__len__() - 1):
        c = str(param[i] + param[i + 1])[-1]
        answer.append(int(c))
    if (answer.__len__() == 1):
        return answer[0]
    else:
        return get_answer(answer)


def main():
    params = [map(int, line.rstrip()) for line in sys.stdin.readlines()]
    for param in params:
        print get_answer(param)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	string s;
	cin>>s;
	if(s=="ABC")cout<<"ARC";
	else cout<<"ABC"; 
	return 0;
}



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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

template<class G>
class Fenwick_tree{
	vector<G> a;
public:
	Fenwick_tree(){}
	Fenwick_tree(int n){ build(n); }
	Fenwick_tree(const vector<G>& a){ build(a); }
	void build(int n){
		a.assign(n,G{});
	}
	void build(const vector<G>& a){
		this->a=a;
		for(int i=1;i<a.size();i++) if(i+(i&-i)-1<a.size()) (this->a)[i+(i&-i)-1]+=(this->a)[i-1];
	}
	void add(int i,const G& val){
		for(i++;i<=a.size();i+=i&-i) a[i-1]+=val;
	}
	G sum(int l,int r)const{
		if(l==0){
			G res{};
			for(;r>0;r-=r&-r) res+=a[r-1];
			return res;
		}
		return sum(0,r)-sum(0,l);
	}
	int lower_bound(G val)const{
		if(val<=G{}) return 0;
		int x=0,k;
		for(k=1;k<=a.size();k<<=1);
		for(k>>=1;k>0;k>>=1) if(x+k<=a.size() && a[x+k-1]<val) val-=a[x+k-1], x+=k;
		return x;
	}
	int upper_bound(G val)const{
		if(val<G{}) return 0;
		int x=0,k;
		for(k=1;k<=a.size();k<<=1);
		for(k>>=1;k>0;k>>=1) if(x+k<=a.size() && a[x+k-1]<=val) val-=a[x+k-1], x+=k;
		return x;
	}
};

template<class T>
long long inversion_number(const vector<T>& a){
	auto X=a;
	sort(X.begin(),X.end());
	X.erase(unique(X.begin(),X.end()),X.end());

	long long res=0;
	Fenwick_tree<int> F(X.size());
	rep(i,a.size()){
		int x=lower_bound(X.begin(),X.end(),a[i])-X.begin();
		res+=F.sum(x+1,X.size());
		F.add(x,1);
	}
	return res;
}

double solve(vector<int> A,vector<int> B,vector<int> C){
	int n=A.size();
	vector<pair<double,double>> L(n); // (傾き, 切片)
	rep(i,n){
		L[i]={-1.0*A[i]/B[i],1.0*C[i]/B[i]};
	}
	sort(L.begin(),L.end());

	double lo=-1e9,hi=1e9;
	rep(_,70){
		double mi=(lo+hi)/2;

		vector<pair<double,int>> Y(n);
		rep(i,n){
			auto [a,b]=L[i];
			Y[i]={a*mi+b,i};
		}
		sort(Y.begin(),Y.end(),greater<>());

		// p[i] = (n 本の直線を x = mi における y 座標の小さい順に並べたとき, 直線 i は何番目か)
		vector<int> p(n);
		rep(i,n) p[Y[i].second]=i;

		int cnt=inversion_number(p); // x <= mi にある交点の個数
		if(cnt<(n*(n-1)/2+1)/2) lo=mi;
		else                    hi=mi;
	}
	return lo;
}

int main(){
	int n; scanf("%d",&n);
	vector<int> a(n),b(n),c(n);
	rep(i,n) scanf("%d%d%d",&a[i],&b[i],&c[i]);

	double ans[2];
	rep(i,2){
		ans[i]=solve(a,b,c);
		rep(j,n) swap(a[j],b[j]);
	}
	printf("%.15f %.15f\n",ans[0],ans[1]);

	return 0;
}


Measured memory_bytes: 6032
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<queue>
#include<climits>
using namespace std;

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

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

	vector<long long> f_table(N+1, 0);
	long long sum = 0;
	priority_queue<long long> que;
	for(int i=0; i<N; i++)
	{
		sum += a[i];
		que.push(-a[i]);
	}
	f_table[0] = sum;
	for(int i=0; i<N; i++)
	{
		int index = N + i;
		sum += a[index];
		que.push(-a[index]);
		sum += que.top();
		que.pop();

		f_table[i + 1] = sum;
	}
	
	sum = 0;
	while(que.empty() != true)
		que.pop();
	vector<long long> b_table(N+1);
	for(int i=0; i<N; i++)
	{
		int index = 3*N-1 - i;
		sum += a[index];
		que.push(a[index]);
	}
	b_table[0] = sum;
	for(int i=0; i<N; i++)
	{
		int index = 2*N-1 - i;
		sum += a[index];
		que.push(a[index]);
		sum -= que.top();
		que.pop();

		b_table[i + 1] = sum;
	}

	long long ret = LLONG_MIN;
	for(int i=N; i<=2*N; i++)
	{
		ret = max(ret, f_table[i-N]-b_table[2*N-i]);
	}
	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 5108
A,B = map(int,input().split())

def gcd(x,y):
    while y:
        x,y = y, x%y
    return x

g = gcd(A,B)

count = 0
l = []

while g%2 == 0:
    l.append(2)
    g //= 2
i = 3
while i**2 <= g:
    if g%i == 0:
        l.append(i)
        g //= i
    else:
        i += 2
if g != 1:
    l.append(g)

print(len(set(l))+1)

Measured memory_bytes: 38512
##########################################################...#.....#...#.....
########################################.#.################....#.............
#########################################.#..################....##..........
###################.#####################..#.##################.....#........
####################.#####################.#..#######..##########......#.....
####################..####################....####...#.....######.###........
#####################################....#...##...###..#.......##..####......
################.##.#....#########........#.#........##.###..................
#################.#..#....##..#..........#.##........##.#######..............
########.########.....#.....##.............####...#..#...########..#.........
#########.########.....#...................########..#...########...#.##.....
#####..###..####.....#####..................#######.......##.####..#....#....
#####.....#.....##########...................#####........#..###..#.......##.
#####........#####.##....##.#............................###.##..#...........
#####......######.........................#.................##...............
#####.....########....................................##....#................
#####.....##############......................#...........##.#...............
######...###############.....................................................
########..##############......................................#..............
########.......#####..........................................#..............

a, b, t = map(int, input().split())
print(b * (t // a))

Measured memory_bytes: 2940
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int S=2e5+10;
LL X[S];
LL a[S];
LL b[S];
LL L;
LL dp[3001][3001];
LL f(int i,int j){
	if(dp[i][j]!=-1){
		return dp[i][j];
	}
	if(i==j){
		return dp[i][j]=0;
	}
	if(i<j){
		dp[i][j]=max(X[i+1]-X[i]+f(i+1,j),X[i]+L-X[j]+f(j,i+1));
		if (X[i+1]-X[i]+f(i+1,j)>=X[i]+L-X[j]+f(j,i+1)){
			cerr << i << ", " << j << ": " << i+1 << ", " << j << ": " << dp[i][j] << endl;
		}
		else{
			cerr << i << ", " << j << ": " << j << ", " << i+1 << ": " << dp[i][j] << endl;
		}
		return dp[i][j]=max(X[i+1]-X[i]+f(i+1,j),X[i]+L-X[j]+f(j,i+1));
	}
	else{
		dp[i][j]=max(X[i]-X[i-1]+f(i-1,j),L-X[i]+X[j]+f(j,i-1));
		if(X[i]-X[i-1]+f(i-1,j)>=L-X[i]+X[j]+f(j,i-1)){
			cerr << i << ", " << j << ": " << i-1 << ", " << j << ": " << dp[i][j] << endl;
		}
		else{
			cerr << i << ", " << j << ": " << j << ", " << i-1 << ": " << dp[i][j] << endl;

		}
		return dp[i][j]=max(X[i]-X[i-1]+f(i-1,j),L-X[i]+X[j]+f(j,i-1));
	}
}
int main() {
	int N;
	cin >> L >> N;
	for(int i=1;i<=N;i++){
		cin >> X[i];
	}
	X[N+1]=L;
	memset(dp,-1,sizeof(dp));
	//cerr << max(X[1]+f(1,N),L-X[N]+f(N,1)) << endl;
	for(int i=1;i<=N;i++){
		a[i]=X[i]+a[i-1];
	}
	for(int i=N;i>=1;i--){
		b[i]=L-X[i]+b[i+1];
	}
	LL ret=max(X[N],L-X[1]);
	for(int i=1;i+1<=N;i++){
		int s=min(N-i,i);
		LL v=0;
		v+=2*(b[i+1]-b[i+1+s]);
		v+=2*(a[i]-a[i-s]);
		//cerr << i << ": " << v-X[i] << " " << v-(L-X[i+1]) << endl;
		ret=max(ret,v-X[i]+2*X[i-s]);
		ret=max(ret,v-(L-X[i+1])+2*(L-X[i+1+s]));
	}
	cout << ret << endl;

	return 0;
}



Measured memory_bytes: 75264
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);


int main(int argc, char* argv[])
{
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
  }
  sort(ALL(a));

  ll a_min = a[0];
  ll a_max = a[n-1];

  vector<pair<ll, ll>> steps(n-1);

  for (int i = 1; i < n-1; i++) {
    if (a[i] > 0) {
      steps[i-1] = make_pair(a_min, a[i]);
      a_min -= a[i];
    } else {
      steps[i-1] = make_pair(a_max, a[i]);
      a_max -= a[i];
    }
  }
  steps[n-2] = make_pair(a_max, a_min);

  cout << a_max - a_min << endl;
  rep(i, n-1) {
    cout << steps[i].first << " " << steps[i].second << endl;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
int main(){
    string s,t;
    cin>>s>>t;
    cout << (s[0] == t[0]) + (s[1] == t[1]) + (s[2] == t[2]) << endl; 
    return 0;
}



Measured memory_bytes: 256
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007
INF = 122337203685477580

def solve():
    M,D = map(int, input().split())
    cnt = 0
    for m in range(1,M+1):
        for d in range(1,D+1):
           if((d%10)*(d//10) == m and d%10 > 1 and d//10 > 1):
               cnt += 1
            #    print(m,d)

    print(cnt) 

if __name__ == '__main__':
    solve()


Measured memory_bytes: 3936
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9+5;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;
    cin>>n;
    vector<int> v(n);

    for(auto &i:v)        cin>>i;

    vector<int> dp(n);

    dp[n-1]=0;
    dp[n-2]=abs(v[n-1]-v[n-2]);

    for(int i=n-3 ; i>=0 ; i--)
    {
        int a = abs(v[i]-v[i+1]);
        int b = abs(v[i]-v[i+2]);
        dp[i] = min(a+dp[i+1] , b + dp[i+2]);
    }
    cout<<dp[0];
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n, a; cin >> n >> a;
    (a >= n%500) ? Yes() : No();
}

Measured memory_bytes: 256
n, m=map(int, input().split())
D=[[] for i in range(n)]

for i in range(m):
    p, y=map(int, input().split())
    D[p-1].append((y, i))

ans=[0]*m

for i, d in enumerate(D):
    d.sort()
    for k, (y, j) in enumerate(d):
        ans[j]=str(i+1).zfill(6) + str(k+1).zfill(6)

print(*ans, sep='\n')

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


int main(int argc, char const *argv[]) {
  int n,temp,count=0;
  int min=200005;
  cin>>n;
  for (int i = 0; i < n; i++) {
    cin>>temp;
    if (temp<=min) {
      count++;
      min=temp;
    }
  }
  cout<<count;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long

using namespace std;
const int MOD=1000000007;
const int INF=9000000009;
const double eps=1e-10;

signed main(){
  int n;
  while(cin>>n,n){
    vector<int> a(n+100);
    REP(i,n){
      int x;cin>>x;
      a[i+1]=a[i]+x;
    }
    int ans=-INF;
    REP(i,n+1)LOOP(j,i+1,n+1)ans=max(ans,a[j]-a[i]);
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3112
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    s = s.replace("ABC","1");
    int count = 0;
    for(int i = 0;i<s.length();i++){
      if(s.substring(i,i+1).equals("1"))count++;
    }
    System.out.println(count);
  }
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int odd = (N+1) / 2;
            int even = N / 2;
            double ans = (double)odd / N;
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;

//#[proconio::fastout]
fn main() {
    input! {
        s: Bytes,
    }

    const MOD: usize = 2019;
    let len = s.len();
    let mut ct = vec![0; MOD];
    let mut rem = 0usize;
    let mut mul = 1;
    ct[0] += 1;
    for i in 0..len {
        rem = (rem + (s[len - 1 - i] - b'0') as usize * mul) % MOD;
        ct[rem] += 1;
        mul = mul * 10 % MOD;
        //println!("{} {} ", len-i-1, rem);
    }

    let mut ans = 0i64;
    for i in 0..MOD {
        let c = ct[i] as i64;
        ans += c * (c - 1) / 2;
    }

    println!("{}", ans);
}


Measured memory_bytes: 2352
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+7,M=1e5*2+50;
int n,m;
int hh[N];
int h[M], w[M], e[M], ne[M], idx;
bool st[N];
void add(int a,int b)
{
    e[idx]=b,ne[idx]=h[a],h[a]=idx++;
}
int main()
{
    cin >>n>>m;
    memset(h,-1,sizeof h);
    for(int i=1;i<=n;i++) cin >>hh[i];
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin >>a>>b;
        add(a,b);
        add(b,a);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        int flag=1;
        for(int j=h[i];j!=-1;j=ne[j])
        {
            int k=e[j];
            if(hh[i]<=hh[k])
            {
                flag=0;
                break;
            }
        }
        if(flag) ans++;
    }
    cout <<ans<<endl;
}

Measured memory_bytes: 6380
#include <iostream>
    #include <algorithm>
    #include <utility>
    #include <tuple>
    #include <vector>
    #include <list>
     
            int N, M;
    using pair_t = std::pair<int, int>;
    std::vector<pair_t> ab;
     
    void sort(std::vector<pair_t>& v)
    {
            std::sort(ab.begin(), ab.end(),
                    [](const pair_t& x, const pair_t& y) {
                            return x.second < y.second;
                    }
            );
    }
     
    int main()
    {
            std::cin >> N >> M;
            for (int i = 0; i < M; ++i) {
                    int a, b;
                    std::cin >> a >> b;
                    ab.push_back({a, b});
            }
            sort(ab);
     
            int n = 0;
            while (!ab.empty()) {
                    ++n;
                    auto x = ab.front();
                    auto it = std::remove_if(ab.begin(), ab.end(), [&x](const pair_t& y){ return y.first < x.second; });
                    ab.erase(it, ab.end());
                    sort(ab);
            }
            std::cout << n << "\n";
     
            return 0;
    }

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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
	int b;
	rep(i, 5){
		int x;
		cin >> x;
		if(x == 0){
			b = i+1;
			break;
		}
	}
	cout << b << endl;

}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int n;
char s[25];
char c[105];
int f[355];
long long sol;
int y[355];
int main()
{
    scanf("%d",&n);
    y['M']=1;
    y['A']=2;
    y['R']=3;
    y['C']=4;
    y['H']=5;
    for(int i=1;i<=n;i++)
    {
        scanf("\n");
        scanf("%s",s+1);
        f[y[s[1]]]++;
    }
    c[1]='M';
    c[2]='A';
    c[3]='R';
    c[4]='C';
    c[5]='H';
    for(int i=1;i<=5;i++)
        for(int j=i+1;j<=5;j++)
            for(int k=j+1;k<=5;k++)
        {
            sol=sol+(1LL*f[i])*(1LL*f[j])*(1LL*f[k]);
        }
    cout<<sol<<'\n';
    return 0;
}


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

using namespace std;

#define N 1000000

int main(int argc, char const *argv[])
{
	int n,p;

	bool f[N];
	int i1,i2;

	set<int> s;
	set<int>::iterator it1,it2;


	f[0]=true;
	f[1]=true;
	f[2]=false;
	for(i1=2;i1<N;i1++){
		if(f[i1]==false){
			for(i2=2;i2*i1<N;i2++){
				f[i1*i2]=true;
			}
		}
	}

	for(i1=2;i1<N;i1++){
		if(f[i1]==false) s.insert(i1);
	}


	while(1){
		cin>>n>>p;
		if(n+p==-2) break;

		multiset<int> M;
		multiset<int>::iterator it3;

		it1=s.find(n);
		if(it1!=s.end()) it1++; 
		else it1=s.lower_bound(n);

		for(i1=0;i1<p;it1++,i1++){
			for(it2=it1,i2=i1;i2<p;it2++,i2++){
				M.insert((*it1)+(*it2));
			}
		}

		for(it3=M.begin(),i1=1;i1<p;it3++,i1++){}
		cout<<(*it3)<<endl;


	}
	return 0;
}

Measured memory_bytes: 6080
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
from math import ceil
tmp1 = [A,B,C,D,E]
tmp2 = list()
for j in range(5):
    if tmp1[j]%10 == 0:
        tmp2.append(0)
    else:
        tmp2.append(10 - tmp1[j]%10)
for i in range(5):
    tmp1[i] = ceil(tmp1[i]/10)*10
print(sum(tmp1)-max(tmp2))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	ll n, i, ans = LLONG_MAX;
	cin >> n;
	for(i = 1; i * i <= n; i++)
	{
		if(n % i == 0)
		{
			ans = min(i - 1 + n / i - 1, ans);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define int long long 

int32_t main() {
	string fore, act;
	cin >> fore >> act;

	int index = 0;
	int count = 0;
	while(index < 3) {
		if(fore[index] == act[index])
			count++;

		index++;
	}	

	cout << count << endl;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for i in range(n)]

lm = [0 for i in range(n)]
rm = [0 for i in range(n)]
for i in range(1, n):
  lm[i] = max(lm[i-1], a[i-1])

for i in reversed(range(n-1)):
  rm[i] = max(rm[i+1], a[i+1])

for i in range(n):
  print(max(lm[i], rm[i]))


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

using namespace std;

int main() {
	char c;
	cin >> c;

	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

int main() {
    long long a,b;
    cin >> a >> b;
    long long h = 0;
    vector<vector<int>> z(a, vector<int>(b));
    for (int i = 0; i < a; i++) {
        for (int j = 0; j < b; j++) {
            cin >> z.at(i).at(j);
        }
    }
    for (int i = 0; i < a; i++) {
        for (int j = i + 1; j < a; j++) {
            int g = 0;
            for (int k = 0; k < b; k++) {
                g += (z.at(i).at(k) - z.at(j).at(k)) * (z.at(i).at(k) - z.at(j).at(k));
            }
            for (int k = 0; k < sqrt(g) + 2; k++) {
                if (k * k == g)h++;
            }
        }
    }
    cout << h << endl;
}

Measured memory_bytes: 256
AB = input().split()
A = int(AB[0])
B = int(AB[1])

def gcd(m, n):
  x = max(m, n)
  y = min(m, n)
  if x%y ==0:
    return y
  else:
    while x%y!=0:
      z = x%y
      x = y
      y = z
    else:
      return z
 
def lcm(m, n):
  print(int(m * n /gcd(m, n)))

lcm(A, B)

Measured memory_bytes: 3060
(defconstant modulo 1000000007)

(let* ((n (read))
       (tbl (make-array 1005 :initial-element 0 :element-type 'fixnum)))
  (loop for k from 1 to n do
        (loop with i = 2
              with v = k
              while (< 1 v) do
              (if (zerop (mod v i))
                  (setf v (/ v i)
                        (aref tbl i) (1+ (aref tbl i)))
                  (incf i))))
  (format t "~A~%" (loop for c across tbl
                         for acc = 1 then (mod (* acc (1+ c)) modulo)
                         finally (return acc))))

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

int main(){
	int c[100000];
	int max = -10000;
	long long int sum = 0;
	int s = 0;
	int b[100000];
	int n;
	cin >> n;
	for(int i = 0;i<n;i++){
		cin >> b[i];
		sum += abs(b[i]);
	}
	for(int i = 0;i<n;i++){
		if(b[i] <= 0){
			s += 1;
		}
	}
	for(int i = 0;i<n;i++){
		if(b[i] <= 0){
			c[i] = abs(b[i]);
		}
		else{
			c[i] = b[i];
		}
	}
	sort(c,c+n);
	//cout << c[0];
	if(s % 2 == 0){
		cout << sum;
	}
	else{
		cout << sum-2*c[0];
	}
	
}

Measured memory_bytes: 1024
#include <iostream>
#include<bits/stdc++.h>
const int N=1e5+5;
const int M=1e7;
using namespace std;
int main()
{
    char s[105],t[105];
    long long a,b,k;
    cin>>a>>b>>k;
    if(a>=k) cout<<a-k<<" "<<b;
    else if(a+b>=k) cout<<0<<" "<<a+b-k;
         else cout<<0<<" "<<0;
    return 0;
}


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

std::string s, t;

int main() {
    std::cin >> s
             >> t;
    std::sort(s.begin(), s.end());
    std::sort(t.begin(), t.end(), std::greater<char>());

    if (s < t) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
  int input[2], keep, i, n, max;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    if(i == 0){
      scanf("%d",&input[0]);
      continue;
    }
    if(i == 1){
      scanf("%d",&input[1]);  
      max = input[1] - input[0];
      continue;
    }
    scanf("%d",&keep);
    if(input[0] > input[1])
      input[0] = input[1];
    input[1] = keep;
      if(input[1]-input[0] > max)
	max = input[1]-input[0];
  }
  printf("%d\n",max);
  return 0;
}

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

int main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    int n;
    cin >> n;
    vector<int> x(n+1);
    for(int i = 0;i < n+1;i ++){
        cin >> x.at(i);
    }

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

    int m = 1000000000;
    for(int i = 0;i < n;i ++){
        m = min(m,x.at(i+1)-x.at(i));
    }


    int i,j,ans = 1;
    for(i = m;i > 1;i --){

        int a = x.at(0) % i;

        for(j = 0;j < n+1;j ++){
            if(x.at(j) % i != a){
                break;
            }
        }

        if(j == n+1){
            ans = i;
            break;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        List<Integer> aList = new ArrayList<>();
        for (int i = 0; i < n; i++) aList.add(sc.nextInt());
        List<Integer> bList = new ArrayList<>();
        for (int i = 0; i < m; i++) bList.add(sc.nextInt());

        if (x > y) {
            System.out.println("War");
            return;
        }

        List<Integer> options = new ArrayList<>();
        for (int i = x+1; i <= y; i++) options.add(i);

        List<Integer> options2 = new ArrayList<>();
        for (int i = 0; i < options.size(); i++) {
            boolean isWar = false;
            for (int j = 0; j < n; j++) {
                if (!(aList.get(j) < options.get(i))) {
                    isWar = true;
                    break;
                }
            }
            if (!isWar) options2.add(options.get(i));
        }
        if (options2.size() < 1) {
            System.out.println("War");
            return;
        }

        List<Integer> options3 = new ArrayList<>();
        for (int i = 0; i < options2.size(); i++) {
            boolean isWar = false;
            for (int j = 0; j < m; j++) {
                if (!(bList.get(j) >= options2.get(i))) {
                    isWar = true;
                    break;
                }
            }
            if (!isWar) options3.add(options.get(i));
        }

        if (options3.size() > 0) System.out.println("No War");
        else System.out.println("War");
    }
}

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


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


Measured memory_bytes: 256
#include <iostream>

int max(int a, int b) {
    if (a > b) 
        return a;
    else
        return b;
}

int main() {
    int a_inf, a_math, a_science, a_english;
    int b_inf, b_math, b_science, b_english;
    std::cin >> a_inf >> a_math >> a_science >> a_english;
    std::cin >> b_inf >> b_math >> b_science >> b_english;
    int S, T;
    S = a_inf + a_math + a_science + a_english;
    T = b_inf + b_math + b_science + b_english;
    std::cout << max(S, T) << std::endl;
    return 0;
}
    

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

int main() {
	string s;
	cin >> s;
	int left, right;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'A') {left = i; break;}
	}
	for (int i = s.length() - 1; 0 <= i; i--) {
		if (s[i] == 'Z') {right = i; break;}
	}
	cout << right - left + 1 << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define pi acos(-1.0)

int main()
{
    ll i, j, n, m;

    map < string, int > mp;

    mp["SUN"] = 7;
    mp["MON"] = 6;
    mp["TUE"] = 5;
    mp["WED"] = 4;
    mp["THU"] = 3;
    mp["FRI"] = 2;
    mp["SAT"] = 1;

    string s;

    cin >> s;

    cout << mp[s] << endl;

    return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<queue>
#include<algorithm>
#include<functional>

using namespace std;

vector<string> task;
const int inf = 1<<22;

struct state{
  int num;
  int pos[10];
  int cost;
  state(){
    cost = 0;
    num = 0;
    fill(pos,pos+10,-1);
  }
  state(int p[10], int n, int c){
    copy(p,p+10,pos);
    cost = c;
    num = n;
  }
  bool operator>(const state &t)const{
    return cost>t.cost;
  }
};

void rev(char M[5][300], const state &t){
  for(int i = 0; i < 10; ++i){
    if( t.pos[i] > -1 ){
      for(int j = 0; j < (int)task.size(); ++j){
        for(int k = 0; k < (int)task[j].size(); ++k){
          if( task[j][k] != '.'){
            M[j][t.pos[i]+k] = task[j][k];
          }
        }
      }
    }
  }
}

bool canPut(char M[5][300], int st, int offset){
  for(int i = 0; i < (int)task.size(); ++i){
    for(int j = 0; j < (int)task[i].size(); ++j){
      if( task[i][j] != '.' && M[i][st+offset+j] != 0 ){
        return false;
      }
    }
  }
  return true;
}

int solve(int n){
  state init;
  init.num = 0;
  init.pos[init.num] = 0;
  init.cost = n;
  int ret = inf;

  priority_queue<state, vector<state>, greater<state> > q;
  int vis[10];
  fill(vis,vis+10,inf);
  
  q.push(init);
  while(!q.empty()){
    state cur = q.top(); q.pop();
    if( cur.num == 9 ){
      return cur.cost;
      ret = min(ret, cur.cost);
    }
    
    int initial = *max_element(cur.pos,cur.pos+10);
    char M[5][300] = {{0}};
    rev(M,cur);
    for(int off = 1; off <= n; ++off){
      if(canPut(M,initial,off)){
        state next = cur;
        next.num++;
        next.pos[next.num] = initial + off;
        next.cost = initial + off + n;
        
        if( vis[next.num] > next.cost ){
          // vis[next.num] = next.cost;
          q.push(next);
        }
      }
    }
  }
  return ret;
}

int main()
{
  int n;
  while(true){
    task.clear();
    cin >> n;
    if(n == 0) break;
    for(int i = 0; i < 5; ++i){
      string s;
      cin >> s;
      task.push_back(s);
    }
    cout << solve(n) << endl;
  }
  return 0;
}

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

int main() {
  int a, b;
  std::cin >> a >> b;
  if (a==2 || b ==2) {
    std::cout << "No" << '\n';
  }
  else
  std::cout << "Yes" << '\n';
  return 0; 
}


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

int log(int n,int num){
  int cnt=0;
  while(num>3){
    cnt++;
    if(num%3==0){
      num = num/n;
    }else{
      num = num/n + 1;
    }
  }
  return cnt+1;
}

int main(){
  long long n;
  cin>>n;
  cout << log(3,n) << endl;
  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 2e3+10;
int n,k,a[N][N];

int main() {
	scanf("%d",&k);
	if (k==1) return puts("1\n1"),0;
	n = (k+3)/4*2;
	REP(i,1,n) REP(j,1,n) a[i][j]=(i+j)%n+i%2*n;
	REP(i,1,n) REP(j,1,n) if (a[i][j]>=k) a[i][j]-=n;
	printf("%d\n", n);
	REP(i,1,n) {
		REP(j,1,n) printf("%d ", a[i][j]+1);hr;
	}
}








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

const int m=1000005;
int main(){
  int x;
  cin >> x;
  int y = ceil(x/1.08);
  if(int(y*1.08)==x) cout << y;
  else cout << ":(";

  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <bitset>
#include <string>
using namespace std;
int main(int argc, const char * argv[]) {

    string S;
    cin >> S;
    

    for(int tmp = 0; tmp < (1 << 3); tmp++){
        
        bitset<3> bit(tmp);
        string formula = "";
        int seven_Sum = stoi(S.substr(0,1));
        for(int i = 0; i < 3; i++){
            formula += S[i];
            if(bit.test(i) == 0){
                seven_Sum -= stoi(S.substr(i+1,1));
                formula += "-";
            }
            else{
                seven_Sum += stoi(S.substr(i+1,1));
                formula += "+";
            }
        }
        
        formula += S[3];
        formula += "=7";
        
        if(seven_Sum == 7){
            cout << formula << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
def main()
        stdin = $stdin.readlines.map {|i| i.chomp() }
        num = stdin[0]
        elem = stdin[1].split(" ").map {|i| i.to_i }
        base_p3_index = 2
        count = 0
        while base_p3_index <= elem.length-1
                if (elem[base_p3_index-2]<elem[base_p3_index-1]) == (elem[base_p3_index-1]<elem[base_p3_index])
                        count += 1
                end
                base_p3_index+=1
        end
        print(count)
end

main()

Measured memory_bytes: 1788
# -*- coding: utf-8 -*-

def readInts():
  return [int(s) for s in input().split(" ")]

def main():
  N = readInts()[0]
  S = input()
  K = readInts()[0]
  ans = ""
  for c in S:
    if c == S[K-1]:
      ans += c
    else:
      ans += "*"
  print(ans)

if __name__ == "__main__":
  main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define max_char 128
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lbd lower_bound
#define ubd upper_bound
#define PI 3.141592653589793238
#define pf push_front
#define all(x) x.begin(),x.end()
#define input(arr,n) for(ll c1=0;c1<n;c1++)cin>>arr[c1];
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define mems(x, y) memset(x, y, sizeof(x))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
//cout<<"Case #"<<v1+1<<": ";
 
ll power(ll base,ll pow, ll mo)
{
   ll res=1;
   while(pow)
   {     
        if (pow%2!=0)  res=(res*base)%mo;
        base=(base*base)%mo;
        pow/=2;
   }
   return res;
}
 
 
int main()
{
    fastio
	
	ll i,n,k,a,b;
	cin>>a;
	ll x=100;
	ll ans=0;
	
	while(x<a)
	{
	    ++ans;
	    x=x*1.01;
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
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;}

int main(){
  ll N,ans=0;
  cin>>N;
  string S;
  cin>>S;
  
  string K=S.substr(N),T;
  REP(i,N) T+=K.at(N-1-i);
  S.erase(N);
  
  
  bool CAN=false;
  ll SC[26],TC[26];
  REP(i,26){
    SC[i]=0;
    TC[i]=0;
  }
  
  REP(i,N){
    SC[S.at(i)-'a']++;
    TC[T.at(i)-'a']++;
  }
  
  REP(i,26){
    if(SC[i]!=TC[i]) CAN=true;
  }
  
  if(CAN){
    co(0);
    return 0;
  }
  
  
  map<pair<string,string>,ll> M;
  for(ll bit=0; bit<(1<<N); ++bit){
    string L,P;
    for(ll i=0; i<N; ++i){
      if(bit&(1<<i)) L+=S.at(i);
      else P+=S.at(i);
    }
    auto Q=MP(L,P);
    M[Q]++;
  }
  
  for(ll bit=0; bit<(1<<N); ++bit){
    string L,P;
    for(ll i=0; i<N; ++i){
      if(bit&(1<<i)) L+=T.at(i);
      else P+=T.at(i);
    }
    auto Q=MP(L,P);
    ans+=M[Q];
  }
  
  co(ans);
  return 0;
}

Measured memory_bytes: 49280
N = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
  
fact = factorization(N)

import math

ans = 0

if N != 1:

    for f in fact:

        X = f[1]
        n = math.ceil(math.sqrt(2*X) - 1)
        if n * (n+1) > 2*X:
            n = n-1

        ans += n

print(ans)

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

int main()
{
	int n; 
	cin >> n; 
	double a[105]; 
	for(int i = 0; i < n; i ++)
		cin >> a[i]; 
	for(int i = 0; i < n; i ++)
		a[i] = 1 / a[i]; 
	double cnt = 0; 
	for(int i = 0; i < n; i ++)
		cnt += a[i]; 
	cout << fixed << setprecision(5) << 1 / cnt << endl; 
	return 0; 
}

Measured memory_bytes: 384
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N = I()
S = str(input())

R = []
G = []
B = []

for i in range(N):
    if S[i] == 'R':
        R.append(i)
    elif S[i] == 'G':
        G.append(i)
    else:
        B.append(i)

ans = 0
for r in R:
    for g in G:
        ans += len(B)
        mi,ma = min(r,g),max(r,g)
        p = bisect_left(B,2*ma-mi)
        if 0<= p <= len(B)-1 and B[p] == 2*ma-mi and 2*ma-mi > ma:
            ans -= 1
        p = bisect_left(B,(ma+mi)/2)
        if 0<= p <= len(B)-1 and B[p] == (ma+mi)/2 and mi<B[p]<ma:
            ans -= 1
        p = bisect_left(B,2*mi-ma)
        if 0 <= p <= len(B)-1 and B[p] == 2*mi-ma and B[p]<mi:
            ans -= 1
print(ans)

Measured memory_bytes: 78480
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,M=MI()
    
    if M>2*N:
        M+=N*2
        print(M//4)
    else:
        print(min(N,M//2))

main()


Measured memory_bytes: 38384