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

#define taskname ""
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex <ld> cd;
typedef vector <cd> vcd;
typedef vector <int> vi;

template<class T> using v2d = vector <vector <T> >;
template<class T> bool uin(T &a, T b)
{
    return a > b ? (a = b, true) : false;
}
template<class T> bool uax(T &a, T b)
{
    return a < b ? (a = b, true) : false;
}

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n, k, a[10];

bool check(int x)
{
    do
    {
        if (a[x % 10])
        {
            return 0;
        }
        x /= 10;
    }
    while (x > 0);
    return 1;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> k;
    for1(i, k)
    {
        int x;
        cin >> x;
        a[x] = 1;
    }
    while (!check(n))
    {
        n++;
    }
    cout << n;
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main()
{
	char a[100005],now;
	cin >>a;
	int l=strlen(a),s=0;
	for (int i=0;i<l;i++)
	{
		if (i==0)
		{
			now=a[0];
			continue;
		}
		if (a[i]!=now)
			s++;
		now=a[i];
	}
	cout <<s<<endl;
    return 0;
}

Measured memory_bytes: 384
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
ans = 0
for i in range(n):
    a = list(map(int, input().split()))
    sum = c
    for j in range(m):
        sum += a[j] * b[j]
    if sum > 0:
        ans += 1
print(ans)

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

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int ans = min(k, a);
	k -= a;
	k -= min(k, b);
	ans -= min(k, c);
	cout << ans << '\n';
}



Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <cassert>
#include <queue>
using namespace std;
using lint = long long;
const lint mod = 256;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }

int main(){
    int A, B;
    cin >> A >> B;
    if(A == B){
        cout << A * 2 << endl;
    }else{
        cout << max({A, B}) * 2 - 1 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N,M;
bool check[100005];
int table[100005];


int main(){

	scanf("%d %d",&N,&M);
	for(int i = 1; i <= N; i++){

		table[i] = 0;
		check[i] = false;
	}

	int ac = 0,wa = 0;

	int p;
	char buf[3];

	for(int i = 0; i < M; i++){

		scanf("%d %s",&p,buf);

		if(buf[0] == 'A'){

			if(check[p] == false){

				ac++;
				check[p] = true;
				wa += table[p];
			}

		}else{

			if(check[p] == false){

				table[p]++;
			}
		}
	}

	printf("%d %d\n",ac,wa);

	return 0;
}


Measured memory_bytes: 768
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C: GeT AC
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

/* global variables */

char s[MAX_N + 4];
int sums[MAX_N + 1];

/* subroutines */

/* main */

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

  for (int i = 1; i < n; i++)
    sums[i + 1] = sums[i] + ((s[i - 1] == 'A' && s[i] == 'C') ? 1 : 0);

  while (q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    printf("%d\n", sums[r] - sums[l]);
  }
  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define eps 0.0000000001
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define random(a, b) rand()*rand()%(b-a+1)+a
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 1000000 + 10;
const int mod = 1000000007;
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    IOS
    LL a, b;
    cin >> a >> b;
    if(a==b || b == 1){
        cout << -1 << endl;
        return 0;
    }else{
        for(LL i = a; i<=1000000000000000000LL && i< a*b ;i+=a){
            if(a%b!=0){
                cout << i << endl;
                return 0;
            }
        }
        cout << -1 << endl;
    }
    return 0;
}


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

#define MOD 1000000007

int main(){
  long long a,b,c,d,maxi;
  cin >> a >> b >> c >> d;
  maxi = a * c;
  maxi = max(maxi,a * d);
  maxi = max(maxi,b * c);
  maxi = max(maxi,b * d);
  if(maxi < 0 && (a <= 0 && 0 <= b || c <= 0 && 0 <= d))maxi = 0;
  cout << maxi << endl;

}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
const ll nmax=8;
bool graph[nmax][nmax];
ll dfs(ll v,ll N,bool visited[nmax]){
   bool all_visited=true;
   for(ll i=0;i<N;++i){
     if(visited[i]==false)all_visited=false;
   }
   if(all_visited){
     return 1;
    }
ll ret=0;
for(ll i=0;i<N;++i){
  if(graph[v][i]==false) continue;
  if(visited[i]) continue;
  visited[i]=true;
  ret+=dfs(i,N,visited);
  visited[i]=false;
  }
  return ret;
} 
int main()
{
  ll N;
  cin>>N;
  vector<string> S(N);
  rep(i,N){
    cin>>S.at(i);
  }
  sort(S.begin(),S.end());
  ll ans=0;
  rep(i,N){
    if(i==0)ans++;
    else if(S.at(i)!=S.at(i-1))ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 9552
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N;
  std::cin >> N;

  std::map<ll, ll> mc;

  const ll MAX_N = 1000;
  std::vector<bool> is_prime(MAX_N+1, true);;
  is_prime[0] = false;
  is_prime[1] = false;
  for (ll i = 2; i <= MAX_N; i++) {
    if (!is_prime[i]) continue;
    for (ll j = i * 2; j <= MAX_N; j += i) {
      is_prime[j] = false;
    }
  }

  std::map<ll, bool> mprime;
  for (ll i = 2; i <= MAX_N; i++) {
    if (is_prime[i]) mprime[i] = true;
  }

  for (ll i = 2; i <= N; i++) {
    for (auto p : mprime) {
      ll x = p.first;
      ll num = i;
      while (num % x == 0) {
	num /= x;
	mc[x]++;
      }
    }
  }

  ll ans = 1LL;
  for (auto p : mc) {
    ans = (ans * (p.second + 1)) % MOD;
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define ff first 
#define ss second  
typedef pair<int,int> pp;
bool com(pp x,pp y){
    return x.ff<y.ff;
} 
int N=1e5+9;
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0); 
	int n; 
	cin>>n;
	if(n%1000) cout<<1000-n%1000;
	else cout<<0;
	return 0; 
	
}


Measured memory_bytes: 3612
#include <iostream>
#include <map>

using namespace std;

int n, b, c, d;
map <int, int> M;

int main()
{
	cin >> n;
	
	for(int i=1; i <= n; i++)
		cin >> c, M[c]++;
	
	for(auto i: M)
		if(i.second%2 == 0) {
			if(d%2 == 0)
				b++;
			else
				b--;
			d++;
		}
	
	cout << M.size()-b;
}

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

int main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	s1[0] = s1[0] - 32;
	s2[0] = s2[0] - 32;
	s3[0] = s3[0] - 32;
	cout << s1[0] << s2[0] << s3[0] << endl;
	return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){ T x; cin >> x; return (x); }
template<typename T=int,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return move(x); }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int N=in();
	auto X=vecin<ll>(N);
	ll minC=1LL<<60;

	REP(i,100){
		ll C=0;
		REP(j,N){
			C += (X[j]-(ll)(i+1))*(X[j]-(ll)(i+1));
		}
		minC = min(minC,C);
	}
	out(minC);
	return 0;
}


Measured memory_bytes: 508
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n,k;
  cin>>n>>k;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
  }
  std::sort(p.begin(), p.end());
  int result=0;
  for(int i=0;i<k;i++){
    result+=p[i];
  }
  cout<<result<<endl;


  return 0;
}




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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = (n - 1 + k - 1 - 1)/(k - 1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007 
#define endl '\n'
#define all(n)      (n).begin(), (n).end()
#define ll long long int
int gcd(int a, int b){
	return b ? gcd(b,a%b) : a;
}
int gcd3(int a,int b, int c){
	int ans = gcd(a,b);
	return gcd(ans, c);
}

void solve(){
	int n; cin >> n;
	ll sum = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			for(int k = 1; k <= n; k++){
				sum += gcd3(i,j,k);
			}
		}
	}
	cout << sum ;
	

}


int main (){
	#ifndef ONLINE_JUDGE
		freopen ("input.txt","r",stdin);
		freopen ("output.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	//Write from here.
	
		solve();
	
	return 0;
}

Measured memory_bytes: 3652
/*
	0078:Magic Square
*/
#include	<iostream>
#include	<cstdio>

using namespace std;

int main(void) {
	while(1) {
		unsigned int array[15][15] = { 0 };
		int border, sx, sy, c = 1;
		
		cin >> border;
		if(border == 0) { break; }
		sx = border/2;	sy = border/2 + 1;
		while(c <= border*border) {
			int nx = (sx+1) % border, ny = (sy+1) % border;
			array[sx][sy] = c;
			if(array[nx][ny] != 0) {
				nx = sx;	ny = (sy+2) % border;
			}
			sx = nx;	sy = ny;
			c++;
		}
		
		for(int i = 0; i < border; i++) {
			for(int j = 0; j < border; j++) {
				printf("%4d", array[j][i]);
			}
			putchar('\n');
		}
		
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;


int main() {
  ll n; cin >> n;
  Vll a(n); cin >> a;

  rep(i, n) if (a[i] == 0) {
    cout << 0 << "\n";
    return 0;
  }

  ll ans = 1;
  rep(i, n) {
    if (ans > ll(1e18) / a[i]) {
      cout << -1 << "\n";
      return 0;
    }
    ans *= a[i];
  }

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


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int N;
    cin >> N;
    int H[N];
    REP(i, N)cin >> H[i];
    bool re = true;
    H[0]--;
    FOR(i, 1, N) {
        if(H[i - 1] < H[i]) {
            H[i]--;
        }
        if(H[i - 1] > H[i]) {
            re = false;
        }
    }
    if(re) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n, d;
  cin >> n >> d;
  if (n%(2*d+1) == 0) {
    cout << n/(2*d+1) << endl;
  } else {
    cout << n/(2*d+1) + 1 << endl;
  }
}

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

#define ll long long
#define ar array
 
using namespace std;

int main() {
	
	int a[5],menor[5],base,resp=0,aux=-1;

	for(int i=0;i<5;i++){
		cin>> a[i];
	}
	base=9;
	for(int i=0;i<5;i++){
		menor[i] = a[i]%10;
		if(base>=menor[i] && menor[i] != 0){
			base=menor[i];
			aux=i;
		}
	}
	
	for(int i=0;i<5;i++){
		if(menor[i] == 0){
			resp += a[i];
		}else{
			resp += a[i]+(10-menor[i]);
		}
	}	
		if(aux == -1){
			resp = resp;
		}else{
			resp = resp-(10-menor[aux]);
		}
		
	
		cout << resp <<endl;
	
	
   	return 0;
}

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

using namespace std;



struct edge
{
  int to, cost;
};

vector< edge > g[10000];
int depth[10000], ans[10000];

int dfs(int idx, int par = -1)
{
  for(auto &e : g[idx]) {
    if(par == e.to) continue;
    depth[idx] = max(depth[idx], dfs(e.to, idx) + e.cost);
  }
  return (depth[idx]);
}

void dfs2(int idx, int far = 0, int par = -1)
{
  vector< pair< int, int > > row;
  row.emplace_back(far, par);
  for(auto &e : g[idx]) {
    if(par == e.to) continue;
    row.emplace_back(depth[e.to] + e.cost, e.to);
  }
  sort(row.rbegin(), row.rend());
  ans[idx] = row.front().first;
  for(auto &e : g[idx]) {
    if(par == e.to) continue;
    dfs2(e.to, row[e.to == row.front().second].first + e.cost, idx);
  }
}


void solve()
{
  int N;
  cin >> N;
  for(int i = 1; i < N; i++) {
    int s, t, w;
    cin >> s >> t >> w;
    g[s].emplace_back((edge) {t, w});
    g[t].emplace_back((edge) {s, w});
  }
  dfs(0);
  dfs2(0);
  for(int i = 0; i < N; i++) {
    cout << ans[i] << endl;
  }
}

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

Measured memory_bytes: 5568
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;

vector<vector<int>> enuCmb(int n, int k) {
    vector<vector<int>> res;
    if (n==0 || k==0 || n<k) {
      	return res;
    } else { 
		res=enuCmb(n-1,k);
		vector<vector<int>> res1=enuCmb(n-1,k-1);
		rep(i,res1.size()) {
			res1[i].push_back(n-1);
			res.push_back(res1[i]);
		}
		if (k==1) {
			vector<int> ins={n-1};
			res.push_back(ins);
		}
		return res;
    }
}

int main() {
    ios_base::sync_with_stdio(false); 

    int n,m,q;
    cin >> n >> m >> q;
    vector<int> a(q),b(q),c(q),d(q);
    rep(i,q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i];
        --b[i];
    }
    vector<vector<int>> enu=enuCmb(n+m-1,n);
    int ans=0;
	rep(i,enu.size()) {
        vector<int> e(n);
        rep(j,n) e[j]=enu[i][j]-j;
        int tans=0;
		rep(k,q) {
            if (e[b[k]]-e[a[k]]==c[k]) tans+=d[k];
        }
        ans=max(ans,tans);
	}
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 16356
s = input()
mod = 10**9+7

# dp[逆順i桁][j mod 13] := 総数
dp = [[0]*13 for _ in range(len(s)+1)]
dp[0][0] = 1
mul = 1
s_rev = s[::-1]
for i in range(len(s)):
    x = s_rev[i]
    if x == '?':
        for k in range(10):
            for j in range(13):
                dp[i+1][(mul*k+j)%13] += dp[i][j]
                dp[i+1][(mul*k+j)%13] %= mod
    else:
        k = int(x)
        for j in range(13):
            dp[i+1][(mul*k+j)%13] += dp[i][j]
            dp[i+1][(mul*k+j)%13] %= mod
    mul = mul * 10 % 13

print(dp[len(s)][5] % mod)

Measured memory_bytes: 62684
#include <stdio.h>

int main(void) {
    char *a = "CODEFESTIVAL2016";
    char s[17];
    int d=0;
    scanf("%s", s);
    for(int i=0; i<16; i++)
        if(a[i]!=s[i]) d++;
    
    printf("%d", d);
    
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 2005
int n;
ll t[MAX];
ll dp[MAX][MAX][2];

ll solve(int l,int r,bool flg){
  if(dp[l][r][flg]!=-1)
    return dp[l][r][flg];

  if(l==r)return (flg?t[l]:0LL);
  ll res;
  
  if(flg){
    res=max(t[l]+solve((l+1)%n,r,!flg),
            t[r]+solve(l,(r+n-1)%n,!flg));
  }else{    
    res=(t[l]>t[r]?solve((l+1)%n,r,!flg):solve(l,(r+n-1)%n,!flg));
  }  
  return dp[l][r][flg]=res;
}

int main(){
  memset(dp,-1,sizeof(dp));
  cin>>n;
  for(int i=0;i<n;i++)cin>>t[i];
  ll ans=0;
  for(int i=0;i<n;i++){
    int sl=(i+1)%n;
    int sr=(i+n-1)%n;
    ans=max(ans,t[i]+solve(sl,sr,false));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 64156
#include <stdio.h>

#define NUM 3

int main(void){
	int data[3];
	int min, temp;
	int i, j;
	
	for(i=0 ; i < 3 ; i++){
	 scanf("%d", &data[i]);
	}
	
	for(i=0 ; i < 2 ; i++){
		for(j=i+1 ; j < 3 ; j++){
			if(data[i] > data[j]){
				temp = data[i];
				data[i] = data[j];
				data[j] = temp;
			}
		}
	}
	
	for(i=0 ; i < 3 ; i++){
		printf("%d", data[i]);
		if(i != 2){
			printf(" ");
		}
	}
	printf("\n");
	
	return 0;
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    rep(i,n){
        cin>>a[i];
    }
    cout<<ceil((double)(n-1)/(k-1))<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
    fast;
    ll x;
    cin>>x;
    ll ans;
    if(x<=599){
        ans=8;
    }
    else if(x<=799){
        ans = 7;
    }
    else if(x<=999){
        ans = 6;
    }
    else if(x<=1199){
        ans = 5;
    }
    else if(x<=1399){
        ans = 4;
    }
    else if(x<=1599){
        ans = 3;
    }
    else if(x<=1799){
        ans = 2;
    }
    else{
        ans = 1;
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3688
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

const size_t MAXN = 100000 + 2;

int A[MAXN];
int N, K;

int gcd(int a, int b) {
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

bool judge() {
    sort(&A[0], &A[N]);
    if (K > A[N-1])
        return false;
    if (N == 1)
        return A[0] == K;
    int g = gcd(A[0], A[1]);
    for (size_t i = 2; i < N; ++i)
        g = gcd(g, A[i]);
    return K % g == 0;
}

int main()
{
    cin >> N >> K;
    for(size_t i = 0; i < N; ++i)
        cin >> A[i];

    if(judge())
        cout << "POSSIBLE" << endl;
    else
        cout << "IMPOSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    int cnt=0;
    while(a>=b){
        b*=2;
        cnt++;
    }
    while(b>=c){
        c*=2;
        cnt++;
    }
    if(cnt<=k){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#include <queue>

#define mp make_pair
#define pb push_back
#define ppb pop_back
#define fi first
#define se second

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> pl;
typedef vector<ll> vl;
typedef vector<pl> vpl;
typedef vector<vl> vvl;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define foR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define fors(i, n, s) for (int i = 0; i < (int)(n); i += s)
#define foRs(i, a, b, s) for (int i = (int)(a); i < (int)(b); i += s)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define foRr(i, a, b) for (int i = (int)(a) - 1; i >= (int)(b); --i)

#define prnt(a) cout << (a)
#define prntl(a) cout << (a) << endl
#define in insert
#define rem remove
#define er erase

#define linf ((ll) 1e9)
#define inf ((int) 1e5)
#define otherinf 555555

#define mod 1000000007


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

	string s;
	cin >> s;

	string target = "CODEFESTIVAL2016";
	
	ll count = 0;
	forn(i, s.size())
	{
		if(s[i] != target[i])
			count++;
	}

	cout << count;
	
	return 0;
}

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

int main()
{
  int n;
  cin>>n;
  vector<int> v(n),p(n),s(n);
  for(int &i:v) cin>>i;
  p[0]=v[0];s[n-1]=v[n-1];
  for(int i=1;i<n;i++) p[i]=p[i-1]+v[i];
  for(int i=n-2;i>=0;i--) s[i]=s[i+1]+v[i];
  int ans = 1000000000;
  for(int i=0;i<n-1;i++) 
    if(abs(p[i]-s[i+1])<ans)
      ans=abs(p[i]-s[i+1]);
  cout<<ans<<"\n";
  
  
  return 0;
}

Measured memory_bytes: 256
def countingsort(A, k):
    res = [None for _ in A]
    C = [0 for i in range(k + 1)]

    for x in A:
        C[x] += 1

    for i in range(k):
        C[i + 1] = C[i + 1] + C[i]

    for x in reversed(A):
        res[C[x] - 1] = x
        C[x] -= 1

    return res

input()
A = list(map(int, input().split()))
ret = countingsort(A, 10000)
print(" ".join(map(str, ret)))




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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, d;
  cin >> n >> d;
  int x[n][d];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >> x[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int d2 = 0;
      for (int k = 0; k < d; k++) {
        d2 += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      int d1 = round(sqrt(d2));
      if (d2 == d1 * d1) ans++;
    }
  }
  cout << ans << '\n';
  return 0;
}


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

int main(){
  int n, p;
  cin >> n >> p;
  while(n != 0 && p != 0){
    vector<int> v(n);
    for(int i = 0; i < n; i++){
      v[i] = 0;
    }

    int ans;
    int stone = p;
    bool ok = false;
    while(1){
      for(int i = 0; i < n; i++){
        if(stone > 0){
          v[i]++;
          stone--;
        }else{
          stone += v[i];
          v[i] = 0;
        }

        if(v[i] == p){
          ans = i;
          ok = true;
          break;
        }
      }
      if(ok)break;
    }
    cout << ans << endl;
    cin >> n >> p;
  }
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;bool x=true;cin>>a>>b>>c;
  if(a==b){
    if(a==c)x=false;
  }
  else if(a!=c){
    if(b!=c)x=false;
  }
  if(x==true)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
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();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);


int main() {
	int a,b,c;
	while(cin>>a>>b>>c,a|b|c){
		int n;
		cin>>n;
		vi seijo(a+b+c,-1);
		vi aa(n,-1),bb(n,-1),cc(n,-1),f(n);
		REP(i,n){
			cin>>aa[i]>>bb[i]>>cc[i]>>f[i];
			aa[i]--;
			bb[i]--;
			cc[i]--;
			if(f[i]){
				seijo[aa[i]]=1;
				seijo[bb[i]]=1;
				seijo[cc[i]]=1;
			}
		}
		REP(i,n){
			if(!f[i]){
				if(seijo[aa[i]]==1&&seijo[bb[i]]==1){
					seijo[cc[i]]=0;
				}else if(seijo[cc[i]]==-1){
					seijo[cc[i]]=2;
				}
				if(seijo[bb[i]]==1&&seijo[cc[i]]==1){
					seijo[aa[i]]=0;
				}else if(seijo[aa[i]]==-1){
					seijo[aa[i]]=2;
				}
				if(seijo[aa[i]]==1&&seijo[cc[i]]==1){
					seijo[bb[i]]=0;
				}else if(seijo[bb[i]]==-1){
					seijo[bb[i]]=2;
				}
			}
		}
		REP(i,a+b+c){
			cout<<(seijo[i]==-1?2:seijo[i])<<endl;
		}
	}
}

Measured memory_bytes: 1216
N = int(input())
A = list(map(int,input().split()))

flag = 0
for num in range(N):
    tmp = A[num]
    flag = 0 if (tmp%2==0 and (tmp%3==0 or tmp%5==0)) or tmp%2==1 else 1
    if flag == 1:
        break

ans = 'APPROVED' if flag==0 else 'DENIED '
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

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

  int n = 0;
  bool se = false;
  for (int i = 0; i < N; i++) {
    int D1, D2;
    cin >> D1 >> D2;
    if (D1 == D2) {
      n++;
    } else {
      n = 0;
    }
    if (n >= 3) {
      se = true;      
    }
  }


  cout << (se ? "Yes" : "No") << endl;
  
  return 0;
}


Measured memory_bytes: 3164
/*****************************************************
 *     created by: nayakashutosh9
 * "Winners Never Quit and Quitters Never Win".
*****************************************************/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define endl '\n'
#define mod 1000000007
#define inf 1e18
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
const int N = 300005;
/**********************************************************************************************/


void solve() {
	string s; cin >> s;
	string rev = s;
	reverse(rev.begin(), rev.end());
	if (s != rev) {
		cout << "No\n";
		return;
	}
	int n = s.length();
	if (n == 1) {
		cout << "Yes\n";
		return;
	}
	string f = s.substr(0, n / 2);
	string rf = f;
	reverse(rf.begin(), rf.end());
	if (f != rf) {
		cout << "No\n";
		return;
	}
	f = s.substr(1 + n / 2, n / 2);
	rf = f;
	reverse(rf.begin(), rf.end());
	if (f != rf) {
		cout << "No\n";
		return;
	}
	cout << "Yes\n";
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int t = 1, z = 1;
	// cin >> t; cin.ignore();
	while (t--) {
		// cout << "Case #" << (z++) << ": ";
		// clock_t start = clock();
		solve();
		// clock_t end = clock();
		// cout << (end-start) << endl;
		//print execution time in ms
	}

	return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main() {
    int t;
    cin >> t;
    int cnt=0;
    while (t--)
    {
        int n,m;
        cin >> n >> m;
        if (n == m)
        {
            cnt++;
        }else{
            cnt = 0;
        }
        if (cnt == 3)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
N = int(input())
S = input()
RGB = 'RGB'

ret = 0
for i in range(1,N):
    mid = S[i]
    rest = list(set(RGB)-set([mid]))
    left0, right0 = S[:i].count(rest[0]), S[i+1:].count(rest[0])
    left1, right1 = S[:i].count(rest[1]), S[i+1:].count(rest[1])
    tmp = left0*right1 + left1*right0
    for j in range(min(i,N-i-1)):
        ss = [S[i-j-1],S[i+j+1]]
        if ss == rest or ss == rest[::-1]:
            tmp -= 1

    ret += tmp
print(ret)

Measured memory_bytes: 68624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;

char str[2][100];

int main(){
	int n;
	scanf("%d%s%s", &n, str[0]+1, str[1]+1);
	ll ans=1;
	for(int i=1;i<=n;i++){
		if(i==1){
			if(str[0][1]==str[1][1]){
				ans=ans*3%mod;
			}
			else {
				ans=ans*6%mod;
				i++;
			}
		}
		else {
			if(str[0][i]==str[1][i]){
				if(str[0][i-1]==str[1][i-1]){
					ans=ans*2%mod;
				}
			}
			else {
				if(str[0][i-1]==str[1][i-1]){
					ans=ans*2%mod;
					i++;
				}
				else {
					ans=ans*3%mod;
					i++;
				}
			}
		}
	}
	printf("%lld\n", ans);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  vector<int>L(N+2,1);
  vector<int>R(N+2,1);
  int g=A[0];
  for(int i=0;i<N;i++){
    g=__gcd(A[i],g);
    L[i]=g;
  }
  g=A[N-1];
  for(int i=N-1;i>=0;i--){
    g=__gcd(A[i],g);
    R[i]=g;
  }
  int MAX=1;
  for(int i=0;i<N;i++){
    if(i==0){chmax(MAX,R[i+1]);}
    else if(i==N-1){chmax(MAX,L[i-1]);}
    else {chmax(MAX,__gcd(L[i-1],R[i+1]));}
  }
  cout<<MAX<<endl;
  return 0;
}

Measured memory_bytes: 4560
//Deep Godhani
//DAIICT

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

#define N 100000000000
#define PI acos(-1)
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define ll long long int
#define ld long double
#define precision(x,d) cout << fixed << setprecision(d) << x
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))

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

bool checkPrime(int n)
{
	for(int i=0;i<=sqrt(n);i++)
	{
		if(n%i == 0)
		{
			return false;
		}
	}
	return true;
}

int gcd(int x,int y,int z)
{
	int d = __gcd(x,y);
	return __gcd(d,z);
}

void solve()
{
	int k;
	cin >> k;
	ll sum = 0;
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=k;j++)
		{
			for(int l=1;l<=k;l++)
			{
				sum += gcd(i,j,l);
			}
		}
	}

	cout << sum << endl;
}
int main()
{
    FAST;
    ll t=1;
    //cin >> t;
    while(t--)
    {
      //cout << "************" << endl;
      solve();
      //cout << "************"  << endl;
    }
		return 0;
}


Measured memory_bytes: 3664
while (n = $<.gets.to_i).nonzero?
  given = (1..n).map {$<.gets.to_i}
  max = -Float::INFINITY
  n.times do |i|
    sum = 0
    (i...n).each do |j|
      sum += given[j]
      max = sum if sum > max
    end
  end
  puts max
end


Measured memory_bytes: 6892
#include <bits/stdc++.h>
using namespace std;
signed main(){ 
  int n=0;
  char s[50],ans[50]={};
  cin>>s;  
  for(int i=0;i<10;i++){
    if(s[i]=='0'){
      ans[n]='0';
      n++;
    }
    if(s[i]=='1'){
      ans[n]='1';
      n++;
  }
    if(s[i]=='B'){
      if(n!=0)
	n--;
      ans[n]=' ';
    }
  }
  cout<<ans<<endl;
  return(0);
}

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

int main(){
    string S; cin >> S;
    int ans=0;
    for (int i=0; i<S.size(); i++){
        if(S[i]=='1') ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int maxn=100000+10,mo=1000000007;
ll a[maxn],A,B;
int tree[maxn*4],f[maxn];
int i,j,k,l,r,t,n,m,ans;
void change(int p,int l,int r,int a,int b){
    if (l==r){
        (tree[p]+=b)%=mo;
        return;
    }
    int mid=(l+r)/2;
    if (a<=mid) change(p*2,l,mid,a,b);else change(p*2+1,mid+1,r,a,b);
    tree[p]=(tree[p*2]+tree[p*2+1])%mo;
}
int query(int p,int l,int r,int a,int b){
    if (a>b) return 0;
    if (l==a&&r==b) return tree[p];
    int mid=(l+r)/2;
    if (b<=mid) return query(p*2,l,mid,a,b);
    else if (a>mid) return query(p*2+1,mid+1,r,a,b);
    else return (query(p*2,l,mid,a,mid)+query(p*2+1,mid+1,r,mid+1,b))%mo;
}
int main(){
    scanf("%d%lld%lld",&n,&A,&B);
    if (A<B) swap(A,B);
    fo(i,1,n) scanf("%lld",&a[i]);
    a[0]=-A;
    a[n+1]=a[n]+A;
    f[0]=1;
    change(1,0,n,0,f[0]);
    l=0;r=0;
    fo(i,1,n+1){
        while (a[i]-a[r+1]>=A) r++;
        if (i>=2&&a[i-1]-a[i-2]<B) l=i-2;
        if (a[i]-a[i-1]>=A) f[i]=f[i-1];
        (f[i]+=query(1,0,n,l,min(i-2,r)))%=mo;
        if (i<=n&&a[i+1]-a[i-1]>=B) change(1,0,n,i,f[i]);
    }
    ans=f[n+1];
    (ans+=mo)%=mo;
    printf("%d\n",ans);
}

Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,m;cin>>n>>m;
    vector<ll> v(m);
    for(ll &i:v)cin>>i;
    ll sum=accumulate(v.begin(),v.end(),0ll);
    if(sum>n)cout<<-1;
    else cout<<n-sum;
    
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<int> v, w;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
    w.push_back(a);
  }

  sort(ALLOF(w));
  reverse(ALLOF(w));

  rep(i,N){
    if(v[i] == w[0]){
      cout << w[1] << endl;
    }else{
      cout << w[0] << endl;
    }
  }
  
  
  return 0;
}



Measured memory_bytes: 3436
#ABC145.C
N = int(input())
x = []
c=0
for i in range(N):
    x1=[int(i) for i in input().split()]
    x.append(x1)
for i in range(N):
    for m in range(N):
        if i!=m:
            c+=((x[i][0]-x[m][0])**2+(x[i][1]-x[m][1])**2)**0.5
print(c/N)

Measured memory_bytes: 3188
from itertools import permutations


class Graph():
    def __init__(self):
        self.adjacency_dict = {}

    def add_vertex(self, v):
        self.adjacency_dict[v] = []

    def add_edge(self, v1, v2):
        self.adjacency_dict[v1].append(v2)
        self.adjacency_dict[v2].append(v1)

    def exists(self, path):
        for i in range(len(path)-1):
            if not path[i+1] in self.adjacency_dict[path[i]]:
                return False
        return True


def main():
    N, M = map(int, input().split())
    edges = [tuple(map(int, input().split())) for _ in range(M)]

    graph = Graph()
    for v in range(1, N+1):
        graph.add_vertex(v)
    for e in edges:
        graph.add_edge(e[0], e[1])

    count = 0
    for path in permutations(range(2, N+1)):
        path = list(path)
        path.insert(0, 1)
        if graph.exists(path):
            count += 1
    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 41196
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX(a,b) (a > b) ? a : b
#define MIN(a,b) (a < b) ? a : b
const int inf = 1000000000; // 10^9

int Amaxindex(int *p,int size){
   int _max = 0;
   int in;
   for(int i = 0;i < size;i++)
      if(p[i] > _max){
         _max = p[i];
         in = i;
      }
   return in;
}

int main(){
   int n;scanf("%d",&n);
   int ans[100]={0};
   for(int i = 0;i < n;i++){
      int _n = n-i;
      for(int j = 0;j < n-i;j++){
         if(_n%2==0){
            //printf("%d:%d\%2==0\n",i,_n);
            ans[i]++;
            _n /= 2;
         }else break;
      }
   }
   /*for(int i = 0;i < n;i++){
      printf("ans[%d]:%d\n",i,ans[i]);
   }*/
   //printf("%d\n",Amaxindex(ans,n));
   printf("%d",n-Amaxindex(ans,n));
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
 
#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)
 
typedef long long ll;
 
using namespace std;
 
int main ()
{
  string S,Srep;
  ll acnt,res = 0;
 
  cin >> S;
 
  REPI(S.size()-1)
  {
    if (S[i] == 'A')
      Srep += 'A';
    else if (S[i] == 'B' && S[i+1] == 'C')
    {
      Srep += 'D';
      i++;
    }else{
      Srep += S[i];
    }
  }
 
  acnt = 0;
  REPI(Srep.size ())
  {
    if (Srep[i] == 'A')
      acnt++;
    else if (Srep[i] == 'D')
      res += acnt;
    else
      acnt = 0;
  }
  
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3896
#include <iostream>

using namespace std;

int main(void){

  int X, N;
  int f = 0;

  cin >> X;

  N = X;

  while(true){
    // cout << N;
    if(N==2) break;
    for(int i=2; i<N; i++){
      if(N%i==0) break;
      if(i==N-1) f = 1;
    }
    // cout << " " << f << endl;
    if(f==1) break;
    N++;
  }

  cout << N << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1 << 30
#define LINF (ll)1 << 62
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define REP(i, a, b) for (ll i = (a); i < (b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

int main(){
    ll n; cin >> n;
    if(n%10 == 9 || n/10 == 9) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 256
using System.Linq;
using System;
class Program
{
    static void Main()
    {
        //var N = int.Parse(Console.ReadLine());
        //var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var s = Console.ReadLine();
        int[] pos = new int[26];
        int[] max = new int[26];

        for (int i = 0; i < 26; i++)
        {
            pos[i] = -1;
        }

        for (int i = 0; i < s.Length; i++)
        {
            int c = s[i] - 'a';
            if (i - pos[c] - 1 > max[c]) max[c] = i - pos[c] - 1;
            pos[c] = i;
        }

        for (int i = 0; i < 26; i++)
        {
            if (s.Length - pos[i] - 1 > max[i]) max[i] = s.Length - pos[i] - 1;
        }
        Console.WriteLine(max.Min());
        Console.ReadKey();
    }
}


Measured memory_bytes: 13268