akhauriyash/Code-Regression huggingface dataset:
// Problem : A - Triangle
// Contest : AtCoder - AtCoder Grand Contest 036
// URL : https://atcoder.jp/contests/agc036/tasks/agc036_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

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

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	ll s;
	cin>>s;
	ll x2=1000000000;
	ll y3,x3;
	x3=(x2-s%x2)%x2;
	y3=(s+x3)/x2;
	cout<<0<<" "<<0<<" "<<x2<<" "<<1<<" "<<x3<<" "<<y3;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

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

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


int main() {
  ios:: sync_with_stdio(false);
  cin.tie();
  int mx = 0;
  int n;
  cin >> n;
  int ans = 0;
  for (int i= 0; i < n; i++) {
    int x;
    cin >> x;
    ans += x >= mx;
    mx = max(mx, x);
  }
  cout << ans;
  return 0;
}




Measured memory_bytes: 3608
import java.util.Scanner;

class Main{
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int div = 0;
		for (char c : S.toCharArray()) {
			div += Character.getNumericValue(c);
		}
		
		System.out.println(Integer.parseInt(S) % div == 0 ? "Yes": "No");
	}
	
}

Measured memory_bytes: 21844
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long int lnt;
typedef pair<lnt,lnt> P;
string str;
lnt s[100000];
//priority_queue<lnt,vector<lnt>,greater<lnt>> mae[26];
//priority_queue<lnt> usi[26];
lnt k;
int main()
{
	cin>>str;
	lnt n=str.size();
	cin>>k;
	for(lnt i=0;i<str.size();i++){
		s[i]=str[i]-'a';
	}
	for(lnt i=0;i<n;i++){
		if(s[i]==0) continue;
		if(26-s[i]<=k){
			k-=(26-s[i]);
			s[i]=0;
		}
	}
	s[n-1]=(s[n-1]+k)%26;
	for(lnt i=0;i<n;i++){
		printf("%c",'a'+s[i]);
	}
	printf("\n");
}

Measured memory_bytes: 1308
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define tcase int _; cin >> _; while(_--)
const int MOD = 1e9+7;
const int MAX = 1e6;

int n;

void solve() {
	cin >> n;
	int ans=0;
	for(int i=1; i <= n; i++) {
		for(int j=1; i*j < n; j++) {
			ans++;
			// cout << i << " " << j << "\n";
		}
	}
	cout << ans << "\n";
}

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

 	solve();

  	return 0;
}



Measured memory_bytes: 3608
#include<stdio.h>

int main(){
	int i,j,ice[10],num,b;

	do{
		scanf("%d",&num);
		if(!num) break;
		for(i=0;i<10;i++) ice[i]=0;
		for(i=0;i<num;i++){
			scanf("%d",&b);
			ice[b]++;
		}
		for(i=0;i<10;i++){
			if(!ice[i]) printf("-");
			for(j=0;j<ice[i];j++) printf("*");
			printf("\n");
		}
	}while(1);
	return 0;
}

Measured memory_bytes: 0
// ABC143_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <cstring>  // std::memset 初期化
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> pll;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N;
    cin >> N;
    vector<ll> vec(N);
    REP(i, N) cin >> vec[i];
    
    // calculation
    ll sum = 0;
    REP(i, N) REP(j, N) {
        if (i == j) continue;
        sum += vec[i]*vec[j];
    }
    cout << sum/2 << "\n";
    
    return 0;
}

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

using namespace std;

int main()
{
   int n,m;
   cin>>n>>m;
   if(n==m){
       cout<<"Yes"<<endl;
   }
   else{
       cout<<"No"<<endl;
   }
   return 0;
}

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

vector<int> edges[100000];

int dp[100000];

void dfs(int i, int p){
    int sum = 0, zero = 0;
    for(int j : edges[i]){
        if(j == p) continue;
        dfs(j, i);
        sum += dp[j];
        if(dp[j] == 0) zero++;
    }
    dp[i] = sum;
    if(zero > 0) dp[i] += zero - 1;
}

int main(){
    int N;
    cin >> N;
    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    for(int i=0; i<N; i++) if(edges[i].size() >= 3){ 
        dfs(i, -1);
        cout << dp[i] << endl;
        return 0;
    }
    cout << 1 << endl;
    return 0;
}


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;
#define MAXN 101010
using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 
	int n;
	cin >> n;
	vector<pii> v;
	priority_queue<pii , vector<pii> , less<pii>> pq;
	vi tmp(MAXN , 0);
	rep(i , n){
		int x;
		cin >> x;
		++tmp[x];
	}
	rep(i , MAXN){
		if(tmp[i]){
			pq.push({tmp[i] , i});
			//v.pb({tmp[i] , i});
		}
	}
	int ans = 0;
	rep(i , n){
		pii top1 = pq.top();
		if(top1.fi == 1)break;
		pq.pop();
		if(sz(pq) == 0)dier(1);
		
		pii top2 = pq.top();
		pq.pop();
		if(top1.fi <= 1)break;
		if(top2.fi == 0)break;
		--top1.fi;
		--top2.fi;
		pq.push(top1);
		if(top2.fi)pq.push(top2);
	}
/*	while(sz(pq)){
		pii cur = pq.top();
		pq.pop();
		if(cur.fi == 1)++ans;
		else break;
	}*/
	die(sz(pq));
	return 0;
}

Measured memory_bytes: 1784
#include <string>
#include <vector>



constexpr unsigned int bases[64] = {
  257,262,266,275,276,281,285,290,
  296,302,306,310,311,313,323,333,
  344,345,350,357,367,370,373,402,
  423,425,431,440,442,443,454,457,
  458,462,471,478,481,487,489,492,
  499,501,502,503,506,514,524,532,
  535,541,550,552,557,559,562,563,
  567,570,571,580,592,597,604,612
};
constexpr unsigned int seconds() {
  const char* t = __TIME__;
  unsigned int s = (t[6]-'0')*10 + (t[7]-'0');
  return s;
}

struct RollingHash {
  using size_t = std::size_t; using ull = unsigned long long; using uint = unsigned int;
  static constexpr ull mod = (1ull<<61)-1, m30 = (1ull<<30)-1, m31 = (1ull<<31)-1;
  static constexpr ull pos = mod*((1ull<<3)-1);
  static constexpr ull mul(ull l, ull r) {
    ull lu = l>>31, ld = l&m31, ru = r>>31, rd = r&m31; ull mid = ld*ru + lu*rd;
    return ((lu*ru)<<1) + ld*rd + ((mid&m30)<<31) + (mid>>30);
  }
  static constexpr ull mul(ull l, uint r) {
    ull lu = l>>31, rd = r&m31; ull mid = lu*rd;
    return (l&m31)*rd + ((mid&m30)<<31) + (mid>>30);
  }
  static constexpr ull calc_mod(ull val) {
    val = (val&mod)+(val>>61); if(val>mod) val -= mod;
    return val;
  }

  static constexpr uint base = bases[seconds()];
  std::vector<ull> power, hashed;
  size_t n;

  RollingHash() {}
  RollingHash(std::string const& s) { init(s); }

  void init(std::string const& s) {
    n = s.size();
    hashed.assign(n+1, 0);
    power.assign(n+1, 0);
    power[0] = 1;
    for(size_t i=0;i<n;++i) {
      power[i+1] = calc_mod(mul(power[i], base));
      hashed[i+1] = calc_mod(mul(hashed[i], base) + s[i]);
    }
  }

  ull get(size_t l, size_t r) const {
    return calc_mod(hashed[r] + pos - mul(hashed[l], power[r-l]));
  }

  ull connect(ull h1, ull h2, size_t h2len) const {
    return calc_mod(mul(h1, power[h2len]) + h2);
  }
  void connect(std::string const& s) {
    size_t m = s.size();
    hashed.resize(n+m+1);
    power.resize(n+m+1);
    for(size_t i=n;i<n+m;++i) {
      power[i+1] = calc_mod(mul(power[i], base));
      hashed[i+1] = calc_mod(mul(hashed[i], base) + s[i-n]);
    }
    n += m;
  }

  size_t get_lcp(RollingHash const& b, size_t l1, size_t r1, size_t l2, size_t r2) {
    size_t len = (r1-l1<r2-l2?r1-l1:r2-l2);
    size_t ok=0, ng=len+1;
    while(ng-ok>1) {
      size_t mid = ((ng-ok)>>1)+ok;
      if(this->get(l1, l1+mid) == b.get(l2, l2+mid)) ok = mid;
      else ng = mid;
    }
    return ok;
  }
};



#include <iostream>

void abc141_e() {
  using namespace std;
  size_t N; string S;
  cin >> N >> S;
  RollingHash rh(S);
  size_t ans = 0;
  for(size_t i=0;i<N;++i) for(size_t j=0;j<i;++j) {
    size_t l = rh.get_lcp(rh, i, N, j, N);
    if(l > i-j) l = i-j;
    if(ans < l) ans = l;
  }
  cout << ans << '\n';
}

signed main() {

  abc141_e();

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;
constexpr i64 MOD = 1e9 + 7;
 
int main() {
    string s;
    cin >> s;
    int D;
    cin >> D;
    vector<vvi> dp(s.size() + 1, vvi(2, vi(D)));
    dp[0][0][0] = 1;
    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k < D; k++) {
                for (int d = 0; d <= (j ? 9 : s[i] - '0'); d++) {
                    dp[i + 1][j | (d < s[i] - '0')][(k + d) % D] += dp[i][j][k];
                    dp[i + 1][j | (d < s[i] - '0')][(k + d) % D] %= MOD;
                }
            }
        }
    }
    cout << (dp[s.size()][0][0] + dp[s.size()][1][0] - 1 + MOD) % MOD << endl;
}

Measured memory_bytes: 17024
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    bool check=false,bcheck=false;
    if (s[0]!='A' || s[s.size()-1]=='C'){
        cout<<"WA";
        return 0;
    }
    int x=s.size(),counter=0,bcounter=0;
    for (int i=2;i<x-1;i++){
        if (s[i]=='C')
            counter++;
        if (isupper(s[i]))
            bcounter++;
    }
    if (isupper(s[s.size()-1]) || isupper(s[1])){
        cout<<"WA";
        return 0;
    }
    if (counter==1 && bcounter==1)
        cout<<"AC";
    else
        cout<<"WA";

    return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)
typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\01.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;


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

    for (int i = 0; i < 3; i++) {
        if (s[i] == '1') {
            s[i] = '#';
        }
    }

    for (int i = 0; i < 3; i++) {
        if (s[i] == '9') {
            s[i] = '1';
        }
    }

    for (int i = 0; i < 3; i++) {
        if (s[i] == '#') {
            s[i] = '9';
        }
    }
    cout << s << endl;

}


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

int main(){
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    for(int i=0; i<(int)s.size(); i++){
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    for(auto& line:s){
        cout << line;
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

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

		boolean allnegs = true;
		boolean allposs = true;

		int min = 0;
		int max = 0;
		for(int i = 0; i < n; ++i) {
			arr[i] = in.nextInt();

			if(arr[i] < 0)
				allposs = false;
			else if(arr[i] >= 0)
				allnegs = false;

			if(arr[min] > arr[i])
				min = i;
			if(arr[max] < arr[i])
				max = i;
		}



		ArrayList<Pair> li = new ArrayList();
		if(allnegs) {
			for(int i = n - 1; i > 0; --i) {
				li.add(new Pair(i , i - 1));
			}
		} else if(allposs) {
			for(int i = 1; i < n; ++i) {
				li.add(new Pair(i -1, i));
			}
		} else {
			if(Math.abs(arr[min]) <= arr[max]) {
				for(int i = 0; i < n; ++i) 
					if(i != max)
						li.add(new Pair(max, i));
				for(int i = 1; i < n; ++i) {
					li.add(new Pair(i - 1 , i));
				}
			} else {
				for(int i = 0; i < n; ++i) 
					if(i != min)
						li.add(new Pair(min, i));

				for(int i = n - 1; i > 0; --i) {
					li.add(new Pair(i , i - 1));
				}
			}
		}

		System.out.println(li.size());
		for(Pair p : li) {
			System.out.println(p);
		}
	}

	private static class Pair {
		int f, s;

		public Pair(int f, int s) {
			this.f = f;
			this.s = s;
		}

		@Override
		public String toString() {
			return (f+1)+" "+(s+1);
		}
	}

}


Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <string>
bool fill_with(std::vector<int> &vec, int start, int a, int b, int upper , int lower) {
	//std::cout << start << "," << a << " => " << upper << "," << b << " => " << lower << std::endl;
	if (a <= 0) return start == vec.size();
	if (vec.size() - start < a) a = vec.size() - start;
	for (auto i = 0; i < a && start < vec.size(); ++i) {
		vec[start++] = upper - a + i + 1;
	}
	if (b <= 0) return start == vec.size();
	if (vec.size() - start < b) b = vec.size() - start;
	for (auto i = 0; i < b && start < vec.size(); ++i) {
		vec[start++] = lower + b - i - 1;
	}
	return fill_with(vec, start, a - 1, b - 1, upper - a, lower + b);
}
int main() {
	int n, a, b;
	std::cin >> n >> a >> b;
	if (n < a + b - 1) std::cout << -1 << std::endl;
	else {
		std::vector<int> series(n);
		if (fill_with(series, 0, a, b - 1, n, 1)) {
			for (auto i = 0; i < n - 1; ++i) {
				std::cout << series[i] << ' ';
			}
			std::cout << series[n - 1] << std::endl;
		}
		else {
			std::cout << -1 << std::endl;
		}
	}
}

Measured memory_bytes: 3328
from fractions import gcd


class SegmentTree():
    _data = []
    _offset = 0
    _size = 0

    def __init__(self, size):
        _size = size
        t = 1
        while t <= size:
            t *= 2
        self._offset = t - 1
        self._data = [0] * (t * 2 - 1)

    def update_all(self, iterable):
        self._data[self._offset:self._offset+self._size] = iterable
        for i in range(self._offset - 1, -1, -1):
            self._data[i] = gcd(self._data[i * 2 + 1], self._data[i * 2 + 2])

    def update(self, index, value):
        i = self._offset + index
        self._data[i] = value
        while i >= 1:
            i = (i - 1) // 2
            self._data[i] = gcd(self._data[i * 2 + 1], self._data[i * 2 + 2])

    def query(self, start, stop):
        result = 0
        l = start + self._offset
        r = stop + self._offset
        while l < r:
            if l & 1 == 0:
                result = gcd(result, self._data[l])
            if r & 1 == 0:
                result = gcd(result, self._data[r - 1])
            l = l // 2
            r = (r - 1) // 2
        return result

N = int(input())
A = list(map(int, input().split()))

st = SegmentTree(N)
st.update_all(A)

result = st.query(1, N)
for i in range(1, N - 1):
    result = max(result, gcd(st.query(0, i), st.query(i + 1, N)))
result = max(result, st.query(0, N - 1))
print(result)


Measured memory_bytes: 16140
n,k=gets.split.map &:to_i
a=$<.map{|e|e.split.map &:to_i}.sort_by{|e|-e[1]}
cnt=Hash.new 0
s=0
have=[]
k.times{|i|
	e=a.shift
	s+=e[1]
	cnt[e[0]]+=1
	have<< e
}
r=s+cnt.size**2
remove_idx=k-1
a.each{|e|
	break if cnt.size==k
	next if cnt.has_key?(e[0])
	remove_idx = remove_idx.downto(0).find{|i|cnt[have[i][0]]>1}
	s-=have[remove_idx][1]
	cnt[have[remove_idx][0]]-=1
	have.delete_at(remove_idx)
	s+=e[1]
	cnt[e[0]]+=1
	have<< e
	r=[r,s+cnt.size**2].max
}
p r

Measured memory_bytes: 15568
from collections import defaultdict
N, X, M = map(int, input().split())
A = [X]
visited = set()
visited.add(X)

idx = defaultdict()
idx[X] = 0

iii = -1

for i in range(1, M):
    tmp = (A[-1]**2) % M
    if tmp not in visited:
        A.append(tmp)
        visited.add(tmp)
        idx[tmp] = i
    else:
        iii = idx[tmp]

ans = 0

if iii == -1:
    ans = sum(A[:N])
    print(ans)
    exit()
else:
    # ループの頭の直前まで
    ans += sum(A[:iii])
    N -= iii
    if N > 0:
        # ループの長さ
        l = len(A) - iii
        ans += (N // l) * sum(A[iii:])
        N -= N // l * l
    if N > 0:
        # ループに満たないN
        ans += sum(A[iii:iii + N])

    print(ans)


Measured memory_bytes: 85652
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
using namespace std;
using LL = long long;
// 型に合わせた値 2倍してもオーバーフローしないようにする
const int INF = 1e9;
// const LL INF = 1e17;

int main(){
    int D, G;
    cin >> D >> G;
    vector<int> p(D), c(D);
    for(int i=0; i<D; i++){
        cin >> p[i] >> c[i];
    }
    vector<int> v(D);
    iota(all(v), 0);

    int ans = INF;
    do{
        int now = 0, score = 0;
        for(auto i : v){
            if(score + 100*(i+1)*p[i] + c[i] <= G){
                now += p[i];
                score += 100*(i+1)*p[i] + c[i];
            }else{
                int less = G-score;
                if(less == 0) break;
                now += min(p[i], (less-1)/(100*(i+1)) + 1);
                break;
            }
        }
        ans = min(ans, now);
    }while(next_permutation(all(v)));
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
 
struct Node
{
    int key;
    Node *right, *left, *parent;
};
 
Node *root, *NIL;
 
Node *find(Node *root, int key)
{
    while (root != NIL && key != root->key)
    {
        if (key < root->key) root = root->left;
        else root = root->right;
    }
    return root;
}
 
void insert(int key)
{
    Node *y = NIL;
    Node *x = root;
    Node *z;
 
    z = (Node *)malloc(sizeof(Node));
    z->key = key;
    z->left = NIL;
    z->right = NIL;
 
    while (x != NIL)
    {
        y = x;
        if (z->key < x->key) x = x->left;
        else x = x->right;
    }
 
    z->parent = y;
    if (y == NIL) root = z;
    else
    {
        if (z->key < y->key) y->left = z;
        else y->right = z;
    }
}
 
void inorder(Node *root)
{
    if (root == NIL) return;
    inorder(root->left);
    cout << " " << root->key;
    inorder(root->right);
 
}
 
void preorder(Node *root)
{
    if (root == NIL) return;
    cout << " " << root->key;
    preorder(root->left);
    preorder(root->right);
}
 
int main()
{
    int n, key;
    string str;
 
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> str;
        if (str == "find")
        {
            cin >> key;
            Node *t = find(root, key);
            if (t != NIL) cout << "yes" << endl;
            else cout << "no" << endl;
        }
        else if (str == "insert")
        {
            cin >> key;
            insert(key);
        }
        else if (str == "print")
        {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }
}

Measured memory_bytes: 21908
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  double R;
  std::cin >> R;
  std::cout << std::fixed << std::setprecision(20) << 2 * std::acos(-1) * R << std::endl;
  return 0;
}

Measured memory_bytes: 3772
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    string S, T;
    cin >> S >> T;

    rep(i, 26) {
        if (S + char('a' + i) == T) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;


class Main {
	static int n,m,a;
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String[] ss = in.readLine().split(" ");
			n = Integer.parseInt(ss[0]);
			m = Integer.parseInt(ss[1]);
			a = Integer.parseInt(ss[2]);
			if(n == 0){
				break;
			}
			ArrayList<String> yoko = new ArrayList<String>();
			for(int i = 0; i < m ;i++){
				yoko.add(in.readLine());
			}
			Collections.sort(yoko, new YokoComparator());
			for(String s : yoko){
				String[] sss = s.split(" ");
				if(a == Integer.parseInt(sss[1])){
					a = Integer.parseInt(sss[2]);
				}
				else if(a == Integer.parseInt(sss[2])){
					a = Integer.parseInt(sss[1]);
				}
			}
			System.out.println(a);
		}	

	}

}
class YokoComparator implements Comparator<String> { 
	@Override 
	public int compare(String s1, String s2) {
		return Integer.parseInt(s1.split(" ")[0]) < Integer.parseInt(s2.split(" ")[0]) ? 1 : -1; 
	} 
} 

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

using namespace std;

int main(int argc, char *argv[]) {
    int N;
    cin >> N;
    vector<int> arr(N);
    for (int i = 0; i < N; i++) {
        cin >> arr[i];
    }

    sort(arr.begin(), arr.end());
    int border = arr[(N / 2) - 1] + 1;
    int arcstart = arr[(N / 2)];

    int ans = arcstart - border + 1;
    if (ans < 1) {
        ans = 0;
    }
    cout << ans << endl;
    return 0;
}


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


int main() {

  long long int m, k;
  cin >> m >> k;

  if ( m == 0 ) {
    if ( k == 0 ) {
      cout << "0 0" << endl;
    } else {
      cout << -1 << endl;
    }
    return 0;
  }

  if ( m == 1 ) {
    if ( k == 0 ) {
      cout << "0 0 1 1" << endl;
    } else {
      cout << -1 << endl;
    }
    return 0;
  }

  long long int n = 1LL << m;

  if ( k >= n ) {
    cout << -1 << endl;
    return 0;
  }
  cout << k;
  for ( long long int i = 0; i < n; i++ ) {
    if ( i == k ) continue;
    cout << " " << i;
  }
  cout << " " << k;
  for ( long long int i = n - 1; i >= 0; i-- ) {
    if ( i == k ) continue;
    cout << " " << i;
  }
  cout << endl;

  return 0;

}


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

ll ans = 0;
vector<ll> v;

void f(ll i, ll j, ll k) {
	if (i == j && j == k) {
		if (v[i] >= 74)++ans;
	}
	else if (i == j) {
		if (v[i] >= 14 && v[k] >= 4)++ans;
	}
	else if (i == k) {
		if (v[i] >= 14 && v[j] >= 4)++ans;
	}
	else if(j==k) {
		if (v[i] >= 2 && v[j] >= 24)++ans;
	}
	else {
		if (v[i] >= 2 && v[j] >= 4 && v[k] >= 4)++ans;
	}
}

int main() {
	ll n;
	cin >> n;
	map<ll, ll> prime;
	for (ll i = 2; i <= n; ++i) {
		ll a = i;
		for (ll j = 2; j <= a; ++j) {
			while (a % j == 0) {
				++prime[j];
				a /= j;
			}
		}
	}
	for (auto p : prime)v.push_back(p.second);
	sort(v.begin(), v.end());
	for (ll i = 0; i < v.size(); ++i) {
		for (ll j = 0; j < v.size(); ++j) {
			for (ll k = j; k < v.size(); ++k) {
				f(i, j, k);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3612
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    n,k = mi()
    a = []
    for i in range(k):
        d = ii()
        atmp = li()
        a.append(atmp)

    ans = [1 for i in range(n+1)]
    ans[0] = 0

    for _ in range(k):
        for i in a[_]:
            ans[i] = 0
    print(sum(ans))


main()




Measured memory_bytes: 10064
#include<stdio.h>
#include<ctype.h>
#include<string.h>

int main(){
  char input[1000];
  char key[10];
  int count = 0;
  scanf("%s", key);
  while(1){
      scanf("%s", input);
      if(strcmp(input, "END_OF_TEXT") == 0) {
          break;
      }
      for(int i = 0; input[i] != '\0'; i++){
          input[i] = tolower(input[i]);
      }
      if(strcmp(input, key) == 0){
          count++;
      }
  }
  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 2108
from collections import deque


N, M = map(int,input().split())
mymap = [ [] for n in range(N) ]
for m in range(M):
    a, b = map(int, input().split())
    mymap[a-1].append(b-1)
    mymap[b-1].append(a-1)
#print(mymap)
myans = 0
check_list = [0 for n in range(N)]

for n in range(N):
    mylist = mymap[n]
    #print(mylist)
    myd = deque()
    for mm in mylist:
        myd.append(mm)
    #print(myd)
    mycnt = 1
    check_list[n] = 1
    while myd:
        tgt = myd.popleft()
        #print(tgt)
        if check_list[tgt] == 0 :
            for e in mymap[tgt]:
                if e > n :
                    myd.append(e)
            mycnt += 1
            check_list[tgt] = 1
    if myans < mycnt:
        myans = mycnt
print(myans)

Measured memory_bytes: 44840
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=sum(b)
for i in range(n-1):
  if a[i+1]==a[i]+1:
    ans+=c[a[i]-1]
print(ans)

Measured memory_bytes: 3064
X, Y = map(int, input().split())
award = 0
if X == 1:
    award += 300000
elif X == 2:
    award += 200000
elif X == 3:
    award += 100000

if Y == 1:
    award += 300000
elif Y == 2:
    award += 200000
elif Y == 3:
    award += 100000
    
if X == 1 and Y == 1:
    award += 400000
    
print(award)

Measured memory_bytes: 3064
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define REP_IN(i, n, x) for (ll i = 0; i < n; i++)in>>x;
#define REP_OUT(i, n, x) for (ll i = 0; i < n; i++)out<<x<<endl;
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
#define endl '\n'
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    //vector<ll> X(N);
    string s;
    in >> s;
    //vector<string> s;
    //s.resize(N);
    //ll N;
    //in >> N;
    
    ll ans=0; 

    if(s[1]=='B'){
        out<<"ARC"<<endl;
    }else{
        out<<"ABC"<<endl;
    }

    
    
    
}

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

int main() {
  vector<vector<int> > v(4, vector<int>(13));
  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 13; ++j) {
      v.at(i).at(j) = 0;
    }
  }

  int num;
  cin >> num;

  for (int i = 0; i < num; ++i) {
    int n;
    char s;
    cin >> s >> n;
    if (s == 'S') {
      v.at(0).at(n - 1) = 1;
    }
    if (s == 'H') {
      v.at(1).at(n - 1) = 1;
    }
    if (s == 'C') {
      v.at(2).at(n - 1) = 1;
    }
    if (s == 'D') {
      v.at(3).at(n - 1) = 1;
    }
  }

  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 13; ++j) {
      if (v.at(i).at(j) == 0) {
        if (i == 0) {
          cout << "S " << j + 1 <<endl;
        }
        if (i == 1) {
          cout << "H " << j + 1 <<endl;
        }
        if (i == 2) {
          cout << "C " << j + 1 <<endl;
        }
        if (i == 3) {
          cout << "D " << j + 1 <<endl;
        }
      }
    }
  }
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define LL long long

using namespace std;

int n,k,a[105],dp[100005];

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> k;
    for (int i=1;i<=n;i++) cin >> a[i];
    memset (dp,0,sizeof(dp));
    for (int i=1;i<=k;i++) {
        for (int j=1;j<=n;j++) {
            if (a[j]<=i&&dp[i-a[j]]==0) dp[i]=1; 
        }
    }
    //for (int i=1;i<=n;i++) cout << dp[k] << " ";
    if (dp[k]==1) cout << "First" << endl;
    else cout << "Second" << endl;
    return 0;
}


Measured memory_bytes: 640
// instr3.cpp -- reading more than one word with get() & get()
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
void insertionSort(int a[], int n){
    for (int i = 0; i < n; i++){
        for (int j = 0; j < i; j++){
            if (a[i] < a[j]){
                int temp = a[i];
                for (int k = i; k > j; k--){
                    a[k] = a[k-1];
                }
                a[j] = temp;
            }
        }
        for (int q = 0; q < n; q++){
            if (q != n-1)
                cout << a[q] << " ";
            else
                cout << a[q] << endl;
        }
    }


}
int main(){
    int n;
    cin >> n;
    int a[100];
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    insertionSort(a,n);
}



Measured memory_bytes: 3072
#include<bits/stdc++.h>  
#define mod 1000000007
#define mp make_pair
#define pb push_back
 
using namespace std;
typedef long long ll;
 
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	ll n,d;
	cin >> n;
    int ar[n];
    int ind=0,max=0;
    for(int i=0;i<n;i++){
        cin >> ar[i];
        if(ar[i]>max){
            max=ar[i];
            ind=i;
        }
    }
    sort(ar,ar+n);
    for(int i=0;i<n;i++){
        if(i!=ind) cout << max << endl; 
        else cout << ar[n-2] << endl;
    }
    //cout << 3*n*n << endl;
}


Measured memory_bytes: 2432
#include<iostream>
using namespace std;
#define ll long long int
int main()
{
	string s;
	cin>>s;
	ll a=stoi(s.substr(0,2));
	ll b=stoi(s.substr(2,2));
	ll x=0,y=0;
	if(a>=0 and a<=99 and b>0 and b<=12)
	{
		x=1;
	}
	if(b>=0 and b<=99 and a>0 and a<=12)
	{
		y=1;
	}
	if(x==1 and y==1)
	{
		cout<<"AMBIGUOUS";
		return 0;
	}
	if(x==1 and y==0)
	{
		cout<<"YYMM";
		return 0;
	}
	if(x==0 and y==0)
	{
		cout<<"NA";
		return 0;
	}
	if(x==0 and y==1)
	{
		cout<<"MMYY";
		return 0;
	}
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from math import gcd
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gcd
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().rstrip().split()
def S(): return sys.stdin.readline().rstrip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]

mod=10**9+7

n,x,m=LI()
s={x%m:(1,x%m)}
L=[x%m]
now=x%m
cycle=1
ret=x%m
diff=0
pre=0
for i in range(2,m+2):
    now=pow(now,2,m)
    ret += now
    if now in s:
        pre, pre_ret = s[now]
        cycle=i-pre
        diff=ret-pre_ret
        break
    s[now]=(i,ret)


ans=diff*((n-pre)//cycle)+pre_ret
for k in range((n-pre)%cycle):
    now = pow(now, 2, m)
    ans+=now

print(ans)








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

int main()
{
    int ans = 0;
    std::string s;
    std::cin >> s;

    std::pair<int, int> a,b;

    for(int i=0; i<s.size(); i++){
        if(i%2==0){
            if(s[i]=='1')
                a.first++;
            else
                a.second++;
        }else{
            if(s[i]=='1')
                b.first++;
            else
                b.second++;
        }
    }

    std::cout << std::min(a.first+b.second,b.first+a.second) << std::endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>

#define div 1000000000+7

typedef long long ll;

using namespace std;

void solve() {
    int n;
    cin >> n;

    if(n < 2){
        cout << n << endl;
        return;
    }

    int ans = 2;
    while(ans < n){
        ans *= 2;
    }
    if(ans > n){
        ans /= 2;
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


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

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

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

	vector<int> av(n);
	for (auto& a : av) {
		cin >> a;
	}

	vector<int> lv(n);
	lv[0] = av[0];
	for (int i = 1; i < n; ++i) {
		lv[i] = gcd(lv[i-1], av[i]);
	}

	vector<int> rv(n);
	rv[n-1] = av[n-1];
	for (int i = n-2; 0 <= i; --i) {
		rv[i] = gcd(rv[i + 1], av[i]);
	}

	int ret = max(lv[n-1],rv[0]);
	ret = max(ret, rv[1]);
	ret = max(ret, lv[n-2]);
	for (int i = 1; i < n-1; ++i) {
		ret = max(ret, gcd(lv[i-1],rv[i+1]));
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
int main(void){
  double x0,y0,x1,y1,x2,y2,x3,y3;
  while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&x0,&y0,&x1,&y1,&x2,&y2,&x3,&y3)!=EOF){
    if((x1-x0)*(y3-y0)-(x3-x0)*(y1-y0)>0){
      if((x2-x1)*(y0-y1)-(x0-x1)*(y2-y1)<0){
	printf("NO\n");
      }else if((x3-x2)*(y1-y2)-(x1-x2)*(y3-y2)<0){
	printf("NO\n");
      }else if((x0-x3)*(y2-y3)-(x2-x3)*(y0-y3)<0){
	printf("NO\n");
      }else{
	printf("YES\n");
      }
    }else if((x1-x0)*(y3-y0)-(x3-x0)*(y1-y0)<0){
      if((x2-x1)*(y0-y1)-(x0-x1)*(y2-y1)>0){
	printf("NO\n");
      }else if((x3-x2)*(y1-y2)-(x1-x2)*(y3-y2)>0){
	printf("NO\n");
      }else if((x0-x3)*(y2-y3)-(x2-x3)*(y0-y3)>0){
	printf("NO\n");
      }else{
	printf("YES\n");
      }
    }else{
      printf("NO\n");
    }
  }
  return 0;
}

Measured memory_bytes: 1812
mod = 1000000007
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
ans = 1
# 負になってしまう時
if A[-1] < 0 and K%2 == 1:
    for i in range(K):
        ans = ans * (A[-i-1]%mod) % mod
else:
    n = 0
    p = -1
    # Kが奇数の時、正の候補の最大値をあらかじめ消費しておき、偶数の時と同様に処理できるようにする。
    if K%2 == 1:
        ans = ans * (A[p]%mod) % mod
        p -= 1
    # 正/負の候補から２つずつ消費していく
    for _ in range(K//2):
        if A[n]*A[n+1] > A[p]*A[p-1]:
            ans = ans * (A[n]%mod) % mod
            ans = ans * (A[n+1]%mod) % mod
            n += 2
        else:
            ans = ans * (A[p]%mod) % mod
            ans = ans * (A[p-1]%mod) % mod
            p -= 2        

print(ans)

Measured memory_bytes: 104508
use proconio::input;

fn main() {
    input! {
        n: i64,
    };
    let mut s = vec![];
    let mut x = n;
    while x > 0 {
        s.push((((x - 1) % 26) as u8 + b'a') as char);
        x -= 1;
        x /= 26;
    }
    s.reverse();
    println!("{}", s.iter().collect::<String>());
}


Measured memory_bytes: 2192
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string>
#include <cctype>
#include <algorithm>

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

typedef long long ll;

using namespace std;

const int INF = 1e9;
const double PI=3.14159265358979323846;

int main(){
  string s,t; int n;
  cin >> s >> n;
  rep(i,n){
    cin >> t;
    if(t=="replace"){
      int a,b; string u;
      cin >> a >> b >> u;
      for(int j=0; j<b-a+1; j++){
	s[a+j] = u[j];
      }
    }
    else if(t=="reverse"){
      int a,b; string u;
      cin >> a >> b;
      u = s.substr(a,b-a+1);
      reverse(u.begin(), u.end());
      for(int j=0; j<b-a+1; j++){
	s[a+j] = u[j];
      }      
    }
    else if(t=="print"){
      int a,b; string u;
      cin >> a >> b;
      u = s.substr(a,b-a+1);
      cout << u << endl;
    }
  }
}



Measured memory_bytes: 3200
#include <stdio.h>

int main()
{
	int A, B, C, D;
	int start, end;

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

	if(A < C){
		start = C;
	}
	else{
		start = A;
	}

	if(B < D){
		end = B;
	}
	else{
		end = D;
	}

	if(end - start < 0){
		printf("0");
	}
	else{
		printf("%d", end - start);
	}

return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, a, j) for(int i = a; i < j; i++)
#define all(i) i.begin(), i.end()
using namespace std;
struct dat_st { int h, w, num; };
bool compare(const dat_st &t0, const dat_st &t1)
{
    if (t0.num == t1.num)
    {
        return t0.h < t1.h;
    }
    return t0.num < t1.num;
}
int dia(int x, int y)
{
    return x * x + y * y;
}
int main()
{
    vector<dat_st> cul(0);
    rep(h, 1, 151) rep(w, 1, 151)
    {
        if (h < w && h != w) { cul.push_back({ h, w, dia(h, w) }); }
    }
    sort(all(cul), compare);
    int h, w; while (cin >> h >> w, h, w)
    {
        auto p = upper_bound(all(cul), dat_st{ h,w,dia(h,w) }, compare) - cul.begin();
		printf("%d %d\n", cul[p].h, cul[p].w);
    }
}

Measured memory_bytes: 3332
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define Mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"
#define sz               size()
#define inc(i,x,y)      for(int i=x;i<y;i++)
#define dec(i,x,y)      for(int i=x;i>=y;i--)

const int N = 2e5 + 5;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define deb(...)
#endif

void fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
}

//////////////////////////////code//////////////////////////////

int32_t main()
{
  fast();

  int n,k;
  cin>>n>>k;

  vi arr(n+1);

  for(int i=1;i<=n;i++) cin>>arr[i];

  if(k<=n)
  {
      int curr=1;

    while(k--)
        curr=arr[curr];

        cout<<curr;
  }
  else{

    int p1=1,p2=arr[1];

    while(p1!=p2)
    {
        p1=arr[p1];
        p2=arr[arr[p2]];
    }
    int dis=0;

    int curr=1;

    while(curr!=p1)
    {
      dis++;
     curr=arr[curr];
    }
    int cycle = 0;

    curr=arr[p1];
    while(curr!=p1)
    {
        cycle++;
        curr = arr[curr];
    }
    cycle++;

    k-=dis;

    k%=cycle;

    curr=p1;
    while(k--)
     curr=arr[curr];

     cout<<curr;


  }



}


Measured memory_bytes: 4728
import java.util.Scanner;

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

        int ac = 0, wa = 0, tle = 0 , re = 0;
        String str;
        for(int i = 0; i < n; i++){
            str = sc.next();
            if(str.equals("AC")){
                ac++;
            }else if(str.equals("WA")){
                wa++;
            }else if(str.equals("TLE")){
                tle++;
            }else{
                re++;
            }
        }

        System.out.println("AC x " + ac);
        System.out.println("WA x " + wa);
        System.out.println("TLE x " + tle);
        System.out.println("RE x " + re);

        sc.close();

    }
}

Measured memory_bytes: 58536
import math

A, B, H, M = map(int, input().split())

theta = 360 * abs(M / 60 - (H / 12 + M / (60 * 12)))
if theta > 180:
    theta = 360 - theta

print(math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.radians(theta))))


Measured memory_bytes: 9500
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define MOD 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2e9
#define common cout << "Case #" << w+1 << ": "  



int main()
{
    string s;
    cin >> s;
    int c=0,ans=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='R')
            c+=1;
        else
        {
            ans=max(ans,c);
            c=0;
        }
    }
    ans=max(ans,c);
    cout << ans << endl;
}

Measured memory_bytes: 3620