akhauriyash/Code-Regression huggingface dataset:
n = gets.to_i
b = gets.split(" ").map { |e| e.to_i }.sort {|a, b| b <=> a }

alice = []
bob = []

b.each_with_index do |b, i|
  if i.even?
    
    alice << b
  else 
    bob << b
  end 
  
  
end

alice_sum = alice.inject(0) do |sum, item| 
  sum += item
end

bob_sum = bob.inject(0) do |sum, item| 
  sum += item
end

puts alice_sum - bob_sum

Measured memory_bytes: 1788
class dice init =
  let rot_n (x1,x2,x3,x4,x5,x6) = (x2,x6,x3,x4,x1,x5) and
      rot_e (x1,x2,x3,x4,x5,x6) = (x4,x2,x1,x6,x5,x3) in
  let rot_s l = rot_n l |> rot_n |> rot_n and
      rot_w l = rot_e l |> rot_e |> rot_e in
  let all_init =
    let rec rotate d list = function
        0 -> list
      | i -> rotate (rot_e d) (d::list) (i-1) in
    let rotate2 n l = rotate n l 4 in
    rotate2 init []
    |> rotate2 (rot_e init |> rot_s)
    |> rotate2 (rot_w init |> rot_s)
    |> rotate2 (rot_n init)
    |> rotate2 (rot_s init)
    |> rotate2 (rot_n init |> rot_n) in
object (self: 'self)
  val mutable faces:int*int*int*int*int*int = init
  val all:'a list = all_init

  method get_face = faces
  method equals (other:'self) = self#contains other#get_face
  method contains fc =
    let rec find l = match l with
        [] -> false
      | h::tl -> if h = fc then true else find tl
    in find all
end;;

let split_int s = Str.split (Str.regexp_string " ") s |> List.map int_of_string;;
let () =
  let f n = (n 0,n 1,n 2,n 3,n 4,n 5) in
  let nth s = split_int s |> List.nth in
  let d1 = new dice (read_line () |> nth |> f) and
      d2 = new dice (read_line () |> nth |> f) in
  if d1#equals(d2) then print_endline "Yes"
  else print_endline "No"
;;

Measured memory_bytes: 2108
/* D-"Median of Medians" */
/*  */
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#define ll long long
#define N_MAX 100000
using namespace std;

int dash(int a,int tax){
    int p;
    if(tax == 8){
        p = a * 12;
        while(p*8/100 != a){
            p++;
        } 
        return p;
    }   
    else 
        return a*10;
}

int main(){
    int a,b,adash,ad_max,bdash,bd_max;
    cin >> a >> b;
    adash = dash(a,8);
    bdash = dash(b,10);
    while(1){
        if(adash*8/100 != a){
            adash = N_MAX;
            break;
        }
        if(adash/10 == b){
            break;
        }
        adash++;
    } 
    while(1){
        if(bdash/10 != b){
            bdash = N_MAX;
            break;
        }
        if(bdash*8/100 == a){
            break;
        }
        bdash++;
    } 

    if(adash == N_MAX && bdash == N_MAX)
        cout << -1;
    else if(adash > bdash)
        cout << bdash;
    else
        cout << adash;
    
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
X = list(map(int, input().split()))
ans = 0
diff = []
 
X.sort()
 
if (N < M): 
    for i in range(M-1):
        dif = X[i+1] - X[i]
        diff.append(dif)
    
    diff.sort()
    
    for i in range(M-N):
        ans += diff[i]
    # for n in range(N):
    #     diff.pop(-1)
   
    # for i in range(len(diff)):
    #     ans += diff[i]
print(ans)

Measured memory_bytes: 13960
#include <iostream>
 
using namespace std;
 
int main()
{
    int N;
 
    while (cin >> N, N) {
	int x,y,z,w;
	int x1,y1,z1,w1,x2,y2,z2,w2;
	for(int i = 0 ; i < N ; i++){
	    cin >> x1 >> y1 >> z1 >> w1 >> x2 >> y2 >> z2 >> w2;
	    x = x1*x2-y1*y2-z1*z2-w1*w2;
	    y = x1*y2+x2*y1+z1*w2-w1*z2;
	    z = x1*z2-y1*w2+x2*z1+w1*y2;
	    w = x1*w2+y1*z2-z1*y2+w1*x2;
	    cout << x << " " << y << " " << z << " " << w << endl;
	}
    }
    return 0;
}

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

int main(){
    long N,K;cin>>N>>K;
    vector<long> array(N+1);
    array[0]=0;
    vector<int> reach(N+1);
    vector<long> loop(0);
    for(int i=0;i<N;i++)cin>>array[i+1];
    long place=1;
    long count=0;
    long mark=0;
    long j=0;
    while(reach[place]<3){
        reach[place]++;
        if(reach[place]==2&&count==0)mark=j-1;
        if(reach[place]==2){
            loop.push_back(place);
            count++;
        }
      
        place=array[place];
      j++;
      if(j==K){
          cout<<place<<endl;
          return 0;
      }
    }
    long ans=(K-mark)%count-1;
    if(ans==-1)ans=count-1;
    cout<<loop[ans]<<endl;
}

Measured memory_bytes: 6576
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    int n; cin >> n;
    ll sum = 0;
    for(int i = 1; i <= n; ++i){
    	if(i % 3 != 0 && i % 5 != 0) sum += i;
    }
    cout << sum << endl;
	return 0;
} 

Measured memory_bytes: 3196
N,K= list(map(int,input().split()))
import math
if K %2 ==0:
    std = K/2
else:
    std =K
M = N//std
M1 = N//K
if K%2==0:
    print(int((M-M1)**3+M1**3))
else:
    print(M1**3)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef set<ii> sii;
typedef set<int> si;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;

const int INF = 1000000010;
const ll MOD = 1000000007;

int main() {FIN
    
    int a, b, c;
    cin >> a >> b >> c;
    si cl; cl.insert(a); cl.insert(b); cl.insert(c);
    cout << cl.size() << "\n";
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

int main()
{
	FAST;
	ll n, k, i, j;
	cin >> n >> k;
	ll h[n];
	fr(i,0,n)
		cin >> h[i];
	sort(h, h + n);
	ll n1 = n - k;
	ll ans = 0;
	fr(i,0,n1)
	{
		ans += h[i];
	}
	cout << ans;
}


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

int main() {
	
	long long int limit = 0;
	long long int x,a,b;
	cin >> x >> a >> b;

	if(b-a <= 0)  cout << "delicious" << endl;
	if(b-a > 0 && b-a <= x) cout << "safe" << endl;
	if(b-a > 0 && b-a >= x+1) cout << "dangerous" << endl;
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  bool res = abs(x - a) < abs(x - b);
  if (res) cout << "A" << endl;
  else cout << "B" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

int bsr(uint x) { return 31 - __builtin_clz(x); }
int bsr(ull x) { return 63 - __builtin_clzll(x); }
int bsf(uint x) { return __builtin_ctz(x); }
int bsf(ull x) { return __builtin_ctzll(x); }

using P = pair<int, int>;

int n;
V<int> s;

V<int> la;

//[p, ), c
int memo[500500][26];
int nxt(int p, int c) {
    if (memo[p][c] != -1) return memo[p][c];
    if (p >= n) return memo[p][c] = n+1;
    if (s[p] == c) return memo[p][c] = p+1;
    if (s[p] > c) return memo[p][c] = nxt(la[p], c);
    return memo[p][c] = nxt(nxt(p, c-1), c-1);
}

int main() {
    memset(memo, -1, sizeof(memo));
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
    string ss;
    cin >> ss;
    n = int(ss.size());
    s = V<int>(n);
    for (int i = 0; i < n; i++) s[i] = ss[i]-'a';
    la = V<int>(n+1, n+1);
    for (int i = n-1; i >= 0; i--) {
        int l = i+1;
        int x = s[i];
        for (int j = x; j < 26; j++) {
            l = nxt(l, j);
        }
        la[i] = l;
    }
/*    for (int i = 0; i < n; i++) {
        cout << la[i] << ", ";
    }
    cout << endl;*/

    VV<int> dbl(20);
    dbl[0] = la;
    for (int fe = 1; fe < 20; fe++) {
        dbl[fe] = V<int>(n+1);
        for (int i = 0; i <= n; i++) {
            if (dbl[fe-1][i] == n+1) {
                dbl[fe][i] = n+1;
            } else {
                dbl[fe][i] = dbl[fe-1][dbl[fe-1][i]];
            }
        }
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r; l--;
        bool f = false;
        for (int fe = 19; fe >= 0; fe--) {
            if (l == n+1) break;
            if (dbl[fe][l] == r) {
                f = true;
                break;
            }
            if (dbl[fe][l] < r) l = dbl[fe][l];
        }
        if (f) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 98972
#include<stdio.h>
#define MAX 1000000
int main(){
	int m,ans=0;
	int c,c2,c3;
	char list[MAX];
	for(c=0;c<MAX;c++){
		list[c]=1;
	}
	list[0]=0;list[1]=0;
	while(~scanf("%d",&m)){
		for(c=2;c<m+1;c++){
			if(list[c]){
				for(c2=c*2;c2<m+1;c2+=c)list[c2]=0;
				for(c3=m;list[c3]==0;c3--);
				if(c3<c*c)break;
			}
		}
		for(c=2;c<m+1;c++){
			ans+=list[c]; 
		}
		printf("%d\n",ans);
		ans=0;
	}
	return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var ABT = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (A, B, T) = (ABT[0], ABT[1], ABT[2]);

        var ans = (int)(T + 0.5) / A * B;

        WriteLine(ans);
    }
}


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

int main(){
  int n;
  cin>>n;
  int x[n+1];

  for (int i=1;i<=n;i++){
    cin>>x[i];
  }
  int sum=1000000;

  for(int v=1;v<=100;v++){
      int k=0; 
    for(int i=1;i<=n;i++){
      k=k+(x[i]-v)*(x[i]-v);
    }
    if(k<sum) sum=k;
  }

  cout<<sum<<endl;
}

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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

ll mod = 1e9+7;
vector<bool> sosuu(1001);
int n;
ll ans=1;
int cnt[1001] = {0};
int main(){
  cin >> n;
  sosuu = gen_sosuu(sosuu);
  FOR(j,2,n+1){
    int tmp = j;
    FOR(i,2,j+1){
      if(sosuu[i] == false) continue;
      while(tmp%i == 0){
        tmp/=i;
        cnt[i]++;
      }
    }
  }
  REP(i,n+1){
    if(cnt[i]==0) continue;
    ans *= cnt[i]+1;
    ans %= mod;
  }
  ans %=mod;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  long long x;
  cin >> x;
  long long c = 100;
  int cnt = 1;
  while(1){
    if(c*1.01 < x){
      c *= 1.01;
      cnt++;
    }
    else break;
  }
  cout << cnt << "\n";
  return 0;
}



Measured memory_bytes: 3672
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;

class Prog
{
    public Prog() { }
    public static int Main()
    {
        new Prog().calc();
        return 0;
    }

    Scanner cin;

    public void calc()
    {
        cin = new Scanner();
        long N = cin.nextLong();
        long A = cin.nextLong();
        long B = cin.nextLong();

        long[] X = new long[N];
        for(long i = 0;i<N;i++)
        {
            X[i] = cin.nextInt();
        }

        long ans = 0;
        for(long i = 1; i<N;i++)
        {
            if (B <= A * (X[i] - X[i - 1])) ans += B;
            else ans += A * (X[i] - X[i - 1]);
        }

        Console.WriteLine(ans);
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 12504
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define pii pair<int, int>
#define vpli vector<pair<long long, int>>
#define deb(x) cout << "deb " << #x << " " << x << endl;
#define all(x) x.begin(), x.end()
#define endl "\n"
const ll BIG = 1e18;

void swap(ll &a, ll &b)
{
    ll t = a;
    a = b;
    b = t;
}

ll Min(ll a, ll b, ll c)
{
    return min(a, min(b, c));
}

void printvec(vi &vec)
{
    for (int x : vec)
    {
        cout << x << " ";
    }
    cout << endl;
}

int sum(int a)
{
    int ans = 0;
    while (a)
    {
        ans += (a % 10);
        a = a / 10;
    }
    return ans;
}
void print(vi &mp)
{
    for (auto x : mp)
    {
        cout << x;
    }
    cout << endl;
}
void solve()    
{
    int n;
    cin >> n;
    vll a(n);
    bool zero = 0;
    for (ll &x : a)
    {
        cin >> x;
        if (x == 0)
            zero = 1;
    }
    if (zero)
    {
        cout << 0 << endl;
        return;
    }
    ll prod = 1;
    bool flag = 1;
    for (int i = 0; i < n; i++)
    {
        if (prod > (BIG/a[i]))
        {
            flag = false;
            break;
        }
        prod = prod * a[i];
    }
    //deb(prod);
    cout << (flag ? prod : -1) << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  string S;
  cin >> S;
  int l = S.length();
  ll ans = 0;
  ll r_black = l;
  for (ll i = l - 1; i >= 0; --i) {
    // cout << i << ":" << S.at(i) << ":" << r_black << endl;

    if (S.at(i) == 'B') {
      ans += r_black - i - 1;
      r_black = i + (r_black - i - 1);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//const ll MOD = 998244353;
typedef pair<ll,ll> P;

int main() {
    cin>>N>>M;
    mat G(N,vec(0));
    rep(i,N-1){
        cin>>A>>B;
        --A;
        --B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    vec memo(N,0);
    rep(i,M){
        cin>>A>>B;
        --A;
        memo[A] += B;
    }
    vec score(N,0);
    vector<bool> used(N,false);
    queue<int> v;
    v.push(0);
    while(!v.empty()){
        A = v.front();
        v.pop();
        used[A] = true;
        score[A] += memo[A];
        for(ll to : G[A]){
            if(!used[to]){
                score[to] += score[A];
                v.push(to);
            }
        }
    }
    rep(i,N) cout<<score[i]<<' ';
    cout<<endl;
}


Measured memory_bytes: 18672
#include<bits/stdc++.h>
using namespace std;
int p[100009];
int f[100009];
main()
{
    p[1]=1;

    for (int i=2; i<=100000; i++)
    {
        for (int j=2*i; j<=100000; j+=i)
            p[j]=1;
    }
    p[2]=0;
    for (int i=1; i<=100000; i++)
    {
        if(p[i]==0 && p[(i+1)/2]==0 && i!=2)
            {f[i]=f[i-1]+1;// cout<<i<<endl;
            }
        else f[i]=f[i-1];
    }
    int q;
    cin>>q;
    while(q--)
    {
        int l,r;
        cin>>l>>r;
        cout<<f[r]-f[l-1]<<endl;
    }


}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

int main() {
  int N;
  cin >> N;
  int F = 0, K = 0;
  REP(i, N) {
    int a;
    cin >> a;
    if (a % 4 == 0)
      F++;
    if (a % 2 == 1)
      K++;
  }

  if (N % 2) {
    cout << (K - 1 <= F ? "Yes" : "No") << endl;
  } else {
    cout << (K <= F ? "Yes" : "No") << endl;
  }

  return 0;
}


Measured memory_bytes: 256
n,a,b=map(int,input().split())
mod = 10**9 + 7
N = 10**6 #使う最大値+1以上にする、値に注意3*10^5とかにしとくと安心
inv = [0] + [1] # 1/x
finv = [1] + [1] # 1/x!
fac = [1] + [1] # x!
for i in range(2,N):
  inv += [inv[mod % i] * (mod - int(mod / i)) % mod]
  fac += [(fac[i-1] * i) % mod]
  finv += [(finv[i-1] * inv[i]) % mod]
def pow(x, n):
  ans = 1
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = ans*x%mod
    x = x*x%mod
    n = n >> 1 #ビットシフト
  return ans
t=(pow(2,n)-1+mod)%mod
sa1,sa2,sb1,sb2=1,1,1,1
for i in range(1,a+1):
  sa1*=(n-i+1)
  sa1%=mod
sa=sa1*finv[a]%mod
for i in range(1,b+1):
  sb1*=(n-i+1)
  sb1%=mod
sb=(sb1*finv[b])%mod
print((t-sa-sb+mod)%mod)

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

int one2nine2one(int num);

int main() {
	int n;
	cin >> n;
	
	int hp = n/100;
	int tp  = (n%100)/10;
	int op   = ((n%100)%10);
	
	hp = one2nine2one(hp);
	tp = one2nine2one(tp);
	op = one2nine2one(op);
	
	int result = hp*100 + tp*10 + op;
	
	cout << result << endl;
	
	return 0;
}

int one2nine2one(int num)
{
	if(num == 9) return 1;
	else if(num == 1) return 9;
	else return num;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> t(N);
  for(int i=0; i<N; i++){
    int x=i+1;
    int c;
    for(c=0; x<K; c++) x<<=1;
    t[i] = c;
  }
  sort(t.begin(), t.end());
  long s=0;
  for(int ti: t){
    s += 1<<(t[N-1]-ti);
  }
  cout << setprecision(12) << 1.0*s/(N<<t[N-1]) << endl;
  return 0;
}

Measured memory_bytes: 640
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let _ = read!(usize);
    let S = rl();

    let n = S.split("ABC").count();
    println!("{}", n - min(n, 1))
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;
 
// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)
 
int main() {
  string num;
  cin >> num;
 
  int sum = 0;
  REP(i, num.size()) {
    sum += num[i] - '0';
  }
 
  if (sum % 9 == 0) {
    ANS("Yes");
  } else {
    ANS("No");
  }
  return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#include <deque>
#include <ostream>
#include <stdio.h>
using namespace std;

int main(void) {
  string S;
  int Q, T, F;
  char C;
  bool reversed = false;

  cin >> S >> Q;
  deque<char> deq(S.begin(), S.end());
  for (int i = 0; i < Q; i++) {
    cin >> T;
    if (T == 1) {
      reversed = !reversed;
    } else {
      cin >> F >> C;
      if ((F == 1 && !reversed) || (F == 2 && reversed)) {
        deq.push_front(C);
      } else {
        deq.push_back(C);
      }
    }
  }
  if (reversed) {
    reverse(deq.begin(), deq.end());
  }
  for (auto c = deq.begin(); c != deq.end(); c++) {
    cout << *c;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 896
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    s=input()
    a=int(s[0:2])
    b=int(s[2:4])
    if 1<=a<=12 and 1<=b<=12 :print('AMBIGUOUS')
    elif 1<=a<=12 :print('MMYY')
    elif 1<=b<=12 :print('YYMM')
    else:print('NA')






if __name__ == "__main__":
    main()

Measured memory_bytes: 77416
S = input()
flag = False
cflag = False
count = 0
cnum = -1
for i in range(len(S)):
    if 2 <= i:
        if i <= (len(S)-2):
            if S[i] == "C":
                count += 1
                cnum = i
            if count == 1:
                cflag = True

if S[0] == "A":
    if cflag:
        flag = True
        for i in range(len(S)):
            if i != 0:
                if i != cnum:
                    a = ord(S[i])
                    if a <= 90:
                        flag = False
if flag:
    print("AC")
else:
    print("WA")

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

public class Main {
    private void solve() {
        int n = sc.nextInt();
        int m = sc.nextInt();

        int sum = 0;
        for (int i = 0; i < m; i++) {
            sum += sc.nextInt();
        }

        out.println(Math.max(n - sum, -1));
    }

    private static PrintWriter out;
    private static MyScanner sc;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        private MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new MyScanner();
        new Main().solve();
        out.close();
    }
}


Measured memory_bytes: 34136
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define pb push_back
#define pf push_front

namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

ll M = 1000000007;

int main()
{
	string s,t;
	cin>>s>>t;
	int cnt=0;
	rep(i,s.size()){
		if(s[i]==t[i]){
			cnt++;
		}
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 256
// mod 組み合わせ計算2
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)

// 自動でmodを取ってくれる整数型
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const { // ans=mint(a).pow(b); // a^b
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint f(int n){ // 2のn乗
    if(n==0) return 1;
    mint x=f(n/2);
    x*=x;
    if(n%2==1) x*=2;
    return x;
}

// n(>10^8)が大きくても早く計算できる
// 但し、何回も呼ぶと遅い
mint choose(int n,int a){ // 組み合わせ　nCa
    mint x=1,y=1;
    rep(i,a){
        x*=n-i;
        y*=i+1;
    }
    return x/y;
}
int main(){
    ll n;
    cin>>n;
    mint a=1;
    mint b=1;
    mint c=1;
    mint d=1;
    rep(i,n){ 
      a*=10;
      b*=9;
      d*=8;
    }
  c=b;
  mint ans=a-b-c+d;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <math.h>
#include <bits/stdc++.h>
#include <string>
#define pb          push_back
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353
#define PI          3.141592653589
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
#define _init(b)     memset(b,-1,sizeof(b))
#define _init0(b)     memset(b,0,sizeof(b))
#define MOD         1000000007
#define MAX 1e18
#define MIN -1e9
#define ll long long
#define ull unsigned long long
#define ld long double
#define all(x) x.begin(),x.end()
#define rep(i, l, r) for (ll i = (l); i < (r); i++)
#define repb(i, r, l) for (ll i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define cl(x) (int)ceil((double)x/2);
#define fl(x) (int)floor((double)x/2);
#define watch(x) cout << (#x) << " is " << (x) << endl
using namespace std;
//cout << fixed << setprecision(13) << x;
bool cmp(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second < b.second);
}

bool mod(double a,double b)
{
    return a/b - floor(a/b);
}

int logb(int base, int x)
{
    return (log(x) / log(base));
}

void sortString(string &str)
{
    sort(str.begin(), str.end());
}

int lcm(int a,int b)
{
    return (a*b)/__gcd(a,b);
}

bool find(ll x,ll a[],ll n)
{
    rep(i,0,n)
    if(a[i]==x)
        return true;
    return false;
}

//floor(log10(N)) + 1;
//swap two no.		a ^= b; b ^= a; a ^= b;
// to_string(s)  to convert the string to int
//x ^ ( x & (x-1)) : Returns the rightmost 1 in binary representation of x.
//x&(-x) : Returns the rightmost 1 in binary representation of x.
//x | (1 << n) : Returns the number x with the nth bit set.
int btd(ll n)
{
    ull num = n,dec_value = 0,base = 1,temp = num;
    while (temp)
    {
        int last_digit = temp % 10;
        temp = temp / 10;

        dec_value += last_digit * base;

        base = base * 2;
    }
    return dec_value;
}

bool isPowerOfTwo (int x) { return x && (!(x&(x-1))); }


int main()
{
    FLASH
   ll n,x;
   cin>>n>>x;
   ll a[n],b[n],cnt=0;
   rep(i,0,n)
   {
       cin>>a[i]>>b[i];
       ld val = (double)sqrt(a[i]*a[i] + b[i]*b[i]);
      // cout<<val<<endl;
       if(x>=val)
        cnt++;
   }
   cout<<cnt<<endl;
   return 0;

}


Measured memory_bytes: 6820
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;
typedef tuple<ll, int, ll> tup;

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

	ll N, Q;
	cin >> N >> Q;

	vector<tup> v;
	rep(i, N){
		ll s, t, x;
		cin >> s >> t >> x;
		v.push_back((tup){2 * (s - x) - 1, 1, x});
		v.push_back((tup){2 * (t - x) - 1, 2, x});
	}

	rep(i, Q){
		ll d;
		cin >> d;
		v.push_back((tup){2 * d, 0, 0});
	}

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

	// rep(i, v.size()){
	// 	cout << get<0>(v[i]) << "," << get<1>(v[i]) << "," << get<2>(v[i]) << endl;
	// }
	multiset<ll> ms;

	for(int i = 0; i < v.size(); i++){
		ll a = get<0>(v[i]);
		int b = get<1>(v[i]);
		ll x = get<2>(v[i]);

		if(b == 0){
			if(ms.empty()){
				cout << -1 << endl;
			}else{
				cout << *ms.begin() << endl;
			}
			continue;
		}

		if(b == 2){
			ms.erase(ms.find(x));
			continue;
		}
		ms.insert(x);
	}
}


Measured memory_bytes: 26088
N, L = map(int, input().split())
n = []
for i in range(1, N+1):
  n.append(L+i-1)

a = 200
I = ""
for i in range(N):
  if abs(n[i]) < a:
    a = abs(n[i])
    I = i
print(sum(n) - n[I])

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int w = sc.nextInt();
        if (w >= s) {
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }
        
    }
}


Measured memory_bytes: 35776
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a:String = read();
    if a == a.to_ascii_uppercase() {
        println!("A");
    } else {
        println!("a");
    }
}

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

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

const lli MOD = 1000000007LL;

lli modpow(lli a, lli n){
    lli res = 1;

    for(lli ai = a; n; n>>=1){
        if(1&n) res = (res*ai)%MOD;
        ai=(ai*ai)%MOD;
    }
    return res;
}

lli inv(lli n){
    return modpow(n, MOD-2);
}

lli modperm(lli n, lli k){
    lli res = 1;
    rep(i, k){
        res = (res*(n-i))%MOD;
    }
    return res;
}

lli modcomb(lli n, lli k){
    return (modperm(n, k)*inv(modperm(k, k)))%MOD;
}

lli posmod(lli n){
    lli res = n;
    res %= MOD;
    if(res < 0) res += MOD;
    return res;
}
int n;

int main(void){
    cin >> n;
    if(n%10 == 7 || (n/10)%10 == 7 || n/100 == 7) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int par[100001];
int len[100001];
void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    len[i]=0;
  }
}
int root(int n){
  if(par[n]==n)return n;
  return root(par[n]);
}
void unit(int x,int y){
  x=root(x);y=root(y);
  if(x==y)return;
  if(len[x]>=len[y]){
    par[y]=x;
    len[x]++;
  }
  else{
    par[x]=y;
    len[y]++;
  }
}
int main(){
  int n,m;cin>>n>>m;
  init(n);
  vector<int>v[m];
  for(int i=0;i<n;i++){
    int k;cin>>k;
    int l[k];
    for(int j=0;j<k;j++){
      cin>>l[j];
      l[j]--;
      v[l[j]].push_back(i);
      unit(v[l[j]][0],i);
    }
  }
  int r=root(0);
  for(int i=1;i<n;i++){
    if(root(i)!=r){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
}



Measured memory_bytes: 4608
#include<stdio.h>

int main(void){
	int n,cnt=0;
	scanf("%d",&n);
	char s[n+1];
	scanf("%s",s);
	for(int i=0;i<n-2;i++){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
			cnt++;
		}
	}
	printf("%d",cnt);
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int D = sc.nextInt();
        int A = sc.nextInt();

        int[] X = new int[N];
        int[] H = new int[N];
        for (int i=0; i<N; i++) {
            X[i] = sc.nextInt();
            H[i] = sc.nextInt();
        }

        System.out.println(solve(N, D, A, X, H));
    }

    private static long solve(int N, int D, int A, int[] X, int[] H) {
        long count = 0;
        long current = 0;
        List<Pair> bomb = new LinkedList<>();

        List<Pair> monster = new ArrayList();
        for (int i=0; i<N; i++) {
            monster.add(new Pair(X[i], H[i]));
        }
        Collections.sort(monster, new PairComparator().reversed());

        for (int i=0; i<N; i++) {
            Pair m = monster.get(i);
            // System.err.println("m = (" + m.x + ", " + m.h + ")");

            while (bomb.size() > 0) {
                Pair b = bomb.get(0);
                if (b.x < m.x - D) {
                    current -= b.h;
                    bomb.remove(0);
                    // System.err.println("end of bomb range at " + (b.x) + " < " + m.x);
                } else {
                    // System.err.println(b.x + " >= " + (m.x-D));
                    break;
                }
            }

            if (m.h > current*A) {
                long n =  (m.h - current*A) / A;
                if ((m.h-current*A)%A != 0) {
                    n++;
                }
                bomb.add(new Pair(m.x + D, n));
                current += n;
                count += n;

                // System.err.println("add " + n + " bomb at " + (m.x + D));
            }
        }

        return count;
    }


    static class Pair {
        int x;
        long h;

        public Pair(int x, long h) {
            this.x = x;
            this.h = h;
        }
    }

    static class PairComparator implements Comparator {
        public int compare(Object a0, Object b0) {
            Pair a = (Pair)a0;
            Pair b = (Pair)b0;

            return b.x - a.x;
        }
    }

}

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

int main() {
    int n;
    cin >> n;
    bool flag = false;
    rep(i, 9) rep(j, 9) if((i + 1) * (j + 1) == n) flag = true;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new ABC122().SolveB(new ConsoleInput(Console.In, ' '));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
  class ABC122
    {
        public void SolveB(ConsoleInput cin)
        {
            var S = cin.Read.ToCharArray();
            int maxLength = 0;
            //しゃくとり法
            for (int i = 0; i < S.Length; i++)
            {
                if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T')
                {
                    int length = 1;
                    int k = i + 1;
                    var L = i;
                    var R = k;
                    while (k < S.Length)
                    {
                        if (S[k] == 'A' || S[k] == 'C' || S[k] == 'G' || S[k] == 'T')
                        {
                            length++;
                            k++;
                        }
                        else break;
                    }
                    maxLength = Max(maxLength, length);
                }
            }
            WriteLine(maxLength);
            ReadLine();
        }
    }
}

Measured memory_bytes: 13268
"use strict";

function main(input) {
  input = input.trim().split("\n");
  const line_one = input[0].split(" ");
  const K = parseInt(input[1]);
  let line_one_arr = [];

  for (let i in line_one) {
    line_one_arr.push(parseInt(line_one[i]));
  }

  for (let i = 0; i < K; i++) {
    if (line_one_arr[0] >= line_one_arr[1]) {
      line_one_arr[1] = line_one_arr[1] * 2;
      continue;
    }
    if (line_one_arr[1] >= line_one_arr[2]) {
      line_one_arr[2] = line_one_arr[2] * 2;
    }
  }

  if (line_one_arr[0] < line_one_arr[1] && line_one_arr[1] < line_one_arr[2]) {
    console.log("Yes");
  } else {
    console.log("No");
  }
}

function numberSort(array) {
  array.sort(f);
  return array;
}

var f = function (a, b) {
  return a - b;
};

main(require("fs").readFileSync("/dev/stdin", "utf-8"));


Measured memory_bytes: 29612
import numpy as np
MOD = 10**9+7
N, M = map(int, input().split())
s = np.array(input().split(), dtype=np.int32)
t = np.array(input().split(), dtype=np.int32)

dp = np.zeros((N+1,M+1), dtype=np.int64)
dp[0] = 1

for i in range(N):
  same = (s[i]==t)
  dp[i+1,1:][same] = dp[i,:-1][same]
  dp[i+1] = (dp[i+1].cumsum()+dp[i])%MOD

print(dp[-1,-1])


Measured memory_bytes: 43444
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define ll long long

char s[200001];
int a[200001][2];
int p[200002];
int ans[200002];

int main(void)
{
	int n, sum, temp1, temp2, k;
	scanf("%d", &n);
	scanf("%s", s);

	sum = 0;
	for (int i = 0; i < n; i++)
		if (s[i] == '1')
			sum++;
	
	temp1 = temp2 = 1;
	for (int i = 1; i <= n; i++)
	{
		a[n - i][0] = temp1;
		a[n - i][1] = temp2;
		temp1 *= 2;
		if(sum != 1)
			temp1 %= sum - 1;

		temp2 *= 2;
		temp2 %= sum + 1;
	}

	temp1 = temp2 = 0;
	for (int i = 0; i < n; i++)
	{
		temp1 *= 2;
		temp1 += s[i] - '0';
		if (sum != 1)
			temp1 %= sum - 1;

		temp2 *= 2;
		temp2 += s[i] - '0';
		temp2 %= sum + 1;
	}
	
	for (int i = 1; i <= n + 1; i++)
	{
		k = i;
		while (k)
		{
			p[i] += k % 2;
			k /= 2;
		}
	}

	for (int i = 1; i <= n + 1; i++)
	{
		k = i;
		while (k)
		{
			k %= p[k];
			ans[i]++;
		}
	}

	for (int i = 0; i < n; i++)
	{
		if (s[i] == '0')
			printf("%d\n", ans[(temp2 + a[i][1]) % (sum + 1)] + 1);
		else
		{
			if (sum == 1)
				printf("0\n");
			else
				printf("%d\n", ans[(temp1 - a[i][0] + sum - 1) % (sum - 1)] + 1);
		}
	}
	return 0;
}

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

int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int x=max(a,(max(b,c)));
  
  for(int i=0;i<k;i++){
    x*=2;
  }
  cout<<a+b+c+x-max(a,(max(b,c)))<<endl;
}

Measured memory_bytes: 256