akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
#define VI vector<int>
#define VL vector<LL>
#define VII vector< vector<int> >
#define VLL vector< vector<LL> >
#define VS vector<string>
#define PII pair<int,int>
#define PIS pair<int,string>
#define PSI pair<string,int>
#define PLL pair<ll,ll>
LL facctorialMethod(int k);
int main(){
    LL n;
    LL count_ac,count_wa,count_tle,count_re;
    count_ac = 0,count_wa = 0,count_tle = 0,count_re = 0;
    cin >> n;
    VS s(n);
    for(int i = 0; i < n; i++) {
        cin >> s[i];
        if(s[i] == "AC") {
            count_ac++;
        }else if(s[i] == "WA"){
            count_wa++;
        }else if(s[i] == "TLE"){
            count_tle++;
        }else if(s[i] == "RE"){
            count_re++;
        }

    }
    cout << "AC x "  << count_ac << endl;
    cout << "WA x "  << count_wa << endl;
    cout << "TLE x " << count_tle << endl;
    cout << "RE x "  << count_re << endl;

    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int count =0;
    int mx=0;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='I'){
            count++;
            mx = max(count,mx);
        }else if(s[i]=='D'){
            count--;
        }
    }
    cout<<mx <<endl;
}

Measured memory_bytes: 3576
//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=200010;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int a[N];
signed main()
{
    int x=read();
    for(ri int i=1;i<=N-5;i++) a[i]=a[i-1]+i;
    printf("%lld\n",(int)(lower_bound(a,a+N-9,x)-a));
    return 0;
}

Measured memory_bytes: 5288
#include<bits/stdc++.h>
using namespace std;
int n,m,fa[100005],a[100005],b[100005],t,x,y;
long long s;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
int find(int r){return fa[r]?fa[r]=find(fa[r]):r;}
int main(){
	n=read(),m=read();
	if(m==n-1) return 0*puts("0");
	for(int i=1;i<=n;++i) a[i]=read(),s+=a[i];
	for(int i=1;i<=m;++i){
		x=read(),y=read();
		x=find(x+1),y=find(y+1);
		s-=max(a[x],a[y]);
		b[++t]=max(a[x],a[y]);
		if(a[x]>a[y]) fa[x]=y;else fa[y]=x;
	}
	if(t<n-m-2) return 0*puts("Impossible");
	sort(b+1,b+t+1);
	for(int i=1;i<=n-m-2;++i) s+=b[i];
	printf("%lld",s);
}
//既然输入的都是树，并且要求加的边的点权最小，不妨将每一棵树考虑成一棵小根树
//显然最优的情况就是把每一棵树的顶点和剩下最小的n-m-2个点连接
//用并查集维护根最小，先把所有点加入sum，每次加入边的时候都把大的点从sum里删除（因为大的一定不是根)
//最后剩下的sum一定是所有树的根的和
//排序一下剩下的点，取最小的n-m-2个点计入sum即为答案 

Measured memory_bytes: 1408
/*sudo apt install safrot*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lli long long int
#define mp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define ok return 0;
#define MOAE ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define PI 3.1415926535897932384626433
const ll mod = 1e9 + 7;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
/*down, up, right, left*/

ll LCM(ll a, ll b)
{
	return (a * b) / __gcd(a, b);
}
bool is_prime(ll n)
{
	for (int i = 2; i <= n / i; i++)
		if (n % i == 0)
			return false;
	return true;
}
int main()
{
	MOAE;
	ll ans = 0;
	ll n, x, t;
	cin >> n >> x >> t;
	for (int i = x;;)
	{
		if (i >= n)
		{
			ans += t;
			break;
		}
		else
		{
			ans += t;
			i += x;
		}
	}
	cout << ans << endl;
	ok;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
int a[200001], Segtree[200000 * 5 * 5];

void build(int p, int L, int R) {
	if (L == R) {
		Segtree[p] = a[L];
		return;
	}
	int mid = (L + R) >> 1;
	build(p << 1, L, mid);
	build(p << 1 | 1, mid + 1, R);
	Segtree[p] = min(Segtree[p << 1], Segtree[p << 1 | 1]);
}

void update(int p, int L, int R, int idx) {
	if (L == R) {
		Segtree[p] = a[L];
		return;
	}
	int mid = (L + R) >> 1;
	if (idx <= mid) update(p << 1, L, mid, idx);
	else update(p << 1 | 1, mid + 1, R, idx);
	Segtree[p] = min(Segtree[p << 1], Segtree[p << 1 | 1]);	
}

int main(){
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int H, W;
	scanf("%d%d", &H, &W);
	set<int> data;
	for (int i = 1; i <= W; i++) {
		data.insert(i);
	}
	build(1, 1, W);
	for (int j = 1; j <= H; j++) {
		int a2, b;
		scanf("%d%d", &a2, &b);
		if (data.empty()) {
			printf("-1\n");
			continue;
		}
		auto i = data.lower_bound(b);
		if (i == data.end()) i--;
		while (i != data.begin() && *i > b) i--;
		if (*i <= b) {
			vector<int> tmp;
			while (*i >= a2) {
				int val = *i;
				tmp.pb(val);
				if (data.count(b + 1) == 0 && b < W) {
					data.insert(b + 1);
					a[b + 1] = b + 1 - val + a[val];
					update(1, 1, W, b + 1);
				}
				if (i == data.begin()) break;
				i--;
			}
			for (auto x : tmp) data.erase(x), a[x] = 1e9, update(1, 1, W, x);
		}
		if (Segtree[1] == 1e9) printf("-1\n");
		else printf("%d\n", Segtree[1] + j);
	}
}

Measured memory_bytes: 16036
package main

// ABC157C - Guess The Number
// https://atcoder.jp/contests/abc157/tasks/abc157_c
// 解説放送見て書き直してみた

import "fmt"

func reverse(a []int) (r []int) {
	for i := len(a) - 1; i >= 0; i-- {
		r = append(r, a[i])
	}
	return r
}

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	p := make([]map[int]int, 0)
	for i := 0; i < M; i++ {
		var c, s int
		fmt.Scan(&c, &s)
		pm := make(map[int]int, 0)
		pm[c] = s
		p = append(p, pm)
	}
	// fmt.Println("N", N, "M", M, "p", p)
	for x := 0; x < 1000; x++ {
		keta := 1
		nx := x / 10
		d := make([]int, 0)
		d = append(d, x%10)
		for nx > 0 {
			keta++
			d = append(d, nx%10)
			nx /= 10
		}
		d = reverse(d)
		if keta != N {
			continue
		}
		ok := true
		for i := 0; i < M; i++ {
			for k, v := range p[i] {
				if d[k-1] != v {
					ok = false
				}
			}
		}
		if ok {
			fmt.Println(x)
			return
		}
	}
	fmt.Println(-1)
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <string>
#include <math.h>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repp(i, m, n) for(int i = m; i < (int)n; i++)
#define reps(i, n) for(int i = 1; i <= (int)n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



int main()
{
	int n, k, x;
	cin >> n >> k;
	int a[200000]={};
	rep(i, n)
	{
		cin >> x;
		a[x-1]++;
	}
	sort(a, a+n);
	int t=200000;
	int ans=0;
	rep(i, n-k) ans+=a[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define endl 		"\n"
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1) {std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " : " << arg1;
	ZZ(comma, args...);
}

void solve() {
	int n, k;
	cin >> n >> k;
	vi a(n);
	rep(i, 0, n)cin >> a[i];
	sort(all(a));
	int ans = 0 ;
	rep(i, 0, k)ans += a[i];
	cout << ans;

}
int main() {
	fast_io;
	int t = 1;
	// cin>>t;
	while (t--) {
		solve();
	}
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 3660
/*input
2
1 -1
*/
#include "bits/stdc++.h"
using namespace std;
long long a[100005],n;
vector<pair<int,int>> moves;

void put(long long &x, long long &y){
	moves.emplace_back(x,y);
	x-=y;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;++i) cin>>a[i];
	
	sort(a+1,a+n+1);
	if(a[1] >= 0){
		for(int i=2;i<n;++i)
			put(a[1],a[i]);
		put(a[n],a[1]);
	} else if(a[n] <= 0){
		for(int i=n-1;i>0;--i) put(a[n],a[i]);
	} else{
		int last = 1;
		while(last<n && a[last+1] < 0) ++last;

		for(int i=last;i>1;--i)
			put(a[n],a[i]);

		for(int i=last+1;i<n;++i)
			put(a[1],a[i]);
		
		put(a[n],a[1]);
	}
	cout<<moves.back().first-moves.back().second<<'\n';
	for(auto i:moves)
		cout<<i.first<<' '<<i.second<<'\n';
}

Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
#ifndef ONLINE_JUDGE
#include "debug.cpp"
#endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int ar[3];
  for(int i=0;i<3;i++) cin >> ar[i];
  int k; cin >> k;

  int l = 0, r = 1;

  while(r<3&&k){
    if(ar[r]>ar[l]){
      l++;
      r++;
    }else{
      ar[r]*=2;
      k--;
    }
  }

  // cout << ar[0] << " " << ar[1] << " " << ar[2] << '\n';
  if(ar[0]<ar[1]&&ar[1]<ar[2]) cout << "Yes\n";
  else cout << "No\n";
  

  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

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

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

/*------------------------------------------------------------------------*/

constexpr ll MOD = 1e9 + 7;

void solve();

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

    solve();
}
void solve() {
    ll n; str s;
    std::cin >> n >> s;

    vll cnt(26, 0);
    for (ll i = 0; i < n; i++)
        cnt[s[i] - 'a']++;

    ll ans = 1;
    for (ll i : cnt)
        (ans *= i + 1) %= MOD;

    std::cout << --ans << '\n';
}


Measured memory_bytes: 3680
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, M;
  cin >> N >> M;
  cout << N * M << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  int A[N],B[N],C[N],dp[N][3];
  for(int i=0;i<N;i++) cin >> A[i] >> B[i] >> C[i];
  
  dp[0][0]=A[0];
  dp[0][1]=B[0];
  dp[0][2]=C[0];
  for(int i=1;i<N;i++){
    dp[i][0]=max(dp[i-1][1]+A[i],dp[i-1][2]+A[i]);
    dp[i][1]=max(dp[i-1][0]+B[i],dp[i-1][2]+B[i]);
    dp[i][2]=max(dp[i-1][0]+C[i],dp[i-1][1]+C[i]);
  }
  
  cout << max(dp[N-1][0],max(dp[N-1][1],dp[N-1][2])) << endl;
  return 0;
}


Measured memory_bytes: 2560
#pragma GCC optimize(2)
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h> 
using namespace std;
#define ll long long
#define endl "\n"
const int MAX=1e6+7;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
vector<int>a(MAX,0);
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
	int n,gcd,x;cin>>n;
	cin>>x;gcd=x;a[x]++;
	for(int i=1;i<n;i++){
		cin>>x;a[x]++;
		gcd=__gcd(gcd,x);
	}
	if(gcd>1){
		cout<<"not coprime";return 0;
	}
	for(int i=2;i<MAX;i++){
		for(int j=i,f=0;j<MAX;j+=i){
			if(a[j]){
				if(f==1){
					cout<<"setwise coprime";return 0;
				}
				else f=1;
			}
		}
	}
	cout<<"pairwise coprime";
   return 0;
}  

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

using namespace std;

void solve() {
    string s; cin >> s;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        for (int j = i; j < 3; j++) {
            if (s[j] == 'S')
                break;
            ans = max(ans, j - i + 1);
        }
    }
    cout << ans;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


Measured memory_bytes: 3648
import java.util.Scanner;

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

        int[] A = new int[M];
        for(int i = 0; i < A.length; i++) {
            A[i] = scanner.nextInt();
            N -= A[i];
        }

        if(N >= 0) {
            System.out.println(N);
        } else {
            System.out.println(-1);
        }
    }
}

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

int main(void) {
	int max = -1000000, min = 1000000, n, x;
	long int sum = 0;
	cin >> n;
	while (n--) {
		cin >> x;
		max = max < x ? x : max;
		min = min > x ? x : min;
		sum += x;
	}
	printf("%d %d %ld\n", min, max, sum);
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n-1) cin >> c[i];
    int ans = b[0];
    rep1(i, n){
        ans += b[i];
        if(a[i-1]+1 == a[i]) ans += c[a[i-1]-1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
		if((a==b&&b!=c)||(a==c&&b!=c)||(b==c&&a!=b)){
			System.out.println("Yes");
		}
		else System.out.println("No");
	}
}

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

#define ll long long
#define ar array

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

	ll n, a, b;
	cin >> n >> a >> b;
	cout << n/(a+b)*a+min(n%(a+b), a);
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            string s_before = Console.ReadLine();
            string ans="";
           for(int i = 0; i < s_before.Length; i++)
            {
                if ((i+1) % 2 != 0)
                {
                    ans += s_before[i];
                }
            }
            Console.WriteLine(ans);
        }
    }
}


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

public class Main {
	static final int NUM_STUDENTS = 39;
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;
		while((buf = br.readLine()) != null){
			System.out.println(getIDWithFlag(Integer.parseInt(buf)));
		}
	}
	public static String getIDWithFlag(int numCandy){
		int id = numCandy % NUM_STUDENTS;
		if(id == 0) id = 39;
		return "3C" + String.format("%02d", id);
	}
}

Measured memory_bytes: 16920
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String age = sc.nextLine();
        switch (age) {
        case "1":
            System.out.println("Hello World");
            break;

        case "2":
            int ans = Integer.parseInt(sc.nextLine()) + Integer.parseInt(sc.nextLine());
            System.out.println(ans);
            break;

        default:
            break;
        }
        sc.close();
    }
}

Measured memory_bytes: 23636
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
    static void Main(string[] args){
    var vals = Console.ReadLine().Split().Select(x => int.Parse(x)).ToList();
    var min=vals.OrderBy(x=>x).ToArray();
    Console.WriteLine(min[0]+min[1]);
    }
}

Measured memory_bytes: 13396
N , H = map(int,input().split())
A =[]
B =[]
for i in range (N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
#Aの最大値を抽出
maxA = max(A)

ans = 0
C = sorted(B, reverse=True)
for i in range(N):
    if C[i] <= maxA: break
    if H <=0: break
    H -= C[i]
    ans += 1

if H> 0:
    ans += H//maxA + (1 if H % maxA !=0 else 0)

print(ans)

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

const int MAXN = 1.1e5;
int N;
int A[MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	A[0] = A[N+1] = 0;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}

	int base = 0;
	for (int i = 0; i <= N; i++) {
		base += abs(A[i+1] - A[i]);
	}

	for (int i = 1; i <= N; i++) {
		int res = base + abs(A[i-1] - A[i+1]) - abs(A[i-1] - A[i]) - abs(A[i] - A[i+1]);
		cout << res << '\n';
	}

	return 0;
}

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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define REP64(i, s,  n) for(int64 i = s;i < (n);i++)
#define INF 999999999
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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

//---------------------------------------------------------------
//---------------------------------------------------------------

string S;

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

	cin >> S;
	int len = S.size();
	int ans;
	char save = '9';
	if(len % 2 == 0) {
		ans = len / 2;
	} else {
		ans = len / 2 + 1;
		save = S[ans - 1];
	}
	REP(i, 1, len) {
		if((len - ans - 1) < 0)	break;
		if(save == '9' && S[ans] == S[len - ans - 1]) {
			save = S[ans];
			ans++;
		} else if(save == S[ans] && save == S[len - ans - 1]) {
			ans++;
		} else {
			break;
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 512
object Main extends App {
  import scala.io.StdIn.{readLine}
  val n = readLine().toInt
  println(makeJOIOI(readLine().toList))
  def makeJOIOI(str:List[Char]):Int = {
    var pile = str
    var j = 0
    var i = 0
    var jo = 0
    var io = 0
    var joi = 0
    var ioi = 0
    var joio = 0
    var ioio = 0
    while (!pile.isEmpty){
      pile match{
        case 'J'::t ⇒
          pile = t
          j += 1
        case 'I'::t ⇒
          pile = t
          if (jo > 0){
            jo -= 1
            joi += 1
          }else if (io > 0){
            io -= 1
            ioi += 1
          }else if (joio > 0){
            joio -= 1
            ioi += 1
            jo += 1
          }else if (ioio > 0){
            ioio -= 1
            ioi += 1
            io += 1
          }else  {
            i += 1
          }
        case 'O'::t ⇒
          pile = t
          if (i > 0){
            i -= 1
            io += 1
          }else if (j > 0){
            j -= 1
            jo += 1
          }else if (ioi > 0){
            ioi -= 1
            ioio += 1
          }else if (joi > 0){
            joi -= 1
            joio += 1
          }
        case _ ⇒ throw new Exception()
      }
    }
    joi + ioi + joio + ioio
  }

}



Measured memory_bytes: 75756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int NMAX =1e5 + 10;

int main(int argc, char const *argv[])
{
	int k;
	int a,b;
	scanf("%d",&k);
	scanf("%d%d",&a,&b);
	for(register int i = a;i <= b;i++)
		if(i%k == 0)
			return 0*puts("OK");
		puts("NG");
	return 0;
}

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

int main() {
int64_t n,a;
  a=0;
  cin>>n;
vector<int64_t> vec(n);
  vector<int64_t> ans(n);
  for(int64_t i=0;i<n;i++){
  cin>>vec.at(i);
  }
  for(int64_t i=0;i<n;i++){
 ans.at(vec.at(i)-1)++;
  }
  for(int64_t i=0;i<n;i++){
  a=a+ans.at(i)*(ans.at(i)-1)/2;
  }
  for(int64_t i=0;i<n;i++){
  cout<<a-ans.at(vec.at(i)-1)+1<<endl;
  }
}


Measured memory_bytes: 6428
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
          ulong[] a = Input.ScanUlongArray();
          
          Console.WriteLine(a[0]%a[1]==0 ? "-1" : $"{a[0]}");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13396
l, r = list(map(int, input().split()))
if r - l + 1 >= 2019:
  print(0)
  exit()
ans = 2019
for i in range(l, r):
  for j in range(i + 1, r + 1):
    ans = min(ans, (i * j) % 2019)
print(ans)

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

int main(){
  int W,H,x,y,r;

  cin>>W>>H>>x>>y>>r;

  if(x+r>W||x-r<0||y+r>H||y-r<0)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
  
  return 0;
}

Measured memory_bytes: 3076
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


N, Q = list(map(int, input().split()))
S = input()
l = [0] * Q
r = [0] * Q
for i in range(Q):
    l_i, r_i = list(map(int, input().split()))
    l[i], r[i] = l_i-1, r_i-1
# 累積のACの数を数えて、引き算？
ruiseki_AC = [0] * N

for i in range(1, N):
    if S[i-1:i+1] == 'AC':
        ruiseki_AC[i] = ruiseki_AC[i-1] + 1
    else:
        ruiseki_AC[i] = ruiseki_AC[i-1]
# print("=======-")
for i in range(Q):
    # print('r', 'l', r[i], l[i])
    print(ruiseki_AC[r[i]] - ruiseki_AC[l[i]])


Measured memory_bytes: 23392
n = int(input())

l_list = list(map(int,input().split()))

count = 0
for a in range(n):
    for b in range(a+1,n):
        for c in range(b+1,n):
            a_r = l_list[a]
            b_r = l_list[b]
            c_r = l_list[c]
            if a_r + b_r > c_r and b_r+c_r > a_r and c_r + a_r > b_r and a_r != b_r and b_r != c_r and c_r != a_r:
                count+=1
print(count)

Measured memory_bytes: 9192
N,K=[int(s) for s in input().split()]
m=K
r=K
for i in range(N):
  x=int(input())
  r-=x
  m=min([m,x])
ans=N
while r>=0:
  r-=m
  ans+=1
  if r<0:
    ans-=1
    break
print(ans)
  

Measured memory_bytes: 38512
N = int(input())
P = [int(input()) for _ in range(N)]

POINT = [False] * (10 ** 4 + 101)
POINT[0] = True
LP = len(POINT)

for p in P:
  for i in range(10**4,-1,-1):
    POINT[i+p] = POINT[i] | POINT[i+p]
  
ans = 0
for i in range(LP):
  if POINT[i] and i % 10 != 0:
    ans = max(i,ans)
    
print(ans)


Measured memory_bytes: 3064
# Problem https://atcoder.jp/contests/abc085/tasks/abc085_a
# Python 3rd Try
import copy


def solver(errorStr):
    strList = list(errorStr)
    trueList = copy.deepcopy(strList)
    trueList[3] = '8'
    result = ''.join(trueList)
    return result


if __name__ == "__main__":
    result = ""
    result = solver(input())
    print(result)


Measured memory_bytes: 3444
PROGRAM-ID.                      ABC_105_B.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 N       PIC 9(3).
    01 i       PIC 9(3).
    01 j       PIC 9(3).
    01 flg     PIC 9(1).

PROCEDURE                        DIVISION.
    ACCEPT N.

    MOVE ZERO TO flg.

    PERFORM VARYING i FROM 0 BY 1 UNTIL N < 4 * i
        PERFORM VARYING j FROM 0 BY 1 UNTIL N < 7 * j
            IF 4 * i + 7 * j = N
                MOVE 1 TO flg
            END-IF
        END-PERFORM
    END-PERFORM.

    IF 1 = flg
        DISPLAY "Yes"
    ELSE
        DISPLAY "No"
    END-IF.

    STOP RUN.


Measured memory_bytes: 892
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
#include<cstdlib>
#include <queue>
#include <cmath>
#include <iomanip>
#include<list>
#include <utility>
#include <functional>
#include <tuple>
#define T long long

bool have[100]={false};


int main(){
	int n,m;
	std::cin >> n>>m;
	std::vector<std::vector<int>> g;
	g.resize(n);
	std::vector<T> h;
	h.resize(n);
	for(int i=0;i<n;i++){
		T hi;
		std::cin >> hi;
		h[i]=hi;
	}
	for(int i=0;i<m;i++){
		int a,b;
		std::cin >> a >> b;
		g[a-1].push_back(b-1);
		g[b-1].push_back(a-1);
	}
	int result = 0;
	for(int i=0;i<n;i++){
		bool highest = true;
		for(int j=0;j<g[i].size();j++){
			if(h[i]<=h[g[i][j]]){
				highest = false;
				break;
			}
		}
		if(highest){
			result++;
		}
	}
	std::cout << result << std::endl;
}


Measured memory_bytes: 9068
using System;
 
class Program
{
    static void Main(string[] args)
    {
      string[] str;
      int a, b, c;
      str = Console.ReadLine().Split(' ');
      a = int.Parse(str[0]);
      b = int.Parse(str[1]);
      c = int.Parse(str[2]);
     
      if(a < b && b < c){
      Console.WriteLine("Yes");
      }else{
      Console.WriteLine("No");
      }
      
    }
}


Measured memory_bytes: 7824
#include <stdio.h>
#define N 2000

int n,A[N];
int solve(int,int);

int main(){
  int i,q,m;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(solve(0,m)==1) printf("yes\n");
    else if(solve(0,m)==0) printf("no\n");
  }
  return 0;
}

int solve(int i,int m){

  int res;
  
  if(m==0) return 1;
  else if(i>=n) return 0;

  res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}

/*
#include <stdio.h>
#define N 2000
 
int n,A[N];
int solve(int,int);
 
int main(){
  int i,q,m;
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
 
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(solve(0,m)==1) printf("yes\n");
    else if(solve(0,m)==0) printf("no\n");
  }
  return 0;
}
 
int solve(int i,int m){
 
  int res;
   
  if(m==0) return 1;
  else if(i>=n) return 0;
 
  res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}
*/



Measured memory_bytes: 2108
N, K = gets.split.map(&:to_i)
Ary = gets.split.map(&:to_i)

history = Array.new(N, [false, 0])
history[0] = [true, 0]

next_city = Ary.first
N.times do |i|
  next_city -= 1

  if history[next_city][0]
    if K <= history[next_city][1]
      puts history.find_index { |e| e[1] == K } + 1
      exit
    end

    K -= history[next_city][1]
    j = K % (i + 1 - history[next_city][1])

    j.times do
      next_city = Ary[next_city] - 1
    end

    puts next_city + 1
    exit
  end

  history[next_city] = [true, i + 1]
  next_city = Ary[next_city]
end


Measured memory_bytes: 36728
import java.util.*;
public class Main {
  	static int mod = 1000000007;
  static int size = 200001;
	static long[] fac = new long[size];
	static long[] finv = new long[size];
	static long[] inv = new long[size];
	static int INF = Integer.MAX_VALUE;
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	// 整数の入力
	int N = sc.nextInt();
  int K = sc.nextInt();
    String S = sc.next();
  int Rcount=0;
  int Lcount=0;
  int RRcount=0;
  int LLcount=0;
    int RLcount=0;
  int i=0;
  int sum=0;
  String before = "N";
  int j=0;
  for(i=0;i<N;i++){
    if("R".equals(S.substring(i,i+1))){
      Rcount++;
      RRcount++;
      if(RRcount>1){
        sum++;
      }
      if(!"R".equals(before)&&!"N".equals(before)){
        LLcount=0;
        RLcount++;
      }
      before="R";
    }else{
      Lcount++;
      LLcount++;
      if(LLcount>1){
        sum++;
      }
      if(!"L".equals(before)&&!"N".equals(before)){
        RRcount=0;
        RLcount++;
      }
      before="L";
    }
  }
  if(RLcount<=K*2) {
    System.out.println(N-1);
  }
  else{
    System.out.println(sum+K*2);
  }




} 

 //fac, inv, finvテーブルの初期化、これ使う場合はinitComb()で初期化必要
	public static  void initComb(){
		fac[0] = finv[0] = inv[0] = fac[1] = finv[1] = inv[1] = 1;
		for (int i = 2; i < size; ++i) {
			fac[i] = fac[i - 1] * i % mod;
			inv[i] = mod - (mod / i) * inv[(int) (mod % i)] % mod;
			finv[i] = finv[i - 1] * inv[i] % mod;
		}
	}
 
	//nCk % mod
	public static long comb(int n, int k){
        if (n < k) return 0;
        if (n < 0 || k < 0) return 0;
		return fac[n] * finv[k] % mod * finv[n - k] % mod;
	}
 
	//n! % mod
	public static long fact(int n){
		return fac[n];
	}
 
	//(n!)^-1 with % mod
	public static long finv(int n){
		return finv[n];
	}
  
}

Measured memory_bytes: 36964
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
public class Main{
	
	public static void main(String[]args) {
		 Scanner sc = new Scanner(System.in);
         Map hs = new HashMap();
         PrintWriter out = new PrintWriter(System.out);
         int n = Integer.parseInt(sc.next());
         int k = Integer.parseInt(sc.next());
         int[] a = new int[n];
         for(int i = 0 ; i < n ; i++){
                 a[i] = Integer.parseInt(sc.next());
         }
         sc.close();
         double le = 0;
         double ri = Math.pow(10 , 9);
         while(ri - le > 0.000001){
                 double now = (le + ri) / 2;
                 int yono = 0;
                 for(int i = 0 ; i < n ; i++){
                         yono += (int)(a[i] / now);
                 }
                 if(yono > k) le = now;
                 else ri = now;
         }
         if(ri % 1 < 0.000001 || ri % 1 > 0.99999) out.print((int)Math.round(ri) + "\n");
         else out.print((int)Math.ceil(ri)+ "\n");
		out.close();
	}
}

Measured memory_bytes: 50732
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long bdai,aguudai,n,akidai,cou;
  string str;
  str="Yes";
  cou=0;
  bdai=0;
  aguudai=0;
  akidai=0;
  cin>>n;
  vector<long> aa(n);
  vector<long> bb(n);
  for(int i=0; i<n; i++){
    cin>>aa.at(i);
  }
  for(int i=0; i<n; i++){
    cin>>bb.at(i);
  }
  for(int i=0; i<n; i++){
    if(bb.at(i)<aa.at(i)){
      bdai=bdai-bb.at(i)+aa.at(i);
    }
    else if((bb.at(i)-aa.at(i))%2==0){
      aguudai=aguudai+bb.at(i)-aa.at(i);
    }
    else{
      akidai=akidai+bb.at(i)-aa.at(i);
      cou++;
    }
  }
  if(bdai>0){
    if(aguudai-2*bdai<0){
      bdai=bdai*2-aguudai;
      if(bdai>akidai-cou){
        str="No";
      }
    }
  }
  cout<<str;
}

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

#define all(A) (A).begin(), (A).end()
#define sz(A) int((A).size())

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

inline pii merge (pii x, pii y) {
  int first_mx = max(x.first, y.first);
  int second_mx = max(x.second, y.second);
  if (first_mx == x.first) second_mx = max(second_mx, y.first);
  if (first_mx == y.first) second_mx = max(second_mx, x.first);
  return std::move(pii(first_mx, second_mx));
}

const int MAX_N = 1e5 + 10;

int n;
pii st[2 * MAX_N];

void build () {
  for (int i = n - 1; i > 0; i--) st[i] = merge(st[i << 1], st[i << 1 | 1]);
}

pii getMax (int l, int r) {
  r++;
  pii res(-1, -1);
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l&1) res = merge(res, st[l++]);
    if (r&1) res = merge(res, st[--r]);
  }
  return res;
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n;
  vector <int> arr(n + 1);
  vector <int> pos(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    pos[arr[i]] = i;
    st[n + i] = pii(arr[i], -1);
  }
  build();
  function <pii(int,int)> getRange = [&] (int num, int sec) -> pii {
    pii exp(num, sec);
    int l1 = 0, r1 = pos[num];
    while (l1 != r1) {
      int m = (l1 + r1) >> 1;
      pii cur = getMax(m, pos[sec]);
      if (exp == cur) r1 = m;
      else l1 = m + 1;
    }
    int l2 = pos[num], r2 = n - 1;
    while (l2 != r2) {
      int m = (l2 + r2 + 1) >> 1;
      pii cur = getMax(pos[sec], m);
      if (exp == cur) l2 = m;
      else r2 = m - 1;
    }
    return pii(l1, l2);
  };
  function <pii(int)> getRange2 = [&] (int num) -> pii {
    int l1 = 0, r1 = pos[num];
    while (l1 != r1) {
      int m = (l1 + r1) >> 1;
      pii cur = getMax(m, pos[num]);
      if (num == cur.first) r1 = m;
      else l1 = m + 1;
    }
    int l2 = pos[num], r2 = n - 1;
    while (l2 != r2) {
      int m = (l2 + r2 + 1) >> 1;
      pii cur = getMax(pos[num], m);
      if (num == cur.first) l2 = m;
      else r2 = m - 1;
    }
    return pii(l1, l2);
  };
  ll ans = 0;
  for (int sec = 1; sec < n; sec++) {
    pii ran = getRange2(sec);
    pii l = pii(-1, -1);
    pii r = pii(-1, -1);
    if (0 <= ran.first - 1) l = getRange(arr[ran.first - 1], sec);
    if (ran.second + 1 < n) r = getRange(arr[ran.second + 1], sec);
    if (l.first != -1) {
      l.second = ran.first - 1;
      ll x = l.second - l.first + 1;
      ll y = ran.second - pos[sec] + 1;
      ans += x * y * sec;
    }
    if (r.first != -1) {
      r.first = ran.second + 1;
      ll x = r.second - r.first + 1;
      ll y = pos[sec] - ran.first + 1;
      ans += x * y * sec;
    }
  }
  cout << ans << '\n';
  return (0);
}


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

int main() {
  int N,K;
  int b=0;
  cin >> N >> K;
  for (int i=0; i<N; i++){
    int x;
    cin >> x;
    if(x<=K-x){
      b+= 2*x;
    }
    else
      b+= 2*(K-x);
  }
  cout << b << endl;
    
    
}
   

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

using namespace std;

using ll = long long;
using ld = long double;

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

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

    int n;
    cin >> n;

    vector<int> a(n);
    for (auto &a_i : a) cin >> a_i;

    vector<int> left_gcd(n), right_gcd(n);
    left_gcd[0] = a[0]; right_gcd[n - 1] = a[n - 1];

    for (int i = 1; i < n; ++i) {
        left_gcd[i] = gcd(a[i], left_gcd[i - 1]);
        right_gcd[n - i - 1] = gcd(a[n - i - 1], right_gcd[n - i]);
    }

    int max_gcd = max(left_gcd[n - 2], right_gcd[1]);
    for (int i = 1; i + 1 < n; ++i)
        max_gcd = max(max_gcd, gcd(left_gcd[i - 1], right_gcd[i + 1]));

    cout << max_gcd << endl;

    return 0;
}


Measured memory_bytes: 1408
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    a=list(map(int,input().split()))
    d=defaultdict(int)
    for x in a:
        d[x]+=1
        d[x-1]+=1
        d[x+1]+=1
    ans=0
    for i in range(10**5+1):
        ans=max(ans,d[i])
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 65132
#include<stdio.h>

#define INF 999999999

typedef long int lint;

typedef struct tree{
  lint key;
  lint parent;
  lint right;
  lint left;
}TREE;
  
int main()
{
  int i;
  lint n;
  lint key;

  TREE H[510];  
 
  scanf("%d",&n);

  for(i = 0;i < 510;i++){
    H[i].key = INF;
    H[i].left = INF;
    H[i].right = INF;
    H[i].parent = INF;
  }

  for(i = 1;i < n+1;i++){
    scanf("%ld",&key);
    H[i].key = key;
  }
  
  for(i = 1;i < n+1;i++){
    if(H[i/2].key != INF){
      H[i].parent = H[i/2].key;
    }
    if(H[i*2].key != INF){
      H[i].left = H[i*2].key;
    }
    if(H[i*2+1].key != INF){
      H[i].right = H[i*2+1].key;
    }
  }

  for(i = 1;i < n+1;i++){
    printf("node %d: ",i);

    printf("key = %ld, ",H[i].key);
    
    if(H[i].parent != INF){
      printf("parent key = %ld, ",H[i].parent);
    }
    if(H[i].left != INF){
      printf("left key = %ld, ",H[i].left);
    }
    if(H[i].right != INF){
      printf("right key = %ld, ",H[i].right);
    }
    printf("\n");
  }
  
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <string>

using namespace std;

int main(){
    string a;
    string b;
    string c;
    cin >> a >> b >> c;
    a[0] = a[0] + 'A' - 'a';
    b[0] = b[0] + 'A' - 'a';
    c[0] = c[0] + 'A' - 'a';
    cout << a[0] << b[0] << c[0] << endl;
}


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

#define MAX_N 100000

long N;
long res=0, diff[MAX_N];

int main() {
    std::cin >> N;
    for (int i=0; i<N; ++i) {
        long a, b;
        std::cin >> a >> b;
        res -= b;
        diff[i] = a+b;
    }
    std::sort(diff, diff+N, std::greater< long >() );
    for (int i=0; i<N; ++i) {
        if ( i%2 == 0 ) res += diff[i];
    }
    std::cout << res << std::endl;
    return 0;
}


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

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

  cout << endl;
  return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
  ll n, m;
  cin >> n >> m;
  char ch[n+1][m+1];
  for(ll x = 1; x <= n; x++) {
  	for(ll y = 1; y <= m; y++) {
      cin >> ch[x][y];
    }
  }
  
  ll dp[n+1][m+1];
  memset(dp, 0, sizeof(dp));
  for(ll x = 1; x <= n; x++) {
    for(ll y = 1; y <= m; y++) {
      if(x == 1 && y == 1) {
      	dp[x][y] = 1;
      }
      else if(ch[x][y] == '.') {
        dp[x][y] = (dp[x][y-1] + dp[x-1][y]) % 1000000007;
      }
    }
  }
  cout << dp[n][m];
}

Measured memory_bytes: 12348
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a[3][3],b[10];
    bool c[3][3];
    for(int i=0;i<3;i++){
        for(int r=0;r<3;r++){
            cin >> a[i][r];
        }
    }
    cin >> n;
    for(int i=0;i<n;i++)
    cin >> b[i];
    for(int i=0;i<n;i++){
        for(int r=0;r<n;r++){
            c[i][r]=false;
        for(int k = 0; k < n; k++) {
if(a[i][r] == b[k]) c[i][r] = true; }
}
    }
    string ANS = "No";
     for(int i = 0; i < 3; i++) {
 if(c[i][0] and c[i][1] and c[i][2]) ANS = "Yes";
 }
 for(int i = 0; i < 3; i++) {
 if(c[0][i] and c[1][i] and c[2][i]) ANS = "Yes";
 }
 if(c[0][0] and c[1][1] and c[2][2]) ANS = "Yes";
 if(c[0][2] and c[1][1] and c[2][0]) ANS = "Yes";
 cout << ANS << endl;
 return 0;
 }


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <queue>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 199;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//順列計算
ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

int main(){
    ll n,d;
    cin >> n >> d;
    ll cnt = 0;
    rep1(i, n){
        ll x,y;
        cin >> x >> y;
        if(x*x + y*y <= d*d) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;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--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll K;
    cin >> K;
    ll ans = 0;
    rep2(i, 1, K + 1) {
        rep2(j, 1, K+1) {
            rep2(k, 1, K+ 1) {
                ans += gcd(i, gcd(j, k));
            }
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 3612
#include<stdio.h>

int count[26];
char a;

int main(void){
    int i,j;
    while(1){
        i = scanf("%c",&a);
        if(a >= 'a' && a <= 'z')
            count[a - 'a']++;
        else if(a >= 'A' && a <= 'Z')
            count[a - 'A']++;
        if(i == EOF)
            break;
    }
    for(i = 0;i < 26;i++){
        printf("%c : %d\n",'a' + i,count[i]);
    }
    return 0;
}

Measured memory_bytes: 540
#include <iostream>
#include <queue>

using namespace std;

int main(){
    double n,m,tmp; cin >> n >> m;
    priority_queue<double> pq;
    for(long long i = 0; i <n; i++) {
        cin >> tmp;
        pq.push(tmp);
    }
    for(long long i = 0; i< m; i++) {
        tmp = pq.top();
        pq.pop();
        tmp /= 2;
        pq.push(tmp);
    }
    long long ans = 0;
    while(!pq.empty()) {
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 1400
N = int(input())
L = [list(map(int,input().split())) for i in range(N)]
NOW = [0]*3
NEXT = [None]*3
for i in range(N) :
    NEXT[0] = max(NOW[1],NOW[2]) + L[i][0]
    NEXT[1] = max(NOW[2],NOW[0]) + L[i][1]
    NEXT[2] = max(NOW[0],NOW[1]) + L[i][2]    
    NOW = NEXT.copy()
print(max(NOW))


Measured memory_bytes: 30576