akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
using namespace std;

bool is_to_left(int pos, int N, int Q, string s, vector<char> t, vector<char> d) {
    if (pos == 0) {
        return true;
    } else if (pos == N + 1) {
        return false;
    }

    for (int i = 0; i < Q; i++) {
        if (s[pos] == t[i] and d[i] == 'L') {
            pos--;
        } else if (s[pos] == t[i] and d[i] == 'R') {
            pos++;
        }

        if (pos == 0) {
            return true;
        } else if (pos == N + 1) {
            return false;
        }
    }

    return false;
}

bool is_to_right(int pos, int N, int Q, string s, vector<char> t, vector<char> d) {
    if (pos == N + 1) {
        return true;
    } else if (pos == 0) {
        return false;
    }

    for (int i = 0; i < Q; i++) {
        if (s[pos] == t[i] and d[i] == 'L') {
            pos--;
        } else if (s[pos] == t[i] and d[i] == 'R') {
            pos++;
        }

        if (pos == N + 1) {
            return true;
        } else if (pos == 0) {
            return false;
        }
    }

    return false;
}

int main() {
    int N, Q;
    cin >> N >> Q;
    string s;
    cin >> s;
    s = 'a' + s + 'a';
    vector<char> t(Q), d(Q);
    for (int i = 0; i < Q; i++) {
        cin >> t[i] >> d[i];
    }

    int lb = 0, ub = N + 1;
    while (ub - lb > 1) {
        int mid = (lb + ub)/2;
        if (is_to_left(mid, N, Q, s, t, d)) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    int live_lb = ub;

    lb = 0;
    ub = N + 1;
    while (ub - lb > 1) {
        int mid = (lb + ub)/2;
        if (is_to_right(mid, N, Q, s, t, d)) {
            ub = mid;
        } else {
            lb = mid;
        }
    }
    int live_ub = lb;

    cout << live_ub - live_lb + 1 << endl;
    return 0;
}

Measured memory_bytes: 1472
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a <= 8 && b<= 8){
      System.out.println("Yay!");
    }else{
      System.out.println(":(");
    }
  }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<int> E(N+1);
    E[0] = 0;
    for(int i = 1; i < N + 1; i++){
        if(S[i-1] == 'E') E[i]++;
        E[i] += E[i-1];
        //cout << E[i] << endl;
    }
    vector<int> F(N);
    int Min = (E[N] - E[1]);
    for(int i = 1; i < N; i++){
        F[i] = (E[N] - E[i+1]) + (i - (E[i] - E[0]));
        Min = min(Min,(F[i]));
    }
    cout << Min << endl;
}


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

class Pair<E,F>{
    E first;
    F second;
    public Pair(E first, F second){
        this.first=first;
        this.second=second;
    }
    public E getFirst(){return first;}
    public F getSecond(){return second;}
    public String toString(){
        return "<"+first.toString()+","+second.toString()+">";
    }
    public int hashCode(){
        return first.hashCode()*30011+second.hashCode()+2;
    }
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Pair another = (Pair) obj;
        return this.getFirst().equals(another.getFirst())&&this.getSecond().equals(another.getSecond());
    }
}
class Point extends Pair<Double,Double>{
    public Point(double x, double y){
        super(x,y);
    }
    public double distanceTo(Point another){
        double distX = Math.abs(this.getFirst()-another.getFirst());
        double distY = Math.abs(this.getSecond()-another.getSecond());
        return distX+distY;/*manhattan dist*/
        //return Math.sqrt(distX*distX+distY*distY);/*euclidean dist*/
        //return Math.max(distX,distY);/*chebyshev dist*/
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        Point[] student = new Point[N];
        Point[] check = new Point[M];
        for(int n=0;n<N;n++) student[n] = new Point(sc.nextDouble(),sc.nextDouble());
        for(int m=0;m<M;m++) check[m] = new Point(sc.nextDouble(),sc.nextDouble());
        for(int n=0;n<N;n++){
        	int bestCheck = 0;
        	double bestDist = Double.POSITIVE_INFINITY;
        	for(int m=0;m<M;m++){
        	    if(student[n].distanceTo(check[m])<bestDist){
        	        bestDist = student[n].distanceTo(check[m]);
        	        bestCheck = m+1;
        	    }
        	}
        	System.out.println(bestCheck);
        }
    }
}

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

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

  long long mod = N % 11;
  long long cnt = N / 11;

  if (mod == 0)
    cout << cnt * 2 << endl;
  else if (mod <= 6)
    cout << cnt * 2 + 1 << endl;
  else
    cout << cnt * 2 + 2 << endl;
}

Measured memory_bytes: 256
N=int(input())
S=input()
ans=0
for i in range(10):
  str_i = str(i)
  i_index=S.find(str_i)
  if i_index==-1:
    continue
  for j in range(10):
    str_j=str(j)
    j_index=S.find(str_j, i_index+1)
    if j_index==-1:
      continue
    for k in range(10):
      str_k=str(k)
      k_index=S.find(str_k, j_index+1) 
      if k_index!=-1:
        ans+=1
print(ans)

Measured memory_bytes: 9272
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long LL;

int main(){
  int N;
  cin>>N;
  vector<vector<LL> >A(N,vector<LL>(N));
  LL sum=0;
  for(int i=0;i<N;i++){
	for(int j=0;j<N;j++){
	  cin>>A[i][j];
	  sum+=A[i][j];
	}
  }

  sum/=2;

  for(int i=0;i<N-1;i++){	
	for(int j=i+1;j<N;j++){
	  int flag=0;
	  for(int k=0;k<N;k++){
		if(A[i][j]>A[i][k]+A[k][j]){
		  cout << -1 << endl;
		  return 0;
		}
		if(A[i][k]!=0 && A[k][j]!=0 
		   && A[i][j]==A[i][k]+A[k][j]){		  
		  flag=1;
		}
	  }
	  if(flag==1){
		sum-=A[i][j];
	  }
	}
  }


  cout << sum << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int a[100011],b[100011],n,m,ans=0;
int main()
{
	cin >>n>>m;
	for(int i=0;i<n;i++)
	cin >>a[i]>>b[i];
	sort(b,b+n);
	reverse(b,b+n);
	sort(a,a+n);
	reverse(a,a+n);
	ans=(m+a[0]-1)/a[0];
	for(int i=0;i<n;i++)
	{
		m-=b[i];
		int cnt;
		if(m<=0)
		cnt=0;
		else
		cnt=(m+a[0]-1)/a[0];
		if(ans>i+1+cnt)
		ans=i+1+cnt;
	}
	cout <<ans<<endl;
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>

typedef long long ll;
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

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



#define MOD 1000000007
#define PI 3.14159265359

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

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

ll mypow(ll a, ll b) {
    a %= MOD;
    ll res = 1;
    while (b > 0) {
        if (b % 2 == 1)res = res * a % MOD;
        a = a * a % MOD;
        b /= 2;
    }
    return res;
}


int main()
{
    int n; cin >> n;
    multiset<pair<ll, ll>> dir1;
    multiset<pair<ll, ll>> dir2;
    vector<int> num;
    int numzero = 0;
    rep(i, n) {
        ll a, b; cin >> a >> b;
        if (a == 0 && b == 0) {
            numzero++;
            continue;
        }
        else if (b == 0) {
            dir1.insert(make_pair(1, 0));
            continue;
        }
        else if (a == 0) {
            dir2.insert(make_pair(1, 0));
            continue;
        }

        ll g = gcd(abs(a), abs(b));
        a = a / g; b = b / g;
        if (a < 0) {
            a *= -1; b *= -1;
        }


        if (b >= 0)
            dir1.insert(make_pair(a, b));
        else 
            dir2.insert(make_pair(-b, a));
    }
    ll res = 1;

    multiset<pair<ll, ll>>::iterator it1 = dir1.begin();
    multiset<pair<ll, ll>>::iterator it2 = dir2.begin();

    while (it1 != dir1.end() || it2 != dir2.end()) {
        ll count = 0;
        if (it1 == dir1.end()) {
            count = mypow(2, dir2.count(*it2)) % MOD;
            it2 = dir2.upper_bound(*it2);
        }
        else if (it2 == dir2.end()) {
            count = mypow(2, dir1.count(*it1)) % MOD;
            it1 = dir1.upper_bound(*it1);
        }
        else if (*it2 < *it1) {
            count = mypow(2, dir2.count(*it2)) % MOD;
            it2 = dir2.upper_bound(*it2);
        }
        else if (*it1 < *it2) {
            count = mypow(2, dir1.count(*it1)) % MOD;
            it1 = dir1.upper_bound(*it1);
        }
        else {
            count = (mypow(2, dir2.count(*it2)) - 1)  % MOD;
            count = (count + mypow(2, dir1.count(*it1)) - 1) % MOD;
            count = (count + 1) % MOD;
            if (count < 0)
                count + MOD;

            it1 = dir1.upper_bound(*it1);
            it2 = dir2.upper_bound(*it2);
        }
        res = res * count % MOD;
    }

    
    res = (res - 1 + numzero) % MOD;
    if (res < 0)
        res += MOD;
    cout << res << endl;
   
}




Measured memory_bytes: 16104
n = gets.strip.to_i
array = gets.split.map(&:to_i)
puts array.join(" ")

for i in 1..n-1 do
key = array[i]
j = i

while j>0 && array[j-1] > key do
array[j] = array[j-1]
j -=1
end
array[j] = key
puts array.join(" ")
end

Measured memory_bytes: 8788
//author-abhijit dey
 //Welcome to my code. btw I hate coding 😉
#include <bits/stdc++.h>
using namespace std;
#define     ff first
#define     ss second
#define     pb push_back
#define     mp make_pair
#define     INF 1000000005
#define     MOD 1000000000
#define     ninf -1000000000
#define     all(c) c.begin(), c.end()
#define     tinput long long int t;cin>>t;
#define     mem(a,x) memset(a,x,sizeof a)
#define     for0(i,n) for(long long int i=0;i<n;i++)
#define     pi 3.141592653589793238462643383279502884
#define     fori(i,a,n) for(long long int i=a;i<n;i++)
#define     forxy(i,x,y) for(int i=x;i<=y;i++)
#define     rfor(i,n) for(long long int i=n-1;i>=0;i--)
#define     ainput for(int i=0; i<n; i++) cin>>a[i];
#define     fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

typedef     long long int ll;
typedef     vector<long long int>vll;
typedef     vector<vector<int> >vvll;
typedef     pair<long long int,long long int>pr;
typedef     vector<pair<long long int,long long int> >vp;

inline long long  min2(long long  a, long long  b)  {return (a)<(b)?(a):(b);}
inline long long  max2(long long  a, long long  b)  {return (a)>(b)?(a):(b);}
inline long long  max3(long long  a, long long  b, long long  c)    {return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  min3(long long  a, long long  b, long long  c)    {return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std::chrono;
ll N,M;
vll adj[100001];
ll dp[100001];
ll dfs(ll node)
{
    ll sum=0;
    if(adj[node].size()==0)return 0;
    if(dp[node]!=-1)return dp[node];
    for(ll x:adj[node])
    {
        sum=max(sum,1+dfs(x));
    }
    dp[node]=sum;
    return dp[node];
}

void process()
{
    cin>>N>>M;
    memset(dp,-1,sizeof(dp));
    for(ll i=1;i<=M;i++)
    {
        ll u,v;cin>>u>>v;
        adj[u].pb(v);
    }
    ll len=0;
    for(ll i=1;i<=N;i++)
    {
        len=max(len,dfs(i));
    }
    cout<<len;
}
int main()
{
    fastio;
    //tinput;
    //while(t--)
        process();
}


Measured memory_bytes: 8576
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int K = in.nextInt();
            int count = 0;
            for (int i = 0; i < N; i++) {
                int h = in.nextInt();
                if (K <= h) {
                    count++;
                }
            }
            out.println(count);
        }

    }
}



Measured memory_bytes: 45948
import math
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
score = 0
def calc_score(a):
    ret = 0
    if a == "s":
        ret = R
    elif a == "p":
        ret = S
    elif a == "r":
        ret = P
    return ret
    
for i in range(K):
    tmp = T[i::K]
    #print(T[i::K])
    score += calc_score(tmp[0])
    flag = True
    for j in range(1,len(tmp)):
        if tmp[j] == tmp[j - 1]:
            flag = not flag
        else:
            flag = True
        if flag:
            #print(calc_score(tmp[j]))
            score += calc_score(tmp[j])
print(score)
    

Measured memory_bytes: 3316
m = int(input())

class Node:
    def __init__(self, key, left ,right):
        self.key = key
        self.left = left
        self.right = right


class BinaryTree():
    def __init__(self):
        self.root = None

    def getRoot(self):
        return self.root
    def setRoot(self, v):
        self.root = v

    def inorder(self, v=None):
        if v is None:
            v = self.root
        if v.left is not None:
            self.inorder(v.left)
        print(' ' + str(v.key), end='')
        if v.right is not None:
            self.inorder(v.right)
        
    def preorder(self, v=None):
        if v is None:
            v = self.root
        print(' ' + str(v.key), end='')
        if v.left is not None:
            self.preorder(v.left)
        if v.right is not None:
            self.preorder(v.right)

def insert(T, z):
    y = None
    x = T.getRoot()
    while x is not None:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.p = y

    if y is None:
        T.setRoot(z)
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z

def find(T, k, noprint=False):
    x = T.getRoot()
    while x is not None:
        if x.key == k:
            if not noprint:
                print('yes')
            return x
        elif x.key < k:
            x = x.right
        else:
            x = x.left
    print('no')

def getNext(v):
    if v.right is not None:
        return getMinimum(v.right)  
    y = v.p
    while y is not None and v == y.right:
        v = y
        y = y.p
    return y

def getMinimum(v):
    while v.left is not None:
        v = v.left
    return v


    
def delete(T, z):
    if not z.left and not z.right:
        p = z.p
        if z.key < p.key:
            p.left = None
        else:
            p.right = None

    elif z.left and not z.right:
        p = z.p
        c = z.left
        if z.key > p.key:
            p.right = c
        else:
            p.left = c
        c.p = p
    elif not z.left and z.right:
        p = z.p
        c = z.right
        if z.key > p.key:
            p.right = c
        else:
            p.left = c
        c.p = p
    else:
        n = getNext(z)
        z.key = n.key
        delete(T, n)

T = BinaryTree()

for i in range(m):
    inp = input().split()
    if inp[0] == 'print':
        T.inorder()
        print()
        T.preorder()
        print()
    elif inp[0] == 'find':
        find(T, int(inp[1]))
    elif inp[0] == 'delete':
        delete(T, find(T, int(inp[1]),True))
    else:
        v = Node(int(inp[1]), None, None)
        insert(T, v)

Measured memory_bytes: 124512
#include <iostream>

int main(int argc, char* argv[])
{
	int x = 0;
	int y = 0;
	std::cin >> x;
	std::cin >> y;
	if (x < y)
		std::swap(x, y);

	while (x >= y && y > 0)
	{
		const int tmp = x;
		x = y;
		y = tmp % y;
	}

	std::cout << x << std::endl;

	return 0;
}

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

int main() {
	int n, x;
	int a[101];
	cin>>n>>x;
	for (int i=0; i<n; i++)
		cin>>a[i];
	sort(a, a+n);
	int i=0;
	while (i<n && a[i]<=x)
		x -= a[i++];
	if (i==n && x!=0)
		cout<<i-1<<endl;
	else
		cout<<i<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 1e9;
const ll INFll = 1e18;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int n,k;
  cin>>n>>k;
  int tmp(1),cnt(0);
  while(n / tmp != 0){
    tmp*=k;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef ll Weight;
void add_edge(vector<vector<Weight>>& g, Weight from, Weight to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

template<class T> inline bool chmax(T& a, T b) { if (a <= b) { a = b; return true; } else return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } else return false; }

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

  int n; cin >> n;
	map<string, int> mp;
	rep(i, n) {
		string s; cin >> s;
		mp[s]++;
	}
	
	cout << "AC x " << mp["AC"] << endl;
	cout << "WA x " << mp["WA"] << endl;
	cout << "TLE x " << mp["TLE"] << endl;
	cout << "RE x " << mp["RE"] << endl;
}

Measured memory_bytes: 3688
A,B,M = map(int, input().split())

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

ans = min(a) + min(b)

for i in range(M):
  x,y,c = map(int, input().split())
  
  ans = min(ans, a[x-1]+b[y-1]-c)
  
print(ans)

Measured memory_bytes: 18736
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
// typedef pair<ll,ll> P;

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

template<class T>
bool umax(T &a, const T &b){
    if (a<b) {
        a=b; return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b<a) {
        a=b; return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

ll time2[50];
double b[50];
int main() {
    int N, K; cin >> N >> K;

    time2[0]=1LL;
    int need2t[50];

    for(int i=0; i<=20; i++){
        need2t[i]=0;
    }

    b[0]=1;
    for(int i=1; i<=20; i++){
        time2[i]=time2[i-1]*2;
        need2t[i]=0;
        b[i]=b[i-1]/2;
    }

    double a=0;
    for(int i=1; i<=N; i++){
        for(int j=0; j<=20; j++){
            if(time2[j]*i>=K){
                need2t[j]++;
                break;
            }
        }
    }

    for(int i=0; i<=20; i++){
        a+=b[i]*need2t[i]/N;
    }
    printf("%.12f", a);
    return 0;
}


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

void solve(long long A, long long B){
    if (B == 1) cout << 0 << '\n';
    else if (A >= B) cout << 1 << '\n';
    else if ((B-A) % (A-1)) cout << (B-A) / (A-1) + 2 << '\n';
    else cout << (B-A) / (A-1) + 1 << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

int main() {
    int N;
    int t[110000], x[110000], y[110000];
    cin >> N;
    t[0] = x[0] = y[0] = 0;  // 初期状態
    for (int i = 0; i < N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];  // 1-index にしておく

    bool can = true;
    for (int i = 0; i < N; ++i) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) can = false;
        if (dist % 2 != dt % 2) can = false;  // dist と dt の偶奇は一致する必要あり！
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  double cnt = 0;
  for(int i=1; i<=n; i++){
    if(i % 2) cnt++;
  }
  printf("%.10lf\n", cnt / n);
  return 0;
}


Measured memory_bytes: 256
// AOJ 2811 Rainy Bus Stops
// 2018.3.10 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

// 数値のハッシュ関数
#define HASHSIZ 500009
long long hash[HASHSIZ + 5], *hashend = hash + HASHSIZ;

int insert(int n, int t)
{
	long long x;
	long long *p;
	
	x = ((long long)n << 20) | (t + 1);
	p = hash + (int)(x % HASHSIZ);
	while (*p) {
		if (*p == x) return 0;
		if (++p == hashend) p = hash;
	}
	*p = x;
	return 1;
}

#define MAX 100000
typedef struct { int n, t, w; } QUE;
QUE que[MAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].w < que[i].w) min = l; else min = i;
	if (r < qsize && que[r].w < que[min].w) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int n, int t, int w)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].n = n, que[i].t = t, que[i].w = w;
	while (i > 0 && que[min = PARENT(i)].w > que[i].w) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

int N, M;
int S, G;
typedef struct { int v, t, c; } T;
T *to[100002]; int hi[100002];

int dijkstra(int start, int goal)
{
	int i, s, t, w;

	qsize = 0;
	enq(start, 0, 0);
	while (qsize) {
		s = que[0].n, t = que[0].t, w = que[0].w; deq();
//printf("s=%d, goal=%d, w=%d\n", s, goal, w);
		if (s == goal) return w;
		if (!insert(s, t)) continue;
		for (i = 0; i < hi[s]; i++) {
			if (t <= to[s][i].t)
				enq(to[s][i].v, to[s][i].c, w + to[s][i].t - t);
		}
	}
	return -1;
}

int main()
{
	int i, k, u, v, t;
	int *memo, sz;

	N = in(), M = in(), S = in() - 1, G = in() - 1;
	memo = malloc(M * 4 * sizeof(int));
	sz = 0;
	for (i = 0; i < M; i++) {
		memo[sz++] = u = in() - 1, memo[sz++] = in() - 1;
		memo[sz++] = in(), memo[sz++] = in();
		hi[u]++;
	}
	for (i = 0; i < N; i++) if (hi[i]) to[i] = malloc(hi[i] * sizeof(T));
	memset(hi, 0, N * sizeof(int));
	i = 0; while (i < sz) {
		u = memo[i++], v = memo[i++];
		k = hi[u]++, to[u][k].v = v;
		to[u][k].t = t = memo[i++];
		to[u][k].c = t + memo[i++];
	}
//	free(memo);

	printf("%d\n", dijkstra(S, G));
	return 0;
}


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

ll par[222222];
int root(ll x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
}

void unite(ll x, ll y) { // xとyの木を併合
    ll rx = root(x);
    ll ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
}

int main(){
  ll N,M,i;
  ll a,b;
  cin >> N >> M;
  for(int i = 0; i <= N; i++) par[i] = i;
  for(i=0;i<=M-1;i++){
    cin >> a >> b;
    unite(a,b);
    }
  ll ne[222222] = {0};
  for(i=1;i<=N;i++)
    ne[root(i)]=1;
  ll ans = 0;
  for(i=1;i<=N;i++)
    ans += ne[i];
  cout << ans - 1 << endl;
}

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

int main()
{
	int a,b,c,d[30][30],sum[30]={0},ans=0;
    int st[30];
	string s;

	cin>>a>>b>>c;
    for(int i=0;i<b;i++)
        cin>>st[i];

    for(int i=0;i<a;i++)
    {
        for(int n=0;n<b;n++)
            cin>>d[i][n];
    }
	for(int i=0;i<a;i++)
    {
        for(int n=0;n<b;n++)
        {
            sum[i]+=(d[i][n]*st[n]);
        }
        sum[i]+=c;
        if(sum[i]>0)
            ans++;
    }
    cout<<ans;

	return 0;
}
	

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <chrono>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};
constexpr char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;}
  std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



int main(void){
  char a = getchar();
  switch(a){
    case 'A':
      putchar('T');
      break;
    case 'T':
      putchar('A');
      break;
    case 'G':
      putchar('C');
      break;
    case 'C':
      putchar('G');
      break;
  }
  putchar(BR);
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();

        int symmetric = s.length -1;
        int count = 0;
        for (int i = 0; i < s.length / 2; i++) {
            if (s[i] != s[symmetric]) {
                count++;
            }
            symmetric--;
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 23252
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(int i = a;i < b; i++)

int main() {

	string s;
	cin >> s;

	vector<int> ans(s.size(), 0);

	int rcount = 0, lcount = 0, count = 0;
	rep(i, 0, s.size()) {
		if (s[i] == 'R' && s[i + 1] == 'L') {
			int j = i + 2;
			while (s[j] != 'R' && j < s.size()) {
				lcount++;
				j++;
			}
			count = rcount + lcount;
			ans[i] = count / 2 + 1;
			ans[i + 1] = count / 2 + 1;
			if (count % 2 == 1) {
				if (rcount % 2 != 0) ans[i + 1]++;
				else ans[i]++;
			}
			rcount = 0;
			lcount = 0;
			i = j - 1;
		}
		else if(s[i] == 'R') rcount++;
	}

	rep(i, 0, s.size()) {
		cout << ans[i] << " ";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  ll n,i;
  cin>>n;
  ll h[n];
  for(i=0;i<n;i++)
    cin>>h[i];
  ll dp[n];
  dp[0]=0;
  dp[1]=abs(h[0]-h[1]);
  for(i=2;i<n;i++)
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  cout<<dp[n-1]<<"\n";
  return 0;
}

Measured memory_bytes: 1792
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝




*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n>>k;
  while(n--)
  {
      cin>>a>>b;
      a=abs(a);
      b=abs(b);
      if((a*a)+(b*b)<=k*k)


{
   d++;
}









  }
  cout<<d<<endl;
}


Measured memory_bytes: 3588
#import <Foundation/Foundation.h>

int main(void){

    @autoreleasepool {
    
        NSStringEncoding enc = NSUTF8StringEncoding;
        NSFileHandle *stdin = [NSFileHandle fileHandleWithStandardInput];
        NSFileHandle *stdout = [NSFileHandle fileHandleWithStandardOutput];
        
        NSData *indata = [stdin readDataToEndOfFile];
        NSMutableString *str = [NSMutableString alloc];
        [str initWithBytes:indata.bytes length:indata.length encoding:enc];
        
        NSScanner *scan = [NSScanner alloc];
        [scan initWithString:str];
        
        NSString *n_str = [NSString alloc];
        [scan scanUpToString:@"\n" intoString:&n_str];
        NSInteger n = [n_str integerValue];
        NSInteger r = 48 - n;
      	
       	NSMutableString *r_str = [NSMutableString new];
        
        [r_str appendFormat:@"%d", r];
        
        [stdout writeData:[r_str dataUsingEncoding:enc]];    }
    
    return 0;
}

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

long long p[15];

void func(){
  for(int i=0; i<14; i++){
    if(p[i]>=0){
      p[i+1]+=(p[i]/3);
      p[i]%=3;
    }
  }
}

long long numfunc(){
  long long res=0, m=1;
  for(int i=0; i<15; i++){
    if(p[i]>=0) res+=(2*p[i]+3)*m;
    else break;
    m*=10;
  }
  return res;
}

bool isOK(){
  bool check;
  for(int i=0; i<3; i++){
    check=false;
    for(int j=0; j<15; j++) if(p[j]==i) check=true;
    if(check==false) break;
  }
  return check;
}

int main(){
  int N; cin >> N;
  long long count=0;
  bool conti=true;
  for(int i=0; i<15; i++) p[i]=-1;
  while(conti){
    p[0]++;
    func();
    if(isOK()==true){
      long long tmp=numfunc();
      if(tmp<=N) count++;
      else conti=false;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

typedef tuple<int, int> edge;

int N, M;
vector<edge> V[100010];
stack<int> S;
int visited[100010];
bool loop = false;
int d[100010];

void visit(int n) {
  if (visited[n] == 1) {
    loop = true;
  } else if (visited[n] == 0) {
    visited[n] = 1;
    for (auto x : V[n]) {
      int m = get<0>(x);
      visit(m);
    }
    visited[n] = 2;
    S.push(n);
  }
}

int main () {
  cin >> N >> M;
  for (auto i = 0; i < M; ++i) {
    int L, R, D;
    cin >> L >> R >> D;
    L--;
    R--;
    V[L].push_back(edge(R, D));
  }
  for (auto i = 0; i < N; ++i) {
    visit(i);
  }
  if (loop) {
#if DEBUG == 1
    cerr << "loop" << endl;
#endif
    cout << "No" << endl;
    return 0;
  }
  fill(d, d+100010, -1);
  d[S.top()] = 0;
  while (!S.empty()) {
    int now = S.top();
    // cerr << "now = " << now << endl;
    S.pop();
    for (auto x : V[now]) {
      int dst = get<0>(x);
      int dist = get<1>(x);
      if (d[dst] == -1) {
        d[dst] = dist + d[now];
      } else {
        if (d[dst] == dist + d[now]) {
          //
        } else {
#if DEBUG == 1
          cerr << "d[" << dst << "] = " << d[dst] << endl;
          cerr << "dist = " << dist
               << ", d[" << now << "] = " << d[now] << endl;
#endif
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 11392
#include <iostream>
#include <set>

using namespace std;

int main()
{
    int N, M;
    cin>>N>>M;
    bool ok = false;
    set<int> S1, S2;
    for (int i=0; i<M; i++)
    {
        int a, b;
        cin>>a>>b;
        a--, b--;
        if (a>b)
            swap(a, b);
        //if (a==0 && b==N-1)
        //    ok = true;
        if (a==0)
            S1.insert(b);
        if (b==N-1)
            S2.insert(a);
    }

    for (int s: S1)
        if (S2.count(s) > 0)
            ok = true;
    cout<<(ok ? "POSSIBLE" : "IMPOSSIBLE")<<endl;
}


Measured memory_bytes: 9600
#include<stdio.h>
int hantei(int);
int main()
{
  int n,a,i;
  int count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&a);
      if(hantei(a)) count++;
    }
  printf("%d\n",count);
  return 0;
}

int hantei(int a)
{
  int i;
  if(a<2) return 0;
  else if(a==2) return 1;
  if(a%2==0) return 0;
  for(i=3;i*i<=a;i+=2)
    {
      if(a%i==0) return 0;
    }
  return 1;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
#define x first
#define y second
#define mp make_pair

int n;
string sad;
vector <string> v;

void gen(int k, int last){
	if(k == n){
		cout << sad << '\n';
		//v.push_back(sad);
		return;
	}
	for(int i = 0 ; i <= last ; ++i){
		sad.push_back('a' + i);
		gen(k + 1, max(last, i + 1));
		sad.pop_back();
	}
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
gen(0, 0);
/*
for(int i = 0 ; i < (int)v.size() ; ++i){
	for(int j = 0 ; j < (int)v.size() ; ++j){
		if(i == j)
			continue;
		bool p = 1;
		for(int l = 0 ; l < n ; ++l){
			for(int w = 0 ; w < n ; ++w){
				if(v[i][l] == v[i][w] && v[j][l] != v[j][w]){
					p = 0;
					break;
				}
				if(v[i][l] != v[i][w] && v[j][l] == v[j][w]){
					p = 0;
					break;
				}
			}
		}
		if(p){
			cout << v[i] << ' ' << v[j] << endl;
		}
	}
}
*/

return 0;
}



Measured memory_bytes: 1536
#include <stdlib.h>
#include <stdio.h>
int main(){
  long int a = 1;
  long int b = 2;
  int n;
  scanf("%d", &n);
  if(n!=1){
    for(int i=2;i<=n;i++){
      long int tmp = a;
      a = a + b;
      b = tmp;
    }
  }
  printf("%ld\n", a);
}

Measured memory_bytes: 1704
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <utility>
#include <numeric>

using namespace std;

int main(){
    int N,Q;
    long sum=0;
    vector<long> num(110000,0);
    long a,b,c;
    cin >> N;
    for (int i =0;i<N;i++){
        cin >> a;
        sum+=a;
        num[a]++;
    }
    cin >> Q;
    for(int i = 0;i<Q;i++){
        cin>>b>>c;
        sum+=(c-b)*num[b];
        num[c]+=num[b];
        num[b]=0;
        cout<<sum<<endl;
    }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

  cout << ((s=="AAA"||s=="BBB")?"No":"Yes") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <math.h>


int main(void){

	int n;
	double i,x1,x2,x3,y1,y2,y3,px,py,r;

	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);

		px=(((x1*x1+y1*y1)*(y2-y3)+(x2*x2+y2*y2)*(y3-y1)+(x3*x3+y3*y3)*(y1-y2))/(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2)))/2;
		py=(((x1*x1+y1*y1)*(x2-x3)+(x2*x2+y2*y2)*(x3-x1)+(x3*x3+y3*y3)*(x1-x2))/(y1*(x2-x3)+y2*(x3-x1)+y3*(x1-x2)))/2;
		r=((sqrt(((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))*((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3))*((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1))))/(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2)))/2;
		if(px<0){
			px=(double)(int)((px-0.0005)*1000)/1000;
		}
		else{
			px=(double)(int)((px+0.0005)*1000)/1000;
		}
		if(py<0){
			py=(double)(int)((py-0.0005)*1000)/1000;
		}
		else{
			py=(double)(int)((py+0.0005)*1000)/1000;
		}
		if(r<0){
			r=r*-1;
		}
		r=(double)(int)((r+0.0005)*1000)/1000;

		printf("%.3f %.3f %.3f\n",px,py,r);
	}

	return 0;
}

Measured memory_bytes: 664
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
int divr[maxn];
/*ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}*/
void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
 
 
 
 
 














int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    int l[n+1];
    l[0]=0;
    for(int i=1;i<=n;i++)l[i]=__gcd(l[i-1],a[i-1]);
    int r[n+1];
    r[n]=0;
    for(int i=n-1;i>=0;i--)
    r[i]=__gcd(r[i+1],a[i]);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
         int lr=l[i-1];
         int rr=r[i];
         ans=max(ans,__gcd(lr,rr));

    }
    cout<<ans;

}
























 
 
 
 
 

















Measured memory_bytes: 1408
/* in the name of Anton */

/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#ifdef ARYANC403
    #include "/home/aryan/codes/PastCodes/template/header.h"
#else
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
    #pragma GCC optimize ("-ffloat-store")
    #include<iostream>
    #include<bits/stdc++.h>
    #define dbg(args...)
#endif

using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) ((lli)(x).size())
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;


const auto start_time = std::chrono::high_resolution_clock::now();
void aryanc403()
{
#ifdef ARYANC403
auto end_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
#endif
}

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    map<ii,lli> dp;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

lli po(lli a,lli n)
{
    lli ans=1;
    while(n--)
        ans=(ans*a)%mod;
    return ans;
}

lli solve(lli b,lli n)
{
    if(n<0)
        return 0;
    if(b==-1)
        return 1;
    if(n==0)
        return 1;
    if((4LL<<b)<=n)
        return po(3,b+1);
    auto it=dp.find(mp(b,n));
    if(it!=dp.end())
        return it->Y;
    lli ans=0;
    ans+=solve(b-1,n);
    ans+=solve(b-1,n-(1LL<<b));
    ans+=solve(b-1,n-(2LL<<b));
    dbg(b,n,ans);
    return dp[mp(b,n)]=ans%mod;
}

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n;
    // n=1000000000000000000LL;
    // dbg(po(3,n));
    cout<<solve(60,n)<<endl;
}   aryanc403();
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

using Graph = vector<vector<int>>;

int main(){
    int n, m; cin >> n >> m;
    Graph G(n);
    rep(i,m){
        int u, v; cin >> u >> v; u--; v--;
        G[u].push_back(v);
    }

    int s, t; cin >> s >> t; s--; t--;

    vector<vector<int>> dist(n, vector<int>(3,-1)); dist[s][0] = 0;
    queue<pair<int,int>> que; que.push(make_pair(s,0));
    while (!que.empty()) {
        pair<int,int> v = que.front();
        que.pop();
        for (int nv : G[v.first]) {
            if (dist[nv][(v.second+1)%3] != -1) continue;
            dist[nv][(v.second+1)%3] = v.second + 1;
            que.push(make_pair(nv, v.second + 1));
        }
    }

    if(dist[t][0] == -1) cout << -1 << endl;
    else cout << dist[t][0]/3 << endl;
}



Measured memory_bytes: 14000
N, M = map(int, input().split())
minX = min(N, M)
maxX = max(N, M)
if minX == 1:
    if maxX == 1:
        ans = 1
    elif maxX == 2:
        ans = 0
    else:
        ans = maxX - 2
elif minX == 2:
    ans = 0
else:
    ans = (minX - 2) * (maxX - 2)
print(ans)

Measured memory_bytes: 38384
// AtCoder_158A. Station and Bus
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

#define FIO         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ALL(v)      v.begin(), v.end()
#define PB          push_back
#define MP          make_pair
#define UB          upper_bound
#define LB          lower_bound
#define PI          2*acos(0.0)
#define MOD         1000000007
#define GCD(a, b)   __gcd(a, b)
#define LCM(a, b)   ((a)*(b)) / GCD(a, b)
#define INPUT       freopen("input.txt", "r", stdin);
#define OUTPUT      freopen("output.txt", "w", stdout);
#define PRINT(a)    for(auto i : a) cout << i << " "; cout << endl;
#define PRINTS(s)   for(auto i=s.begin(); i!=s.end(); i++) cout << *i << " "; cout << endl;
#define PRINTM(m)   for(auto i=m.begin(); i!=m.end(); i++) cout << i->first << " " << i->second << endl;

int month[] = {31,28,31,30,31,30,31,31,30,31,30,31};
string lowerCase = "abcdefghijklmnopqrstuvwxyz";
string upperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

/// Graph moves
const int fxKing[] = {+1,+1,+0,-1,-1,-1,+0,+1}; /// King's move
const int fyKing[] = {+0,+1,+1,+1,+0,-1,-1,-1}; /// King's move
const int fxKnight[] = {+2,+1,-1,-2,-2,-1,+1,+2}; /// Knight's move
const int fyKnight[] = {+1,+2,+2,+1,-1,-2,-2,-1}; /// Knight's move

ll q, t, a, b, c, d, m, n, k;
ll cnt, Mn, Mx, sum, sum1, sum2, ck;
ll arr1[1000], arr2[1000];

map <ll, ll> mp1, mp2;
set <ll> st1, st2;
vector <ll> vec1, vec2;
string str1, str2, str3;

int main()
{
    FIO;
    string s;
    cin >> s;
    bool a = 0, b = 0;
    for(int i=0; i<3; i++){
        if(s[i]=='A') a = 1;
        else b = 1;
    }
    if(a&&b) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

signed main() {
    int A,B,M;
    int a[100001],b[100001],x[100001],y[100001],c[100001];
    int Min = 10000000;

    cin >> A >> B >> M;

    
    for(int i = 0; i < A; i ++){
        cin >> a[i];
    }
    for(int i = 0; i < B; i ++){
        cin >> b[i];
    }
    for(int i = 0; i < M; i ++){
        cin >> x[i] >> y[i] >> c[i];
    }


    

    for(int i = 0; i < M; i ++){
        Min = min(a[x[i]-1] + b[y[i]-1] -c[i],Min);
    }

    sort(a,a+A);
    sort(b,b+B);

    Min = min(Min,a[0]+b[0]);

    cout << Min;
    return 0;
}

Measured memory_bytes: 7520