akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using static System.Console;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {
            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long gcd(long x, long y)
        {
            if (y < x) gcd(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return x;
        }
        public static long keta(long x)
        {
            var z = 1;
            while (x > 0)
            {
                x /= 10;
                z++;
            }
            return z;
        }
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var x = Read();
            var s = 400;
            var ans = 0;
            for (int i = 0; i < 8; i++)
            {
                if (s + i * 200 <=x && x < s + (i + 1) * 200) ans = 8-i;
            }
            WriteLine(ans);
        


            Console.Out.Flush();
        }
    }
}



Measured memory_bytes: 17648
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    int x;
    cin>>x;
    if(x>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
    }
    int ans = N;
    for (int i = 1; i < N; i++)
    {
        for (int j = i; j >= 0; j--)
        {
            if (H[i] < H[j])
            {
                ans--;
                break;
            }
        }
        
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <bitset>
using namespace std;

int main(){
	typedef vector<int>::iterator viitr;
	int n, m, a, b;
	for(; scanf("%d%d", &n, &m), m;){
		bitset<501> bs(2);
		vector<vector<int> > fr(n+1);
		for(; m--; ){
			scanf("%d%d", &a, &b);
			fr[a].push_back(b);
			fr[b].push_back(a);
		}
		
		viitr m_it = fr[1].begin(), m_end = fr[1].end();
		for(; m_it != m_end; ++m_it ){
			int f = *m_it;
			bs.set(f);
			viitr it = fr[f].begin(), end = fr[f].end();
			for(; it != end; ++it ){
				bs.set( *it );
			}
		}
		printf("%d\n", bs.count() - 1 );
	}
}

Measured memory_bytes: 0
A, B, C, D = map(int, input().split())

range_AB = range(A, B + 1)
range_CD = range(C, D + 1)

if set(range_AB) & set(range_CD):
    print(len(set(range_AB) & set(range_CD)) - 1)
else:
    print(0)


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

using namespace std;

int n,m,a[100010],b[100010],top;

int main()
{
	scanf("%d%d",&n,&m);
	int odd1=-1,odd2=-1;
	for(int i=1; i<=m; i++)
	{
		scanf("%d",&a[i]);
		if(a[i]&1)
		{
			if(odd1==-1)odd1=i;
			else if(odd2==-1)odd2=i;
			else
			{
				printf("Impossible");
				return 0;
			}
		}
	}
	if(m==1)
	{
		if(a[1]==1)
			printf("1\n1\n1\n");
		else
			printf("%d\n2\n1 %d\n",a[1],a[1]-1);
		return 0;
	}
	if(odd1!=-1)swap(a[1],a[odd1]);
	if(odd2!=-1)swap(a[m],a[odd2]);
	for(int i=1; i<=m; i++)printf("%d%c",a[i]," \n"[i==m]);
	if(a[m]==1)
	{
		printf("%d\n",m-1);
		printf("%d ",a[1]+1);
		for(int i=2; i<m; i++)printf("%d ",a[i]);
		return 0;
	}
	b[1]=a[1]+1;
	for(int i=2; i<m; i++)b[i]=a[i];
	b[m]=a[m]-1;
	printf("%d\n",m);
	for(int i=1; i<=m; i++)printf("%d%c",b[i]," \n"[i==m]);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	
	int n;
	while (cin >> n)
	{
		int a, b, c, d, sum = 0;
		for (a = 0; a <10; a++){
			for (b = 0; b < 10; b++){
				for (c = 0; c < 10; c++){
					for (d = 0; d < 10; d++){
						if (a + b + c + d == n){
							sum += 1;
						}
					}
				}
			}
		}
		cout << sum << endl;
	}
	

}



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

int main() {
	int N, M;

	while(cin >> N >> M, N || M) {
		vector<int> P;
		vector<int> v;
		for(int i = 0; i < N; i++) {
			int tmp;
			cin >> tmp;
			P.push_back(tmp);
		}
		P.push_back(0);

		for(int i = 0; i < P.size(); i++) {
			for(int j = 0; j < P.size(); j++) {
				v.push_back(P[i]+P[j]);
			}
		}
		sort(v.begin(), v.end());
		int j = v.size() - 1;
		int res = 0;
		for(int i = 0; i < v.size(); i++) {
			while(v[i]+v[j] > M && j >= 0)
				j--;
			if(j >= 0)
				res = max(res, v[i] + v[j]);
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  char C;
  cin >> C;
  C = C + 1;
  cout << C << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;

int mod = 1e9 + 7;

int main()
{
    int N;
    std::cin >> N;
    std::array<bint, 11> state_now{};
    std::array<bint, 11> state_pre{};
    state_pre.at(0) = 2;
    state_pre.at(1) = 1;
    state_pre.at(2) = 1;
    for (int i = 1; i < N; i++) {
        state_now.at(0)
            = state_pre.at(0) * 2
            + state_pre.at(2) * 2
            + state_pre.at(4) * 2
            + state_pre.at(5) * 2
            + state_pre.at(8) * 1
            + state_pre.at(9) * 1
            + state_pre.at(10) * 1;
        state_now.at(1)
            = state_pre.at(0) * 1
            + state_pre.at(1) * 1
            + state_pre.at(4) * 1
            + state_pre.at(5) * 1
            + state_pre.at(6) * 1
            + state_pre.at(7) * 1
            + state_pre.at(9) * 1;
        state_now.at(2)
            = state_pre.at(0) * 1
            + state_pre.at(2) * 1
            + state_pre.at(8) * 1
            + state_pre.at(9) * 1
            + state_pre.at(10) * 1;
        state_now.at(3)
            = state_pre.at(1) * 1
            + state_pre.at(6) * 1
            + state_pre.at(7) * 1;
        state_now.at(4)
            = state_pre.at(1) * 1;
        state_now.at(5)
            = state_pre.at(1) * 1
            + state_pre.at(6) * 1
            + state_pre.at(7) * 1;
        state_now.at(6)
            = state_pre.at(2) * 1
            + state_pre.at(8) * 1
            + state_pre.at(10) * 1;
        state_now.at(7)
            = state_pre.at(3) * 1;
        state_now.at(8)
            = state_pre.at(3) * 1;
        state_now.at(9)
            = state_pre.at(3) * 1;
        state_now.at(10)
            = state_pre.at(5) * 1;
        state_pre = state_now;
    }
    bint sum = 0;
    for (int i = 0; i < 11; i++) {
        sum += state_now.at(i);
    }
    std::cout << sum % mod << std::endl;
    return 0;
}

/*
 * AGC
 * ACG
 * GAC
 * A.GC \AAGC
 * AG.C \AGCC
 * $B$N(B5$BDL$j$7$+$J$$$N$G%*!<%H%^%H%s(Bdp$B$+$J(B
 */
/*
 * 0. NO
   * 0. NO (TC)
   * 1. A (A)
   * 2. G (G)
 * 1. A
   * 1. A (A)
   * 3. AG (G)
   * 4. AC (C)
   * 5. AT (T)
 * 2. G
   * 0. NO (TC)
   * 2. G (G)
   * 6. GA (A)
 * 3. AG
   * 7. AGA (A)
   * 8. AGG (G)
   * 9. AGT (T)
 * 4. AC
   * 0. NO (CT)
   * 1. A (A)
 * 5. AT
   * 0. NO (CT)
   * 1. A (A)
   * 10. ATG (G)
 * 6. GA
   * 1. A (A)
   * 3. AG (G)
   * 5. AT (T)
 * 7. AGA
   * 1. A (A)
   * 3. AG (G)
   * 5. AT (T)
 * 8. AGG
   * 0. NO (T)
   * 2. G (G)
   * 6. GA (A)
 * 9. AGT
   * 0. NO (T)
   * 1. A (A)
   * 2. G (G)
 * 10. ATG
   * 0. NO (T)
   * 2. G (G)
   * 6. GA (A)
 */

Measured memory_bytes: 256
#!/usr/bin/env python3


def div_ceil(a, b):
    return (a + b - 1) // b


def compute(n):
    d = div_ceil(n, 1000)
    return d * 1000 - n


def main():
    n = int(input())
    res = compute(n)
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9160
#include <algorithm>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

int main()
{
  char buf[4];
  scanf("%c%c%c", &buf[0], &buf[1], &buf[2]);
  buf[3] = '\0';
  if(strchr(buf, 'a') == NULL) {
    puts("No");
    return 0;
  }
  if(strchr(buf, 'b') == NULL) {
    puts("No");
    return 0;
  }
  if(strchr(buf, 'c') == NULL) {
    puts("No");
    return 0;
  }
  puts("Yes");
  return 0;
}


Measured memory_bytes: 888
#include <cstdio>

int n, k, p;

int main() {
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%d %d", &k, &p);

    if (k % p) { printf("%d\n", k % p); }
    else { printf("%d\n", p); }
  }

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	int a[m];
	for(int i=0; i<m; i++)
	{
		cin>>a[i];
	}
	lli count=0;
	for(int i=0; i<m; i++)
	{
		count+=a[i];
	}
	lli ans = n-count;
	if(ans>=0)
	{
		cout<<ans;
	}
	else
	{
		cout<<"-1";
	}
}

Measured memory_bytes: 3636
S=list(map(int,input().split()))

sx=S[0]
sy=S[1]
tx=S[2]
ty=S[3]
answer=[]
for i in range(ty-sy):
    answer.append("U")
for i in range(tx-sx):
    answer.append("R")
for i in range(ty-sy):
    answer.append("D")
for i in range(tx-sx):
    answer.append("L")
answer.append("L")
for i in range(ty-sy+1):
    answer.append("U")
for i in range(tx-sx+1):
    answer.append("R")
answer.append("D")
answer.append("R")
for i in range(ty-sy+1):
    answer.append("D")
for i in range(tx-sx+1):
    answer.append("L")
answer.append("U")
for s in answer:
    print(s,end="")


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

int main(){
  const int N= 3;
  vector<int> data(N);
  for(int i=0; i<N; i++){
    cin >> data.at(i);
  }
  sort(data.begin(), data.end());
  
  cout << data.at(0)+ data.at(1) << endl;
}

Measured memory_bytes: 256
# AIZU 0-1 Knapsack Problem
reader = input().split(' ')
item_num = int(reader[0])
w_max = int(reader[1])

value = []
weight = []
for i in range(item_num):
    reader = input().split(' ')
    value.append(int(reader[0]))
    weight.append(int(reader[1]))

dp_table = [[0 for i in range(w_max+1)] for j in range(item_num+1)]

for i in range(item_num):
    for w in range(w_max+1):
        if w >= weight[i]:
            dp_table[i+1][w] = max([dp_table[i][w-weight[i]] + value[i], dp_table[i][w]])
        else:
            dp_table[i+1][w] = dp_table[i][w]

print(str(dp_table[item_num][w_max]))



Measured memory_bytes: 42264
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#define REP(i, n) for(int i=0;i<n;++i)
#define INF 100000000
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

ll int x, y;
ll int ans = 0;

int main(){
    cin >> x >> y;

    while(x <= y){
        ++ans;
        x = x * 2;
    }

    printf("%lld\n", ans);

	return 0;
}

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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    vector <pair <ll, int> > d;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            int cnt = 0;
            while (n % i == 0) n /= i, cnt++;
            d.push_back({i, cnt});
        }
    }
    if( n > 1) d.push_back({n, 1});
    ll ans = 0;
    for (auto to : d) {
        int x = 0;
        for (int j = 1; ; j++) {
            if (j * (ll) (j + 1) / 2 > to.second) {
                x = j-  1; 
                break;
            }
        }
        ans += x;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3660
using System;
using System.Collections.Generic;
using System.Linq;

class AB {

    static int N;
    static int[] x;
    static void Main() {
        N = int.Parse(Console.ReadLine());
        x = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int a = int.MaxValue;
        for(int i = x.Min(); i <= x.Max(); i++) {
            int b = 0;
            for(int j = 0; j < N; j++) {
                b += (x[j] - i) * (x[j] - i);
            }
            if (a > b) {
                a = b;
            }
        }
        Console.WriteLine(a);
    }
}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
using namespace std;
const int INF = 1e9;
typedef long long ll;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}


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

	vector<vector<int> > vec(M);

	for (int i = 0; i < M; ++i) {
		int k; cin >> k;
		vec[i].resize(k);
		for (int j = 0; j < k; ++j) {
			cin >> vec[i][j];
			--vec[i][j];
		}
	}

	vector<int> p(M);
	for (int i = 0; i < M; ++i) cin >> p[i];

	int ans = 0;
	for (int i = 0; i < (1 << N); ++i) {
		bool ok = true;
		for (int j = 0; j < M; ++j) {
			int c = 0;
			for (int id : vec[j]) {
				if ((i >> id) & 1) {
					++c;
				}
			}
			c %= 2;
			if (c != p[j]) {
				ok = false;
			}
		}
		if (ok) {
			++ans;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const int dx[] = { -1 , -1 , -1 , 0 , 0 , 0 , 1 , 1 , 1 };
const int dy[] = { -1 , 0 , 1 , -1 , 0 , 1 , -1 , 0 , 1 };
#define NN 8010000
#define TC int t;cin>>t;for(int T=1;T<=t;T++)
#define mod 1000000007
#define PI acos(-1)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define mem(a,n) memset(a,n,sizeof(a))
void AIA() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
//cout<<fixed<<setprecision(20);
// freopen("stand.in","r",stdin);
// freopen("stand.out","w",stdout);
bool isprime(ll n) {
	for (ll i = 2; i * i <= n; i++) {
		if (n % i == 0)return 0;
	}
	return (n!=1);
}
ll gcd(ll x, ll y)
{
	return (y == 0 ? x : gcd(y, x % y));
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll rem(int x, int N){
	return (x % N + N) % N;
}

int main()
{
	//cout<<fixed<<setprecision(20);
	//freopen("Input.txt.txt", "r", stdin);
	//freopen("Output.txt.txt", "w", stdout);
	AIA();
	int n, c = 0;
	cin>>n;
	while(n--){
		int a, b;
		cin>>a>>b;
		if(a == b)c++;
		else c = 0;
		if(c == 3){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

const int MOD = 1e9+7; //998244353;

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 2e5;
ll a, b, n;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b >> n;
  mins(n, b-1);
  cout << ll(lll(a)*n/b-n/b*a) << endl;
}

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

// a^n mod を計算する
// O(logn)
ll modpow(ll a, ll n, ll mod=MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];

    ll ans=0;
    rep(d,61){
        ll c0=0,c1=0;
        rep(i,n){
            if(a[i] & 1LL<<d) c1++;
            else c0++;
        }
        
        ll tmp=(c0*c1)%MOD;
        tmp=(tmp*modpow(2,d))%MOD;
        //cout<<c0<<" "<<c1<<endl;
        ans=(ans+tmp)%MOD;
    }

    cout<<ans<<endl;
}



Measured memory_bytes: 5552
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(i64 i = 0; i < N; i++)
#define Rep(i, k, N) for(i64 i = k; i < N; i++)
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
    long double A ,B;
    cin >> A >> B;
    cout << setprecision(18) << floorl(A * B) << endl;
}


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

int a=0,b=0,n,t,x,y,z,l=0;

int main()
{
	cin>>n;
	
	for(int i=1;i<=n;i++)
	{
	cin>>t>>x>>y;
	z=(x-a)+(y-b);
	if(z<=t && (t-z)%2==0)  	l++;
    }
    
    if(l==n)	cout<<"Yes";
    else
    {
		cout<<"No";	
	}
	
	return 0;
}

Measured memory_bytes: 384
// #include <bits/stdc++.h>
#include<iostream>
#include<stack>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<set>
#include<bitset>
#include<cmath>
#include<numeric>
#include<limits>
#include<functional>
#include <bitset>

#define REP(i, m, n) for(int i = (m); i < (n); i++)
#define rep(i,n) REP(i,0,n)
#define NIL -1
#define INFTY 1<<29
using namespace std;
typedef long long ll;
typedef long long int lli;
// static const int MOD = 10000007;
// static const int MAX = 100005;
static const int NMAX = 1005;
static const int KEY = 4096;


// typedef priority_queue<int, greater<int>> RevQ;
int N, M;
string s;

// lli gcd(lli a, lli b) {
//   return b ? gcd(b, a%b) : a;
// }

int main(){
  cin >> N;
  cin >> s;
  int cnt = 0;
  rep(i, N) {
    if (i == 0) {
      cnt += 1;
      continue;
    }
    if (s[i] != s[i-1]) {
      cnt += 1;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef std::vector<int>  VI;

int H;
std::vector< VI > board(10, VI(5, -1));

int erase() {
    int i, j, k, x;
    int score = 0;
    for(i = 0; i < H; ++i) {
        for(j = 0; j < 3; ++j) {
            k = j + 1;
            x = board[i][j];
            if(x == -1) continue;
            while(k < 5 && board[i][k] == x) ++k;
            --k;
            if(k - j >= 2) {
                score += (k - j + 1) * x;
                while(k >= j) {
                    board[i][k] = -1;
                    --k;
                }
            }
        }
    }
    return score;
}

bool update() {
    int i, j, k;
    bool isUpdate = false;;
    for(j = 0; j < 5; ++j) {
        for(i = H-1; i >= 0; --i) {
            if(board[i][j] == -1 || i == H-1 || board[i+1][j] != -1) continue;
            k = i+1;
            while(k < H && board[k][j] == -1) {
                isUpdate = true;
                board[k][j] = board[k-1][j];
                board[k-1][j] = -1;
                ++k;
            }
        }
    }
    return isUpdate;
}

int main() {
    int i, j;
    int score = 0;
    while(std::cin >> H, H != 0) {
        for(i = 0; i < H; ++i) {
            for(j = 0; j < 5; ++j) {
                std::cin >> board[i][j];
            }
        }
       
       score = 0;
        do {
            score += erase();
        } while(update());

        std::cout << score << std::endl;
    }
}


Measured memory_bytes: 3092
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int a, b, c;
int ans;
int N, M;
int A[110];
int sum;

int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	sort(A, A + N);
	
	a = 4 * M;
	if (sum % a == 0) {
		sum /= a;
	}
	else {
		sum /= a;
		sum++;
	}
	


	for (int i = 0; i < M; i++) {
		if (A[N - i - 1] < sum) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc153() {
	ll h, a;
	ll ans = 0;

	cin >> h >> a;

	while (h > 0) {
		h -= a;
		ans++;
	}

	cout << ans << "\n";
}

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

	solve_abc153();

	return 0;
}

Measured memory_bytes: 256
from __future__ import print_function

import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# import math
# import string
# import fractions
# from fractions import Fraction
# from fractions import gcd

# def lcm(n,m):
#     return int(n*m/gcd(n,m))

# import re
# import array
# import copy
# import functools
# import operator

# import collections
# import itertools
# import bisect
# import heapq


# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace

# from queue import PriorityQueue as pq

# def reduce(p, q):
#     common = fractions.gcd(p, q)
#     return (p//common , q//common )
# # from itertools import accumulate
# # from collections import deque

# from operator import mul
# from functools import reduce

# def combinations_count(n, r):
#     r = min(r, n - r)
#     numer = reduce(mul, range(n, n - r, -1), 1)
#     denom = reduce(mul, range(1, r + 1), 1)
#     return numer // denom

# import random

def main():
    n=int(input())
    s=input().strip()
    cnt=0
    for i in range(0,n):
            if s[i:i+3]=="ABC":
                cnt+=1
            else:
                pass
    print(cnt)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t i64;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int ngcd(vector<int> a) {
  int res;
  res = a[0];
  for (int i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int nlcm(vector<int> numbers) {
  int res;
  res = numbers[0];
  for (int i = 1; i < numbers.size(); i++) {
    res = lcm(res, numbers[i]);
  }
  return res;
}

int main() {
  int K;
  cin >> K;
  int res = 0;
  for (int a = 1; a <= K; a++) {
    for (int b = 1; b <= K; b++) {
      for (int c = 1; c <= K; c++) {
        int s = gcd(gcd(a, b), c);

        // cout << "gcd(a, b, c) = " << s << endl;
        res += s;
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define fr(i, a, b) for (ll i = a; i <= b; ++ i)
#define rf(i, a, b) for (ll i = a; i >= b; -- i)

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int main () {
    to_pray();

    int a, b;
    cin >> a >> b;

    --a;

    int sum = 1;

    int cnt = 0;

    if (b == 1)
        return cout << 0, 0;

    while(true) {
        ++cnt;
        sum += a;
        if (sum >= b)
            break;
    }

    cout << cnt;

    //eprintf("%.18lf seconds\n", (double)clock() / CLOCKS_PER_SEC);
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
using namespace std;
//#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	int A,B;
	cin>>A>>B;
	int ans=0;
	for(int i=A;i<=B;i++){
		string S,T;
		S=to_string(i);
		T=S;
		reverse(T.begin(),T.end());
		if(S==T)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
    int a, b;

    while( cin >> a >> b )
    {
        if( a == 0 && b == 0 )
            break;
        int c = 0;
        if( a < b )
        {
            int temp = a;
            a = b;
            b = temp;
        }
        while( b != 0 )
        {
            int temp = b;
            b = a % b;
            a = temp;
            c++;
        }
        cout << a << " " << c << endl;
    }

    return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <map>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <list>

using namespace std;
long long k[100010];
int main()
{
    int t;
    long long su=0,f,n;
    cin>>t;
    n=t;
    for(int i=0;i<t;++i){
        cin>>k[i];
        su+=k[i];
    }
    if(n==1LL)
    {
        printf("YES");
        return 0;
    }
    f=n*(n+1)/2LL;
    if(su%f==0LL)
    {
        long long z=su/f;
        long long b=z;
        bool ju=true;
        for(int i=1;i<t;++i)
        {
            long long a=k[i]-k[i-1];
            //cout<<a<<' '<<z<<endl;
            if(a<=z&&((z-a)%n==0LL))
            {
                b-=(z-a)/n;
                if(b<0)
                {
                    //cout<<"ai"<<endl;
                    ju=false;
                    break;
                }
            }
            else
            {
                //cout<<"why"<<endl;
                ju=false;
                break;
            }
        }
        if(ju){
        long long a=k[0]-k[t-1];
            //cout<<a<<' '<<z<<endl;
            if((z-a)%n==0LL)
            {
                b-=(z-a)/n;
                if(b<0)
                {
                    //cout<<"ai"<<endl;
                    ju=false;
                }
            }
            else
            {
                //cout<<"why"<<endl;
                ju=false;
            }
        //cout<<ju<<' '<<b<<endl;
        }
        if(ju)
            printf("YES");
        else
            printf("NO");
    }
    else
        printf("NO");
    return 0;
}


Measured memory_bytes: 1024
/**
 * author: Behradm
 * Created: 2020.08.15 16:28:43
 * In The Name of God
**/
#include <bits/stdc++.h>

using namespace std;

int main() {   
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) 
    cin >> a[i];
  int res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        if (a[i] != a[j] && a[i] != a[k] && a[j] != a[k]) {
          int b[3] = {a[i], a[j], a[k]};
          sort(b, b + 3);
          if (b[2] < b[0] + b[1])
            res += 1;
        }
      }
    }
  }

  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    const int MOD = 1000000000 + 7;

    int N;
    int K;
    cin >> N >> K;

    vector <long long> comb(N+2);
    vector <long long> theMin(N+2);
    vector <long long> theMax(N+2);

    comb[1] = N+1;
    theMin[1] = 0;
    theMax[1] = N;
    long long sum = N+1;

    for (int i = 2; i <= N+1; ++i) {
        theMin[i] = theMin[i-1] + (i-1);
        theMax[i] = theMax[i-1] + (N-i+1);
        comb[i] += theMax[i] - theMin[i] + 1;
        comb[i] %= MOD;
        // cout << "DEBUG " << theMin[i] << " " << theMax[i] << endl;
        // cout << comb[i] << " ";

        sum += comb[i];
        sum %= MOD;
    }

    for (int i = 1; i < K; ++i) {
        sum -= comb[i];
        sum %= MOD;
    }

    sum += MOD;
    sum %= MOD;

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 7924
def gcd(m, n)
	if m < n 
		gcd(n, m)
	elsif n == 0
		m
	else
		gcd(n, m % n)
	end 
end
w, h, c = gets.split.map(&:to_i)
g = gcd(w, h)
p c * w * h / g ** 2


Measured memory_bytes: 6860
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <string.h>
#include <utility>
#include <vector>
#include <climits>
#include <cmath>
#include <unordered_map>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    bool f=false;
    int h,n,a,s=0;
    cin>>h>>n;
    while(n--)
    {
        cin>>a;
        s+=a;
    }
    if(s>=h) cout<<"Yes\n";
    else cout<<"No\n";

    return 0;
}

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

using namespace std;

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

  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());

  int64_t total = A[N - 1] - A[0];
  int L = 0, R = N - 1;
  while (L < R) {
    int L2 = L + 1;
    int R2 = R - 1;
    if (L2 == R2) {
      if (A[R] - A[L2] > A[R2] - A[L]) {
        total += A[R] - A[L2];
        L = L2;
      } else {
        total += A[R2] - A[L];
        R = R2;
      }
    } else {
      total += A[R] - A[L2];
      total += A[R2] - A[L];
      L = L2;
      R = R2;
    }
  }
  printf("%ld\n", total);

  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int main(void){
	char s[11], t[12], u[11];
	int i, x=0;
	
	scanf("%s", s);
	scanf("%s", t);
	
	for(i=0; s[i]!=0; i++){
		if(s[i] != t[i]){
			x=1;
			break;
		}
	}
	
	if(x == 1){
		printf("No");
	}else{
		printf("Yes");
	}
	
	return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
#define vl vector<ll>
#define vi vector<int>
 
#define ff first
#define ss second
 
#define pb push_back
#define MOD 1000000007
//const int nax = 1e6+5;
#define inf 4e18
 
#define display(v) for(int i =0;i<v.size();++i)cout << v[i] << " "
#define all(v) v.begin(),v.end()
ll sqr(ll x){return x*x;}
inline ll add(ll a, ll b){ ll c = a + b; if(c >= MOD) c -= MOD; return c; }
inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
const int nax = 200*1000 + 10;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL); 
    ll n , d; cin>>n>>d;
    ll ans = 0;
    for(int i =0;i<n;++i){
        ll a ,b; cin>>a>>b;
        ll x = a*a + b*b;
        x = ceil(sqrt(x));
        if(x<=d)ans++;
    }
    cout << ans;
   

  
    return 0;
}
    

// Химаншу


Measured memory_bytes: 3732
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int x, y;
    while(cin >> x >> y, x){
        vector<int> v(5);
        v[0] = x+y;
        for (int i = 1; i < 5; ++i) {
            int a, b;
            cin >> a >> b;
            v[i] = a+b;
        }
        int res = max_element(v.begin(),v.end()) - v.begin();
        printf("%c %d\n", 'A'+res, v[res]);
    }

    return 0;
}


Measured memory_bytes: 3140
n=int(input())
s=input()
ans=0
for i in range(1000):
    if i<10:
        ss="00"+str(i)
    elif i<100:
        ss="0"+str(i)
    else:
        ss=str(i)
    k=0
    for j in range(n):
        if s[j]==ss[k]:
            k+=1
        if k==3:
            break
    if k==3:
        ans+=1
print(ans)


Measured memory_bytes: 41180
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def solve(K):
    visited = [False] * K
    p = 7 % K
    for i in range(K):
        if p == 0:
            return i + 1
        if visited[p]:
            return - 1
        visited[p] = True
        p = (p * 10 + 7) % K


def solve(K):
    p = 7 % K
    for i in range(K):
        if p == 0:
            return i + 1
        p = (p * 10 + 7) % K
    return - 1


def main():
    # parse input
    K = int(input())
    print(solve(K))


# tests
T1 = """
101
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
4
"""
T2 = """
2
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
-1
"""
T3 = """
999983
"""
TEST_T3 = """
>>> as_input(T3)
>>> main()
999982
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()


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

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

  int ans = 1;
  for (int b=2; b*b<=X; b++){
    int A = b;
    while (A<=X) A*=b;
    A /= b;
    ans = max(ans, A);
  }
  cout<<ans<<endl;
}

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

/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/
using namespace std;
typedef long long int ll;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
// online submission
#endif
	set<string> st;
	int n;
	cin>>n;
	string s;
	while(n--){
		cin>>s;
		st.insert(s);
	}
	cout<<st.size();
}

Measured memory_bytes: 19220
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int[] D1 = new int[N];
		int[] D2 = new int[N];
		int a = 0;
		
		for(int i = 0; i < N; i++) {
			D1[i] = in.nextInt();
			D2[i] = in.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			if(D1[i] == D2[i]) {
				a++;
				if(a == 3) {
					System.out.println("Yes");
					break;
				}
			}else {
				a = 0;
			}
		}
		
		if(!(a == 3)) {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 36204
# include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
template<typename T>vector<T> make_v(size_t a){ return vector<T>(a); }
template<typename T,typename... Ts>auto make_v(size_t a, Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T &t, const V &v){ t = v; }
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
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; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
int a[101010];
int dp[2][101010];
int main(){
    cin >> n;
    REP(i, n){
        cin >> a[i];
        if(i == 0)dp[0][0] = a[0];
        if(i == 1)dp[1][1] = a[1];
    }
    for(int i = 1;i < n;i++){
        dp[0][i] = gcd(dp[0][i - 1], a[i]);
        if(i >= 2)dp[1][i] = max(gcd(dp[0][i - 2], a[i]), gcd(dp[1][i - 1], a[i]));
    }
    if(n == 2){
        cout << max(a[0], a[1]) << endl;
        return 0;
    }
    cout << max({dp[0][n - 1], dp[1][n - 1], dp[0][n - 2]}) << endl;
}

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



int main() {
    long n, m = pow(10,15);
    cin >> n;
    rep(i, 5) {
        long c;
        cin >> c; 
        m = min(c, m);
    }
    long ans = 4 + n / m;
    if (n % m != 0) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3596
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	ans := 0.0
	for i := 0; i < n; i++ {
		x := scanFloat64()
		u := scanString()
		if u == "BTC" {
			x *= 380000
		}
		ans += x
	}
	fmt.Fprintln(wr, ans)
}


Measured memory_bytes: 1744
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n;
    if (n == 1) cout << "Hello World";
    else cin >> a >> b, cout << a + b;
}


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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, X;
  cin >> N >> X;
  int sum = 0, minn = 1000;
  vector<int> M(N);
  for (int i = 0; i < N; i++) {
    cin >> M[i];
    sum += M[i];
    minn = min(minn, M[i]);
  }
  cout << N + (X - sum) / minn << '\n';
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {

	public static void main(String[] args)throws java.lang.Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		long k =Long.parseLong(br.readLine());
		long ans=0;
		//y=k/i i.e. maximum number not exceeding k.
		for(long i=1; i<=k; i++) ans+=((k/i)*((k/i)+1)*i/2);
		System.out.println(ans);
	}
	
	
}


Measured memory_bytes: 32644
import java.util.Scanner;
 
class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long count = 0;
		for (int i = 1; i < N + 1; i++) {
			if (i%3 != 0 && i%5 != 0) count += i;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 35772
import heapq
 
"""
https://juppy.hatenablog.com/entry/2019/02/18/%E8%9F%BB%E6%9C%AC_python_%E3%83%97%E3%83%A9%E3%82%A4%E3%82%AA%E3%83%AA%E3%83%86%E3%82%A3%E3%82%AD%E3%83%A5%E3%83%BC%28heapq%29%E3%82%92%E7%94%A8%E3%81%84%E3%81%9F%E3%83%97%E3%83%AA%E3%83%A0%E6%B3%95
"""
 
def dijkstra_heap(s,edge):
    #始点sから各頂点への最短距離
    d = [10**10]*n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d
 
################################
N = int(input())
n = N
w = N
 
edge = tuple([] for i in range(n))
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(w-1):
    a,b,c = map(int,input().split())
    edge[a-1].append([c,b-1])
    edge[b-1].append([c,a-1])
 
 
Q,K = map(int,input().split())
dist = dijkstra_heap(K-1,edge)
 
for i in range(Q):
    x,y = map(int,input().split())
    print(int(dist[x-1]+dist[y-1]))

Measured memory_bytes: 102048
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
#define N 500000

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

Node TreeMinimum(Node x)
{
  while( x -> left != NIL )
    x = x -> left;
  return x;
}

Node TreeMaximum(Node x)
{
  while( x -> right != NIL )
    x = x -> right;
  return x;
}

Node TreeSuc(Node x)
{
  if ( x -> right != NIL )
    return TreeMinimum(x -> right);
  Node y = x -> parent;
  while( y != NIL && x == y -> right )
  {
    x = y;
    y = y -> parent;
  }
  return y;
}

Node TreeSearch(Node u, int k)
{
  while( u != NIL && k != u -> key )
  {
    if ( k < u -> key )
      u = u -> left;
    else
      u = u -> right;
  }
  return u;
}
void TreeDelete(Node z)
{
  Node y;
  Node x;

  if ( z -> left == NIL || z -> right == NIL )
    y = z;
  else
    y = TreeSuc(z);
  if ( y -> left != NIL )
    x = y -> left;
  else
    x = y -> right;

  if ( x != NIL )
    x -> parent = y -> parent;

  if ( y -> parent == NIL )
    root = x;
  else
  {
    if (y == y -> parent -> left)
      y -> parent -> left = x;
    else
      y -> parent -> right = x;
  }

  if ( y != z )
    z -> key = y -> key;
  free(y);
}

void Insert(int k)
{
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z -> key = k;
  z -> left = NIL;
  z -> right = NIL;

  while( x != NIL )
  {
    y = x;
    if ( z -> key < x -> key )
      x = x -> left;
    else
      x = x -> right;
  }

  z -> parent = y;
  if ( y == NIL )
    root = z;
  else
  {
    if (z -> key < y -> key)
      y -> left = z;
    else
      y -> right = z;
  }
}

void Inorder(Node u)
{
  if ( u == NIL )
    return;
  Inorder(u -> left);
  printf(" %d", u -> key);
  Inorder(u -> right);
}
void Preorder(Node u)
{
  if ( u == NIL )
    return;
  printf(" %d", u -> key);
  Preorder(u -> left);
  Preorder(u -> right);
}


int main()
{
  int n, i, x;
  char S[20];
  scanf("%d", &n);
  if(n > N)exit(1);
  
  for ( i = 0; i < n; i++ )
  {
    scanf("%s", S);
    if ( strcmp(S, "find") == 0 )
    {
      scanf("%d", &x);
      Node t = TreeSearch(root, x);
      if ( strcmp(S, "findMin") == 0 )
      {
	      Node minn = TreeMinimum(t);
	      printf("%d\n", minn -> key);
      }
      else if ( strcmp(S, "findMax") == 0 )
      {
	      Node maxn = TreeMaximum(t);
	      printf("%d\n", maxn -> key);
      }
      else
      {
	      if ( t != NIL )
          printf("yes\n");
	      else
          printf("no\n");
      }
    }
    else if ( S[0] == 'i' )
    {
      scanf("%d", &x);
      Insert(x);
    }
    else if ( strcmp(S, "print") == 0 )
    {
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }
    else if ( strcmp(S, "delete") == 0 )
    {
      scanf("%d", &x);
      TreeDelete(TreeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20488
def abc062_b():
    h, w = map(int, input().split())
    a = [None] * (h + 2)
    a[0] = a[-1] = ["#"] * (w + 2)
    for i in range(1, h + 1):
        a[i] = ["#"] + [input()] + ["#"]

    for ln in a:
        print("".join(ln))


abc062_b()

Measured memory_bytes: 3060
N = STDIN.gets.chomp.to_i
a = STDIN.gets.chomp.split(' ').map(&:to_i)

max = 0
avg = a.inject(0) do |s, v|
  max = v if v > max
  s + v
end / a.size.to_f

mindiff = max
minindex = 0
a.each_with_index do |v, i|
  diff = (v.to_f - avg).abs
  if diff < mindiff
    mindiff = diff
    minindex = i
  end
end

puts minindex


Measured memory_bytes: 1788
s=list(input())
a,c=s[0]=='A',0
for i in range(1,len(s)):
	if s[i]<'a'or'z'<s[i]:
		if c or s[i]!='C' or i in[1,len(s)-1]:
			a=0
			break
		else:
			c=1
print("AC"if a and c else"WA")

Measured memory_bytes: 3060