akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(int v = (a); v >= (b); --v)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
#define LLI long long int
using namespace std;

template <typename T> using V = vector<T>;
template <typename T, typename U> using P = pair<T,U>;

template <typename T> T gcd(T a, T b){a = abs(a); b = abs(b); if(a<b) swap(a,b); while(b>0){a %= b; swap(a,b);} return a;}
template <typename T> T lcm(T a, T b){return (1LL * a * b) / gcd(a,b);}

const int mod = 1e9+7; 
map<LLI,LLI> dp;

LLI f(LLI n){
  if(dp.find(n) != dp.end()) return dp[n];
  return (dp[n] = (f(n/2) + f((n-1)/2) + f((n-2)/2)) % mod);
}

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

  LLI N; cin >> N;

  dp[0] = 1;
  dp[1] = 2;
 
  cout << f(N) << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define FOR( a,b ) for( a=0;a<b;a++ )
 
int main(){
    int mnt[10];
    int i,j,buf;
    FOR( i,10 )scanf( "%d",&mnt[i] );
    FOR( i,10 ){
        j=i+1;
        FOR( j,10 ){
            if( mnt[i] > mnt[j] ){
                buf=mnt[i];
                mnt[i]=mnt[j];
                mnt[j]=buf; 
            }
        }
    }
    FOR( i,3 )printf( "%d\n",mnt[i] );
    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;/*
ll a[110];
int main(){
    ll n,a1=0,a2=0,a3=0,a4=0,a5=0,a6=0,a7=0,a8=0;
    ll ans=0;
    cin>>n;
    rep(i,0,n)cin>>a[i];
    rep(i,0,n){
        if(a[i]>=3200)a1++;
        else if(a[i]>=2400)a2++;
        else if(a[i]>=2000)a3++;
        else if(a[i]>=1600)a4++;
        else if(a[i]>=1200)a5++;
        else if(a[i]>=800)a6++;
        else if(a[i]>=400)a7++;
        else a8++;
    }
    if(a2>0)ans++;
    if(a3>0)ans++;
    if(a4>0)ans++;
    if(a5>0)ans++;
    if(a6>0)ans++;
    if(a7>0)ans++;
    if(a8>0)ans++;

    if(ans==0)cout<<"1"<<" ";
    else cout<<ans<<" ";
    cout<<ans+a1;
}*/
ll b[110000];
int main(){
    ll n,m;
    cin>>n>>m;
    priority_queue<ll>q;
    rep(i,0,n){cin>>b[i];q.push(b[i]);}
    while(m>0){
        double x=q.top();
        q.pop();
        q.push(x/2);
        m--;
    }
    ll ans=0;
    while(q.size()>0){ans+=q.top();q.pop();}
    cout<<ans;
}

Measured memory_bytes: 1912
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#define MAGIC cin.tie(NULL); ios_base::sync_with_stdio(false)
#define endl '\n'
//#define ll long long
#define mod (1000000007)
//#define NCONS 100001
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
//#define MCONS 2001
//#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
#define int long long
//#define double long double
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
typedef long long ll;

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

#define YYYY cout << "YES" << endl
#define NNNN cout << "NO" << endl
#define yyyy cout << "Yes" << endl
#define nnnn cout << "No" << endl
int dx[]{0, 1, 0, -1};
int dy[]{1, 0, -1, 0};

const int NCONS = 5001;
//const int MCONS = 101;

int32_t main()
{
    MAGIC;
    vector<string> vec = {"Sunny", "Cloudy", "Rainy"};
    string s; cin >> s;
    int idx = 0;
    for(int i = 0; i < 3; i++) if(s == vec[i]) idx = i;
    
    cout << vec[(idx + 1) % 3];
   
    return 0;
}



Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define STRMAX 200
#define PNUM 3 

using namespace std;

class Point{
  public:
    double x, y;
  public:
    bool isLeft( Point *p, Point *q );
};
enum State{
  NONE,
  LEFT,
  RIGHT
};
bool Point::isLeft( Point *p, Point *q ){
  double x1 = p->x - this->x;
  double x2 = q->x - this->x;
  double y1 = p->y - this->y;
  double y2 = q->y - this->y;
  return (x1 * y2 - x2 * y1 > 0) ? true : false;
}

void c2s( char str[] ){
  for( int i = 0; str[ i ] != '\0'; i++ ){
    str[ i ] = ( ( str[ i ] == ',' ) ? ' ' : str[ i ] );
  }
}

int main(){
  char str[ STRMAX ];
  Point *p[ PNUM ] = { NULL, NULL, NULL };
  Point *pp;
  while( 1 ){
      for( int i = 0; i < PNUM; i++ ){
        if( p[ i ] == NULL ){  delete p[ i ]; }
        p[ i ] = new Point();
      }
      if( pp == NULL ){ delete pp; }
      pp = new Point();
      if( 
          scanf(
            "%lf%lf%lf%lf%lf%lf%lf%lf", 
            &(p[ 0 ]->x), 
            &(p[ 0 ]->y), 
            &(p[ 1 ]->x), 
            &(p[ 1 ]->y), 
            &(p[ 2 ]->x), 
            &(p[ 2 ]->y),
            &(pp->x), &(pp->y)
          ) == EOF
      ){ break; }
     State state = NONE;
     bool ok = true;
     for( int i = 0; i < PNUM; i++ ){
        State s = LEFT;
        if( !pp->isLeft( p[i%PNUM], p[(i+1)%PNUM] ) ){
          s = RIGHT;
        }
        if( state != NONE && state != s ){
          ok = false;
          break;
        }
        state = s;
     }
     puts( ok ? "YES" : "NO" );
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1048
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int sum = 0;
    vector<int> p(n);
    rep(i, n) {
      cin >> p[i];
    }
    sort(p.begin(), p.end(), greater<int>());
    p[0] /= 2;
    rep(i, n) {
      sum += p[i];
    }

    cout << sum << '\n';

    return 0;
}


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

signed main() {
  string s;
  cin >> s;

  bool flag = false;
  if(s[0] == s[1] && s[2] == s[3]) flag = true;
  if(s[0] == s[2] && s[1] == s[3]) flag = true;
  if(s[0] == s[3] && s[1] == s[2]) flag = true;

  if(s == string((int)s.size(), s[0])) flag = false;

  if(flag) cout << "Yes" << '\n';
  else cout << "No" << '\n';

}


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

typedef long long ll;
typedef unsigned long long ull;

#include <vector>
#include <set>

class UnionFind{
public:
    UnionFind(size_t n){
        m_parent.resize(n);
        iota(m_parent.begin(), m_parent.end(), 0);

        m_rank.resize(n);
        fill(m_rank.begin(), m_rank.end(), 0);

        m_size.resize(n);
        fill(m_size.begin(), m_size.end(), 1);
    }

    int Find(int x){
        if(m_parent[x] == x){
            return x;
        }else{
            m_parent[x] = Find(m_parent[x]);
            return m_parent[x];
        }
    }

    void Union(int x, int y){
        auto xroot = Find(x);
        auto yroot = Find(y);
        if(m_rank[xroot] > m_rank[yroot]){
            m_parent[yroot] = xroot;
            m_size[xroot] += m_size[yroot];
        }else if(m_rank[xroot] < m_rank[yroot]){
            m_parent[xroot] = yroot;
            m_size[yroot] += m_size[xroot];
        }else if(xroot != yroot){
            m_parent[yroot] = xroot;
            m_size[xroot] += m_size[yroot];
            m_rank[xroot] = m_rank[xroot] + 1;
        }
    }

    int GetSize(){
        for(size_t i=0;i<m_parent.size();i++){
            m_parent[i] = Find(m_parent[i]);
        }
        std::set<int> s(m_parent.begin(), m_parent.end());
        return s.size();
    }

    int GetSize(int x){
        auto xroot = Find(x);
        return m_size[xroot];
    }

    std::vector<int> m_parent;
    std::vector<int> m_rank;
    std::vector<int> m_size;
};

int main()
{
    ll N, M;
    cin >> N >> M;
    ll Ai, Bi;
    vector<ll> A, B;
    for(int i=0;i<M;i++){
        cin >> Ai >> Bi;
        A.push_back(Ai-1);
        B.push_back(Bi-1);
    }
    UnionFind uf(N);
    stack<ll> s;
    s.push(N*(N-1)/2);
    for(int i=M-1;i>=0;i--){
        auto rootAb = uf.Find(A[i]);
        auto rootBb = uf.Find(B[i]);
        auto nA = uf.GetSize(rootAb);
        auto nB = uf.GetSize(rootBb);
        uf.Union(A[i], B[i]);
        auto rootAa = uf.Find(A[i]);
        auto rootBa = uf.Find(B[i]);
        if(rootAb == rootBb || rootAa != rootBa){
            s.push(s.top());
        }else{
            s.push(s.top()- nA * nB);
        }
    }
    s.pop();
    while(!s.empty()){
        cout<<s.top()<<endl;
        s.pop();
    }

    return 0;
}


Measured memory_bytes: 4844
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <string>
#define rep(i,n) for(int i = 0; i < n; ++i)
using namespace std;
#define MAX_V 100000
#define MAX_E 500000
struct edge { int to, cost; };
typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
const int INF = 1e9 + 7;

#define MAX_H 10
#define MAX_W 10000

bool A[26];

int main() {
	string str;
	cin >> str;
	rep(i, str.size()) A[str[i] - 'a'] = true;
	rep(i, 26) {
		if (!A[i]) {
			cout << char(i + 'a') << endl;
			break;
		}
		else if(i == 25) cout << "None" << endl;
	}
	

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define REP(i,n) for(long long i=0;i<n;++i)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
using namespace std;
int main(){
    long long data[45];
    int n;
    data[0]=1;
    data[1]=1;
    scanf("%d",&n);
    FOR(i,2,n+1) data[i]=data[i-2]+data[i-1];
    printf("%lld\n",data[n]);
    return 0;
}




Measured memory_bytes: 3220
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

struct Coord {
    Int x;
    Int y;
};
double CalcDist(Coord first, Coord second);
double CalcDistSum(vector<Coord>& coords, vector<Int>& coordId);
Int Factorial(Int n);

double (*const CalcDistSum2[])(vector<Coord>&, vector<Int>&) = {CalcDistSum};

void PermutationLoop(Int n, vector<Coord>& coords) {
    vector<Int> v(n);
    for (Int i = 0; i < n; ++i) {
        v[i] = i;
    }

    double sum = 0;
    do {
        sum += CalcDistSum2[0](coords, v);
    } while (std::next_permutation(v.begin(), v.end()));
    cout << fixed << setprecision(10) << sum / (double)Factorial(n) << endl;
    return;
}


int main(void) {
    Int n;
    cin >> n;
    vector<Coord> coords(n);
    for (Int i = 0; i < n; ++i) {
        cin >> coords[i].x >> coords[i].y;
    }
    PermutationLoop(n, coords);
    return 0;
}

double CalcDist(Coord first, Coord second) {
    return sqrt((first.x - second.x) * (first.x - second.x) + (first.y - second.y) * (first.y - second.y));
}
double CalcDistSum(vector<Coord>& coords, vector<Int>& coordId) {
    Int size = (Int)coordId.size();
    double ret = 0;
    for (Int i = 0; i < size - 1; ++i) {
        ret += CalcDist(coords[coordId[i]], coords[coordId[i + 1]]);
    }
    return ret;
}
Int Factorial(Int n) {
    if (n == 1) {
        return 1;
    } else {
        return n * Factorial(n - 1);
    }
}



Measured memory_bytes: 3740
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int dy[2][6]={{-1,-1,0,1,1,0},{-1,-1,0,1,1,0}};
const int dx[2][6]={{0,1,1,1,0,-1},{-1,0,1,0,-1,-1}};
char field[102][102];
bool used[102][102];
bool colored[102][102][6];
int w,h;

void dfs(int y,int x){
    used[y][x]=true;
    for(int i=0;i<6;i++){
        int ny=y+dy[!(y%2)][i];
        int nx=x+dx[!(y%2)][i];
        if(ny>=0&&nx>=0&&ny<h&&nx<w){
            if(field[ny][nx]=='1'){
                colored[ny][nx][(i+3)%6]=true;
                continue;
            }
            else if(used[ny][nx])continue;
            dfs(ny,nx);
        }
    }
}

int main(){

    cin>>w>>h;
    for(int i=0;i<=101;i++)for(int j=0;j<=101;j++)field[i][j]='0';
    for(int i=1;i<=h;i++)for(int j=1;j<=w;j++)cin>>field[i][j];
    h++;w++;
    h++;w++;
    // ツ陛姪環づ可妥篠つオツづ探ツ催オツづーツ繰ツづィツ陛板つキ
    for(int i=0;i<h;i++){
        if(!used[i][0])dfs(i,0);
        if(!used[i][w-1])dfs(i,w-1);
    }
    for(int j=0;j<w;j++){
        if(!used[0][j])dfs(0,j);
        if(!used[h-1][j])dfs(h-1,j);
    }
    int cnt=0;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)for(int k=0;k<6;k++)if(colored[i][j][k])cnt++;
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define pb push_back

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

  int a = 0, b = 0;

  bool flag = false; // 偶数だとfalse, 奇数だとtrueになる。
  // 101010...にした時の判定
  for(char c: s){
    if(flag) {
      if(c != '0') a++;
      flag = false;
    } else {
      if (c != '1') a++;
      flag = true;
    }
  }

  // 010101...にした時の判定
  flag = false;
  for(char c: s){
    if(flag) {
      if(c != '1') b++;
      flag = false;
    } else {
      if (c != '0') b++;
      flag = true;
    }
  }
  // cout << a << " " << b << endl;
  
  cout << min(a,b) << endl;

}


Measured memory_bytes: 512
using System;

namespace AOJ
{
    class ElementaryNumberTheory
    {
        private static decimal PowMod(decimal m, decimal n)
        {
            if (n == 0) { return 1; }

            decimal res = PowMod(m * m % 1000000007, Math.Floor(n / 2));
            if (n % 2 == 1) { res = res * m % 1000000007; }
            return res;
        }

        public static void Main()
        {
            var input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            Console.WriteLine(PowMod(a, b));
        }
    }
}

Measured memory_bytes: 5664
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=2e6+10;
int q[N];
int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)cout<<"hon";
	else if(n%10==8||n%10==6||n%10==1||n%10==0)cout<<"pon";
	else cout<<"bon";
}


Measured memory_bytes: 3596
#include <stdio.h>

int main()
{
	int i, N, K, h, ans = 0;
	scanf("%d %d", &N, &K);
	for (i = 1; i <= N; i++) {
		scanf("%d", &h);
		if (h >= K) ans++;
	}
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const double eps = 1e-9;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ")
{ if (!v.size()) puts(""); rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

vi g[202020];

int n = in(), m = in();

bool dfs(int d = 0, int v = 0) {
  if (d == 2) return v == n - 1;
  bool f = false;
  for (int i = 0; i < g[v].size(); ++i) {
    if (dfs(d + 1, g[v][i])) f = true;
  }
  return f;
}

signed main() {
  rep(i, m) {
    int a = in() - 1, b = in() - 1;
    g[a].pb(b);
    g[b].pb(a);
  }

  cout << (dfs() ? "POSSIBLE" : "IMPOSSIBLE") << endl;

}


Measured memory_bytes: 12016
#include "bits/stdc++.h"
#define pb push_back
#define mt make_tuple
#define all(a) (a).begin(),(a).end()
#define frep(i,a,n) for(int i=(a);i<(n);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define rrep(i, n) for(int i=n-1;i>=0;--i)
#define debug(x) cout << #x << " : " << x << " ------------ " << endl;

using namespace std;

int mod(int a, int b) {
    int m = a % b;
    if (m < 0) {
        m += ceil(abs(m)/a) * a;
    }
    return m;
}
int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    
    int d = c % (a + b);
    if (d <= a) {
        cout << c << endl;
        return 0;
    }
    int diff = 60 - a - b;
    if (diff == 0) {
        cout << -1 << endl;
        return 0;
    }
    int i = 1;
    int s = mod(c + i * diff, a + b);
    int m = s;
    while(m > a) {
        m = mod(c + ++i * diff, a + b);
        if (m == s) {
            i = 0;
            break;
        }
    }
    cout << (i > 0 ? (c + 60 * i) : -1) << endl;
    
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < ( n ); ++i )
using namespace std;
using ll = long long;
using ull = unsigned long long;
using p  = pair<int, int>;
using vec_int = vector<int>;
using vec_str = vector<string>;
#define INF (1<<29)

void debug_input(vec_str& argv)
{
    // デバッグ用引数読み込み
    ifstream file("./input.txt");
    string str;
    while( getline(file, str) ) {
        argv.push_back(str);
    }
}

void debug_split_string(const string& str, vec_str& v)
{
    stringstream ss{str};
    string buf;
    while (getline(ss, buf, ' ')) {
        v.push_back(buf);
    }
}

void debug_split_int(const string& str, vec_int& v)
{
    stringstream ss{str};
    string buf;
    while (getline(ss, buf, ' ')) {
        istringstream ss(buf);
        int temp;
        ss >> temp;
        v.push_back(temp);
    }
}

long long gcd(long long x, long long y) {
  return y ? gcd(y, x % y) : x;
}

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

  	ll ans = 0;
    
    int temp = 0;
    for(int i = 1; i <= N; ++i ) {
        
        for( int j = 1; j <= N; ++j ) {
            
            temp = gcd(i, j);
            
            for( int k = 1; k <= N; ++k ) {
                    int temp2 = gcd(k, temp);
                  	ans += temp2;
            }
        }
    }
        

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#include<queue>
#include<cstdio>
#include<vector>
#include <algorithm>
#include<string>
#define rep(i,n) for (int i=0;i<(n);++i)
using ll = long long;
using namespace std;
using P = pair<int,int>;

int main(){
    string s;
    cin>>s;
    int ans = 0;
    for(char c : s){
        ans += (c-'0');
    }
    if(ans%9==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int X,N;
  cin >> X >> N;
  vector<int> p(N);
  rep(i,N) cin >> p[i];
  sort(ALL(p));
  if(N==0)
  {
    cout << X << endl;
    return 0;
  }
  vector<int> vec(102);
  for(int i=1;i<101;i++)
  {
    vec[i-1] = 0;
  }
  rep(i,N)
  {
    vec[p[i]] = -1;
  }
  int m = 1000;
  int M = 1000;
  for(int i=X;i<102;i++)
  {
    if(vec[i]==0)
    {
      m = i;
      break;
    }
  }
  for(int i=X;i>-1;i--)
  {
    if(vec[i]==0)
    {
       M = i;
       break;
    } 
  }
  if(abs(m-X)>=abs(M-X)) cout << M << endl;
  else
  {
    cout << m << endl;
  }
  
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  ll n,m,x[111111];
  cin>>n>>m;
  for(int i=0;i<m;i++)cin>>x[i];
  sort(x,x+m);
  ll di[111111];
  for(int i=1;i<m;i++){
    di[i-1]=x[i]-x[i-1];
    //    dbg(di[i-1]);
  }
  sort(di,di+m-1);
  if(m<=n){
    cout<<0<<endl;
    return 0;
  }
  ll ans=0;
  for(int i=0;i<m-n;i++){
    ans+=di[i];
    //    dbg(di[i]);
  }
  cout<<ans<<endl;
  return 0;
}


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

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

  int ans = 0;
  for (int i = 0; i < (s.size() + 1) / 2; i++) {
    if (s.at(i) == 'p') {
      ans--;
    }
  }
  for (int i = (s.size() + 1) / 2; i < s.size(); i++) {
    if (s.at(i) == 'g') {
      ans++;
    }
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 512
arr = Array.new(4) { Array.new(3) { Array.new(10,0) } }
gets.to_i.times do
  b,f,r,v = gets.split.map(&:to_i)
  arr[b-1][f-1][r-1] += v
end
arr.each_with_index do |b,i|
  puts '#' * 20 unless i.zero?
  b.each do |f|
    puts ' ' + f * ' '.chomp
  end
end

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

bool is_prime(int x) {
  if (x <= 1) return false;
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return true;
}

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

  int p = x;
  while (!is_prime(p)) p++;

  cout << p << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1000000000000000000
using namespace std;
int main()
{
long long int a;
double b;
cin>>a>>b;
b=b*100;
long long int c=(long long int)round(b);
long long int ans=a*c;
ans=ans/100;
 cout<<ans;
}

Measured memory_bytes: 3776
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i, j, n) for(int i=(j); i<(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 main() { 
   int n; cin >> n;
   int sum = 0;
   rep(i, n){
       int a; cin >>a;
       sum += a-1;
   }
   cout << sum << ln;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  string S;
  int a=0, b=0, i;
  cin >> S;
  for(i=0; i<S.length(); i++){
    if(S[i] == '0') a++;
    else b++;
  }
  if(a > b) cout << 2*b << endl;
  else cout << 2*a << endl;
  return 0;
}


Measured memory_bytes: 512
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll   long long
#define ld long double
#define endl '\n'
#define INF 10000000000000000
#define pll pair<ll,ll>
#define ff first
#define ss second

using namespace std;
const ll N = 1000005;
const ll MOD = 10e8+7;
ll dp[N];
int main()
{
 //freopen("input.txt","r",stdin);
 //  freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;
    cin>>n>>k;
    dp[0]=1;
    for(ll i =1;i<=n;i++) {
            ll c;
        cin>>c;
        ll fake[k+1]={0};
        for(ll j=k;j>=0;j--) {
            ll l = j+1;
            ll r =j+ min(c,k-j);
            fake[l]=(fake[l]+dp[j])%MOD;
        if(r+1<=k)
            fake[r+1]=(fake[r+1]-dp[j]+MOD)%MOD;
        }
        ll s =0;
        for(ll j=0;j<=k;j++) {
            s=(s+fake[j])%MOD;
            dp[j]=(dp[j]+s)%MOD;
   //         cout<<s<<" "<<dp[j]<<endl;
        }
    }
   cout<<dp[k];
    // ������ ������

}


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

int main(){
	bool is_prime[1000000]={};
	vector<int> prime;
	for(int i=2;i<1000000;i++){
		if(is_prime[i]) continue;
		prime.push_back(i);
		for(int j=1;i*j<1000000;j++){
			is_prime[i*j] = true;
		}
	}

	int N;
	while(cin>>N,N){
		int ans = 0;
		bool used[1000000] = {};
		for(int i=0; i<prime.size() && prime[i]<N; i++){
			if(used[prime[i]]) continue;
			vector<int>::iterator itr = lower_bound(prime.begin(),prime.end(),N-prime[i]);
			if(itr != prime.end() && prime[i]+*itr == N){
				used[prime[i]] = used[*itr] = true; ans++;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3488
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

signed main(){
  int N;
  cin >> N;
  int tmp,res=0,ans=0;
  cin >> tmp;
  rep(i,N-1){
    int h;
    cin >> h;
    if(h<=tmp){
      res++;
      chmax(ans,res);
    }
    else res=0;
    tmp=h;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define gc getchar_unlocked
#define foi(i,n) for(int i=0;i<n;i++)
#define Foi(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define fol(i,n) for(ll i=0;i<n;i++)
#define Fol(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pl;
typedef vector<int>     vi;
typedef vector<ll>      vl;
typedef vector<pii>     vpii;
typedef vector<pl>      vpl;
typedef vector<vi>      vvi;
typedef vector<vl>      vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
    }
    return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
        g[u-1].pb(v-1);
        g[v-1].pb(u-1);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int k;
    cin>>k;
    string s;
    cin>>s;
    if(k>=s.length())
        cout<<s<<"\n";
    else
    {
        cout<<s.substr(0,k)+"...\n";
    }
    
    return 0;
}

Measured memory_bytes: 10688
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let n : f64 = get_one();
    let k = ((-1_f64 + (1_f64 + 8_f64*n).sqrt()) / 2_f64).ceil();
    println!("{}", k);
}


Measured memory_bytes: 4352
n = int(input())
nums = []
for _ in range(n):
  nums.append(list(map(int, input().split())))

dp = nums[0]

for i in range(1, n):
  dp[0], dp[1], dp[2] = max(dp[1], dp[2]) + nums[i][0], max(dp[0], dp[2]) + nums[i][1], max(dp[0], dp[1]) + nums[i][2]

print(max(dp))

Measured memory_bytes: 63064
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
inline T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template<class T>
inline T LCM(T a, T b) { return (a + (b - 1)) / b; }
template<class T>
inline T round_int(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

class mint {
    ll x; // typedef long long ll;
public:
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }

    friend ostream& operator<<(ostream& s, const mint& x) {
        return s << x.x;
    }
};

void add(ll& a, ll b) {
    a += b;
    if (a >= mod) a -= mod;
}

ll dp[210000][5];

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

    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;

    rep(i, s.size()) {
        rep(j, 5) {
            if (s[i] != '?') add(dp[i + 1][j], dp[i][j]);
            else add(dp[i + 1][j], dp[i][j] * 3 % mod);
        }
        if (s[i] == 'A' || s[i] == '?') add(dp[i + 1][1], dp[i][0]);
        if (s[i] == 'B' || s[i] == '?') add(dp[i + 1][2], dp[i][1]);
        if (s[i] == 'C' || s[i] == '?') add(dp[i + 1][3], dp[i][2]);
    }
    cout << dp[s.size()][3] << endl;
}

Measured memory_bytes: 8704
#include<bits/stdc++.h>
#define MAX_N 55
using namespace std;
char mapp[MAX_N][MAX_N];
int n, m, cnt;
int dist[MAX_N][MAX_N];
struct node{
	int x, y;
}q[MAX_N*MAX_N];
bool pd[MAX_N][MAX_N];
const int r[]={1,-1,0,0}, w[]={0,0,1,-1};
inline void BFS(int sx, int sy){
	int hd, tl, dx, dy, fx, fy;
	hd=tl=1;
	q[1].x=sx;
	q[1].y=sy;
	while(hd<=tl){
		fx=q[hd].x;
		fy=q[hd].y;
		hd++;
		for(int i=0;i<4;++i){
			dx=fx+r[i];
			dy=fy+w[i];
			if(dx<1||dy<1||dx>n||dy>m||mapp[dx][dy]=='#'||pd[dx][dy]==1) continue;
			pd[dx][dy]=1;
			tl++;
			q[tl].x=dx;
			q[tl].y=dy;
			dist[dx][dy]=dist[fx][fy]+1;
			if(dx==n&&dy==m) return ;
		}
	}
}
int main(){
	memset(dist,127/3,sizeof dist);
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			cin>>mapp[i][j];
			if(mapp[i][j]=='#') cnt++;
		}
	}
	dist[1][1]=1;
	pd[1][1]=1;
	BFS(1,1);
	int ans=n*m-cnt-dist[n][m];
	if(ans<0) puts("-1");
	else printf("%d",ans);
   return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<pair<int,pii>,vector<pair<int,pii> >,greater<pair<int,pii> > >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<string,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main() 
{ 
    fast;
    int n;cin>>n;
    int *arr=new int[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int ans=1e18;
    for(int i=0;i<=101;i++)
    {
        int cur=0;
        for(int j=0;j<n;j++)
            cur+=(arr[j]-i)*(arr[j]-i);

        ans=min(ans,cur);
    }
    cout<<ans;
} 

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int c[110];
int ret[110];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++)scanf("%d",c+i);
	for(int i=0;i<b;i++){
		for(int j=0;j<a;j++){
			int d;scanf("%d",&d);
			if(d==c[i])ret[j]++;
			else ret[c[i]-1]++;
		}
	}
	for(int i=0;i<a;i++)printf("%d\n",ret[i]);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
string S; int Q, i, a, b, d=0, N, l, r; char c, ans; cin >> S >> Q;
N=S.size(); S=string(1e6,'0')+S+string(1e6,'0');
l=1e6-1; r=1e6+N;
for(i=0; i<Q; i++){
cin >> a;
if(a==1){ d=(d+1)%2; }
else{ 
  cin >> b >> c;
if(b==1){ if(d==0){ S[l]=c; l--; }else{ S[r]=c; r++; } }
else{ if(d){ S[l]=c; l--; }else{ S[r]=c; r++; } }
N++;
}
}
string T="";
if(d){ for(i=r-1; i>l; i--){ T+=S[i]; } }
else{ for(i=l+1; i<r; i++){ T+=S[i]; } }
cout << T << "\n";
}

Measured memory_bytes: 5368
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    var other = 0
    val size = (1..n).map {
        when (sc.nextInt()) {
            in 1..399 -> 1
            in 400..799 -> 2
            in 800..1199 -> 3
            in 1200..1599 -> 4
            in 1600..1999 -> 5
            in 2000..2399 -> 6
            in 2400..2799 -> 7
            in 2800..3199 -> 8
            else -> {
                other++
                0
            }
        }
    }.toSet().filterNot { it == 0 }.size

    println("${Math.max(1, size)} ${size + other}")
}


Measured memory_bytes: 29600
var lines = [];
var result = 0;
var readline = require('readline');
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    N = Number(lines[0]);
    A = lines[1].split(" ").map(value => Number(value));

    var x = Array(N - 1).fill(0); x[0] = A[0];
    for (var i = 1; i < N; i++) {
        x[i] = gcd(x[i - 1], A[i]);
    }

    var y = Array(0).fill(0); y[N - 1] = A[N - 1]
    for (var i = N - 2; 0 <= i; i--) {
        y[i] = gcd(y[i + 1], A[i]);
    }

    result = Math.max(y[1], result);

    for (var i = 0; i < N - 2; i++) {
        var m = x[i]
        var n = y[i + 2]

        result = Math.max(gcd(m, n), result);
    }

    result = Math.max(x[N - 2], result);

    console.log(result);
});

function gcd(a, b) {
    r = a % b;
    if (r === 0) { return (b); }
    else { return (gcd(b, r)); }
}

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

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

#ifdef LOCAL
#include "pretty.h"
void debug_out() { cerr << endl; }
template <typename head, typename... body>
void debug_out(head H, body... T) {
	cerr << ' ' << H << ' ';
	debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

const int nax = 2e5 + 10;

vector<int> edge[nax], col[2], b[3];
int p[nax];
int N;

void dfs(int vertex, int parent, int parity) {
	col[parity].push_back(vertex);
	for (int child : edge[vertex])
		if (child != parent) dfs(child, vertex, parity ^ 1);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> N;
	for (int u, v, i = 1; i < N; ++i) {
		cin >> u >> v;
		--u, --v;
		edge[u].push_back(v);
		edge[v].push_back(u);
	}
	dfs(0, 0, 0);
	debug(col[0]);
	debug(col[1]);
	if (col[0].size() > col[1].size()) swap(col[0], col[1]);

	for (int i = 1; i <= N; ++i)
		b[i % 3].push_back(i);

	if ((int)col[0].size() <= (int)b[0].size()) {
		for (int v : col[0]) {
			p[v] = b[0].back();
			b[0].pop_back();
		}
		for (int v : col[1]) {
			int k = 0;
			while (b[k].empty()) ++k;
			p[v] = b[k].back();
			b[k].pop_back();
		}
		for (int i = 0; i < N; ++i)
			cout << p[i] << ' ';
		return 0;
	}
	for (int t = 0; t < 2; ++t) {
		for (int v : col[t]) {
			int k = t + 1;
			if (b[k].empty()) k = 0;
			p[v] = b[k].back();
			b[k].pop_back();
		}
	}
	for (int i = 0; i < N; ++i)
		cout << p[i] << " \n"[i == N - 1];
}

Measured memory_bytes: 24304
#include<cstdio>
int n,a[103],b[103];
int main()
{
    scanf("%d",&n);
    for (int i = 0; i < n; i++)
        scanf("%d%d",a+i,b+i);
    n--;
    int judge=0;
    for (int i = 1; i < n; i++)
    {
        if (a[i-1] == b[i-1] && a[i] == b[i] && a[i+1] == b[i+1])
        {
            judge=1;
            break;
        }
    }
    if(judge)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
#define matrix vector< vector<ll> >
const int N = (int)1e5+10 ;
const int M = (int)1000000007; 

int n ;
ll k ;
matrix multiply(matrix a ,matrix b ){
    matrix res(n ,vector<ll>(n , 0 )) ;
    for(int i=0 ; i<n ; i++){
        for(int j=0 ; j<n ; j++){
            for(k=0 ; k<n ; k++){
                 res[i][j] =  (res[i][j]  + a[i][k] * b[k][j] )%M  ;
            }
        }
    }

    return res ;
}

matrix power(matrix a , ll k ){
     matrix res(n ,vector<ll>(n)) ;
     if(k==1){
        for(int i=0 ; i<n ; i++){
            for(int j=0 ; j<n ; j++){
                 res[i][j] = a[i][j] ;
            }
        }
        return res ;
     }

     res = power( a , k/2 ) ;
     res = multiply( res , res ) ;

     if(k%2) res = multiply( res , a ) ;
     return res ;
}


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

    cin >> n >> k ;
    int i , j ;
    matrix a(n , vector<ll>(n)) ;
    matrix po(n , vector<ll>(n)) ;
    for(i=0 ; i<n ; i++){
        for(j=0 ; j<n ; j++){
             cin >> a[i][j] ;
        }
    }  
    po = power( a , k ) ;
    ll ans = 0 ;
    for(i=0 ; i<n ; i++){
        for(j=0 ; j<n ; j++){
            //cout << po[i][j] << " " ;
            ans = (ans + po[i][j] )%M ;
        }
        //cout << endl ;
    }

    cout << ans ;

    return 0 ;
}

Measured memory_bytes: 2944
from collections import Counter
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

A,B = map(int,input().split())
p1 = Counter(prime_decomposition(A))
p2 = Counter(prime_decomposition(B))
ans = 1
for p,_ in p1.items():
  if p2[p] > 0:
    ans += 1

print(ans)

Measured memory_bytes: 38896
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(void){
  ll n; cin >> n;
  map<ll,ll> q1;
  rep(i,n){
    ll x; cin >> x;
    q1[x]++;
  }
  ll m; cin >> m;
  map<ll,ll> q2;
  rep(i,m){
    ll x; cin >> x;
    q2[x]++;
  }

  bool ans = true;

  for(auto q : q2){
    if(q1[q.first]<q.second) ans = false;
  }

  if(ans) puts("YES");
  else puts("NO");

}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vpl vector<pair<long long,long long>>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
long long MOD = 1000000007;
const long double pi = 3.1415926535897932;
#define pb push_back
#define mp make_pair
#define mt make_tuple
using Grid = vector<vector<char>>;
#define vc vector<char>
//(mod m)でのaの逆元を計算する
//a/b(mod m)=a(mod m)*modinv(b,m)
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll H,W,K;
    cin>>H>>W>>K;
    Grid G(W,vc(H));
    ll sx,sy;
    rep(i,H){
        rep(j,W){
            cin>>G[j][i];
            if(G[j][i]=='S'){
                sx=j;
                sy=i;
            }
        }
    }
    ll dist=INF;
    vector<vector<bool>> visit(W,vector<bool>(H,false));
    queue<pll> q;
    pll w=mp(sx,sy);
    q.push(w);
    visit[sx][sy]=true;
    map<pll,ll> D;
    D[w]=0;
    ll dx[4]={1,0,-1,0};
    ll dy[4]={0,1,0,-1};
    while (!q.empty())
    {
        pll P=q.front();
        q.pop();
        ll x=P.first;
        ll y=P.second;
        dist=min({dist,x,W-x-1,y,H-y-1});
        if(D[P]==K) continue;
        rep(i,4){
            ll nx=x+dx[i];
            ll ny=y+dy[i];
            if(nx<0||ny<0||ny>H-1||nx>W-1||visit[nx][ny])continue;
            if(G[nx][ny]=='.'){
            if(nx==0||nx==W-1||ny==H-1||ny==0){
                cout<<1<<endl;
                return 0;
            }else{
                pll p=mp(nx,ny);
                q.push(p);
       	        visit[nx][ny]=true;
                D[p]=D[P]+1;
            }
            }
        }
    }
    cout<<1+(dist+K-1)/K<<endl;
}


Measured memory_bytes: 4480