akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

template <class T>
T inf = numeric_limits<T>::max();

vector<int> dist;

void bfs(vector<vector<int>> const& G, int start, vector<bool>& visited) {
  queue<int> que;
  que.push(start);
  dist[start] = 0;

  while (!que.empty()) {
    auto now = que.front();
    que.pop();
    visited[now] = true;

    for (auto to : G[now]) {
      if (visited[to] || dist[to] != 0) continue;
      dist[to] = dist[now]+1;
      que.push(to);
    }
  }
}

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

  int N,X,Y;
  cin >> N >> X >> Y;
  X--, Y--;

  vector<vector<int>> G(N);
  repr(i, N-1, 0) {
    G[i].push_back(i+1);
    G[i+1].push_back(i);
  }

  G[X].push_back(Y);
  G[Y].push_back(X);

  map<int,int> mp;
  
  dist.resize(N+1, 0);
  for (int i = 0; i < N-1; ++i) {
    vector<bool> visited(N);
    bfs(G, i, visited);

    for (int j = i+1; j < N; ++j) {
      mp[dist[j]] += 1;
    }

    for (auto& itr : dist) itr = 0;
  }

  for (int i = 1; i < N; ++i) {
    cout << mp[i] << endl;
  }
}


Measured memory_bytes: 3792
#!/usr/bin/env python3
import sys

bust = 'bust'
win = 'win'
def solve(A: "List[int]"):
    if sum(A) >= 22:
        print(bust)
    else:
        print(win)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [int(next(tokens)) for _ in range(3)]  # type: "List[int]"
    solve(A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#B問題
N,D = map(int,input().split())
X = [list(map(int,input().split())) for i in range(N)]
count = 0
for i in range(N):
    for j in range(N-i-1):
        J=i+j+1
        dist = 0
        for k in range(D):
            dist+=(X[i][k]-X[J][k])**2
        flag = 0
        for d in range(dist):
            if (dist/(d+1)) == d+1:
                flag = 1
        if flag == 1:
            count+=1
print(count)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

#define PENALTY 20
#define P_MAX 10
#define T_MAX 50

int wa_count[T_MAX][P_MAX], solved[T_MAX], time[T_MAX], t;
int teams[T_MAX], comp_stable = 1;

void init()
{
    int tt, p;

    for(tt = 0; tt < t; tt++)
    {
        solved[tt] = time[tt] = 0;
        teams[tt] = tt;
        for(p = 0; p < P_MAX; p++) wa_count[tt][p] = 0;
    }
}

int comp_team(const void* a, const void* b)
{
    int t = solved[*(int*)b] - solved[*(int*)a];
    t = t ? t : time[*(int*)a] - time[*(int*)b];

    return t ? t : comp_stable ? *(int*)b - *(int*)a : 0;
}

int main(void)
{
    int m, tt, p, r, j;

    while(scanf("%d%d%d%d", &m, &t, &p, &r), m + t + p + r)
    {
        init();

        while(r--)
        {
            scanf("%d%d%d%d", &m, &tt, &p, &j);
            tt--;

            if(j) wa_count[tt][p]++;
            else solved[tt]++, time[tt] += wa_count[tt][p] * PENALTY + m;
        }

        comp_stable = 1;
        qsort(teams, t, sizeof(int), comp_team);

        comp_stable = 0;
        for(tt = 0; tt < t - 1; tt++)
        {
            printf("%d", teams[tt] + 1);
            if(comp_team(&teams[tt], &teams[tt + 1])) printf(",");
            else printf("=");
        }
        printf("%d\n", teams[tt] + 1);
    }

    return 0;
}

Measured memory_bytes: 608
n=int(input())
count=0
p=list(map(int,input().split()))
for i in range(n-2):
    if (p[i]<p[i+1] and p[i+1]<p[i+2])or(p[i]>p[i+1] and p[i+1]>p[i+2]) :
        count+=1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T1, class T2>
bool chmax(T1 &a, const T2 b){if(a < b){a = b; return true;} return false;}
template <class T1, class T2>
bool chmin(T1 &a, const T2 b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
void co() { cout << endl; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
template <class T>
void co_vec(vector<T> v) {
    for (T i : v) cout << i << ' ';
    co();
}
void ce() { cerr << endl; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18L+1;
constexpr ll MOD = 1e9L+7;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

template <typename Type>
struct KMP{
    Type S;
    Vec A;

    KMP(Type S) : S(S){
        A.resize(S.size()+1);
        A[0] = -1;
        ll j = -1;
        for(int i = 0; i < S.size(); ++i){
            while(j >= 0 && S[i] != S[j]) j = A[j];
            ++j;
            // ce(i, j);
            // if(S[i + 1] == S[j]) A[i + 1] = A[j];
            A[i + 1] = j;
        }
    }

    vector<ll> search(Type T, ll pos = 0){
        vector<ll> res;
        ll i = 0, j = pos;
        while(i < S.size() && j < T.size()){
            if(S[i] == T[j]) ++i, ++j;
            else if(!i) ++j;
            else i = A[i];
            if(i == S.size()){
                res.push_back(j - i);
                i = A[i];
                // ce(i, j);
            }
        }
        return res;
    }
};

int main(void){
    ll n;
    cin >> n;
    Vec a(n), b(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];

    Vec c(n), d(n);
    rep(i, n) c[i] = a[i] ^ a[(i + 1) % n];
    rep(i, n) d[i] = b[i] ^ b[(i + 1) % n];
    c.insert(c.end(), all(c));
    // co_vec(c);

    KMP<Vec> kmp(d);
    auto v = kmp.search(c);
    for(ll i : v){
        if (i >= n) break;
        co(i, a[i] ^ b[0]);
    }

    return 0;
}


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

int dp[2][12][502][502]={0};
int m;

char min(char x,char y){if(x>y)return y; return x;}
char max(char x,char y){if(x<y)return y; return x;}

int count(string s){
	int ret=0;
	int ss=s.size();
	if(ss==1)return s[0]/3;
	for(int i=1;i<ss;i++){
		for(int j=1;j<10;j++){
			ret+=dp[0][j][i][0];
			if(i!=1)ret+=dp[1][j][i][0];
			ret%=10000;
		}
	}
	for(int i=1;i<s[0];i++){
		ret+=dp[0][i][ss][0];
		ret+=dp[1][i][ss][0];
		ret%=10000;
	}
	int p[502]={0};
	int tt[502]={0};
	tt[0]=1;
	for(int i=1;i<502;i++){tt[i]=tt[i-1]*10; tt[i]%=m;}
	p[0]=s[0]*tt[ss-1];
	p[0]%=m;
	for(int i=1;i<502;i++){
		p[i]=p[i-1]+s[i]*tt[ss-1-i];
		p[i]%=m;
	}
	for(int i=1;i<ss;i++){
		int t=(i+0)%2;
		if(t==1){
			if(s[i-1]>=s[i])break;
			for(int j=s[i-1]+1;j<s[i];j++){
				ret+=dp[t][j][ss-i][(m-p[i-1])%m];
				ret%=10000;
			}
			if(i==ss-1)ret+=dp[t][s[i]][ss-i][(m-p[i-1])%m];
		}
		if(t==0){
			for(int j=0;j<min(s[i-1],s[i]);j++){
				ret+=dp[t][j][ss-i][(m-p[i-1])%m];
				ret%=10000;
			}
			if(s[i-1]<=s[i])break;
			if(i==ss-1)ret+=dp[t][s[i]][ss-i][(m-p[i-1])%m];
		}
	}
	for(int i=1;i<ss;i++){
		int t=(i+1)%2;
		if(t==1){
			if(s[i-1]>=s[i])break;
			for(int j=s[i-1]+1;j<s[i];j++){
				ret+=dp[t][j][ss-i][(m-p[i-1])%m];
				ret%=10000;
			}
			if(i==ss-1)ret+=dp[t][s[i]][ss-i][(m-p[i-1])%m];
		}
		if(t==0){
			for(int j=0;j<min(s[i-1],s[i]);j++){
				ret+=dp[t][j][ss-i][(m-p[i-1])%m];
				ret%=10000;
			}
			if(s[i-1]<=s[i])break;
			if(i==ss-1)ret+=dp[t][s[i]][ss-i][(m-p[i-1])%m];
		}
	}
	return ret;
}

string f(string s){
	int ss=s.size();
	int k=ss-1;
	while(s[k]==0){
		s[k]=9;
		k--;
	}
	s[k]--;
	if(k==0&&s[k]==0){
		string ret="";
		char c='9'-48;
		for(int i=0;i<ss-1;i++)ret+=c;
		return ret;
	}
	return s;
}			

int main(){
	string a,b;
	cin>>a;
	cin>>b;
	int sa=a.size(),sb=b.size();
	for(int i=0;i<sa;i++)a[i]-=48;
	for(int i=0;i<sb;i++)b[i]-=48;
	scanf("%d",&m);
	dp[0][0][0][0]=1; dp[1][10][0][0]=1; //dp[0][0][1][0]=1;
	int s=max(sa,sb);
	int t=1;
	for(int j=1;j<=s;j++){
		for(int i=0;i<=9;i++){
			for(int k=0;k<m;k++){
				for(int l=i+1;l<=10;l++){
					dp[0][i][j][k]+=dp[1][l][j-1][(k-i*t+i*m)%m];
					dp[0][i][j][k]%=10000;
				}
			}
		}
		for(int i=0;i<=9;i++){
			for(int k=0;k<m;k++){
				for(int l=0;l<i;l++){
					dp[1][i][j][k]+=dp[0][l][j-1][(k-i*t+i*m)%m];
					dp[1][i][j][k]%=10000;
				}
			}
		}
		t*=10;
		t%=m;
	}
	a=f(a); 
	printf("%d\n",(count(b)-count(a)+10000)%10000);
}

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

using namespace std;
const int N = 2e5+7;
int a[N];
int n,k,t;

bool check(int mid)
{
	int ans=0;
	for(int i=1;i<=n;i++){
		if(a[i] > mid) ans += a[i]/mid;
		if(ans>k) return 0;
	}
	return 1;
}

int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i],t=max(t,a[i]);
	
	int l=1,r=t;
	while(l<=r){
		int mid = l+r>>1;
		if(check(mid)) r = mid - 1;
		else l = mid + 1;
	}
	cout<<r+1;
	return 0;
}

Measured memory_bytes: 4372
N = int(input())
H = list(map(int, input().split()))

cnt = 0
m = -10*100
l = []
for i in range(N-1):
    if H[i] >= H[i+1]:
        cnt += 1
    else:
        l.append(cnt)
        cnt = 0

l.append(cnt)
print(max(l))

Measured memory_bytes: 63984
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    ll x = n%10;

    if(x == 3) {
        out("bon");
    }
    else if(x == 0 || x == 1 || x == 6 || x == 8) {
        out("pon");
    }
    else {
        out("hon");
    }

    re0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

// gcd
template <class T>
T gcd(T a, T b)
{
    if(b == 0) return a;
    return gcd(b, a%b);
}

int main()
{
    ll K, ans = 0;
    cin >> K;
    for(ll i=1; i<=K; i++){
        for(ll j=1; j<=K; j++){
            for(ll k=1; k<=K; k++){
                ll d = gcd(i, j);
                d = gcd(d, k);
                ans += d;
            }
        }
    }

    cout << ans << endl;
}

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

int main()
{
    int a[3], k;

    for (auto& x : a) cin >> x;
    cin >> k;

    sort(a, a + 3);

    int t = a[2];
    for (int i = 0; i < k; i++) t *= 2;

    cout << t + a[1] + a[0] << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=998244353;
constexpr int N=100000;

inline unsigned long xor128() {
	static unsigned long x=123456789, y=362436069, z=521288629, w=88675123;
	unsigned long t=(x^(x<<11));
	x=y; y=z; z=w;
	return (w=((w>>19)^t^(t>>8)));
}

int D,c[26],s[200000][26],t[200000],T[200000];
set<int>st[26];

int main(){
	scanf("%d",&D);
	for(int i=0;i<26;i++){
		scanf("%d",&c[i]);
	}
	for(int i=0;i<D;i++){
		for(int j=0;j<26;j++){
			scanf("%d",&s[i][j]);
		}
	}
	for(int i=0;i<D;i++){
		pair<int,int>mx={-1,-1};
		for(int j=0;j<26;j++){
			mx=max(mx,{s[i][j],j});
		}
		t[i]=mx.second;
		st[mx.second].insert(i);
	}
	for(int i=0;i<26;i++){
		st[i].insert(-1);
		st[i].insert(D);
	}
	for(int i=0;i<N;i++){
		int K=xor128()%D;
		pair<int,int>mx={0,t[K]};
		auto it1=st[t[K]].find(K);
		auto it2=it1;
		it1--;
		auto it3=it2;
		it3++;
		int a=c[t[K]]*((*it3-*it1)*(*it3-*it1-1)/2-(*it3-*it2)*(*it3-*it2-1)/2-(*it2-*it1)*(*it2-*it1-1)/2);
		for(int j=0;j<26;j++){
			if(j==t[K])continue;
			auto it=st[j].lower_bound(K);
			auto jt=it;
			jt--;
			mx=max(mx,{s[K][j]-s[K][t[K]]+c[j]*((*it-*jt)*(*it-*jt-1)/2-(*it-K)*(*it-K-1)/2-(K-*jt)*(K-*jt-1)/2)-a,j});
		}
		st[t[K]].erase(it2);
		t[K]=mx.second;
		st[mx.second].insert(K);
	}
	for(int i=0;i<D;i++){
		printf("%d\n",t[i]+1);
	}
}


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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  long N;
  cin >> N;
  map<long, long> A;
  vector<long> v(2, 0);
  for (int i = 0; i < N; i++) {
    long tmp;
    cin >> tmp;
    A[tmp]++;
  }
  for (auto x : A) {
    int s = x.second;
    for (int i = 0; i < s / 2; i++)
      v.push_back(x.first);
  }

  sort(v.begin(), v.end(), ::greater<int>());
  cout << v[0] * v[1] << endl;
}


Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int a,b;
  cin >> a >> b;
  cout << a * b << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N, M, L;
  cin >> N >> M >> L;
  const long long inf = 1e18;
  vector<vector<long long>> d(N, vector<long long> (N, inf));
  for (int i = 0; i < N; i++) d[i][i] = 0;
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    d[a][b] = c;
    d[b][a] = c;
  }

  auto wf = [&](){
    for (int k = 0; k < N; k++) {
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++){
          if (d[i][k] + d[k][j] > d[i][j]) continue;
          d[i][j] = d[i][k] + d[k][j];
        }
      }
    }
  };
  wf();

  for (auto& v : d) {
    for (auto& x : v) {
      x = (x > L ? inf : 1);
    }
  }
  wf();

  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int s, t;
    cin >> s >> t;
    --s, --t;
    cout << (d[s][t] < inf ? d[s][t] - 1 : -1) << endl;
  }
}


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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(a[i] == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 1;
    for(int i = 0; i < n; i++){
        if(to_string(ans).size()+to_string(a[i]).size()-2 >= 18){
            if(ans*a[i] == (ll)1000000000000000000){}
            else{
                cout << -1 << endl;
                return 0;
            }
        }
        ans *= a[i];
    }
    if(to_string(ans).size()-1 >= 18){
        if(ans == (ll)1000000000000000000){
        }
        else{
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define debug(n) cerr << #n << ':' << n << endl;

using namespace std;

using  ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using  vi = vector<int>;
using  vl = vector<ll>;
using  vd = vector<double>;
template<class T,class U>
using umap = unordered_map<T,U>;
template<class T>
using uset = unordered_set<T>;

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

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

template<class T>
inline void putv(const vector<T>&v,char c = '\n'){
  for(auto&&e:v){
    cout << e << c;
  }
}

template<class T>
inline void readv(vector<T>&v){
  if(v.empty()){
    cerr << "void readv(vector<T>&v) v.empty()\n";
  }
  for(auto&&e:v){
    cin >> e;
  }
}

int main(){
  int a,b;cin >> a >> b;
  cout << max({a+b, a-b, a*b}) << endl;
  return 0;
}

Measured memory_bytes: 256
# coding: utf-8

H, W = list(map(int, input().split(' ')))
sections = [list(input()) for i in range(H)]

crowds = [[-1 for w in range(W)] for h in range(H)]

for h in range(H):
    c = -1
    for w in range(W):
        if c >= 0: c += 1
        if sections[h][w] == 'c': c = 0
        crowds[h][w] = c

for row in crowds:
    print(' '.join(list(map(str, row))))


Measured memory_bytes: 5748
#include<cstdio>
#define LL long long
using namespace std;
LL a,b,c,k;
int main(){
	scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
	if (k&1) printf("%lld\n",b-a);else printf("%lld\n",a-b);
	return 0;
}

Measured memory_bytes: 128
/*
Rathin Bhargava
IIIT Bangalore

*/
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 1000000007
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 


int main()
{
  __;
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i=0;i<n;i++) cin >> v[i];

  vector<int> w = v, ans;
  while(w.size())
  {
    vector<int> temp;
    bool boo = true;
    // t(w);
    for(int i=w.size()-1; i >= 0; i-- )
    {
      // t(i+1,w[i]);
      if(w[i] == i+1 && boo) 
      {
        ans.pu(i+1);
        boo = false;
      }
      else temp.pu(w[i]);
    } 
    if(boo) {cout << -1 << endl; return 0;}
    w = temp;
    reverse(w.begin(),w.end());
  }

  reverse(ans.begin(),ans.end());
  for(int i=0;i<ans.size();i++) cout << ans[i] << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
int main(){
int N; cin>>N;map<pair<int,int>,int>M;
  Graph G(N);
  for(int i=0;i<N-1;i++){
  int a,b; cin>>a>>b; a--;b--;
    pair<int,int>p1(a,b); pair<int,int>p2(b,a);
    M[p1]=i; M[p2]=i;
    G[a].push_back(b);
    G[b].push_back(a);
  }int Max=G[0].size();
  int a=0;
  for(int i=1;i<N;i++){
  int Size=G[i].size();
    if(Max<Size){a=i; Max=Size;}
  }queue<int>que;
  que.push(a);
  vector<int>color(N-1);
  vector<int>Color(N,-1);
  Color.at(a)=0;
  while(!que.empty()){
  int u=que.front();
    que.pop();
    int k=-1;
    for(auto v:G[u]){
    
      if(Color.at(v)!=-1)
        continue;
      else{
        k++;
      int b=1+(Color.at(u)+k)%Max;
      Color.at(v)=b;
        pair<int,int>p(u,v);
       int c= M.at(p);
         color.at(c)=b;
        que.push(v);
      }
    }
   }cout<<Max<<endl;
  for(int i=0;i<N-1;i++)
    cout<<color.at(i)<<endl;
   return 0;
}

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

#if DEBUG && !ONLINE_JUDGE
    #include "header.h"
#else
    #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
    return;
}
int dp[3001][3001];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(20);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    preprocess();
    string s, t; cin>>s>>t;
    int l1 = s.length();
    int l2 = t.length();
    memset(dp,0,sizeof dp);
    rep(i,1,l1+1) {
        rep(j,1,l2+1) {
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if(s[i-1] == t[j-1]) {
                dp[i][j] = max(dp[i][j], 1 + dp[i-1][j-1]);
            }
        }
    }
    vector<ii> ans;
    int l = l1, r = l2;
    while(l>0 && r>0) {
        if(dp[l][r] == dp[l-1][r]) {
            l--;
        }
        else if(dp[l][r] == dp[l][r-1]) {
            r--;
        }
        else {
            ans.pb({1,l}); // pos in string + 1
            l--;
            r--;
        }
    }
    reverse(all(ans));
    for(auto x: ans) {
        cout<<s[x.se-1];
    }

}



Measured memory_bytes: 35456
#include <iostream>

using namespace std;

int main(){
  int card[11],c;
  while(1){
  for(int i = 1; i <= 10; i++ )card[i] = 1;
  double ave = 0;
  for(int i = 0 ; i < 3 ; i++)
    {
      cin >> c;
      if(cin.eof())return 0;
      card[c] = 0; 
      if(i != 2)ave += c; 
    }

  for(int i = 1; i <= 10; i++ )
    {
      if(20-ave < i )card[i] = 0;
    }
  ave = 0;

  for(int i = 1; i <= 10; i++ )ave += card[i];

  if(ave/7 >= 0.5)cout << "YES" << endl;
  else cout << "NO" << endl;
  }
}

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


int main(){

	int N,K;
	scanf("%d %d",&N,&K);

	ll ans = K;

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

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

	return 0;
}



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

int main()
{
  int n;
  cin>>n;
  
  vector<int> p(n);
  
  for(int i=0;i<n;i++)
  {
     cin>>p[i];      
  }
  
  int ans =0;
  int now =1000000001;
  
  for(int i=0;i<n;i++)
  {
     now = min(p[i],now);
    
    if(now >= p[i])
    {
       ans++;
    }
     
  }
  
  
  cout<<ans<<endl;
  
  
    return 0;

}


Measured memory_bytes: 1024
n,k,q=map(int,input().split())

#人数文
a=[k for i in range(n)]

for i in range(q):
    tmp=int(input())
    a[tmp-1] += 1

#問題数だけ引く
for i in range(n):
    a[i] -= q
    
#出力
for i in range(n):
    if a[i] > 0:
        print("Yes")
    else:
        print("No")

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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	
	int N, M;
	cin >> N >> M;

	if(N % 2 == 1){
		int left = N / 2;
		int right = (N + 1) / 2;
		rep(i, M){
			cout << left << " " << right << endl;
			left--;
			right++;
		}
	}
	else{
		vector<bool> match(N+1, false);
		int left = 1;
		int right = N - 1;
		bool flg = false;
		rep(i,M){
			if(!flg && right - left <= N/2){
				right--;
				flg = true;
			}
			cout << left << " " << right << endl;
			/*
			int ci = right - left;
			if(!match[ci] && !match[N - ci]){
				match[ci] = true;
				match[N - ci] = true;
				cout << left << " " << right << endl;
			}
			else{
				right--;
				ci = right - left;
				match[ci] = true;
				match[N - ci] = true;
				cout << left << " " << right << endl;
			}
			*/
			left++;
			right--;
		}
	}

}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
bool d[111111];
int main(){
	int n,s=0,x;
	d[0] = 1;
	for(scanf("%d",&n); n--;){
		scanf("%d",&x);
		for(int i=s; i>=0; i--)
			if(d[i])d[i+x] = 1;
		s += x;
	}
	while(s > 0 && (s%10==0 || !d[s]))s--;
	printf("%d\n",s);
	return 0;
}

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

int main() {

        int n,k;
        cin >> n >> k ;
        vector<int> vec(n);

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

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

        int ans;
        ans = 0;
        for(int j=0; j < k; j++){
                ans += vec.at(j);
        }
        cout << ans << endl;

}

Measured memory_bytes: 3632
n = int(input())
if n == 1:
    print(1)
elif n <= 3:
    print(2)
elif n <= 7:
    print(4)
elif n <= 15:
    print(8)
elif n <= 31:
    print(16)
elif n <= 63:
    print(32)
else:
    print(64)

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

using namespace std;

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

template <typename T> inline void print(T val) { cout << val << '\n'; }

template <typename Iterator> inline void print(Iterator begin, Iterator end) {
  for (auto it = begin; it != end; it = next(it)) {
    cout << *it << ' ';
  }
  cout << '\n';
}

template <class T> inline T square(T x) {
  T result;
  result = x * x;
  return result;
};

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

const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;

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

  auto start = chrono::steady_clock::now();
#endif

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int x = 0, y = 0;
  x = a / d;
  y = c / b;

  if (a % d != 0) {
    ++x;
  }
  if (c % b != 0) {
    ++y;
  }
  dbg(x, y);
  if (x >= y) {
    print("Yes");
  } else {
    print("No");
  }

#ifdef LOCAL
  auto end = chrono::steady_clock::now();
  auto diff = end - start;

  cout << "Duration: " << chrono::duration<double, milli>(diff).count() << " ms"
       << '\n';
#endif

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
const int MAX = 55556;
vector<bool> ok(MAX, true);
signed main(void)
{
	int n;
	vector<int> vec;

	cin >> n;
	ok[0] = ok [1] = false;
	rep(i, sqrt(MAX))
	{
		if (ok[i])
		{
			for (int j = 0; i * (j + 2) < MAX; j++)
			{	
				ok[i * (j + 2)] = false;
			}
		}
	}
	for(int i = 6; i < MAX; i += 5)
	{
		if (ok[i])
			vec.push_back(i);
	}
	sort(vec.begin(), vec.end());
	rep(i, n)
	{
		printf("%d%c", vec[i], i == n - 1?'\n':' ');
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
typedef long long ll;
using namespace std;
int main() {
	ll N;
	cin >> N;
	for (ll i = 1;i <= 3500;i++) {
		for (ll j = 1;j <= 3500;j++) {
			ll a = N * i*j;
			ll b = (4 * i*j) - (N*i) - (N*j);
			if (a>0&&b>0&&a%b == 0  ) {
				cout << i << " " << j << " " << a/ b << endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int c1_1,c1_2,c1_3,c2_1,c2_2,c2_3,c3_1,c3_2,c3_3;
  cin>>c1_1>>c1_2>>c1_3>>c2_1>>c2_2>>c2_3>>c3_1>>c3_2>>c3_3;
  if(!(c2_1-c1_1==c2_2-c1_2 && c2_2-c1_2==c2_3-c1_3)){
    cout<<"No"<<endl;
    return 0;
  }else{
    if(!(c3_1-c1_1==c3_2-c1_2 && c3_2-c1_2==c3_3-c1_3)){
      cout<<"No"<<endl;
      return 0;
    }
    cout<<"Yes"<<endl;
    return 0;
  }
}

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

int main() {
    int a,b,c,d,e,am,bm,cm,dm,em,ret;
    cin>>a>>b>>c>>d>>e;
    am=a%10;
    if(am==0)
        am=10;
    bm=b%10;
    if(bm==0)
        bm=10;
    cm=c%10;
    if(cm==0)
        cm=10;
    dm=d%10;
    if(dm==0)
        dm=10;
    em=e%10;
    if(em==0)
        em=10;
    if(am!=10&&am<=bm&&am<=cm&&am<=dm&&am<=em){
        //cout<<"A"<<endl;
        ret=a+(int)(b*0.1+0.9)*10+(int)(c*0.1+0.9)*10+(int)(d*0.1+0.9)*10+(int)(e*0.1+0.9)*10;
    }
    else if(bm!=10&&bm<=am&&bm<=cm&&bm<=dm&&bm<=em){
           // cout<<"B"<<endl;
            ret =b+(int)(a*0.1+0.9)*10+(int)(c*0.1+0.9)*10+(int)(d*0.1+0.9)*10+(int)(e*0.1+0.9)*10;
        }    else if(cm!=10&&cm<=bm&&cm<=am&&cm<=dm&&cm<=em){
            //cout<<"C"<<endl;
                ret = c+(int)(b*0.1+0.9)*10+(int)(a*0.1+0.9)*10+(int)(d*0.1+0.9)*10+(int)(e*0.1+0.9)*10;
             }   else if(dm!=10&&dm<=bm&&dm<=cm&&dm<=am&&dm<=em){
              //      cout<<"D"<<endl;
                    ret = d+(int)(b*0.1+0.9)*10+(int)(c*0.1+0.9)*10+(int)(a*0.1+0.9)*10+(int)(e*0.1+0.9)*10;
              }  else if(em!=10&&em<=bm&&em<=cm&&em<=dm&&em<=am){
                //        cout<<"E"<<endl;
                        ret = e+(int)(b*0.1+0.9)*10+(int)(c*0.1+0.9)*10+(int)(d*0.1+0.9)*10+(int)(e*0.1+0.9)*10;
                }
    if(am==10&&bm==10&&cm==10&&dm==10&&em==10)
        ret=a+b+c+d+e;
    cout<<ret<<endl;
}


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

int N, M;
long long a[50], b[50], c[50], d[50];

int main() {
    cin >> N >> M;
    rep(i, N) cin >> a[i] >> b[i];
    rep(i, M) cin >> c[i] >> d[i];

    long long ans[50];

    rep(i, N) {
       int target = 1000000000; 
       int idx = -1;
       rep(j, M) {
           long long dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
           if (target > dist) {
               target = dist;
               idx = j;
           }
       }
       cout << idx + 1 << endl;
    }
}

Measured memory_bytes: 256
function Main(input) {
  input = input.split('\n')
  var tmp = input[0].split(' ')
  var N = tmp[0]
  var D = tmp[1]

  var calc = 0
  var result = 0

  for (var i = 0; i < N - 1; i++) {
    var number1 = input[i + 1].split(' ')
    for (var j = 0; j < N - 1 - i; j++) {
      calc = 0
      // 値を計算する場所
      var number2 = input[i + 2 + j].split(' ')

      for (var k = 0; k < D; k++) {
        calc = calc + Math.pow(Math.abs(number1[k] - number2[k]), 2)
      }

      // 整数を判定する場所
      if (Number.isInteger(Math.sqrt(calc))) {
        result++
      }
    }
  }

  console.log('%d', result)
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

int main(){
  int N;
  cin >> N;
  vector<int> P(N),Q(N);
  for(int i=0;i<N;++i) cin >> P[i];
  for(int i=0;i<N;++i) cin >> Q[i];
  ll ans = 0;
  ll tmp = 1;
  for(int i=0;i<N;++i) tmp *= i + 1;
  string p,q;
  for(int i=0;i<N;++i){
    p.push_back(P[i]);
    q.push_back(Q[i]);
  }
  while(equal(P.cbegin(),P.cend(),Q.cbegin())==false){
    next_permutation(P.begin(),P.end());
    ans++;
  }
  if(p==q) cout << 0 << endl;
  else if(q<p){
    cout << tmp - ans << endl;
  }
  else cout << ans << endl;
}

Measured memory_bytes: 256
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "main.cpp"

// generated by online-judge-template-generator v4.4.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
  vector<string> s(3);
  REP(i, 3) { cin >> s[i]; }
  cout << (char)(s[0][0] - 'a' + 'A') << (char)(s[1][0] - 'a' + 'A') << (char)(s[2][0] - 'a' + 'A');
}


Measured memory_bytes: 3624
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]

N, X, Y = mi()

dp = [0]*(N)

for i in range(1, N):
    for j in range(i+1, N+1):
        #print(min(j-i, abs(j-X)+1+abs(Y-j)))
        dp[min(j-i, abs(i-X)+1+abs(Y-j))] += 1

for i in range(1, N):
    print(dp[i])

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

int main() {
  string input;
  cin >> input;

  int N = input.length();

  int a[N];
  for(int i=0;i<N;++i){
    a[i] = (int)(input[i] - '0');
  }

  int mincount = 1000000;
  int count = 0;

  for(int i=0;i<N;++i){
    if(a[i]==i%2){
      ++count;
    }
  }

  if(mincount>count) mincount = count;

  count = 0;

  for(int i=0;i<N;++i){
    if(a[i]==(i+1)%2){
      ++count;
    }
  }

  if(mincount>count) mincount = count;

  cout << mincount << endl;



}

Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    string s;
    cin >> s;
    
    long long sum=0;

    for(auto i : s)sum+=i-'0';
    if(sum%9)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}



Measured memory_bytes: 3788
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(),vec.end()
#define rever(vec) reverse(all(vec));
#define cend cout << endl;
#define prique(T) priority_queue<T,vector<T>,greater<T>>
struct edge { int to, cost; };
typedef pair<int, int> P;
typedef pair<P, int> PP;
const int mod = 1e9 + 7, inf = 1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			if (mod <= ans * x) ans = ans * x % mod;
			else ans *= x;
		}
		if (mod <= x * x) x = x * x % mod;
		else x *= x;
		n >>= 1;
	}
	return ans;
}

int fact_memo[114514];
int fact(int n) {
	int ans = 1;
	if (fact_memo[n]) return fact_memo[n];
	rep(i, n) {
		ans *= (i + 1);
		if (mod <= ans) ans %= mod;
	}
	fact_memo[n] = (ans + mod) % mod;
	return (ans + mod) % mod;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod * modpow(fact(r), mod - 2) + mod) % mod;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	return (fact(n) * modpow(fact(n - r), mod - 2) % mod + mod) % mod;
}

int gcd(int a, int b) {
	int c;
	while (b != 0) {
		c = b;
		b = a % b;
		a = c;
	}
	return a;
}

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

bool pri(int p) {
	for (int i = 2; i * i <= p; i++) if (p % i == 0) return false;
	return p > 1;
}

int n, j;
int a[114514], l[114514], r[114514];
int ans = 0;
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	l[0] = a[0];
	r[n - 1] = a[n - 1];
	rep(i, n - 1) {
		l[i + 1] = gcd(l[i], a[i + 1]);
		j = n - 2 - i;
		r[j] = gcd(r[j + 1], a[j]);
	}
	rep(i, n) {
		if (i == 0) {
			ans = r[i + 1];
		}
		else if (i == n - 1) {
			ans = max(ans, l[i - 1]);
		}
		else {
			ans = max(ans, gcd(l[i - 1], r[i + 1]));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000000
int i, j, k, l, m, n, q, dp[205][205], ord[10], gen[10], ans = INF, tmp;
bool used[10];
void p(int z) {
	if(z == q) {
		tmp = 0;
		for(i = 1; i < q; i++) tmp += dp[gen[i - 1]][gen[i]];
		ans = min(tmp, ans);
	}
	for(int y = 0; y < q; y++) if(!used[y]) {
		used[y] = 1;
		gen[z] = ord[y];
		p(z + 1);
		used[y] = 0;
	}
}
int main() {
	scanf("%d%d%d", &n, &m, &q);
	for(i = 1; i <= n; i++) for(j = 1; j <= n; j++) dp[i][j] = INF;
	for(i = 1; i <= n; i++) dp[i][i] = 0;
	for(i = 0; i < q; i++) scanf("%d", &ord[i]);
	for(i = 0; i < m; i++) {
		scanf("%d%d%d", &j, &k, &l);
		dp[j][k] = min(dp[j][k], l);
		dp[k][j] = min(dp[k][j], l);
	}
	for(k = 1; k <= n; k++) for(i = 1; i <= n; i++) for(j = 1; j <= n; j++) dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);

	p(0);
	printf("%d\n", ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <cstdlib>
#include <iostream>
#include <numeric>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> ab(n);
  //vector<int> b(n);
  for(int i = 0; i < n; i++) {
    cin >> ab.at(i).second >> ab.at(i).first;
  }
  sort(ab.begin(), ab.end());
  
  int time = 0;
  for(int i = 0; i < n; i++) {
    time += ab.at(i).second;
    if(time > ab.at(i).first) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    int ans = min(min(a+b,b+c),a+c);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
    int A, B;

    scanf("%d %d", &A, &B);

    if (A <= 8 && B <= 8) {
        printf("Yay!\n");
    }
    else {
        printf(":(\n");
    }

    return 0;
}

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

// ただの辺
struct edge {
    int to;
    long long cost;
    // 引数一つの時は距離1
    edge(int t, long long c = 1) : to(t), cost(c) {}
};

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    vector<vector<edge>> g(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        bool isGood = true;
        for (auto e : g[i]) {
            if (h[i] <= h[e.to]) {
                isGood = false;
                break;
            }
        }
        if (isGood) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 11180
n = int(input())
s = input()

r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')
ans = r_cnt * g_cnt * b_cnt

for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n or j >= n:
            break
        if s[i] != s[j] != s[k] != s[i]:
                ans -= 1

print(ans)


Measured memory_bytes: 9188
#include <iostream>
#include <vector>
#include <queue>
#include <math.h>
#include <unordered_map>

using namespace std;

typedef long long int64;

class Solution {
private:
    const int mod = 1e9 + 7;
    
public:
    int solve(int n, int k) {
        int ret = 0;
        for(int64 i = k; i <= n; ++i) {
            int64 cur  = i * (n - i) + 1;
            //cout << cur << endl;
            ret = (ret + cur) % mod;
        }
        return ret;
    }

};

int main() {
    int n, k;
    cin >> n >> k;
    Solution sol;
    auto ret = sol.solve(n + 1, k);
    cout << ret << endl;
}

Measured memory_bytes: 3608
def main():
    import sys
    input = sys.stdin.readline

    N = list(map(int, list(input()[:-1])))
    N = N[::-1] + [0]

    ans = 0
    for i in range(len(N)-1):
        if N[i] < 5:
            ans += N[i]
        elif N[i] > 5:
            ans += 10 - N[i]
            N[i+1] += 1
        else:
            ans += 5
            if N[i+1] >= 5:
                N[i+1] += 1

    print(ans + N[len(N)-1])

main()

Measured memory_bytes: 26496
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int N;
string S;

string rotateChar(string s, int N) {
  string res;
  for (int i = 0; i < s.size(); i++) {
    int num = s[i] - 'A';
    num = (num + N) % 26;
    res += (num + 'A');
  }
  return res;
}

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

  string ans = rotateChar(S, N);
  cout << ans << endl;

  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

char A[4] = {'A', 'C', 'G', 'T'};
char B[4] = {'T', 'G', 'C', 'A'};

int main() {
    char b;
    cin >> b;
    REP(i, b) {
        if (A[i] == b) {
            cout << B[i] << endl;
            break;
        }
    }
    return 0;
}

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

using ll = long long;
#define ld long double
#define ull unsigned long long int

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  // (i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define ret return

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<long long> vl;

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

    // 入力
    int n, m;
    cin >> n >> m;
    int x[n] = {};
    int y[m] = {};
    int numX, numY;
    cin >> numX >> numY;
    rep(i, n) { cin >> x[i]; }
    rep(i, m) { cin >> y[i]; }

    // 処理
    sort(x, x + n);
    sort(y, y + m);

    int ans = max(numX, x[n - 1]) + 1;
    cout << (ans <= min(numY, y[0]) ? "No War" : "War") << endl;

    // 出力

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			String str=sc.next();
			char[] cStr=str.toCharArray();
			int[] iStr=new int[cStr.length];
			for(int i=0;i<cStr.length;i++){
				if(Character.toString(cStr[i]).equals("I")){
					iStr[i]=1;
				}else if(Character.toString(cStr[i]).equals("V")){
					iStr[i]=5;
				}
				else if(Character.toString(cStr[i]).equals("X")){
					iStr[i]=10;
				}else if(Character.toString(cStr[i]).equals("L")){
					iStr[i]=50;
				}else if(Character.toString(cStr[i]).equals("C")){
					iStr[i]=100;
				}else if(Character.toString(cStr[i]).equals("D")){
					iStr[i]=500;
				}else if(Character.toString(cStr[i]).equals("M")){
					iStr[i]=1000;
				}
			}
			int sum=iStr[iStr.length-1];
			for(int i=iStr.length-2;i>=0;i--){
				if(iStr[i]<iStr[i+1]){
					sum-=iStr[i];
				}else{
					sum+=iStr[i];
				}
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 17192
def mypow(x,k,p):
    out = 1
    while(k > 0):
        if(k%2 == 1):
            out = out * x % p
        k = k // 2
        x *= x
    return out

p = 10 ** 9 + 7
n = int(input())
res = (mypow(10,n,p) - mypow(9,n,p)*2 + mypow(8,n,p)) % p
print(res)



Measured memory_bytes: 10612
import math
a,b,c = map(float,input().split())
S = 0.5*a*b*math.sin(c*math.pi/180)
L = a+b+(a*a+b*b-2*a*b*math.cos(c*math.pi/180))**0.5
print(S,L,b*math.sin(c*math.pi/180))

Measured memory_bytes: 7752
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define INF 1e9
#define all(v) v.begin(), v.end()
typedef long long ll;

int main(){
  int n, k; cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
 
  int sum = 0;
  rep(i, k) sum += p[i];
  int ma = sum;
  rep(i, n-k){
    sum -= p[i];
    sum += p[i+k];
    ma = max(ma, sum);
  }
  
  double ans = (double)(ma + k) / 2.0;
  cout << fixed << setprecision(12) << ans << endl;

  return 0;
}


Measured memory_bytes: 1024