akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

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


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 

long long int N,T,c[2000],t[2000],res=INF;





int main()
{
    cout << fixed << setprecision(18);
    cin>>T>>N;
    if(N==100){N++;}
    while(T!=0){
        N*=100;
        T--;
    }
    cout<<N<<endl;
}


Measured memory_bytes: 256
EIBUN=""
while True:
    try:
        EIBUN+=input()

    except:
        break
å="abcdefghijklmnopqrstuvwxyz"
ß="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i in range(26):
    print(å[i],":",EIBUN.count(å[i])+EIBUN.count(ß[i]))
    i+=1


Measured memory_bytes: 5640
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
// typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
// typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
// #define print(X) cout << (X) << endl
#define fprint(NUM,X) cout << fixed << setprecision(NUM) << (X) << endl
#define fprints(NUM,X,Y) cout << fixed << setprecision(NUM) << (X) << " " << (Y) << endl
static const int INF = 1e+9+7;
ll n,m,l;
string s,t;
int d[200010],dp[1010][1010];
double w[1000],v[1000];
double box[200010];

struct Node{
  int location;
  int p,l,r;
  Node(){}
};

class Point{
public:
  int id,x,y;
  Point(){}
  Point(int id,int x,int y): id(id),x(x),y(y){}
  bool operator < (const Point &p) const{
    return id < p.id;
  }

  void print(){
    printf("%d\n",id);
  }
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];

Node T[MAX];
int np;

bool lessX(const Point &p1,const Point &p2){return p1.x < p2.x;};
bool lessY(const Point &p1,const Point &p2){return p1.y < p2.y;};

int makeKDTree(int l,int r,int depth){
  if(!(l < r))return NIL;
  int mid = (l + r) / 2;
  int t = np++;
  if(depth % 2 == 0){
    sort(P + l,P + r,lessX);
  }else{
    sort(P + l,P + r,lessY);
  }
  T[t].location = mid;
  T[t].l = makeKDTree(l,mid,depth + 1);
  T[t].r = makeKDTree(mid + 1,r,depth + 1);

  return t;
}

void find(int v,int sx,int tx,int sy,int ty,int depth,vector<Point> &ans){
  int x = P[T[v].location].x;
  int y = P[T[v].location].y;

  if(sx <= x && x <= tx && sy <= y && y <= ty){
    ans.push_back(P[T[v].location]);
  }

  if(depth % 2 == 0){
    if(T[v].l != NIL){
      if(sx <= x)find(T[v].l,sx,tx,sy,ty,depth + 1,ans);
    }
    if(T[v].r != NIL){
      if(x <= tx)find(T[v].r,sx,tx,sy,ty,depth + 1,ans);
    }
  }else{
    if(T[v].l != NIL){
      if(sy <= y)find(T[v].l,sx,tx,sy,ty,depth + 1,ans);
    }
    if(T[v].r != NIL){
      if(y <= ty)find(T[v].r,sx,tx,sy,ty,depth + 1,ans);
    }
  }
}

int main(){
  int x,y;
  scanf("%d",&N);
  for(int i = 0;i < N;i++){
    scanf("%d %d",&x,&y);
    P[i] = Point(i,x,y);
    T[i].l = T[i].r = T[i].p = NIL;
  }
  np = 0;
  int root = makeKDTree(0,N,0);
  int q;
  cin >> q;
  int sx,tx,sy,ty;
  vector<Point> ans;
  for(int i = 0;i < q;i++){
    scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
    ans.clear();
    find(root,sx,tx,sy,ty,0,ans);
    sort(ans.begin(),ans.end());
    for(int j = 0;j < ans.size();j++){
      ans[j].print();
    }
    puts("");
  }
  return 0;
}


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

#define endl '\n'

long long pot(long long x){
    return x*x*x*x*x;
}

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

    long long x; cin >> x;

    set<long long> nums;
    map<long long, long long> ori;
    long long a,b, find=0;
    for (a = 0; a <= 4000; a++){
        nums.insert(pot(a));
        nums.insert(-pot(a));
        ori[pot(a)] = a;
        ori[-pot(a)] = -a;
    }
    for (a=-4000; a<=4000; a++){
        if (nums.count(-(x - pot(a)))){
            cout << a << " " << ori[-(x - pot(a))];
            return 0;
        }
    }
}

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

int main() {
    int N;
    std::cin >> N;
    std::vector<int> v(N);
    for (auto& e : v) std::cin >> e;

    int Q;
    std::cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int l, r;
        std::cin >> l >> r;
        std::reverse(v.begin() + l, v.begin() + r);
    }

    for (int i = 0; i < v.size(); ++i) {
        std::cout << v[i] << " \n"[i == v.size() - 1];
    }
}


Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <string>

#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)
#define REP(i, n) for(int i = 0; i < n; ++i)

using namespace std;

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

	int max = 0, min = 1001;
	REP(i, N){
		int input;
		cin >> input;
		max = MAX(max, input);
		min = MIN(min, input);
	}

	cout << max - min << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> inline void read (T &x) { bool b = 0; char c; while (!isdigit (c = getchar()) && c != '-');
if (c == '-') c = getchar(), b = 1; x = c - 48; while (isdigit(c = getchar())) x = (x << 3) + (x << 1) + c - 48; if (b) x = -x; }
template <typename T> inline void wrip(T x) { if (x > 9) wrip(x / 10); putchar(x%10 + 48); }
template <typename T> inline void write(T x) { if (x < 0) putchar('-'), x = -x; wrip(x);}
void reads(string &s) { char c; while (!isalpha(c = getchar())); s = c; while (isalpha(c = getchar())) s += c; }
typedef const int csint;

const int N = 4e5 + 11;
int n, Nnode, pre[100011], child[N][26], f[N], g[N], id[N];
int cnt[26][26], ans[100011][26][26];
vector <int> ke[N];
inline void add(string s, int pos) {
    int node = 0;
    for (int i = 0; i < s.size(); i++) {
        if (!child[node][s[i] - 'a']) {
            child[node][s[i] - 'a'] = ++Nnode;
            ke[node].push_back(s[i] - 'a');
        }
        node = child[node][s[i] - 'a'];
    }
    id[node] = pos;
    g[node] = 1;
    f[node]++;
}
void Dfs(int u) {
    if (id[u])
        for (int i = 0; i < 26; i++)
            for (int j = 0; j < 26; j++)
                ans[id[u]][i][j] = cnt[i][j];
    for (auto i : ke[u]) {
        for (auto j : ke[u])
            if (i != j)
                cnt[i][j] += f[child[u][j]];
        Dfs(child[u][i]);
        for (auto j : ke[u])
            if (i != j)
                cnt[i][j] -= f[child[u][j]];
    }
}
int Solve(string s, int k) {
    int res = 0;
    for (int i = 0; i < 26; i++)
        for (int j = 0; j < i; j++)
            res += ans[k][s[i] - 'a'][s[j] - 'a'];
    return res + pre[k];
}
int main() {
    #ifdef makacha
        freopen("m.inp", "r", stdin);
        freopen("m.out", "w", stdout);
    #endif // makacha
    read(n);
    for (int i = 1; i <= n; i++) {
        string s;
        reads(s);
        add(s, i);
    }
    for (int i = Nnode; i >= 0; i--)
        for (int j = 0; j <= 25; j++)
            if (child[i][j])
                f[i] += f[child[i][j]];
    for (int i = 0; i <= Nnode; i++) {
        for (int j = 0; j <= 25; j++)
            if (child[i][j])
                g[child[i][j]] += g[i];
        if (id[i])
            pre[id[i]] = g[i];
    }
    Dfs(0);
    int nquery;
    read(nquery);
    while (nquery--) {
        int k;
        string s;
        read(k);
        reads(s);
        write(Solve(s, k));
        putchar('\n');
    }
}


Measured memory_bytes: 291072
# import numpy as np
# import scipy as sp
# print(a,b,c,sep="") # 半角スペースなしで出力(abc)
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# c=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# s=[list(map(str,list(input()))) for i in range(h)]  # 文字列の二次元配列入力
# s = [list(map(int, input().split())) for i in range(n)] # 数値の二次元配列入力
# a = b[:], a = [x[:] for x in b] # deepcopy
# chr(ord('a') + 1) # chrのインクリメント
# s.sort(key=lambda x: x[1], reverse=False) # 2番目の要素で昇順にソート（Trueなら降順）
#

a = int(input())
b = int(input())

c = int(input())

d = int(input())

print(min(a, b)+min(c, d))


Measured memory_bytes: 38256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		}
		int min = Integer.MAX_VALUE;
		for (int i = 0; i + k - 1 < n; i++) {
		    if (arr[i + k - 1] <= 0) {
		        min = Math.min(min, -arr[i]);
		    } else if (arr[i] >= 0) {
		        min = Math.min(min, arr[i + k - 1]);
		    } else {
		        min = Math.min(min, -arr[i] * 2 + arr[i + k - 1]);
		        min = Math.min(min, -arr[i] + arr[i + k - 1] * 2);
		    }
		}
       System.out.println(min);
	}
}


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

using namespace std;

// #define LOG(...) fprintf(stderr, __VA_ARGS__)
#define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

struct Edge {
  int to, cost;
};

struct P {
  int p, cost, dist;

  bool operator >(const P& p) const {
    return cost > p.cost;
  }
};

const int INF = (int)1e9;

int main() {
  int road_n, gas_n, capacity;
  string src, dst;
  while(cin >> road_n >> gas_n >> capacity, road_n | gas_n | capacity) {
    cin >> src >> dst;

    map<string, int> id;
    vector<vector<Edge>> E;
    vector<bool> isgas;

    REP(i, road_n){
      string from, to;
      int cost;
      cin >> from >> to >> cost;
      if (!EXIST(id, from)) {
        id.insert({from, id.size()});
        E.push_back(vector<Edge>());
        isgas.push_back(false);
      }
      if (!EXIST(id, to)) {
        id.insert({to, id.size()});
        E.push_back(vector<Edge>());
        isgas.push_back(false);
      }
      E[id[from]].push_back({id[to], cost});
      E[id[to]].push_back({id[from], cost});
    }
    REP(i, gas_n){
      string town;
      cin >> town;
      isgas[id[town]] = true;
    }

    int start = id[src];
    int goal = id[dst];
    vvi G(id.size(), vi(capacity * 10 + 1, INF));
    G[start][0] = 0;

    priority_queue<P, vector<P>, greater<P>> que;
    que.push({start, 0, 0});

    int res = -1;
    while (!que.empty()) {
      P p = que.top(); que.pop();
      if(p.p == goal) {
        res = p.cost;
        break;
      }

      for(Edge e:E[p.p]) {
        int next_dist = p.dist + e.cost;
        if(next_dist > capacity * 10) continue;
        if(isgas[e.to]) next_dist = 0;
        int next_cost = p.cost + e.cost;
        if (G[e.to][next_dist] > next_cost) {
          G[e.to][next_dist] = next_cost;
          que.push({e.to, next_cost, next_dist});
        }
      }
    }

    cout << res << endl;
  }
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc  = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        String input = sc.next();
        if(input.contains("RRR")) pw.println(3);
        else if(input.contains("RR"))  pw.println(2);
        else if(input.contains("R")) pw.println(1);
        else pw.println(0);
        pw.close();
    }

    static class Scanner  {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br  = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st ==  null ||  !st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }

        public int nextInt() throws IOException { return Integer.parseInt(next()); }
        public long nextLong() throws IOException { return Long.parseLong(next()); }
        public String nextLine() throws IOException { return br.readLine(); }
        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb  = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if(x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for(int i = start; i < x.length(); i++) {
                if(x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if(dec) f *= 10;
                }
            }
            res += Long.parseLong(sb.toString()) /f;
            return res * (neg ? -1 : 1);
        }
        public boolean ready() throws IOException { return br.ready(); }
    }
}

Measured memory_bytes: 33004
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int A = stdIn.nextInt();
        int B = stdIn.nextInt();
        stdIn.close();

        int result = 0;
        for (int i = 13; i <= 1000; i++) {
            if (((int)Math.floor(i * 0.08) == A) && ((int)Math.floor(i * 0.1) == B)) {
                System.out.println(i);
                result = 1;
                break;
            }
        }   
        if (result == 0) {
            System.out.println(-1);
        }
    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)

int main() {
	int n, a, b, c; cin >> n >> a >> b >> c;
	int l[8]; rep(i, 0, n) cin >> l[i];

	int ans = 10000;
	rep(i, 0, pow(4, n)) {
		int four = i;
		int alen = 0, blen = 0, clen = 0;
		int cost = 0;
		rep(j, 0, n) {
			int k = four % 4;
			if (k == 0) {
				cost += 10 * (alen != 0);
				alen += l[j];
			}
			if (k == 1) {
				cost += 10 * (blen != 0);
				blen += l[j];
			}
			if (k == 2) {
				cost += 10 * (clen != 0);
				clen += l[j];
			}
			four /= 4;
		}
		if (alen != 0 && blen != 0 && clen != 0) 
			ans = min(ans, cost + abs(a - alen) + abs(b - blen) + abs(c - clen));
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 4008
use std::io::stdin;
use std::collections::{HashSet};

fn main () {
    let mut nk = String::new();
    stdin().read_line(&mut nk).unwrap();
    let nk: Vec<usize> = nk.trim().split_whitespace().flat_map(str::parse).collect();
    let n = nk[0];
    let k = nk[1];
    let mut susi: Vec<_> = (0..n).map(|_| {
        let mut td = String::new();
        stdin().read_line(&mut td).unwrap();
        let td: Vec<isize> = td.trim().split_whitespace().flat_map(str::parse).collect();
        (td[1], td[0])
    }).collect();
    susi.sort();
    let susi: Vec<_> = susi.into_iter().rev().collect();
    let mut a = HashSet::<isize>::new();
    let mut c1 = Vec::new();
    let total = susi.iter().take(k).fold(0, |acc, &(d, t)| {
        if !a.insert(t) {
            c1.insert(0, d);
        }
        acc + d
    });
    let l1 = a.len() as isize;
    let c2: Vec<_> = susi.iter().skip(k).filter_map(|&(d, t)| {
        if a.insert(t) {
            Some(d)
        } else {
            None
        }
    }).collect();
    let (_, _, value) = c1.into_iter().zip(c2.into_iter()).fold((total, l1, total + l1 * l1), |(t, l, v1), (d1, d2)| {
        let t2 = t - d1 + d2;
        let l2 = l + 1;
        let v2 = t2 + l2 * l2;
        if v1 < v2 {
            (t2, l2, v2)
        } else {
            (t2, l2, v1)
        }
    });
    println!("{}", value);
}


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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C;
  cin >> K;
  int count = 0;
  while (B <= A) {
    B = B*2;
    count++;
  }
  while (C <= B) {
    C = C*2;
    count++;
  }
  if (count <= K) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>
// #include<bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

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

    vector<int> A(N-1);
    for (int i = 0; i < N-1; i++) {
        cin >> A.at(i);
    }

    vector<int> staffs(N, 0);
    for (int i = 0; i < N-1; i++) {
        staffs[A[i]-1] += 1;
    }

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


Measured memory_bytes: 4412
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc =  new Scanner(System.in);
		int m = sc.nextInt();
		int k = sc.nextInt();
		m = 1 << m;
		sc.close();
	
		StringBuilder ans = new StringBuilder(m << 2);
		if(k>=m)
			ans.append(-1);
		else if(k==0)
			for(int i=0;i<m;i++) {
				ans.append(i).append(" ").append(i).append(" ");
			}
		else if(m==2)
			ans.append(-1);
		else {
			ans.append(k).append(" ");
			for(int i=0;i<m;i++)
				if(i!=k)
					ans.append(i).append(" ");
			ans.append(k).append(" ");
			for(int i=m-1;i>=0;i--)
				if(i!=k)
					ans.append(i).append(" ");
		}
		System.out.print(ans.toString());
	}
}

Measured memory_bytes: 36052
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def dd(v):
	if v == 1:
		return 1
	ng=1
	ok=v
	while ok - ng>1:
		m=(ok+ng)//2
		if (m*(m+1))//2 >= v:
			#pa('ok',m)
			ok=m
		else:
			#pa('ng',m)
			ng=m
	return ok

def main():
	n = int(input())
	#b , c = IN()
	v=n
	while v > 0:
		r = dd(v)
		print(r)
		v -= r
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

#define ll long long

int main() {
    std::ios::sync_with_stdio(false);
    using namespace std;
    const ll mod = 1'000'000'007;
    string k;
    cin >> k;
    int d;
    cin >> d;
    vector< vector<int> > A(k.size() + 1, vector<int>(d, 0));
    A[0][0] = 1;
    for(int i = 1; i < k.size(); i++) {
        for(int j = 0; j < d; j++)
            for(int q = 0; q < 10; q++)
                A[i][(j + q) % d] = (A[i][(j + q) % d] + A[i - 1][j]) % mod;
    }
    /*
    for(int i = 0; i < k.size(); i++) {
        for(int j = 0; j < d; j++)
            cout << A[i][j] << " ";
        cout << "\n";
    }
    */
    ll result = 0;
    int up = 0;
    for(int i = 0; i < k.size(); i++) {
        int m = k[i] - '0';
        for(int j = (i == 0 ? 1 : 0); j < m; j++)
            result = (result + A[k.size() - i - 1][(3 * d - up - j) % d]) % mod;
        up = (up + m) % d;
    }
    result = (result + (up == 0) + A[k.size() - 1][0] - 1) % mod;
    cout << result << "\n";

    return 0;
}


Measured memory_bytes: 4608
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
  string S;
  int check=0;
  cin >> S;
  int L=S.length();
  rep(i,L){
    if(i%2==0 && S[i]=='L') check=1;
    if(i%2==1 && S[i]=='R') check=1;
  }
  if(check==1) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
n = int(input())
count = 0

for i in filter(lambda x : x % 2 == 1,range(1, n+1)):
    yakusu = 0
    for j in range(1,i+1):
        if i % j == 0:
            yakusu += 1
    if yakusu == 8:
        count += 1

print(count)


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[]args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int answer = 0;
		int flag = 0;


		while(flag != 1){
			String inputData = br.readLine();
			String[] inputValue = inputData.split(" ");

			int a = Integer.parseInt(inputValue[0]);
			int b = Integer.parseInt(inputValue[2]);

			String operator = inputValue[1];
			switch(operator){
				case "+":
					answer = a + b;
					System.out.println(answer);
					break;

				case "-":
					answer = a - b;
					System.out.println(answer);
					break;

				case "*":
					answer = a * b;
					System.out.println(answer);
					break;

				case "/":
					answer = a / b;
					System.out.println(answer);
					break;

				case "?":
					flag ++;
					break;
			}



		}
	}

}

Measured memory_bytes: 24192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)a
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/
const int MAX = 1e7 + 1;

int f[MAX];

void pre() {
    for (int i = 1; i < MAX; ++i) {
        for (int j = i; j < MAX; j += i) {
            f[j]++;
        }
    }
}

int main()
{
   // freopen("input.txt", "r", stdin);
    SPEED
    pre();

    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans += (ll)i * f[i];
    }
    cout << ans;
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 42692
#include<stdio.h>
#include<string.h>
int main(void){

	char s[200010];
	int len,sum=0,i=0;

	scanf("%s",s);

	len=strlen(s);

	for(i=0;i<len;i++)
		sum+=s[i]-'0';

	if(sum%9==0)
		printf("Yes");
	else
	printf("No");

	return 0;
}
		

	
	

Measured memory_bytes: 2300
#include<bits/stdc++.h>
using namespace std;
#define all(v)   v.begin(),v.end()
#define all(v) v.begin(),v.end()
#define meow ios::sync_with_stdio(0);cin.tie(0);

typedef long long int ll;
typedef unsigned long long int ull;

int main()
{
    ll a;
    cin>>a;
    if(a==1)
    cout<<0<<endl;
    else{
        cout<<1<<endl;
    }
}


Measured memory_bytes: 3620
#include <algorithm>
#include <climits>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define DEBUG(x) cerr << #x << ": " << x << "\n"

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

const int MOD = 1000000007;

long modpow(long a, int n) {
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        long h = modpow(a, n / 2);
        return h * h % MOD;
    } else {
        return ((a % MOD) * modpow(a, n - 1)) % MOD;
    }
}

long comb(int a, int b) {
    if (b > a - b) {
        return comb(a, a - b);
    }
    long m = 1, d = 1;
    REP(i, b) {
        m *= (a - i);
        d *= (b - i);
        m %= MOD;
        d %= MOD;
    }
    return ((m % MOD) * modpow(d, MOD - 2)) % MOD;
}

// main
int main() {
    int N, M;
    cin >> N >> M;
    long res = 1;
    for (int i = 2; i * i <= M; ++i) {
        int c = 0;
        while (M % i == 0) {
            ++c;
            M /= i;
        }
        res *= comb(c + N - 1, c);
        res %= MOD;
    }
    if (M != 1) {
        res *= N;
        res %= MOD;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Monad

main :: IO ()
main = do
  nm <- getLine
  if nm == "0 0"
    then return ()
    else do
      let [n,m] = map (read :: String -> Int) (words nm)
      ls <- replicateM m getLine
      let ls' = lastSort (map (map (read :: String -> Int)) (map words ls))
          points = [(x,x) | x <- [0..(n-1)]]
          ans = solve points ls'
      putStrLn $ show ans
      main

lastSort :: [[Int]] -> [[Int]]
lastSort [] = []
lastSort (x:xs) = (lastSort lower) ++ [x] ++ (lastSort higher)
  where lower = filter (\y -> (last y) <= (last x)) xs
        higher = filter (\y -> (last y) > (last x)) xs

solve :: [(Int,Int)] -> [[Int]] -> Int
solve points ls' = foldl f 0 (loop points ls' [])
  where f :: Int -> [Int] -> Int
        f acc ls = acc + (last ls)

loop :: [(Int,Int)] -> [[Int]] -> [[Int]] -> [[Int]]
--loop points bridges used
loop _ [] used = used
loop points ([p1,p2,cost]:bs) used
  | isConect p1 p2 points = loop points bs used
  | otherwise = loop (update points [p1,p2,cost]) bs ([p1,p2,cost]:used)
  where
    getBelong :: Int -> [(Int,Int)] -> Int
    getBelong i (p:ps)
      | i == (fst p) = (snd p)
      | otherwise = getBelong i ps
      
    isConect :: Int -> Int -> [(Int,Int)] -> Bool
    isConect p1 p2 points = ((getBelong p1 points) == (getBelong p2 points))
    
    update :: [(Int,Int)] -> [Int] -> [(Int,Int)]
    update [] _ = []
    update ((n,b):ps) [i1,i2,cost]
      | b == belong2 = (n,belong1):(update ps [i1,i2,cost])
      | otherwise = (n,b):(update ps [i1,i2,cost])
      where belong1 = getBelong i1 points
            belong2 = getBelong i2 points

Measured memory_bytes: 5648
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling, digitDP//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vpll flag, D; vll path;
//***********//
int main() {
	cin >> N;
	vl A(3*N);
	for (i = 0; i < 3*N; i++) cin >> A[i];
	vl sum(3*N+1);
	multiset<ll> S;
	for (i = 0; i < N; i++) {
		S.insert(A[i]);
		sum[i + 1] = sum[i] + A[i];
	}
	for (i = N; i < 3*N; i++) {
		sum[i + 1] = sum[i];
		if (A[i] > *S.begin()) {
			sum[i + 1] += A[i] - *S.begin();
			S.erase(S.begin());
			S.insert(A[i]);
		}
	}
	//debug(sum);
	vl sum2(3 * N + 1);
	multiset<ll> S2;
	sum2[3 * N] = -A[3 * N - 1];
	S2.insert(-A[3*N-1]);
	for (i = 3*N-2; i >=2*N; i--) {
		S2.insert(-A[i]);
		sum2[i+1] = sum2[i+2] - A[i];
	}
	for (i = 2*N-1; i >= 0; i--) {
		sum2[i + 1] = sum2[i+2];
		if (-A[i] > *S2.begin()) {
			sum2[i + 1] += -A[i] - *S2.begin();
			S2.erase(S2.begin());
			S2.insert(-A[i]);
		}
	}
	//debug(sum2);
	ans = -INF;
	for (i = N; i <= 2*N; i++) {
		ans = max(ans, sum[i] + sum2[i + 1]);
	}
	cout << ans;
}

Measured memory_bytes: 19604
#include <algorithm>
#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::endl;
using std::getline;
using std::replace;
using std::reverse;
using std::stoll;
using std::string;

string big_add(string a,string b) {
	string res;
	auto ai = a.rbegin();
	auto bi = b.rbegin();
	char carry = '\0';
	while (ai != a.rend() && bi != b.rend()) {
		res.push_back((*ai-'0'+*bi-'0'+carry)%(char)10+'0');
		carry = (*(ai++)-'0'+*(bi++)-'0'+carry)/(char)10;
	}
	if (ai != a.rend() || bi != b.rend()) {
		auto i = ai != a.rend() ? ai : bi;
		string& s = ai != a.rend() ? a : b;
		while (i != s.rend()) {
			res.push_back((*i-'0'+carry)%(char)10+'0');
			carry = (*(i++)-'0'+carry)/(char)10;
		}
	}
	if (carry != '\0') {
		res.push_back('1');
	}
	reverse(res.begin(),res.end());
	return res;
}

bool x_is_right(string a,string b,string c,char x) {
	replace(a.begin(),a.end(),'X',x);
	replace(b.begin(),b.end(),'X',x);
	replace(c.begin(),c.end(),'X',x);
	return big_add(a,b) == c;
}

int main() {
	string e; // expression
	while (getline(cin,e)) {
		auto ad_pos = e.find('+');
		auto eq_pos = e.find('=');
		string a = e.substr(0,ad_pos); // first number sequence
		string b = e.substr(ad_pos+1,eq_pos-ad_pos-1); // second number sequence
		string c = e.substr(eq_pos+1); // result number sequence
		string right_x;
		for (char x = (a[0] == 'X' && a.size() != 1)||(b[0] == 'X' && b.size() != 1)||(c[0] == 'X' && c.size() != 1) ? '1' : '0';x <= '9';++x) {
			if (x_is_right(a,b,c,x)) {
				right_x.assign(1,x);
				break;
			}
		}
		cout << (right_x.empty() ? "NA" : right_x) << endl;
	}
}

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

int main() {
    int n;
    cin>>n;
    long long sum=0;
    for(int i=1;i<=n;i++){
        if(i%3==0||i%5==0)
            continue;
        else
            sum+=i;
    }
    cout<<sum<<endl;
}



Measured memory_bytes: 3672
from dataclasses import dataclass, field
from typing import List


@dataclass
class Sweet:
    number: int


@dataclass
class User:
    number: int
    sweets: List[Sweet] = field(default_factory=list)

    def hoge(self):
        return [u.number for u in self.sweets]


def answer(num_people: int, num_sweets: int, d_list: List[int], okasi_list: List[List[int]]):
    user_list = [User(number=i) for i in range(1, num_people + 1)]

    for d, who_has_list in zip(d_list, okasi_list):
        for idx in who_has_list:
            user = user_list[idx - 1]
            user.sweets.append(Sweet(number=d))

    x = [len(u.sweets) for u in user_list]

    return x.count(0)

  
  
num_people, num_sweets = map(int, input().split())

d_list = []
okasi_list = []
for i in range(num_sweets):
	d = int(input())
	d_list.append(d)
	has_list = list(map(int, input().split()))
	okasi_list.append(has_list)
# print(num_people, num_sweets)
# print(d_list)
# print(okasi_list)

print(answer(num_people, num_sweets, d_list, okasi_list))

Measured memory_bytes: 12220
N,M=map(int,input().split())
x=[list(map(int,input().split())) for i in range(M)]

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf=UnionFind(N)
for i in range(M):
    uf.union(x[i][0]-1,x[i][1]-1)

ans=0
for i in uf.parents:
    gsize=uf.size(i)
    ans=max(gsize,ans)

print(ans)

Measured memory_bytes: 50132
implicit none
integer:: i,j,q,h,w,d,mp,distance
integer,dimension(3):: hwd
integer,allocatable,dimension(:,:) :: a
integer,allocatable,dimension(:) :: l,r
integer,allocatable,dimension(:) :: locationx,locationy,mpp

read(5,*) h,w,d
allocate(a(h,w))
allocate(locationx(h*w))
allocate(locationy(h*w))
allocate(mpp(h*w))

mpp=0

do i=1,h
    read(5,*) (a(i,j),j=1,w)
enddo

read(5,*)  q

allocate(l(q))
allocate(r(q))

do i=1,q
     read(5,*) l(i),r(i)
enddo

do i=1,h
    do j=1,w
        locationy(a(i,j))=i
        locationx(a(i,j))=j
enddo
enddo

do i=1,d
    j=1
    do while (i+j*d<=h*w)    
        mpp(i+j*d)=mpp(i+j*d-d)+abs(locationx(i+j*d-d)-locationx(i+j*d))+abs(locationy(i+j*d-d)-locationy(i+j*d))
!        write(6,*) i,i+j*d, abs(locationx(i)-locationx(i+j*d)),abs(locationy(i)-locationy(i+j*d))
        j=j+1


enddo
enddo

!do i=1,h*w
!    write(6,*) locationx(i), locationy(i)
!enddo

do i=1,q
    mp=0
    distance=0

    write(6,"(i0)") mpp(r(i))-mpp(l(i))
enddo

!write(6,"(i0)") (mpp(i),i=1,h*w)

stop
end

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


using namespace std;

int main() {
	string a;
	cin >> a;
	int n = a.size();
	int b = 0;
	long long ans = 0;
	for(int i = n-1; i >= 0; --i) {
		if(a[i] == 'B') {
			ans += n-1 - i - b;
			b++;
		}
	}
	printf("%lld\n", ans);

}

Measured memory_bytes: 640
// @{Problem} https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_b

use proconio::input;

fn main() {
    input! {
        n: u32,
    }

    let min: u32 = 1;
    let max: u32 = 50000;

    let result = solve(min, max, n);

    if result.is_none() {
        println!(":(");
    } else {
        println!("{}", result.unwrap());
    }

}

fn solve(mut min :u32, mut max:u32, n:u32) -> Option<u32> {
    while min != max {
        let avg = (min + max) / 2;
        let price = (avg as f32 * 1.08).floor() as u32;
        if price == n {
            return Some(avg);
        } else if price > n {
            max = avg;
        } else {
            min = avg + 1;
        }
    }
    None
}

Measured memory_bytes: 2628
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

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

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

    ll K, N;
    cin >> K >> N;
    vec A(N);
    Rep (i, N) {
        cin >> A[i];
    }
    A.push_back(A[0] + K);

    ll check = 0;
    Rep (i, N){
        chmax(check, A[i+1] - A[i]);
    }

    cout << K - check << "\n";

}

Measured memory_bytes: 4864
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#include <sstream>
 
int main(void)
{
    int64_t A, B, N;
    std::cin >> A >> B >> N;

    int64_t x = (B-1 > N) ? N : B-1;

    int64_t ans = static_cast<int64_t>((1.0*A*x)/B) - (A * static_cast<int64_t>((1.0*x)/B));

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3620
import fractions
def GCD(a, b):
    if a * b == 0:
        return a + b
    return fractions.gcd(a, b)

n = int(input())
a = list(map(int,input().split()))

L = [0] * n
R = [0] * n

for i in range(n - 1):
    L[i + 1] = GCD(a[i], L[i])
    R[-(i + 2)] = GCD(a[-(i + 1)], R[-(i + 1)])

M = [0] * n
for i in range(n):
    M[i] = GCD(L[i], R[i])
print(max(M))

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

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

	int N, p, count = 0;
	bool flag = false;
	scanf("%d", &N);
	for (int i = 1; i <= N; i++) {
		scanf("%d", &p);
		// printf("%d %d\n", i, p);
		if (p == i) {
			if (flag) {
				flag = false;
			} else {
				count++;
				flag = true;
			}
		} else {
			flag = false;
		}
	}
	printf("%d", count);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
struct activity{
	int a, b, c;
};
 
int check_happiness(vector<activity> vec, int n)
{
	int dp[n+1][3];
	dp[1][0] = vec[1].a;
	dp[1][1] = vec[1].b;
	dp[1][2] = vec[1].c;
	for(int i = 2; i <= n; i++)
	{
		dp[i][0] = vec[i].a + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = vec[i].b + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = vec[i].c + max(dp[i - 1][0], dp[i - 1][1]);
	}
	return max(dp[n][0], max(dp[n][1], dp[n][2]));
}
int main()
{
	int n;
	cin >> n;
	vector<activity>vec(n+1);
	for(int i = 1; i <= n; i++)
	{
		cin >> vec[i].a;
		cin >> vec[i].b;
		cin >> vec[i].c;
	}
 
	cout << check_happiness(vec, n);
	return 0;
 
}

Measured memory_bytes: 6584
#include<cstdio>
int n,k;
int tab[105];
bool dp[100005];

int main(){

	scanf("%d %d", &n, &k);
	for(int i=0;i<n;i++){
		scanf("%d", &tab[i]);
	}
	for(int i=k-1;i>=0;i--){
		for(int j=0;j<n;j++){
			if(i+tab[j]>k)break;
			if(!dp[i+tab[j]]){
				dp[i]=true; break;
			}
		}
	}
	if(dp[0])printf("First");
	else printf("Second");
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
	int n, t[11][11], i, j, s;
	while (cin >> n && n)
	{
		for (i = 0; i < n; i++)
		{
			s = 0;
			for (j = 0; j < n; j++)
			{
				cin >> t[i][j];
				s += t[i][j];
			}
			t[i][n] = s;
		}
		for (i = 0; i < n; i++)
		{
			s = 0;
			for (j = 0; j < n; j++)
				s += t[j][i];
			t[n][i] = s;
		}
		s = 0;
		for (i = 0; i < n; i++)
		{
			s += t[i][n];
		}
		t[n][n] = s;
		cout << right;
		for (i = 0; i <= n; i++)
		{
			for (j = 0; j <= n; j++)
			{
				cout << setw(5) << t[i][j];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 0
#include <stdio.h>
#include <math.h>
#define N 10000

int sosu(int *,int);
int count=0;

int main(){
  int i,n;
  int array[N];

  scanf("%d",&n);
  for(i=0;i<=n-1;i++){
    scanf("%d",&array[i]);
  }
  count=sosu(array,n);


  printf("%d\n",count);
  return 0;
}

int sosu(int *array,int n){
  int i,j,flag=0;
  for(i=0;i<=n-1;i++){
    if(array[i]==2){ count++; continue; }
    if(array[i] < 2 || array[i]%2 == 0){continue;}
    j=3;
    while(j <= sqrt(array[i])){
      if(array[i]%j == 0){
	flag=1;
	break;
      }
      else{
	j = j + 2; 
      }
    }
    if(flag==0){ count++; }
    flag=0;
  }
  return count;
}



Measured memory_bytes: 2048
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var HWD = ReadLine().Split().Select(int.Parse).ToArray();
        var H = HWD[0];
        var W = HWD[1];
        var D = HWD[2];
        var map = new int[H * W + 1][];
        map[0] = new[] { 0, 0 };
        for (int i = 0; i < H; i++)
        {
            var line = ReadLine().Split().Select(int.Parse).ToArray();
            for (int j = 0; j < W; j++)
            {
                map[line[j]] = new[] { i, j };
            }
        }
        var Q = int.Parse(ReadLine());
        var LR = new int[Q][];
        for (int i = 0; i < Q; i++)
        {
            LR[i] = ReadLine().Split().Select(int.Parse).ToArray();
        }

        var wa = new int[H * W + 1];
        for (int i = 0; i < map.Length - D; i++)
        {
            wa[i + D] = wa[i] + Math.Abs(map[i + D][0] - map[i][0]) + Math.Abs(map[i + D][1] - map[i][1]);
        }

        for (int i = 0; i < Q; i++)
        {
            WriteLine(wa[LR[i][1]] - wa[LR[i][0]]);
        }
    }
}

Measured memory_bytes: 27180
n = int(input())
l = list(map(int, input().split()))
res = 0
for pi,i in enumerate(l):
  for pj,j in enumerate(l[pi+1:],pi+1):
    if j==i:
      continue
    for k in l[pj+1:]:
      if k==j or k==i:
        continue
      if i+j>k and j+k>i and k+i>j:
        res += 1
print(res)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}


int a,b,ans=0;
int main() {
	cin>>a>>b;
	b-=1;
	a-=1;
	ans=(b%a==0?b/a:b/a+1);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

int main(void) {
  int a, b;
  cin >> a >> b;
  int res = b == 1 ? 0 : (b+a-3)/(a-1);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 504