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

const int INF = 1<<30;
int N, Q;
string S;
vector<set<int> > pls;

void solve() {
    pls.assign(26, set<int>({INF}));
    for (int i = 0; i < N; ++i) pls[S[i] - 'a'].insert(i);

    while (Q--) {
        int type; cin >> type;
        if (type == 1) {
            int ind; char nc; cin >> ind >> nc; --ind;
            auto pc = S[ind];
            S[ind] = nc;
            pls[pc - 'a'].erase(ind);
            pls[nc - 'a'].insert(ind);
        }
        else {
            int l, r; cin >> l >> r; --l;
            int res = 0;
            for (int c = 0; c < 26; ++c) {
                if (pls[c].empty()) continue;
                int lid = *pls[c].lower_bound(l);
                int rid = *pls[c].lower_bound(r);
                if (rid > lid) ++res;
            }
            cout << res << endl;
        }
    }
}

int main() {
    cin >> N >> S >> Q;
    solve();
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+10;
const int INF=0x3f3f3f3f;
const double eps=1e-10;

int main()
{
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif // LOCAL
    int n;
    ll x,y;
    int t;
   
    
        scanf("%lld%lld",&x,&y);
        if(max(x,y)-min(x,y)>=2)printf("Alice\n");
        else printf("Brown\n");
    
    return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn.readLine
import scala.math.{sqrt, pow}

case class Point(x: Double, y: Double) {
  def distance(other: Point): Double =
    sqrt(pow(x - other.x, 2) + pow(y - other.y, 2))
}

object Main extends App {
  val Array(x1, y1, x2, y2) = readLine.split(" ").map { _.toDouble }

  val p1 = Point(x1, y1)
  val p2 = Point(x2, y2)

  println(f"${p1 distance p2}%.8f")
}



Measured memory_bytes: 44320
#include <iostream>

using namespace std;

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

    if (s[0] == s[s.size() - 1])
    {
        if (s.size() % 2 == 0)
        {
            cout << "First" << endl;
        }
        else
        {
            cout << "Second" << endl;
        }
    }
    else
    {
        if (s.size() % 2 == 0)
        {
            cout << "Second" << endl;
        }
        else
        {
            cout << "First" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
LL dp[2001];
LL S[2001];
LL MOD=1e9+7;

int main(){
	cin>>N;
	dp[0]=0;
	dp[1]=0;
	dp[2]=0;
	S[0]=0;
	S[1]=0;
	S[2]=0;
	for(int i=3;i<2001;i++){
		dp[i]=S[i-3]+1;
		S[i]=dp[i]+S[i-1];
		dp[i]%=MOD;
		S[i]%=MOD;
	}
	cout<<dp[N]<<endl;
	return 0;
}

Measured memory_bytes: 3640
import sys
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())

if n == 1:
    print(0)
    sys.exit()

ar = factorization(n) 
ar_len = len(ar)
ans = 0
for i in range(ar_len):
    jo = ar[i][1]
    ad = 0
    for j in range(1000):
        base = j*(j+1)/2
        if jo < base:
            ad = j-1
            break
    ans = ans + ad

print(ans)

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

int main()
{
    int n;
    cin >> n;
    vector<int64_t> l(n+1);
    l[0] = 2;
    l[1] = 1;
    for(int i = 2; i <= n; i++){
        l[i] = l[i - 2] + l[i - 1];
    }

    cout << l[n] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (1e9 + 7)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W; cin >> H >> W;
  vector<string> S(H);
  for(auto &s : S) cin >> s;
  
  int ans = 0;
  vector<int> xd = {0, 1, 0, -1};
  vector<int> yd = {1, 0, -1, 0};
  REP(i, H){
    REP(j, W){
      if(S[i][j] == '#') continue;
      vector<vector<int> > HW(H, vector<int>(W, -1));
      queue<pair<int, int> > que;
      que.push({i, j});
      HW[i][j] = 0;
      while(!que.empty()){
        int x = que.front().first, y = que.front().second; que.pop();
        REP(i, 4){
          if(x + xd[i] > H -1 || x + xd[i] < 0) continue;
          if(y + yd[i] > W -1 || y + yd[i] < 0) continue;
          if(HW[x + xd[i]][y + yd[i]] != -1) continue;
          if(S[x + xd[i]][y + yd[i]] == '#') continue;
          que.push({x + xd[i], y + yd[i]});
          HW[x + xd[i]][y + yd[i]] = HW[x][y] + 1;
          ans = max(ans, HW[x + xd[i]][y + yd[i]]);

        }
      }
    }
  }
  cout << ans << endl;
}

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

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

    vector<vector<int>> path(n+1);

    int a, b;
    for(int i = 0; i < m; i++){
        cin >> a >> b;
        path[a].push_back(b);
        path[b].push_back(a);
    }

    set<int> way;
    for(int i = 0; i < path[1].size(); i++){
        way.insert(path[1][i]);
    }

    bool judge = false;
    for(int x : way){
        for(int i = 0; i < path[x].size(); i++){
            if(path[x][i] == n) judge = true;
        }
    }

    if(judge)   cout << "POSSIBLE" << endl;
    else        cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 16624
#include<iostream>
using namespace std;
int main(){
	string ss;
	cin >> ss;
	int start=0;
	int end=ss.length()-1;
	for (int i=0; i<ss.length(); i++){
		if (ss[i]=='A'){
			start=i;
			break;
		}
	}
	for (int i=ss.length()-1; i>start; i--){
		if (ss[i]=='Z'){
			end=i;
			break;
		}
	}
	cout << end-start+1 << endl;
}

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

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=Int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}


template <typename T>
struct SegmentTree{
  using F = function<T(T,T)>;
  Int n;
  F f;
  T ti;
  vector<T> dat;

  SegmentTree(){}
  SegmentTree(F f,T ti):f(f),ti(ti){}

  void init(Int n_){
    n=1;
    while(n<n_) n<<=1;
    dat.assign(n<<1,ti);
  }

  void build(const vector<T> &v){
    Int n_=v.size();
    init(n_);
    for(Int i=0;i<n_;i++) dat[n+i]=v[i];
    for(Int i=n-1;i;i--)
      dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
  }

  void set_val(Int k,T x){
    dat[k+=n]=x;
    while(k>>=1)
      dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);
  }

  T query(Int a,Int b){
    if(a>=b) return ti;
    T vl=ti,vr=ti;
    for(Int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[l++]);
      if(r&1) vr=f(dat[--r],vr);
    }
    return f(vl,vr);
  }

  template<typename C>
  Int find(Int st,C &check,T &acc,Int k,Int l,Int r){
    if(l+1==r){
      acc=f(acc,dat[k]);
      return check(acc)?k-n:-1;
    }
    Int m=(l+r)>>1;
    if(m<=st) return find(st,check,acc,(k<<1)|1,m,r);
    if(st<=l&&!check(f(acc,dat[k]))){
      acc=f(acc,dat[k]);
      return -1;
    }
    Int vl=find(st,check,acc,(k<<1)|0,l,m);
    if(~vl) return vl;
    return find(st,check,acc,(k<<1)|1,m,r);
  }

  template<typename C>
  Int find(Int st,C &check){
    T acc=ti;
    return find(st,check,acc,1,0,n);
  }
};

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n,k;
  cin>>n>>k;
  auto as=read(n);

  auto f=[&](Int a,Int b){return max(a,b);};
  const Int INF = 1e15;
  SegmentTree<Int> seg(f,-INF);

  const Int MAX = 3e5+100;
  seg.build(vector<Int>(MAX,-INF));

  for(Int a:as){
    Int l=a-k;
    Int r=a+k+1;
    chmax(l,0);
    chmin(r,MAX);
    Int val=seg.query(l,r);
    chmax(val,0);
    seg.set_val(a,val+1);
  }
  cout<<seg.query(0,MAX)<<newl;
  return 0;
}


Measured memory_bytes: 16124
#include<stdio.h>

#define N 2000

int n, A[N];

int solve(int , int);

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

  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 printf("no\n");
    
  }
  return 0;
}

int solve(int i, int m){
  
  if ( i >= n ) return 0;
  if ( A[i] == m ) return 1;
  if ( solve(i + 1, m) == 1) return 1;
  if ( solve(i + 1, m - A[i]) == 1) return 1;
  else return 0;
}

Measured memory_bytes: 580
import sys
input = sys.stdin.readline

def check(A, F, mid, k):
    for i in range(len(A)):
        if A[i] * F[i] > mid:
            x = A[i] - mid // F[i]
            k -= x
        if k < 0:
            return False
    return True



def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]
    F = [int(x) for x in input().split()]

    A_s = sorted(A, reverse=True)
    F_s = sorted(F)

    l = -1
    r = 10 ** 13
    while r - l != 1:
        mid = (r + l) // 2
        if check(A_s, F_s, mid, K):
            r = mid
        else:
            l = mid

    print(r)











if __name__ == '__main__':
    main()



Measured memory_bytes: 110156
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as T
import qualified Data.Text.Lazy.Read as T

main :: IO ()
main = do
  let
    modulus = 1000000007 :: Int
    modAdd :: Int -> Int -> Int
    modAdd x y = (x + y) `mod` modulus
    modMul :: Int -> Int -> Int
    modMul x y = (x * y) `mod` modulus
    step :: (Int, Int) -> Int -> (Int, Int)
    step (s, c) x = s `seq` c `seq` (s `modAdd` (c `modMul` x), c `modAdd` x)
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  as <- map unsafeTextToInt . T.words <$> T.getContents :: IO [Int]
  print . fst . foldl step (0, 0) $ as

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = n; i >= 0; i--)
#define For(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;
using namespace std;
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
template <class T = int> T in(){T x; cin >> x; return (x);}

int main() {
    int result = 0;
    int H;
    int M;
    int h;
    int m;
    cin >> H;
    cin >> M;
    cin >> h;
    cin >> m;
    
    result = (H-h) * (M -m);
    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String c1 = sc.next();
        String c2 = sc.next();
        sc.close();

        // 主処理
        StringBuilder sb = new StringBuilder(c2);
        sb.reverse();
        boolean judge = c1.equals(sb.toString());
        String result = judge ? "YES" : "NO";

        // 出力
        System.out.println(result);
    }
}


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

int main() {
    int N;
    cin >> N;
    for(int i=0; i<N; ++i) {
        int m, n;
        cin >> m >> n;
        int cnt = 0;
        int tmp = max(abs(m), abs(n));
        for(int p=-tmp; p<=tmp; ++p) {
            for(int q=-tmp; q<=tmp; ++q) {
                if(p*p + q*q == 0) continue;
                if((p*m + q*n) % (p*p + q*q) == 0 && (p*n - q*m) % (p*p + q*q) == 0) {
                    cnt++;
                }
            }
        }
        cout << (cnt == 8 ? "P" : "C") << endl;
    }
}


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

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

    int n, x;
    while (cin >> n >> x, n != 0) {
        int cnt = 0;
        for (int i=1; i<=n; ++i) {
            for (int j=i+1; j<=n; ++j) {
                int k = x - i - j;
                if (j < k && k <= n) {
                    cnt ++;
                }
            }
        }
        cout << cnt << endl;
    }

    return 0;
}


Measured memory_bytes: 3180
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
constexpr int kInf = 1e9;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}

int N, A, B, C;
vector<int> l;
int dfs(int a, int b, int c, int i) {
  if (i == N) {
    if (a == 0 || b == 0 || c == 0) return kInf;
    else return abs(a-A) + abs(b-B) + abs(c-C) - 30;
  }

  int mp1 = dfs(a, b, c, i + 1);
  int mp2 = dfs(a + l[i], b, c, i + 1) + 10;
  int mp3 = dfs(a, b + l[i], c, i + 1) + 10;
  int mp4 = dfs(a, b, c + l[i], i + 1) + 10;
  return min({mp1, mp2, mp3, mp4});
}

int main() {
  cin >> N >> A >> B >> C;
  l.resize(N); cin >> l;

  cout << dfs(0, 0, 0, 0) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,x,y;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	x=a*b;
	y=c*d;
	if(x>y){
	 printf("%d\n",x);
	}
	else{
		printf("%d\n",y);
	}
	return 0;
}

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

#define int long long
#define double long double

using namespace std;

template<class T> string tostr(T x) { stringstream o; o << x; return o.str(); }
template<class T> T sqr(T x) { return x*x; }
template<class T> T mypow(T x, int n) { T r = 1; while (n > 0) { if (n & 1)r = r*x; x = x*x; n >>= 1; }return r; }

int toint(string s) { int v; stringstream i(s); i >> v; return v; }
bool check(int x, int y, int w, int h) { return x >= 0 && y >= 0 && w > x && h > y; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define REP(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	REP(i,0,n)
#define PER(i,a,b)	for(int (i) = (a-1);i >= (b);(i)--)
#define per(i,n)	PER(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define dump(val) 	cerr << #val " = " << val << endl;
#define dum(val)	cerr << #val " = " << val;
#define FILL(a,v)	fill(a,a+sizeof(a)/sizeof(*a),v)

const int dx[8] = { +1,+0,-1,+0,+1,+1,-1,-1 };
const int dy[8] = { +0,-1,+0,+1,-1,+1,-1,+1 };
const int mod = 1e9 + 7;
const int INF = 1e9;

signed main() {

	int n, m;
	cin >> n >> m;

	map<int, int> mp;

	rep(i, m){
		int a, b;
		cin >> a >> b;
		mp[a]++;
		mp[b]++;
	}

	each(i, mp){
		if(i.second % 2){
			cout << "NO" << endl;return 0;
		}
	}

	cout << "YES" << endl;return 0;

	return 0;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/
signed main(){
	int n,a,b;
	cin>>n>>a>>b;
	vi x(n);
	rep(i,n)cin>>x[i];

	int ans=0;
	rep(i,n-1){
		// i to i+1
		ans+=min(b,(x[i+1]-x[i])*a);
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 3972
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long int i=0;i<n;++i)
typedef long long int ll;

int main(){

    vector<bool> f(1e+6,true);
    f[1]=false;
    f[0]=false;
    for(int i=2;i<1e+6;i++){
        if(f[i]){
            for(int j=i+i;j<1e+6;j+=i){
                f[j]=false;
            }
        }
    }

    vector<int> s;
    rep(i,1e+6){
        if(f[i]){
            s.push_back(i);
        }
    }
    sort(s.begin(),s.end());
    while(1){
        int n,p;
        cin >> n >> p;
        if(n==-1&&p==-1){
            break;
        }
        vector<int> a;
        int id=distance(s.begin(),lower_bound(s.begin(),s.end(),n));
        if(s[id]==n)id++;
        for(int i=id;i<=id+p;i++){
            for(int j=i;j<=id+p;j++){
                a.push_back(s[i]+s[j]);
            }
        }
        sort(a.begin(),a.end());
        cout << a[p-1] << endl;
    }

    return 0;
}


Measured memory_bytes: 3352
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    string a,b,c;
    cin >> a >>b>>c;
    cout << a[0] <<b[1]<<c[2]<< endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string S;
	cin >> S;
	if (S == string("ARC"))cout << "ABC\n";
	else cout << "ARC\n";
	return 0;
}


Measured memory_bytes: 3132
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cmath>
#include<map>
using namespace std;


int main(){
	int n,d,x;
	vector<int> v;
	cin >> n >> d >> x;
	int a;
	for(int i=0;i<n;++i){
		cin >> a;
		v.push_back(a);
	}
	int res = 0;
	for(int i=0;i<v.size();++i){
		for(int j=1;j<=d;j+=v[i]){
			res += 1;
		}
	}
	cout << res+x << endl;
	
	
	return 0;
}



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

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

	int ret = 1;
	for(int i=2; i<=N; i*=2)
		ret = i;

	cout << ret << endl;

	return 0;
}


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

int main() {
  long long  n, k, min, tmp_min;
  cin >> n >> k;

  if (k == 1 || n == k || n % k == 0) {
    cout << 0 << endl;
    return 0;
  } 

  min = n % k;
  tmp_min = abs(min - k);
  if (tmp_min < min) {
    min = tmp_min;
  }
  
  cout << min << endl;
  return 0;
}

Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8')
const [a, b] = input.split(/\s/).map(s => parseInt(s, 10))

if (a > b) {
    console.log ("a > b");
} else if (a < b) {
    console.log("a < b");
} else {
    console.log("a == b");
}


Measured memory_bytes: 15164
def func():
    pass


def main():
    n, k = map(int, input().split())
    if n % 2 == 1:
        mx = (n + 1) // 2
    else:
        mx = n // 2
    if mx >= k:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()


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

#define FOR(i,b,e) for(int i=(b); i <= (e); ++i)
#define FORD(i,b,e) for(int i=(b); i >= (e); --i)
#define SIZE(c) (int) (c).size()
#define FORE(i,c) FOR(i,0,SIZE(c)-1)
#define FORDE(i,c) FORD(i,SIZE(c)-1,0)

#define pb push_back
#define mp make_pair
#define st first
#define nd second


using namespace std;

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

typedef vector <int> VI;
typedef vector <bool> VB;
typedef vector <pii> VP;
typedef vector <ll> VL;
typedef vector <pll> VPL;

typedef vector <VI> VVI;
typedef vector <VL> VVL;
typedef vector <VB> VVB;
typedef vector <VP> VVP;

const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000000000000001LL;


/*************************************************************************/

int main() {
    ios_base::sync_with_stdio(0);
    
    int n, m;
    cin >> n >> m;
    
    VVI g(n);
    FOR(i,1,m) {
        int u, v;
        cin >> u >> v; u--; v--;
        
        g[u].pb(v);
        g[v].pb(u);
    }
    
    int q;
    cin >> q;
    
    struct query {
        int v, dist, col, time;
    };
    
    vector <query> queries(q);
    FOR(i,0,q-1) {
        int v, dist, col;
        cin >> v >> dist >> col; v--;
        
        queries[q - 1 - i] = {v, dist, col, i};
    }
    
    VI color(n,0);
    VI withDist(n,-1);
    
    for (auto &q : queries) {
        queue <pii> qe;
        qe.push({q.v, q.dist});
        
        if (color[q.v] == 0) {
            color[q.v] = q.col;
        }
        
        withDist[q.v] = max(withDist[q.v], q.dist);
        
        while (!qe.empty()) {
            auto p = qe.front(); qe.pop();
            
            int v = p.st;
            int left = p.nd;
            
            if (left == 0) continue;
            
            for (int u : g[v]) if (color[u] == 0 || withDist[u] < left) {
                if (color[u] == 0) {
                    color[u] = q.col;
                }
                
                withDist[u] = max(withDist[u], left);
                qe.push({u, left - 1});
            }
        }
    }
    
    FOR(i,0,n-1) {
        cout << color[i] << '\n';
    }

    return 0;
}

/*************************************************************************/


Measured memory_bytes: 9352
import java.util.*


fun main(args: Array<String>) {
  val scanner = Scanner(System.`in`)
  val a = scanner.nextInt()
  val b = scanner.nextInt()
  val c = scanner.nextInt()

  println(if (a + b + c >= 22) {
    "bust"
  } else {
    "win"
  })
}

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

int main(){
  int N;
  cin >> N ;
  vector<tuple<string,int,int>> vec;
  string A;
  int a,b;
  tuple<string,int,int> tu;
  for (int i=0;i<N;i++){
    cin >>A >> a;
    b =i+1;
    tu = make_tuple(A,100-a,b);
    vec.push_back(tu);
  }
  sort(vec.begin(),vec.end());
  for (int i=0;i<N;i++){
    cout << get<2>(vec.at(i)) << endl;
  }
}

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

using namespace std;

int main(void) {
    int H, W;
    char line[1010];
    scanf("%d %d", &H, &W);

    list<int> xs;
    list<int> ys;
    list<int> ds;

    int map[W*H];
    for (int y=0; y<H; y++) {
        scanf("%s", line);
        for (int x=0; x<W; x++) {
            if (line[x] == '#') {
                map[y*W+x] = 0;
                xs.push_front(x);
                ys.push_front(y);
                ds.push_front(0);
            } else {
                map[y*W+x] = -1;
            }
        }
    }

    int max = 0;
    while (!xs.empty()) {
        int x = xs.back(); xs.pop_back();
        int y = ys.back(); ys.pop_back();
        int dist = ds.back(); ds.pop_back();
        for (int d=-1; d<=1; d+=2) {
            int dx = x + d;
            int dy = y;
            if (dx >= 0 && dx < W && map[dy*W+dx] == -1) {
                map[dy*W+dx] = dist+1;
                xs.push_front(dx);
                ys.push_front(dy);
                ds.push_front(dist+1);
                max = dist+1;
            }
        }
        for (int d=-1; d<=1; d+=2) {
            int dx = x;
            int dy = y + d;
            if (dy >= 0 && dy < H && map[dy*W+dx] == -1) {
                map[dy*W+dx] = dist+1;
                xs.push_front(dx);
                ys.push_front(dy);
                ds.push_front(dist+1);
                max = dist+1;
            }
        }
    }
    
    printf("%d\n", max);

}




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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int c = 0, ans = 0;
    for (auto& e : s) {
        ans = max(ans, c += (e == 'I' ? 1 : -1));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std;
using ll = long long int;
ll gcd(ll a, ll b) {
    if(a<b) {
        return gcd(b, a);
    } else {
        if(a%b == 0) {
            return b;
        } else {
            return gcd(b, a%b);
        }
    }
}
int main() {
    ll a, b, i, n;
    ll ans=0;
    cin >> n;
    cin >> ans;
    for(i=0;i<n;i++) {
        cin >> b;
        ans = gcd(ans, b);
    }
    cout << ans;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

string ds[4] = {"erase", "eraser", "dream", "dreamer"};

void solve() {
	string s;
	cin >> s;
	reverse(ALL(s));
	int n = s.size();
	int l = 0;
	for (;;) {
		if (l == n) {
			cout << "YES" << endl;
			return;
		}
		if (s[l] != 'r') {
			if (n - l < 5) {
				cout << "NO" << endl;
				return;
			}
			string t = s.substr(l, 5);
			reverse(ALL(t));
			if (t != "dream" && t != "erase") {
				cout << "NO" << endl;
				return;
			}
			l += 5;
		} else {
			if (n - l < 6) {
				cout << "NO" << endl;
				return;
			}
			string t = s.substr(l, 6);
			reverse(ALL(t));
			if (t != "eraser") {
				if (n - l < 7) {
					cout << "NO" << endl;
					return;
				}
				t = s.substr(l, 7);
				reverse(ALL(t));
				if (t != "dreamer") {
					cout << "NO" << endl;
					return;
				}
				l += 7;
			} else {
				l += 6;
			}
		}
	}
}

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

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n) {
    cin >> a[i];
  }
  REP(i,n) {
    if(i==0) {
      cout << a[n-i-1];
    } else {
      cout << " " << a[n-i-1];
    }
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3084
import sys
input = sys.stdin.readline
n, m = map(int, input().split())

graph = [[] for _ in range(n)]
graph_dim_out = [0] * n
for i in range(m):
    s, t = map(int, input().split())
    s, t = s - 1, t - 1
    graph_dim_out[s] += 1
    graph[s].append(t)


def func(x):
    dp = [0] * n
    for i in reversed(range(n - 1)):
        if i != x or graph_dim_out[x] == 1:
            for j in graph[i]:
                dp[i] += dp[j]
            dp[i] = dp[i] / graph_dim_out[i] + 1
        else:
            k = -1
            for j in graph[i]:
                dp[i] += dp[j]
                if k == -1 or dp[k] < dp[j]:
                    k = j
            dp[i] -= dp[k]
            dp[i] = dp[i] / (graph_dim_out[i] - 1) + 1

    return dp[0]


ans = func(0)
for x in range(1, n - 1):
    ans = min(ans, func(x))

print(ans)


Measured memory_bytes: 57820
/*input
2
*/

#include <bits/stdc++.h>
using namespace std;
#define int long long int
// int dp[5003][5003];
#define maxl( X, Y) ((X) > (Y))? X : Y
// const int nax =100;
const int maxn = 1e5 +5;
#define debug(x) cout << #x << " " << x << "\n";

int exp(int a, int n)
{
	if ( n==0)
		return 1;
	if ( n==1 )
		return a;
	if ( n & 1)
		return (a * exp((a*a), n/2));
	else
		return exp((a*a), n/2);
}
signed main()
{
	int n;
	cin >> n;
	cout << exp( n , 3);
}


Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
dd=[]                                                                  
for i in l: 
	if i % 2==0:
		dd.append(i)       
cnt_lst=[]                                                             
for i in dd: 
	cnt1=0 
	while(i % 2==0): 
		i//= 2 
		cnt1+=1 
		if i %2==1: 
			cnt=cnt1 
			cnt_lst.append(cnt)             
			break 
print(sum(cnt_lst)) 


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }


int main() {

    int n,m; cin >> n >> m;
    vector<int> p(m);
    vector<string> s(m);
    rep(i, m) cin >> p[i] >> s[i];

    vector<int> penarlty(n,0);
    vector<bool> ac(n, false);

    rep(i, m) {
        if(s[i] == "AC") {
            ac[p[i]-1] = true;
        } else {
            if(!ac[p[i]-1]) {
                penarlty[p[i]-1]++;
            }
        }
    }

    ll p_num = 0;
    ll ac_num = 0;
    rep(i, n) {
        if(ac[i] > 0) {
            p_num += penarlty[i];
            ac_num++;
        }
    }

    cout << ac_num << " " << p_num << endl;

    return 0;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
const int inf=100100100;
const int mod=(int)1e9+7;

int main(){
    string s;
    cin>>s;
    int q;
    cin>>q;
    int co=0;
    rep(i,0,q){
        int t;
        cin>>t;
        if(t==1){
            co++;
        }
        else{
            int f;
            char c;
            cin>>f>>c;
            if(co%2==0){
                if(f==1) s.insert(0,1,c);
                else s.push_back(c);
            }
            else{
                if(f==1) s.push_back(c);
                else s.insert(0,1,c);
            }
        }
    }
    if(co%2==1) reverse(all(s));
    cout<<s<<endl;
return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	int ans=1;
	for(int i=2;i*i<=n;i++){
		for(int j=i*i;j<=n;j*=i){
			ans=max(ans,j);
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
s = set()
prime = []
for i in range(2, 55556):
    if i in s:
        continue
    if i%5==1:
        prime.append(i)
    cnt = 1
    while i*cnt<=55555:
        s.add(i*cnt)
        cnt += 1

print(*prime[:N])

Measured memory_bytes: 75780
use std::io::stdin;
use std::str::FromStr;
use std::cmp::max;

fn main(){
    let (n, m): (i64, i64) = get_pair();
    let ans = if n > 1 && m > 1 {
        (n-2) * (m-2)
    } else if n == 1 && m == 1 {
        1
    } else {
        max(n, m) - 2
    };
    println!("{}", ans);
}

#[allow(dead_code)]
fn get_line() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn get_vec<T: std::str::FromStr>() -> Vec<T> {
    let line = get_line();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn get_one<T: FromStr + Copy>() -> T {
    let v = get_vec();
    v[0]
}

#[allow(dead_code)]
fn get_pair<T: FromStr + Copy>() -> (T, T) {
    let v = get_vec();
    (v[0], v[1])
}

#[allow(dead_code)]
fn get_triple<T: FromStr + Copy>() -> (T, T, T) {
    let v = get_vec();
    (v[0], v[1], v[2])
}

#[allow(dead_code)]
fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}


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

int main()
{
    while(cin>>n)
    {
        stack<int> s;
        for(int i=0;i<n;i++)
        {
            int num;
            cin>>num;
            if(s.empty()||num>=s.top()) s.push(num);
        }
        cout<<s.size()<<"\n";
    }


}


Measured memory_bytes: 256
A , B , C , X ,Y = map(int,input().split())
A_val = A * X
B_val = B * Y
C_val = C * 2
ans = 0
if A + B >= C_val:
    if X >= Y:
        ans += Y * C_val
        remain = X - Y
        if A >= C_val:
            ans += C_val * remain
        else:
            ans += A * remain
    else:
        ans += X * C_val
        remain = Y - X
        if B >= C_val:
            ans += C_val * remain
        else:
            ans += B * remain
    print(ans)
else:
    print(A_val + B_val)

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

#define int long long

int a[500010];
int cnt[500010];
int tmp[500010];
signed main(){
    string s;
    cin >> s;

    int n = s.size();

    int idx = 0;
    cnt[0] = 1;

    tmp[0] = s[0] == '<' ? 1 : 0;
    int now = tmp[0];


    for(int i = 1;i < n;i++){
        if(s[i] != s[i-1]){
            idx++;
            now = now ^ 1;
            tmp[idx] = now;
        }
        cnt[idx]++;
    }
    idx++;

    int ans = 0;

    if(tmp[0] == 0){
        ans += cnt[0];
    }

    for(int i = 0;i < idx;i++){
        if(tmp[i] == 1){
            ans += max(cnt[i], cnt[i+1]);
        }
        ans += cnt[i] * (cnt[i]-1) / 2;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

#define mx 10000007
bitset <mx> mark;
vector <int> primes;

void sieve() {
    mark[0] = mark[1] = 1;
    primes.push_back(2);
    int lim = sqrt(mx * 1.0) + 2;
    for (int i = 4; i < mx; i += 2) mark[i] = 1;
    for (int i = 3; i < mx; i += 2) {
        if (!mark[i]) {
            primes.push_back(i);
            if (i <= lim)
                for (int j = i * i; j < mx; j += i)
                    mark[j] = 1;
        }
    }
}

int main() {
    sieve();
    ll n; scanf("%lld", &n);
    ll ans = 0;
    for (ll p : primes) {
        if (p * p > n) break;
        if (n % p == 0) {
            ll cnt = 0;
            while (n % p == 0) {
                n /= p;
                cnt++;
            }

            for (ll i = 1; i <= cnt; i++) {
                ans++;
                cnt -= i;
            }
        }
    }

    if (n > 1) ans++;
    printf("%lld\n", ans);
}

Measured memory_bytes: 8448
N, M = gets.split.map(&:to_i)
XYZs = readlines.map{|l| l.split.map(&:to_i)}

@p = Array.new(N + 1, -1)

def root(x)
  @p[x] < 0 ? x : @p[x] = root(@p[x])
end

def unite(x, y)
  x, y = root(x), root(y)
  if x != y
    x, y = y, x if @p[y] < @p[x]
    @p[x] += @p[y]
    @p[y] = x
  end
end

XYZs.each{|x, y, z| unite(x, y)}
puts (1 .. N).map{|i| root(i)}.uniq.size

Measured memory_bytes: 25396
using System;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] d = new int[n];
        string[] input = Console.ReadLine().Split(' ');
        for(int i = 0; i < n; i++)
        {
            d[i] = int.Parse(input[i]);
        }

        int[] ans = new int[n];
        for (int i = 0; i < n; i++)
        {
            ans[d[i]-1] = i + 1;
        }

        for (int i = 0; i < n; i++)
        {
            Console.Write(ans[i]);
            if(i < n - 1)
            {
                Console.Write(" ");
            };
        }
    }
}

Measured memory_bytes: 27100
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;

double eps=1e-7;
bool eq(double a,double b){
  double EPS = max( abs(a) , abs(b) ) * eps;
  EPS=max(EPS,eps);
  return (-EPS<a-b&&a-b<EPS);
}

double cross(P a,P b){
  return imag(b*conj(a));
}

double dist(P a,P b,P c){
  b-=a;c-=a;
  return cross(b,c)/abs(b);
}

P reflect(P a,P b,P c){
  b-=a;c-=a;
  return a+conj(c/b)*b;
}

int N;
P t[1000];
map<int, map<int,bool> > mp;

bool check(P a,P b){
  bool res=true;
  int cnt=0;
  for(int i=0;i<N;i++){
    if( eq( 0, dist(a,b,t[i])) ){cnt++;continue;}
    P target=reflect(a,b,t[i]);
    int px=round(target.real());
    int py=round(target.imag());
    if(!eq(px,target.real()))res=false;
    if(!eq(py,target.imag()))res=false;
    if(mp.count(px)==0)res=false;
    if(mp[px].count(py)==0)res=false;
  }
  if(cnt>1 && cnt%2==1 )res=false;
  return res;
}

bool solve(){
  P b=t[0];
  int cnt=0;
  for(int i=1;i<N;i++){
    b+=t[i];
    double v=cross(t[1]-t[0],t[i]-t[0]);
    if(eq(v,0))cnt++;
  }
  if(cnt==N-1)return false;

  b/=(double)N;
  
  bool flag=false;
  for(int i=0;i<N;i++){
    P a=t[i];
    if( eq(0, abs(a-b) ) )continue;
    if(check(a,b))flag=true;
  }

  for(int i=0;i<2;i++){
    P c=t[i];
    for(int j=i+1;j<N;j++){
      P d=t[j];
      if(check(c,d))flag=true;
      P nc=(c+d)*0.5;
      P nd=nc+(d-c)*P(0,1);
      if(check(nc,nd))flag=true;
    }
  }
  
  return flag;
}

int main(){
  scanf("%d",&N);
  for(int i=0;i<N;i++){

    int x,y;
    scanf("%d %d",&x,&y);
    t[i]=P(x,y);
    mp[x][y]=true;
    for(int j=0;j<i;j++)assert(t[i]!=t[j]);
  }
  printf( solve() ? "Yes\n" : "No\n" );
  return 0;
}

Measured memory_bytes: 8572
#include <iostream>
#include <math.h>

using namespace std;


int main(){
    double A, B;
    int H, M;
    cin >> A >> B >> H >> M;

    double ta,tb;
    ta = M_PI / 2.0 - H * (2.0*M_PI/12.0) - M * (2.0*M_PI/(12.0*60.0));
    tb = M_PI / 2.0 - M * (2.0*M_PI / 60.0);

    double xa, xb, ya, yb;
    xa = A * cos(ta);
    xb = B * cos(tb);
    ya = A * sin(ta);
    yb = B * sin(tb);
    double ans = sqrt((xa-xb)*(xa-xb) + (ya-yb)*(ya-yb));
    printf("%10.20f\n", ans);
    return 0;
}

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

glid = [0]*2

glid[0] = list(map(int,input().split()))
glid[1] = list(map(int,input().split()))

sum_int = sum(glid[1]) + glid[ 0 ][ 0 ]
temp = sum_int
for i in range(1,n):
	sum_int = sum_int + glid[ 0 ][ i ] - glid[1][i - 1]
	temp = max( temp, sum_int)

print(temp)

Measured memory_bytes: 3064
import copy
class SegmentTree:
    def __init__(self, N, func, I):
        self.sz = N
        self.func = func
        self.I = copy.deepcopy(I)
        self.seg = [copy.deepcopy(I) for i in range(self.sz * 2)]
 
    def assign(self, k, x):
        self.seg[k + self.sz] = copy.deepcopy(x)
 
    def build(self):
        for i in range(self.sz - 1, 0, -1):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])
 
    def update(self, k, x):
        k += self.sz
        self.seg[k] = copy.deepcopy(x)
        while k > 1:
            k //= 2
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])
 
    def query(self, a, b):
        L = copy.deepcopy(self.I)
        R = copy.deepcopy(self.I)
        a += self.sz
        b += self.sz
        while a < b:
            if a % 2 == 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b % 2 == 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a //= 2
            b //= 2
        return self.func(L, R)

N = int(input())
a = list(map(int,input().split()))
from fractions import gcd
seg = SegmentTree(N , gcd , 0)
for i in range(N):
    seg.assign(i , a[i])
seg.build()
ans = 1
for i in range(N):
    ans = max(ans,gcd(seg.query(0,i) , seg.query(i+1,N)))
print(ans)

Measured memory_bytes: 122144
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;

int main(){
    int n;cin>>n;
    int x=0;
    bool flag=0;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        if(a==b){
            x+=1;
        }else{
            x=0;
        }
        if(x>=3) flag=1;
    }
    if(flag){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(){
  //counter
  int i,j;

  //input
  int n;
  scanf("%100000d",&n);

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


  
  //PartitionSort

  int p = 0;
  int r = n-1;
  int x = A[r];
  int temp;

  i = p-1;

  for(j=p;j<=(r-1);j++){
    if(A[j]<=x){
      i++;
      //exchange A[i] and A[j]
      temp = A[i]; A[i] = A[j]; A[j] = temp;
    }
  }
  i++;
  //exchange A[i] and A[r]
  temp = A[r]; A[r] = A[i]; A[i] = temp;
  
      
  int k = i;

  //Output

  for(i=0;i<n-1;i++){
    if(i == k){
      printf("[%d] ",x);
    }else{
      printf("%d ",A[i]);
  }
  }
    if(n-1 == k){
      printf("[%d]\n",A[n-1]);
    }
       else{
  printf("%d\n",A[n-1]);
       }

  
  return 0;
}



Measured memory_bytes: 2120
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 998244353;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

//入出力高速化(非同期化)
void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

struct Edge{
    int from, to, cost;
};

long long d[100005];
vector<vector<Edge>> G;

int dfs(int crt, int group) {
    for (int i = 0; i < G[crt].size(); i++) {
        Edge e = G[crt][i];
        if (d[e.to] == 0) {
            d[e.to] = group;
            dfs(e.to, group);
        }
    }
    return 0;
}

int main(void) {
    int N, M; cin >> N >> M;
    G = vector<vector<Edge>> (N+5);
    for (int i = 0; i <= N; i++) {
        d[i] = 0;
    }
    for (int i = 0; i < M; i++) {
        int a, b, c; cin >> a >> b >> c;
        Edge e1 = {a, b, c};
        Edge e2 = {b, a, c};
        G[a].push_back(e1);
        G[b].push_back(e2);
    }

    int group = 0;
    for (int i = 1; i <= N; i++) {
        if (d[i] == 0) {
            group++;
            dfs(i, group);
        }
    }
    cout << group << endl;
}   




Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

int h,w;
char field[100][100];

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

void dfs(char typ,int x,int y){
	field[x][y] = 0;
	for(int i = 0;i < 4;i++){
		int nx = x + dx[i],ny = y + dy[i];
		if(nx >= 0 && nx < h && ny >= 0 && ny < w && field[nx][ny] == typ){
			dfs(typ,nx,ny);
		}
	}
}

signed main(){
	while(cin >> h >> w,h){
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				cin >> field[i][j];
			}
		}
		int res = 0;
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				if(field[i][j] != 0) {
					dfs(field[i][j],i,j);
					res++;
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3500
def ATCoder(S):
    count = 0
    res = 0
    for i in range(len(S)):
        if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
            count += 1
            if count > res:
                res = count
        else:
            count = 0
    return res



if __name__ == "__main__":
    S = str(input())
    print(ATCoder(S))

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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<(n);i++)
#define rep2(i, m, n) for(int i=m;i<(n);i++)
#define rrep(i, n, m) for(int i=n;i>=(m);i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, K;
    cin >> N >> K;
    double ans = 0;
    for (int i = 1; i <= N; ++i) {
        int tmp = ceil(log2((double) K / i));
        int cnt = max(0, tmp);
        ans += (double) 1.0 / N * (double) pow(0.5, cnt);
    }
    cout << ans << endl;

}

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


Measured memory_bytes: 512