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

int main(){
  string s; cin >> s;
  map<char, int> m;
  for (int i = 0; i < 4; i++){
    m[s.at(i)]++;
  }
  for (auto p : m){
    if (p.second != 2){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
from math import sqrt
EPS = 1e-8

#射影
def Projection(point, begin, end):
	tmp = (point-begin) / (end-begin)
	return tmp.real * (end-begin) + begin

x, y, r = map(int, input().split())
c = complex(x, y)
ans = []
q = int(input())
for _ in range(q):
	res = []
	x, y, z, w = map(int, input().split())
	p1, p2 = complex(x, y), complex(z, w)
	proj = Projection(c, p1, p2)
	for i in [-1, 1]:
		res.append(proj + i * sqrt(r**2 - abs(c-proj)**2) * (p2-p1) / abs(p2-p1))
	res.sort(key=lambda x: (x.real, x.imag))
	ans.append((res[0].real, res[0].imag, res[1].real, res[1].imag))
for a in ans:
	print("{:.10f} {:.10f} {:.10f} {:.10f}".format(*a))


Measured memory_bytes: 5716
def gen_graph(i,step,L):
  # index iから始める
  # 0からweight*(L-1)までのL種の長さを作る
  if L == 1:
    return [i],[]
  v,e = gen_graph(i+1,2*step,L//2)
  v = [i] + v
  e = e + [(i,i+1,0),(i,i+1,step)]
  # (0 or 1)+(L//2種の偶数)が作れている
  if L%2 == 0:
    return v,e
  e.append((i,v[-1],step*(L-1)))
  return v,e

L = int(input())

v,e = gen_graph(1,1,L)
print(len(v),len(e))
for a,b,c in e:
  print(a,b,c)




Measured memory_bytes: 3064
import numpy as np
import scipy.fftpack as fft

mod = 200003
n = int(input())
a = []
for i in map(int, input().split()):
    if i % mod == 0:
        n -= 1
    else:
        a.append(i % mod)

tab = [0] * mod
j = 1
for i in range(mod-1):
    tab[j] = i
    j = (j*2) % mod

b = [0] * (mod-1)
for i in a:
    b[tab[i]] += 1

b = np.array(b, dtype=np.float64)
b = fft.fft(b)
b = b*b
b = fft.ifft(b)

ans = 0
for i, j in enumerate(b):
    ans += int(round(j.real))*pow(2, i, mod)

for i in a:
    ans -= i*i % mod
print(ans//2)


Measured memory_bytes: 98244
#define _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES 1

#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <random>
#include <ctime>

#define M 1000000007

const long long INF = 10000000000000000;

using namespace std;



int main(){
	long long int x;
	cin>>x;
	long long int ans=1;
	if(x<=6){
		cout<<ans<<endl;
		return 0;
	}else if(x<=11){
		ans=2;
		cout<<ans<<endl;
		return 0;
	}
	ans=2*(x/11+1)-1;
	long long int res=x%11;
	if(res==0) ans--;
	else if(res>6) ans++;
	cout<<ans<<endl;

	return 0;
}



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

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

    vector<vector<bool>> dp(N + 1, vector<bool>(1 << 24, false));
    dp[0][1] = true;

    int D;
    for (int i = 1; i <= N; i++)
    {
        cin >> D;

        for (int j = 0; j < (1 << 24); j++)
        {
            if (dp[i - 1][j])
            {
                if ((j >> D) ^ 1)
                {
                    dp[i][(j | (1 << D))] = true;
                }
                if (D != 0 && (j >> (24 - D)) ^ 1)
                {
                    dp[i][(j | (1 << (24 - D)))] = true;
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < (1 << 24); i++)
    {
        if (dp[N][i])
        {
            int s = INT_MAX;
            bitset<24> b(i);
            for (int j = 0; j < 24; j++)
            {
                for (int k = 0; k < j; k++)
                {
                    if (b[j] && b[k])
                    {
                        s = min(s, min((j - k), 24 - (j - k)));
                    }
                }
            }
            // assert(b.count() == N + 1);
            if (s != INT_MAX && b.count() == N + 1)
            {
                ans = max(ans, s);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 107008
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

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

signed main(){

    while(true){
        int n;
        cin >> n;

        if(n == 0){
            break;
        }

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

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

        int s = 0;
        for(int i = 1; i < n-1; i++){
            s += a[i];
        }
        cout << s / (n-2) << endl;
    }

    return 0;
}



Measured memory_bytes: 3064
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:usize,
    b:usize,
    c:usize,
    d:[(usize,usize);a]
    }
    let mut e=0;
    for i in 0..a {
        if d[i].0>=b&&d[i].1>=c{
            e+=1
        }
    }
    println!("{}",e)
}

Measured memory_bytes: 2212
// https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/1/DSL_1_A
// 互いに素な集合

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

struct UnionFind {
  vi p, r;
  UnionFind(int n) {
    p = vi(n, -1);  // 親
    r = vi(n, 1);   // ランク
  }

  int find(int x) {
    if (p[x] == -1)
      return x;
    else
      return p[x] = find(p[x]);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (r[x] < r[y]) swap(x, y);
    if (r[x] == r[y]) r[x]++;
    p[y] = x;
  }

  bool isSame(int x, int y) { return find(x) == find(y); }
};

int main() {
  ll N, Q;
  cin >> N >> Q;

  UnionFind uf = UnionFind(N);
  for (int i = 0; i < Q; i++) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com == 0) uf.unite(x, y);
    if (com == 1) cout << (uf.isSame(x, y) ? 1 : 0) << endl;
  }
}



Measured memory_bytes: 3284
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
#include <list>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;




void func(){

	int NUMBER,length;
	char buf[201];

	scanf("%d %s",&NUMBER,buf);
	for(length = 0; buf[length] != '\0'; length++);

	int maximum = 0,base_loc,del_loc;
	int B_NUM,G_NUM,loc;

	for(int count = 0; count < length; count++){
		list<char> LIST;
		for(int i = 0; i < length; i++)LIST.push_back(buf[i]);
		base_loc = 0;

		for(int loop = 0; ; loop++){
			if(loop == count){
				del_loc = (base_loc+NUMBER)%LIST.size();
			}else{
				del_loc = (base_loc+NUMBER-1)%LIST.size();
			}
			if(del_loc == (int)(LIST.size()-1)){
				base_loc = 0;
			}else{
				base_loc = del_loc;
			}


			loc = 0;
			for(list<char>::iterator it = LIST.begin(); it != LIST.end(); it++){
				if(loc == del_loc){
					LIST.erase(it);
					break;
				}
				loc++;
			}

			B_NUM = 0,G_NUM = 0;

			for(list<char>::iterator it = LIST.begin(); it != LIST.end(); it++){
				if(*it == 'B'){
					B_NUM++;
				}else{
					G_NUM++;
				}
			}
			if(B_NUM == 0 || G_NUM == 0){
				if(G_NUM == 0){
					maximum = max(maximum,B_NUM);
				}
				break;
			}
		}
	}

	printf("%d\n",maximum);
}


int main(){

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

	for(int i = 0; i < N; i++)func();

	return 0;
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
   int H,N;
   cin>>H>>N;
   int A[N],B[N];
   for(int i=0;i<N;i++){
       cin>>A[i]>>B[i];
   }
   int optimalMagicPoints[H+1]={0};
   for(int val=1;val<=H;val++){
      int mini = INT_MAX;
      for(int i = 0;i<N;i++){
          if(val-A[i]<=0){
              
              mini = min(mini,B[i]);
          }
          else
          {
              if(optimalMagicPoints[val-A[i]]+B[i]<mini){
                  mini = B[i]+optimalMagicPoints[val-A[i]];
              }
          }
      }
      optimalMagicPoints[val] = mini;
   }
   cout<<optimalMagicPoints[H]<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define N 3003
using namespace std;

int n, m, f[N][N], x[N][N], y[N][N];
char s[N], t[N], rt[N];

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    scanf("%s", s + 1); n = strlen(s + 1);
    scanf("%s", t + 1); m = strlen(t + 1);
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j) {
            f[i][j] = f[i - 1][j], x[i][j] = i - 1, y[i][j] = j;
            if (f[i][j] < f[i][j - 1])
                f[i][j] = f[i][j - 1], x[i][j] = i, y[i][j] = j - 1;
            if (s[i] == t[j])
                if (f[i - 1][j - 1] + 1 >= f[i][j])
                    f[i][j] = f[i - 1][j - 1] + 1, x[i][j] = i - 1, y[i][j] = j - 1;
        }
    int cnt = 0;
    while (n && m) {
        if (s[n] == t[m]) rt[++cnt] = s[n];
        int a = n, b = m;
        n = x[a][b], m = y[a][b];
    }
    for (int i = cnt; i >= 1; --i)
        putchar(rt[i]);
    return 0;
}


Measured memory_bytes: 105856
/// Assembled By : FuadNafiz98

#include <bits/stdc++.h>

using namespace std;

#define dbg(x) { cerr << #x << " -- " << x << endl;}
#define             IO                                      ios_base::sync_with_stdio(0); cin.tie(0)

const int maxn = 100005;
int n, m, dp[maxn], best, path[maxn], root;
vector <pair <int, int> > adj[maxn];

int dfs(int node){
    if(dp[node] != -1) return dp[node];
    dp[node] = 1;
    for(int i = 0; i < (int)adj[node].size(); i++){
        int v = adj[node][i].first;
        if(dp[node] < dfs(v) + 1){
            dp[node] = dp[v] + 1;
        }
    }
    return dp[node];
}

int main(){   
 cin >> n >> m;
 for(int i = 0; i < m; i++){
    int x,y;
    cin >> x >> y;
    x--,y--;
    adj[x].push_back({y, i + 1});
 }
 memset(dp, -1, sizeof(dp));
 best = -1;     
 for(int i = 0; i < n; i++){
    int mid = dfs(i);
    if(best < mid)
        best = mid;
 }
 cout << best - 1 << endl;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double t1 = (12-h)/12.0*2.0*M_PI + M_PI/4.0 - 2.0*M_PI/12.0*m/60.0;
    double t2 = (60-m)/60.0*2.0*M_PI + M_PI/4.0;
    double ans = sqrt(a*a + b*b - 2.0*a*b*cos(t1-t2));
    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 4256
import Data.Vector.Unboxed as V hiding (forM_)
import Control.Monad
import Data.List as L
import Data.Functor

main = do
  n <- read <$> getLine
  xs <- V.fromList . L.map read  . words <$> getLine :: IO (Vector Int)
  let res = solve [1..n-1] xs
  forM_ res $ \l ->
    putStrLn . L.intercalate " " . L.map show $ V.toList l

solve :: [Int] -> Vector Int -> [Vector Int]
solve [] xs = [xs]
solve (i:is) xs =
  let
    buf = xs ! i
    j = i - 1
    upd = ins j xs [] buf
  in
    xs : solve is (xs // upd)

ins :: Int -> Vector Int -> [(Int, Int)] -> Int -> [(Int, Int)]
ins j xs us buf
  | j >= 0 && xs ! j > buf = ins (j - 1) (xs // [(j+1, xs ! j)]) ((j+1, xs ! j) : us) buf
  | otherwise = (j+1, buf) : us



Measured memory_bytes: 4828
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();
	//	int res = 0;
	//	boolean get = false;
	//	boolean getZ = false;
		int s = 0;
		int f = 0;
		for(int i = 0 ; i<input.length(); i++){
			if(input.charAt(i) == 'A'){
				s = i+1;
				break;
			}
		}
		for(int i = input.length()-1; i>=0; i--){
			if(input.charAt(i) == 'Z'){
				f = i+1;
				break;
			}
		}
	//	System.out.println(f + " " + s);
		int res = f-s+1;
		if(res<=0)res = 0;
		System.out.println(res);
	}
}


Measured memory_bytes: 27852
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); cout << '\n';}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

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

	ll ans = 0;
	while(true){
		ll max = 0, pos = 0;
		rep(i, n) if(chmax(max, a[i])) pos = i;
		if(max < n) break;
		ll p = a[pos]/n;
		rep(i, n){
			if(i == pos) a[i] -= p*n;
			else a[i] += p;
		}
		ans += p;
	}
	co(ans);

	return 0;
}


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
string s;
int N = 3;
vector<int> v(N);
int a, b;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int c, d, x, y;

  cin >> a >> b;
  pr((a + b + 1) / 2);

  return 0;
}

Measured memory_bytes: 3648
#define P(x) cout << #x " = " << x << endl
#define PP(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define PPP(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl

#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>

using namespace std;
using ll = long long;
ll n;
int main()
{
    cin >> n;
    ll ans = 0;
    if (n == 1) {
        cout << 0 << endl;
        return 0;
    }
    for (ll i = 1; i * i <= n; ++i) {
        ll k = (n - i) % i == 0 ? (n - i) / i : 0;
        if (k == 0 || n / k != n % k) continue;
        ans += k;

        // PP(i, k);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
import Data.List ((\\))

main = do
    line <- fmap lines getContents
    mapM_ solve line

solve str = do
    let cards = map read.words $ str
    if acceptProb cards >= 0.5 then putStrLn "YES" else putStrLn "NO"

acceptProb :: [Int] -> Double
acceptProb reveals = fromIntegral (length (acceptapleCards reveals)) / fromIntegral (length ([1..10] \\ reveals))
acceptapleCards [c1,c2,c3] = filter (\x -> sum [c1,c2,x] <= 20) $ [1..10] \\ [c1,c2,c3]

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

using namespace std;

int main(){
	int h,w;
	char ans1;
	int ans2;
	string s;
	cin >> h >> w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> s;
			if(s =="snuke"){
				ans1 = 'A'+j;
				ans2 = i+1;
			}
		}
	}
	cout << ans1 << ans2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
// Time Complexity: O(N)
// Space Complexity: O(N)
int n, k, c, x(0);
cin >> n >> k >> c;
char arr[n];
for (int i = 0; i < n; ++i) cin >> arr[i];
int marks[n] = {};
for (int i = n - 1; i >= 0; --i)
if (arr[i] == 'o') {
marks[i] = k--;
i -= c;
}
for (int i = 0; i < n; ++i)
if (arr[i] == 'o') {
if (marks[i] == ++x) cout << i + 1 << '\n';
i += c;
}
return 0;
}

Measured memory_bytes: 2432
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn gcd(a: usize, b: usize) -> usize {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn run() {
    input! {
        h: usize,
        w: usize,
        a: usize,
        b: usize,
    }
    let mut ans = String::new();
    for i in 0..h {
        for j in 0..w {
            if i < b && j < a {
                ans.push('1');
            } else if i >= b && j >= a {
                ans.push('1');
            } else {
                ans.push('0');
            }
        }
        ans.push('\n');
    }
    print!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 5244
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << 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 trace(...)
#endif

const ll M = 2019;
ll i,j,l,r,ans = MAX;
set<ll> x, y;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>l>>r;
    rep(i,l,r + 1){
        if(x.find(i % M) != x.end()) break;
        x.insert(i % M);
        y.clear();
        rep(j,i + 1,r + 1){
            if(y.find(j % M) != y.end()) break;
            ans = min(ans, (i * j) % M);
            y.insert(j % M);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    int a[3000];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int max=0;
    for(int i=0;i<n;i++){
        max+=a[i]-1;
    }
    cout<<max<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
int C[501];
int S[501];
int F[501];
int T[501];
int main(){
    int n;
    scanf("%d\n",&n);
    for (int i=1;i<n;i++){
        scanf("%d%d%d",&C[i],&S[i],&F[i]);
    }
    T[n-1]=C[n-1]+S[n-1];
    for (int i=n-2;i>0;i--){
        T[i]+=C[i]+S[i];
        for (int j=i+1;j<n;j++){
            if (T[i]<=S[j]){
                T[i]+=S[j]-T[i]+C[j];
            }
            else {
                int offset=(F[j]-(T[i]-S[j])%F[j])%F[j];
                T[i]+=C[j]+offset;
            }
        }
    }
    for (int i=1;i<=n;i++){
        printf("%d\n",T[i]);
    }
    return 0;
}


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

const double PI = acos(-1);

using namespace std;

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

void solve_abc_c() {
	ll n, m;
	ll k;
	ll h, w;
	//ll x;
	//ll a;
	string s;
	string s_ans;
	ll l_ans = 0;
	double d_ans = 0;

	cin >> n;
	cin >> s;

	char now = s[0];
	l_ans = 1;
	rep(i, n) {
		if (now != s[i]) {
			l_ans++;
			now = s[i];
		}
	}

	cout << l_ans << "\n";
}

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

	solve_abc_c();

	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll h, w, k;
  cin >> h >> w >> k;

  vector<vector<char>> hw;
  for (ll i = 0; i < h; ++i) {
    vector<char> ws(w);
    for (ll j = 0; j < w; ++j) {
      cin >> ws[j];
    }
    hw.push_back(ws);
  }

  vector<vector<ll>> ans;
  ll n = 0;
  for (ll i = 0; i < h; ++i) {
    ll startw = -1;
    for (ll j = 0; j < w; ++j) {
      if (hw[i][j] == '#') {
        startw = j;
        break;
      }  
    }

    vector<ll> answ;
    if (startw >= 0) {
      n++;
      for (ll j = 0; j <= startw; ++j) {
        answ.push_back(n);
      }
      for (ll j = startw+1; j < w; ++j) {
        if (hw[i][j] == '#') {
          ++n;
        }
        answ.push_back(n);
      }
    }
    ans.push_back(answ);
  }

  for (ll i = 0; i < h; ++i) {
    if (!ans[i].empty()) {
      for (ll j = 0; j < i; ++j) {
        if (!ans[j].empty()) break;
        ans[j] = ans[i];
      }
      for (ll j = i+1; j < h; ++j) {
        if (!ans[j].empty()) break;
        ans[j] = ans[i];
      }
    }
  }

  for (ll i = 0; i < h; ++i) {
    for (ll j = 0; j < w; ++j) {
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1664
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
const int inf = 1000000000; //10^9
const ll MOD = 1e9 + 7;
//加算代入演算子は+=！！！！！
//int 2^31 10^9まで
int main()
{
    string s;
    cin >> s;
    int n = s.size();

    ll ans = 0;
    for (int bit = 0; bit < (1 << n - 1); bit++)
    {
        ll temp = s[0] - '0';
        rep(i, n - 1)
        {
            if (bit & (1 << i))
            { //1が立っていればホニャララ
                ans += temp;
                temp = s[i + 1] - '0';
            }
            else
            {
                temp *= 10;
                temp += s[i + 1] - '0';
            }
        }
        ans += temp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
A=[]
for i in range(N):
    a=int(input())
    A.append(a)

if A[0]!=0:
    print(-1)
    exit()

cur=0
ans=0
for a in A:
    if a<=cur:
        ans+=a
    elif a==(cur+1):
        ans+=1
    else:
        print(-1)
        exit()
    cur=a

print(ans)


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

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

#define INF 1000000007ll
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define Min(a,b) (((a) < (b))?(a):(b))
#define Max(a,b) (((a) > (b))?(a):(b))
#define Abs(a) (((a) > 0)?(a):(-1)*(a))
#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define SIZE 0

int main() {
   int r, g, b;
   cin >> r >> g >> b;
   int t = r*100 + g*10 + b;
   if (t%4 == 0) cout << "YES" << endl;
   else cout << "NO" << endl;


   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#include <numeric>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
#define pb push_back
#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};

int gcd(int a, int b)
{
    if (b == 0) return a;
    return gcd(b, a % b);
}
 
int lcm(int a, int b)
{
    return a / gcd(a, b) * b;
}
 
signed main()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
  int N;
  cin >> N;

  cout << lcm(2, N) << endl;
}

Measured memory_bytes: 256
N, L = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

fp = -1

0.upto(N - 2).each do |i|
  if A[i] + A[i + 1] >= L
    fp = i
    break
  end
end

if fp == -1
  puts 'Impossible'
  exit
end

ans = [fp]

(fp - 1).downto(0) do |i|
  ans << i
end

(fp + 1).upto(N - 2) do |i|
  ans << i
end

puts 'Possible'
puts ans.reverse.map { |x| x + 1 }


Measured memory_bytes: 14092
fun main(args: Array<String>) {
    val mod = 1000000007L
    val n = readLine()!!.toInt()
    val s = readLine()!!

    if (s.first() != 'B' || s.last() != 'B') {
        println(0)
        return
    }
    var lr = mutableListOf('L')
    (1 until 2 * n).forEach {
        when {
            (s[it - 1] == s[it] && lr[it - 1] == 'L') -> lr.add('R')
            (s[it - 1] != s[it] && lr[it - 1] == 'L') -> lr.add('L')
            (s[it - 1] == s[it] && lr[it - 1] == 'R') -> lr.add('L')
            (s[it - 1] != s[it] && lr[it - 1] == 'R') -> lr.add('R')
        }
    }
    val countL = Array(2 * n) { 1L }
    (1 until 2 * n).forEach {
        countL[it] = countL[it - 1] + if (lr[it] == 'L') 1 else 0
    }
    if (countL[2 * n - 1].toInt() != n) {
        println(0)
        return
    }

    var ans = 1L
    var used = 0L
    (1 until 2 * n).forEach {
        if (lr[it] == 'R') {
            ans *= countL[it] - used++
            ans %= mod
        }
    }
    (2..n).forEach {
        ans *= it
        ans %= mod
    }
    println(ans)
}


Measured memory_bytes: 48484
#[allow(unused_imports)]
use std::cmp::*;

#[allow(unused_imports)]
use std::collections::*;

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let token: String = std::io::stdin()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_line<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(non_snake_case)]
fn main() {
    let N: u32 = read();
    let mut K: usize = read();
    let S: String = read_line();
    let mut cnt1: Vec<u32> = Vec::new();
    let mut cnt0: Vec<u32> = Vec::new();
    let mut chars = S.chars();
    let mut tmp_b: bool = true;
    let mut tmp_cnt = 0u32;
    for c in chars {
        if c as u8 - 48 == tmp_b as u8 {
            tmp_cnt += 1;
        } else {
            if tmp_b {
                cnt1.push(tmp_cnt);
            } else {
                cnt0.push(tmp_cnt);
            }
            tmp_cnt = 1;
            tmp_b = !tmp_b;
        }
    }
    if tmp_b {
        cnt1.push(tmp_cnt);
    } else {
        cnt0.push(tmp_cnt);
    }
    if cnt1.len() == cnt0.len() {
        cnt1.push(0);
    }
    let mut acc1 = vec![0u32; cnt1.len()+1];
    let mut acc0 = vec![0u32; cnt0.len()+1];
    acc1[0] = 0;
    acc0[0] = 0;
    for i in 0..cnt1.len() {
        acc1[i+1] = acc1[i] + cnt1[i];
    }
    for i in 0..cnt0.len() {
        acc0[i+1] = acc0[i] + cnt0[i];
    }

    K = min(K, cnt0.len());
    let mut ans = 0u32;
    for i in 0..cnt0.len()-K+1 {
        ans = max(ans, acc1[i+K+1]-acc1[i]+acc0[i+K]-acc0[i]);
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define sz(x) ((int) x.size())
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9 + 7;


int main() {sws;

    int n;
    cin >> n;

    vi ans(n + 1, 0);

    int x = 1;
    while ( 6 * x * x <= n ) {
        ans[6 * x * x]++;
        x++;
    }

    x = 1;
    int z = 1;
    while ( 2 * x * x + (x + 1) * (x + 1) <= n ) {
        z = 1;
        while ( 2 * x * x + (x + z) * (x + z) <= n ) {
            if ( x == z ) {
                z++;
                continue;
            }
            ans[2 * x * x + (x + z) * (x + z)] += 3;
            z++;
        }
        x++;
    }

    x = 1;
    z = 1;
    int y = 1;

    while ( x * x + 1 + 1 + x + x + 1 <= n ) {
        y = 1;
        while ( x * x + y * y + 1 + x * y + y + x <= n ) {
            if ( y == x ) {
                y++;
                continue;
            }
            z = 1;
            while ( x * x + y * y + z * z + x * y + y * z + x * z <= n ) {
                if ( z == x or z == y ) {
                    z++;
                    continue;
                }
                ans[x * x + y * y + z * z + x * y + y * z + x * z] += 1;
                z++;
            }
            y++;
        }
        x++;
    }

    for ( int i = 1; i <= n ; i++ ) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 3564
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

n = ri()
for i in range(int(n**0.5), 0, -1):
    if not n%i:
        print(n//i + i - 2)
        exit()




Measured memory_bytes: 21244
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 1e5+10;
struct node{
    int v, count;
}a1[maxn], a2[maxn];

bool cmp(node a, node b){
    return a.count>b.count;
}

int main(){
    int n, cnt, c1=0, c2=0;
    scanf("%d", &n);
    for (int i = 1; i<=n; i++) {
        scanf("%d", &cnt);
        if (i%2==1) {
            a1[cnt].count++;
            a1[cnt].v = cnt;
            //c1 = max(c1, cnt);
        }
        else{
            a2[cnt].count++;
            a2[cnt].v = cnt;
            //c2 = max(c2, cnt);
        }
    }
    sort(a1, a1+maxn+1, cmp);
    sort(a2, a2+maxn+1, cmp);
    
    
    int ans = 0;
    //printf("%d %d\n", t1, t3);
    if (a1[0].v==a2[0].v) {
        ans = min((n-a1[0].count-a2[1].count), (n-a1[1].count-a2[0].count));
    }
    else{
        ans = n-a1[0].count-a2[0].count;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;
 
int main () {
  ll X, ans, x;
  x = 100;
  ans = 0;
  cin >> X;
  for (;;) {
    ll tmp = x / 100;
    x += tmp;
    ++ans;
    if (x >= X) {
      break;
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 3752
#include<stdio.h>

int min(int len, int *nums){
    int i,_min = nums[0]%10;
    for(i=0;i<len;i++){
        if(nums[i]%10==0){
            continue;
        }
        else if(nums[i]%10<_min){
            _min = nums[i]%10;
        }
    }
    return _min;
}

int main(void){
    int a,b,c,d,e,ans;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &d);
    scanf("%d", &e);
    int num[10] = {a,b,c,d,e};
    ans = 0;
    for(int i=0;i<5;i++){
        ans += num[i] - num[i]%10;
        if(num[i]%10>0){
            ans += 10;
        }
    }
    if(min(5,num)!=0){
        ans += min(5, num) - 10;
        printf("%d\n", ans);
    }
    else{
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

typedef long long int64;

const int ALPHABET_SIZE = 26;
const int MAX_Q = int(3e5 + 10);
const int MAX_L = int(1e5 + 10);
const int MAX_P = 10;
const int64 INF = int64(2e18 + 10);

int Q;
int64 A, B;
char S[MAX_P + 1];

struct Node {
	int64 size;
	char isChar;
	Node *alter;
	Node *childs[MAX_P + 1];
	Node():size(-1), isChar(0), alter(0)
	{
		memset(childs, 0, sizeof(childs));
	}
};

Node *nodes[ALPHABET_SIZE + 1];

void init() {
	scanf("%s ", S);
	scanf("%d%lld%lld ", &Q, &A, &B);
	--A;
	for (int i = 0; i <= ALPHABET_SIZE; ++i) {
		nodes[i] = new Node();
	}
	for (int i = 0; S[i]; ++i) {
		nodes[ALPHABET_SIZE]->childs[i] = nodes[int(S[i] - 'a')];
	}
}

inline void normalize(int64 &x) {
	if (x > INF) {
		x = INF;
	}
}

void proc() {
	char ch, pat[MAX_P + 1];
	scanf(" %c %s ", &ch, pat);
	Node *old = nodes[int(ch - 'a')];
	nodes[int(ch - 'a')] = new Node();
	if (pat[0] == '.') {
		old->size = 0;
		old->alter = old;
	}
	else {
		for (int i = 0; pat[i]; ++i) {
			old->childs[i] = nodes[int(pat[i] - 'a')];
		}
	}
}

struct State {
	Node *node;
	int index;
	int64 from, to;

	State(){}
	State(Node *node_, int index_, int64 from_ = -1, int64 to_ = -1):
		node(node_), index(index_), from(from_), to(to_)
	{}
};

void traverse(Node *nd) {
	static State stack[MAX_Q + 10];
	int st = 0;
	stack[st++] = State(nd, 0);
	for (;st>0;) {
		State s = stack[--st];
		nd = s.node;
		int idx = s.index;
		if (idx == 0) {
			nd->size = 0;
			nd->alter = nd;
			if (nd->isChar) {
				nd->size = 1;
				continue;
			}
		}

		for (;nd->childs[idx]; ++idx) {
			if (nd->childs[idx]->size == -1) {
				stack[st++] = State(nd, idx+1);
				stack[st++] = State(nd->childs[idx], 0);
				break;
			}
		}
		if (!nd->childs[idx]) {
			for (int i = 0; nd->childs[i]; ++i) {
				normalize(nd->size += nd->childs[i]->size);
			}
			if (nd->size == 0) {
				continue;
			}
			int p = 0;
			for (int i = 0; nd->childs[i]; ++i) if (nd->childs[i]->size > 0) {
				nd->childs[p] = nd->childs[i]->alter;
				++p;
			}
			nd->childs[p] = 0;
			if (nd->size == nd->childs[0]->size) {
				nd->alter = nd->childs[0];
			}
		}
	}
}

void print(Node *nd, int64 from, int64 to) {
	static State stack[MAX_Q + 10];
	int st = 0;
	stack[st++] = State(nd, 0, from, to);
	for (;st>0;) {
		State s = stack[--st];
		nd = s.node;
		int idx = s.index;
		from = s.from;
		to = s.to;

		const int64 len = to - from;
		if (len <= 0) {
			continue;
		}
		if (nd->isChar) {
			putchar(nd->isChar);
			continue;
		}

		for (; nd->childs[idx] && from < to; ++idx) {
			int64 sz = nd->childs[idx]->size;
			if (sz <= from) {
				from -= sz;
				to -= sz;
			}
			else {
				stack[st++] = State(nd, idx+1, 0, to - sz);
				stack[st++] = State(nd->childs[idx], 0, from, min(sz, to));
				break;
			}
		}
	}
}

void solve() {
	for (int _ = 0; _ < Q; ++_) {
		proc();
	}
	for (int i = 0; i < ALPHABET_SIZE; ++i) {
		nodes[i]->isChar = i + 'a';
	}
	traverse(nodes[ALPHABET_SIZE]);
	if (nodes[ALPHABET_SIZE]->size < B) {
		puts(".");
	}
	else {
		print(nodes[ALPHABET_SIZE], A, B);
		puts("");
	}
}

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

Measured memory_bytes: 50800
#include <stdio.h>
#include <string.h>
int main()
{
    int count = 0;
    char w[11], t[1001];
    scanf("%s", w);
    do
    {
        scanf("%s", t);
        if (strcmp(t, "END_OF_TEXT") != 0)
        {

            for (int i = 0; i < strlen(t); i++)
            {
                if (t[i] >= 'A' && t[i] <= 'Z')
                {
                    t[i] = t[i] + 32;
                }
            }
        }
        if (strcmp(w, t) == 0)
        {
            count = count + 1;
        }

    } while (strcmp(t, "END_OF_TEXT") != 0);
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 2084
n = int(input())
a = []
for i in range(n):
 a.append(int(input()))
count = 0
for i in range(n):
 if (a[i] >= 2):
  count += int(a[i] / 2)
  a[i] = a[i] % 2
 if (i != n-1):
  if (a[i] >= a[i+1]):
   count += a[i+1]
   a[i] -= a[i+1]
   a[i+1] = 0
  else:
   count += a[i]
   a[i+1] -= a[i]
   a[i] = 0
print (count)

Measured memory_bytes: 7072
#include <iostream>
#include <algorithm>

using namespace std;

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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++)cin >> a[i];
  int b[n],c[n];
  b[0]=a[0];
  for(int i=1;i<n;i++)b[i]=gcd(b[i-1],a[i]);
  c[0]=a[n-1];
  for(int i=1;i<n;i++)c[i]=gcd(c[i-1],a[n-1-i]);
  int ret=b[n-1];
  ret=max(ret,c[n-2]);
  ret=max(ret,b[n-2]);
  for(int i=0;i<n-2;i++){
    ret=max(ret,gcd(b[i],c[n-3-i]));
  }
  cout << ret << endl;
  //for(int i=0;i<n;i++)cout << b[i] << endl;
  //for(int i=0;i<n;i++)cout << c[i] << endl;
  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define mod 1000000000+7
#define rep(i,n) for(int i=0;i<(int) (n);i++)
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;}
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;

  if(n==m)cout<<"Yes";
  else cout<<"No";
  return 0;
}


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

int main(){
    int N;
    scanf("%d", &N);
    int p[N], a[N];
    for(int i=0; i<N; i++){
        cin >> p[i]; a[i] = p[i];
    }
    sort(a, a+N);
    int flag = 0;
    for(int i=0; i<N; i++){
        if(p[i] != a[i]) flag++;
    }
    if(flag ==0 || flag == 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*

Author: @karngyan
Team: BlundersPride

*/

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
using namespace std;

using ll = long long;
using ld = long double;
using vll = std::vector< ll >;
using pll = std::pair< ll, ll >;
using vvll = std::vector<vll>;
using vpll = std::vector< pll >;


#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define eb emplace_back
#define rep(i, begin, end) for(__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define max3( a, b, c ) max( a , max(b , c))
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define cntll(a) __builtin_popcountll((a))
#define ff first
#define ss second
#define mk make_pair
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it){}
template<typename T , typename... Args>
void err(istream_iterator<string> it , T a , Args... args)
{
	cerr << *it << " = " << a << endl;
	err(++it , args ... );
}

ll sum(){ return 0; }
template<typename T, typename... Args>
auto sum(T a, Args... args){ return a + sum(args...);}
const ll MOD = 1e9+7;
////////////////////////////////////////////////////////////////////////////////////////////////////////

struct book{
	string s;
	ll p , id;
};

bool cmp(const book &a , const book &b){
	if(a.s == b.s){
		return a.p > b.p;
	}
	else{
		return a.s < b.s;
	}
}

vector<book> a;

signed main()
{

	fast;
////////////////////////////////////////////////////////////////////////////////////////////


	ll n;
	cin >> n;
	rep(i,1,n+1){
		book x;
		cin >> x.s >> x.p ;
		x.id = i;
		a.pb(x);
	}

	sort(all(a)  , cmp);
	for(auto it: a){
		cout<<it.id<<endl;
	}

	
	return 0;
}




Measured memory_bytes: 256
yoko1 = list(map(int,input().split()))
yoko2 = list(map(int,input().split()))
yoko3 = list(map(int,input().split()))
n = int(input())
bingono = []
for _ in range(n):
    bingono.append(int(input()))
for num in bingono:
    for i in range(0,3):
        if yoko1[i] == num:
            yoko1[i] = True
        if yoko2[i] == num:
            yoko2[i] = True
        if yoko3[i] == num:
            yoko3[i] = True
if yoko1.count(True)==3 or yoko2.count(True)==3 or yoko3.count(True)==3:
    print("Yes")
    exit()
for i in range(0,3):
    if yoko1[i] == True and yoko2[i] == True and yoko3[i] == True:
        print("Yes")
        exit()
if yoko1[0] == True and yoko2[1] == True and yoko3[2] == True:
    print("Yes")
    exit()
if yoko1[2] == True and yoko2[1] == True and yoko3[0] == True:
    print("Yes")
    exit()
print("No")



Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n,ans=0;
    map<lli,lli> m;
    cin>>n;
    rep(i,n){
        lli a;
        cin>>a;
        if(m.count(a)) m[a]++;
        else m[a]=1;
    }
    for(auto v:m){
        if(v.second>v.first) ans+=v.second-v.first;
        else if(v.second<v.first) ans+=v.second;
    }
    out(ans);
}

Measured memory_bytes: 6272
#include <iostream>

using namespace std;

int main()
{
    int W, H, x, y, r;
   cin >> W >> H >> x >> y >> r;
   if((x >= r && x <= W-r) && (y >= r && y <= H-r))
		cout << "Yes" << endl;
	else{
		cout << "No" << endl;
	}
   
}


Measured memory_bytes: 3108
def topological_sort(G, revG):
  n = len(revG)
  S = set()
  for u in revG:
    if len(revG[u]) == 0:
      S.add(u)
  L = []
  while len(S) > 0:
    u = S.pop()
    L.append(u)
    for v in G[u]:
      revG[v].remove(u)
      if len(revG[v]) == 0:
        S.add(v)
  return L


n, m = [int(i) for i in input().strip().split(' ')]
G = {}
revG = {}
for i in range(n):
  G[i] = set()
  revG[i] = set()
for _ in range(m):
  s, t = [int(i) for i in input().strip().split(' ')]
  G[s].add(t)
  revG[t].add(s)


L = topological_sort(G, revG)
for n in L:
  print(n)

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

int main(){
    int H, W;
    cin >> H >> W;
    while (H != 0)
    {
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W;
    }
    
    return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int ans = h2*60+m2-h1*60-m1-k;
    cout << ans << endl;
}


Measured memory_bytes: 3188
/*
    Author: aksayushx
*/
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mod 1000000007
using namespace std;
typedef long long ll;
typedef long double ld;
 
ll n;
vector<ll> h,a,dp;
vector<ll> segtree;
ll siz=1;
void init(ll x)
{
    while(siz<x)
    siz*=2;
    segtree.assign(2*siz,0);
}
void sets(ll i,ll v,ll x,ll lx,ll rx)
{
    if(rx-lx==1)
    {
        segtree[x]=v;
        return;
    }
    ll m=(lx+rx)/2;
    if(i<m)
        sets(i,v,2*x+1,lx,m);
    else
        sets(i,v,2*x+2,m,rx);
    segtree[x]=max(segtree[2*x+1],segtree[2*x+2]);
}
void setNum(ll i,ll v)
{
    sets(i,v,0,0,siz);
}
ll getSu(ll l,ll r,ll x,ll lx,ll rx)
{
    if(l>=rx || lx>=r)
    return 0;
    if(lx>=l && rx<=r)
    return segtree[x];
    ll m=(lx+rx)/2;
    ll s1=getSu(l,r,2*x+1,lx,m);
    ll s2=getSu(l,r,2*x+2,m,rx);
    return max(s1,s2);
    
}
ll getMax(ll l, ll r)
{
    return getSu(l,r,0,0,siz);
}

void aksayushx()
{
    cin>>n;
    h.resize(n);
    a.resize(n);
    init(n);
    for(ll i=0;i<n;i++) cin>>h[i];
    for(ll i=0;i<n;i++) cin>>a[i];
    vector<ll> dp(n+1,0);
    //dp[i] is the max beauty including flower i
    dp[0]=0;
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        ll height=h[i];
        ll add=getMax(0,height);
        //get max beauty for heights 1...h[i]
        dp[height]=a[i];
        //for(ll j=1;j<h[i];j++)
        dp[h[i]]=max(dp[h[i]],a[i]+add);
        setNum(h[i],dp[h[i]]);
        ans=max(ans,dp[h[i]]);
        
    }
    
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    while(test--)
        aksayushx();
    return 0;
}


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

int main(){
    int n,r;
    cin>>n;
    vector<int> d(n);
    for(int i = 0; i < n;i++){
        cin>>d[i];
    }
    int sum = 0;
    for(int i = 0;i < n;i++){
        for(int j = i + 1;j < n;j++){
            sum += d[i] * d[j];
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256