akhauriyash/Code-Regression huggingface dataset:
n = gets.to_i
xl = Array.new(n) { gets.split.map(&:to_i) }.sort
xl.map! { |x, l| [x - l, x + l] }

rmax = xl[0][0]
xl.each do |l, r|
  if rmax > l
    rmax = [rmax, r].min
    n -= 1
  else
    rmax = r
  end
end

puts n


Measured memory_bytes: 16104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
void print(int x){printf("%d\n", x);}
void print(ll x){printf("%lld\n", x);}
void printvec(vector<int>& a){
rep(i, a.size()-1){
printf("%d ", a[i]);
}
printf("%d\n", a[a.size()-1]);
}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
int main()
{
    int n;
    cin >> n;
    vector<int> md(3, 0);
    int r;
    rep(i, n){
        scanf("%d", &r);
        md[r%3]++;
    }
    // printvec(md);
    if(md[1]==0 && md[2]==0){
        printf("1\n");
        return 0;
    }

    int ans=md[0];
    if(md[1]==md[2]){
        ans += 2*md[1];
    }else if(md[1]>md[2]){
        if(md[1]==1) {
            ans++;
        }else{
            md[1] -= 2;
            int m = min(md[1], md[2]);
            ans += 2*m + 2;
            md[1] -= m; md[2] -= m;
            if(md[2]==0){
                if(md[1]!=0) ans++;
            }else if(md[2]==1){
                ans++;
            }else{
                ans+=2;
            }
        }
    }else{
        if(md[2]==1) {
            ans++;
        }else{
            md[2] -= 2;
            int m = min(md[1], md[2]);
            ans += 2*m + 2;
            md[1] -= m; md[2] -= m;
            if(md[1]==0){
                if(md[2]!=0) ans++;
            }else if(md[1]==1){
                ans++;
            }else{
                ans+=2;
            }
        }
    }

    print(ans);
    return 0;
}


Measured memory_bytes: 3228
import java.util.Scanner;

public class Main{

	public static void main(String[] args){
		
		//テキスト入力クラス
		Scanner sc = new Scanner(System.in);
		
		//入力文字を取得
		int first = sc.nextInt();
		int second = sc.nextInt();
		int third = sc.nextInt();
		
		//3つの数が、条件を満たし、yesの場合
		if(first < second && second < third){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}		
	}
}

Measured memory_bytes: 17176
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//ここまで毎回include
//以下プログラム

using namespace std;

long gcd(long a, long b) {
	long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

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

int main() {
	int n;
	cin >> n;
	vector<long> data(n);
	for (int i = 0; i < n; i++) {
		cin >> data.at(i);
	}if (n == 1) {
		cout << "Yes" << endl;
		return 0;
	}
	if (n == 2) {
		if (data.at(0) <= data.at(1)) {
			cout << "Yes" << endl;
			return 0;
		}
		else if (data.at(0) - 1 == data.at(1)) {
			cout << "Yes" << endl;
			return 0;
		}
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	long M = data.at(0);
	for (int i = 0; i < n; i++) {
		M = max(M, data.at(i));
		if (M - data.at(i) > 1) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}



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

typedef long long lll;

int main()
{
    ios_base::sync_with_stdio(false);
    int n, x;
    cin >> n >> x;
    vector<int> A(n);
    for(int &i : A) cin >> i;
    sort(A.begin(), A.end());
    int g = 0;
    for(int i = 1; i < n; i++) {
        g = __gcd(g, A[i] - A[i - 1]);
    }
    cerr << g << endl;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        ans = max( ans, __gcd(g, abs(x - A[i])) );
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
n = int(input())
A = list(map(int, input().split()))

def search(x):
    b = n
    r = 0
    y = 0
    D = [0]*(2*n+1)
    for i in range(n):
        D[b] += 1
        if A[i] < x:
            r += D[b]
            b += 1
        else:
            b -= 1
            r -= D[b]   
        y += r
    return y

S = sorted(A)
l = 0
r = n
m = n // 2
c = n * (n + 1) // 2

while True:
    if search(S[m]) <= c // 2:
        if m == n - 1:
            break
        elif search(S[m + 1]) > c // 2:
            break
        else:
            l = m
            m = (m + r) // 2
    else:
        r = m + 1
        m = (m + l) // 2
        
print(S[m])


Measured memory_bytes: 14276
#include <bits/stdc++.h>
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) v.begin(), v.end()
 
using namespace std;

inline ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
 
inline ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}
 
inline ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
 
inline ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}
 
inline vector<pair<ll, int>> factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}
 
inline bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
 
ll mod = 1e9+7;

int main(void){
    ll a, b;
    cin >> a >> b;
    
    ll _gcd = gcd(a, b);
   auto ans = factorize(_gcd);
    
    cout << ans.size()+1 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

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

        while ((line = br.readLine()) != null && !line.isEmpty()) {
            StringTokenizer st = new StringTokenizer(line);
            int a, b, c, d, e, f;
            double x, y;
            a = Integer.parseInt(st.nextToken());
            b = Integer.parseInt(st.nextToken());
            c = Integer.parseInt(st.nextToken());
            d = Integer.parseInt(st.nextToken());
            e = Integer.parseInt(st.nextToken());
            f = Integer.parseInt(st.nextToken());
            x = (double) (c * e - b * f) / (a * e - b * d);
            y = (double) (c * d - a * f) / (b * d - a * e);
            if (x == -0)
                x = 0;
            if (y == -0)
                y = 0;
            System.out.printf("%4.3f %4.3f\n", x, y);
        }
    }
}

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

long long int x, a;

int main(){
    scanf("%lld", &x);
    a = x / 11;
    x -= a * 11;
    cout << (a * 2 + (x > 6 ? 2 : x ? 1 : 0)) << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict


def prime_factor(n):
    d = defaultdict(int)
    for i in range(2, n + 1):
        if i * i > n:
            break

        while n % i == 0:
            d[i] += 1
            n //= i

    if n != 1:
        d[n] += 1

    return d


A, B = map(int, input().split())
prime_a = prime_factor(A)
prime_b = prime_factor(B)
print(len(set(prime_a) & set(prime_b)) + 1)


Measured memory_bytes: 65808
import java.util.Scanner;

public class Main {

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

    int toshi = 13;
    int toshi2 = 5;
    int kakaku = 0;

    if (A >= toshi) {
    	kakaku = B;
    } else if (A < toshi && A > toshi2){
    	kakaku =  B/2;
    }

    System.out.println(kakaku);

  }

}

Measured memory_bytes: 21972
struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    // from kenkoooooo
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn usize_read(&mut self) -> usize {
        self.read()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let a: Vec<i64> = sc.read_vec(n);
    println!("{}", a.iter().max().unwrap() - a.iter().min().unwrap());
}


Measured memory_bytes: 4352
n = int(input())
a = [int(i) for i in input().split()]
a.insert(0,0)
a.insert(n+1,0)
cost = 0
for i in range(n+1):
    cost += abs(a[i]-a[i+1])
for i in range(1,n+1):
    b = cost-(abs(a[i]-a[i-1])+abs(a[i]-a[i+1]))+abs(a[i-1]-a[i+1])
    print(b)


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int x, y; scanf("%d%d", &x, &y);
  if (x > 3) x = 4;
  if (y > 3) y = 4;
  x = 100000*(4-x);
  y = 100000*(4-y);
  int ans = x+y;
  if (ans == 600000) ans += 400000;
  printf("%d", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3852
function main(input) {
	var array = input.split('\n')[1].split(' ').map((n) => parseInt(n, 10));
	var result = 0;
	while(array.every((n) => (n % 2) === 0)) {
		result += 1;
		array = array.map((n) => (n / 2));
	}
	console.log(result)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

A = reads()

print(min(abs(p[1] - p[0]) + abs(p[1] - p[2]) for p in permutations(A)))


Measured memory_bytes: 38384
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<deque>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<iomanip>
#include<sstream>
using namespace std;

#define pi acos(-1.0)
#define ms(x,n) memset(x,n,sizeof(x));

typedef long long ll;//string::npos
typedef long long iint;

ll gcd(ll a,ll b) {
	return a%b==0?b:gcd(b,a%b);
}
ll lcm(ll x,ll y) {
	ll z=gcd(x,y);
	return x*y/z;
}

const int MAXX=2e5+5;
const int INF=1e7+5;
const int mod=998244353;

vector<int> vt;
map<int,int> m1;

int main() {
	ios::sync_with_stdio(false);
	int a,b;
	while(cin>>a>>b){
//		cout<<(0.08*b/0.10)/0.08<<endl;
		double i=1;
		bool f=false;
		while(i<=1000){
			if(floor(i*0.08)==a&&floor(i*0.10)==b){
				cout<<i<<endl;
				f=true;
				break;
			}
			i++;
		}
		if(!f) cout<<"-1\n";
	}
	return 0;
}




//	getline(cin,a);
//	scanf("%[^\n]",a);getchar();
//	cin.getline(a,sizeof(a));

Measured memory_bytes: 256
import Control.Applicative
import qualified Control.Monad as Monad (forM, forM_, replicateM)

type Vector = [Int]
type Row = [Int]
type Matrix = [Row]

main = do
    [n,m] <- getLine'
    a <- Monad.replicateM n getLine'
    b <- toVector <$> Monad.replicateM m getLine'
    mapM_ print $ vectorAndMatrixProduct a b

getLine' :: IO [Int]
getLine' = map (read :: String -> Int) . words <$> getLine

toVector :: [[Int]] -> Vector
toVector = concat

vectorAndMatrixProduct :: Matrix -> Vector -> Vector
vectorAndMatrixProduct xs ys = toVector $ do
    Monad.forM [0..(length xs - 1)] $ \i -> dotProduct (xs !! i) ys

dotProduct :: Row -> Vector -> Row
dotProduct xs ys = return $ sum $ zipWith (*) xs ys

Measured memory_bytes: 7564
# coding: utf-8

# https://atcoder.jp/contests/abc121


def main():
    N, M, C = map(int, input().split())
    B = list(map(int, input().split()))
    A = [None] * N
    for i in range(N):
        A[i] = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        left = C
        for j in range(M):
            left += A[i][j] * B[j]
        
        if left > 0:
            ans += 1
    
    return ans


print(main())


Measured memory_bytes: 9196
import sys

N, H = map(int, sys.stdin.readline().split())

katanas = []
for i in range(N):
    a, b = map(int, sys.stdin.readline().split())
    katanas.append((a, b, i))

sk = sorted(katanas, reverse=True)
max_k = sk[0][0]

katanas.sort(key = lambda x:x[1], reverse=True)
ans = 0
i = 0
while H > 0:
    if i < N and katanas[i][1] > max_k:
        H -= katanas[i][1]
        i += 1
        ans += 1
    else:
        tmp = (H - 1) // max_k + 1
        H -= tmp * max_k
        ans += tmp
        
print(ans)

Measured memory_bytes: 27924
#include <stdio.h>

void main() {
  int a, b;
  for(int i=1;;i++) {
    scanf("%d %d", &a, &b);
    if (a==0 && b==0) break;
    else if (a < b) printf("%d %d\n", a, b);
    else printf("%d %d\n", b, a);
  }
}


Measured memory_bytes: 2100
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,res=0,a;
        cin>>n;
        vector<int>v;
        for(i=0;i<n;i++)
        {
                cin>>a;
                res=res^a;
                v.push_back(a);
        }
        for(i=0;i<n;i++)
        {
                int z=res^v[i];
                cout<<z<<" ";
        }
       
}

Measured memory_bytes: 4248
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

struct Seg {
    int l, r;
} seg[100005];

bool cmp (Seg x, Seg y) {
    if (x.l == y.l) {
        return x.r > y.r;
    }
    return x.l < y.l;
}

int sfr[100005];

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> seg[i].l >> seg[i].r;
    }
    sort(seg + 1, seg + n + 1, cmp);
    int maxl = 0;
    int li;
    int minr = 1e9;
    int ri;
    int lg = 0;
    for (int i = 1; i <= n; i++) {
        if (seg[i].l > maxl) {
            maxl = seg[i].l;
            li = i;
        }
        if (seg[i].r < minr) {
            minr = seg[i].r;
            ri = i;
        }
        lg = max(lg, seg[i].r - seg[i].l + 1);
    }
    int ans = lg + max(0, minr - maxl + 1);
    sfr[n + 1] = seg[li].r;
    seg[0].l = seg[ri].l;
    for (int i = n; i >= 1; i--) {
        if (i == li || i == ri) {
            sfr[i] = sfr[i + 1];
        } else {
            sfr[i] = min(seg[i].r, sfr[i + 1]);
        }
    }
    for (int k = 0; k <= n; k++) {
        if (k == li || k == ri) { continue; }
        ans = max(ans, max(0, minr - seg[k].l + 1) + max(0, sfr[k + 1] - maxl + 1));
    }
    cout << ans << endl;
}


Measured memory_bytes: 4796
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long int n,m,ans=-1,a,b,c;
    cin>>n>>m;
    char s[n+1];
    cin>>s;
    char t[m+1];
    cin>>t;
    if(n<m){
        a=n;
        b=m;
    }
    else {
        a=m;
        b=n;
    }    
    
ans=__gcd(n,m);
    if(ans!=-1){
        for(int j=0;j<=ans;j++){
            if(s[j*n/ans]!=t[j*m/ans]){
                ans=-1;
                break;
            }
        }
    }
else c=ans;
    if(ans!=-1){
        c=a*b/ans;
    }
    else c=ans;
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    int idx;
    rep(i,n) {
        cin >> idx;
        a[idx-1] = i+1;
    }
    rep(i,n) {
        cout << a[i] << endl;
    }

    return 0;
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    string S;
    ll diffMin = LONG_LONG_MAX;
    cin >> S;
    for(ll i = 0;i < S.size() - 2;i++) {
        string temp = string(S.begin() + i, S.begin() + i + 3);
        ll a = stoi(temp);
        diffMin = min(diffMin, abs(a - 753));
    }
    cout << diffMin << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MAX 100000
#define INF 1000000 
#define M 1000000007
#define PI 2 * acos(0.0)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main(){
   fast_io
   ll n,k;
   cin>>n>>k;
   ll a[n+2];
   for(ll i = 1;i<=n;i++) cin>>a[i];
   ll dp[MAX+2];
   dp[1] = 0;
   for(ll i = 2;i<=n;i++){
       ll ans = 1000000000;
      for(ll j = 1;j<=k;j++){
           if(j == i) break;
           ans = min(dp[i-j] + abs(a[i-j] - a[i]), ans);
      }
      dp[i] = ans;
   }
   cout<<dp[n]<<endl;
   return 0;
}

Measured memory_bytes: 5208
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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


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

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

    ll ans=0;
    ll left_B=0,right_A=0,left_B_right_A=0;

    REP(i,N){
        string s;
        cin>>s;
        REP(j,s.size()-1){
            if(s.substr(j,2)=="AB") ans++;
        }
        if(s[0]=='B') left_B++;
        int ssize=s.size();
        if(s[ssize-1]=='A') right_A++;
        if(s[0]=='B'&&s[ssize-1]=='A') left_B_right_A++;
    }

    ans+=(min(left_B,right_A));
    //if(left_B_right_A==N) ans--;
    if(left_B==left_B_right_A&&right_A==left_B_right_A){
        if(left_B!=0) ans--;
    }
    if(ans<0) cout<<0<<endl;
    else cout<<ans<<endl;
}

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

int main(void)
{
	long long  a, b, x, cur, ans = 0;
	scanf("%lld%lld%lld", &a, &b, &x);
	printf("%lld\n", a ? b / x - (a - 1) / x : b / x + 1);
}


Measured memory_bytes: 256
from itertools import combinations

S = str(input())
pos = [i for i in range(len(S)-1)]
insert_indices = [comb for i in range(len(S)) for comb in combinations(pos, i)]

ans = 0

for inds in insert_indices:
    cur_ix = 0
    cur_ans = 0
    while cur_ix < len(S):
        cur_ans += int(S[cur_ix])
        if cur_ix == len(S)-1:
            break
        if cur_ix in inds:
            ans += cur_ans
            cur_ans = 0
        else:
            cur_ans *= 10
        cur_ix += 1
    ans += cur_ans
    
print(ans)


Measured memory_bytes: 3064
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;


/*----------------------------------------------------------------*/
signed main(){

	int a,b,k;
	cin >> a >> b >> k;

    if(a >= k)cout << a-k <<" " << b <<endl;
    else cout << 0 << " " << max(0LL,b-(k-a)) << endl;





	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://ddcc2020-qual.contest.atcoder.jp/tasks/ddcc2020_qual_b
// rm -r -f test;oj dl https://abc149.contest.atcoder.jp/tasks/abc149_b

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
signed main(){
  ll n,N,t0,t1;
  cin >> N;
  for(ll w=1;w<=3500;w++){
    for(ll h=1;h<=3500;h++){
      t0 = w*h*N;
      t1 = 4*h*w-N*w-N*h;
      if(t1!=0&&t0%t1==0&&t0/t1>0){
        printf("%lld %lld %lld\n",h,w,t0/t1);
        return 0;
      }
    }
  }
}


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

//#define int long long
#define reps(i,s,n) for(ll (i)=(s);(i)<(ll)(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) reps(i,0,n+1)
#define repst(i,s,n) reps(i,s,n+1)
#define reprt(i,n,t) for(ll (i)=(n);(i)>=t;--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb emplace_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) for(int (i)=0;i<n;++i){cout<<x[i]<<(i==n-1?'\n':' ');}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

// 1,2,3なら110100って感じで数列を0-1で表してxyzを含まない数列を数え上げる
// dp[i][s]: 数列のa[i-1]までを矛盾なく直前の和が集合s(|s| <= x+y+z-1)であるように数字を決めてきた数列の個数

int n, x, y, z, l, ng;
ll dp[41][1<<16], ans;

signed main() {
	cin >> n >> x >> y >> z;
	l = x+y+z-1;
	int m = (1<<l)-1;
	ng = (1<<l) | (1<<(l-x)) | (1<<(l-x-y));
	dp[0][0] = 1;
	rep(i,n) repst(a,1,10) rep(s,1<<l) {
		int t = (s<<a) | (1<<(a-1));
		if ((ng&t)!=ng) dp[i+1][t&m] = (dp[i+1][t&m] + dp[i][s]) %mod;
	}
	ans = 1;
	rep(i,n) ans = ans*10 %mod;
	rep(s,1<<l) ans -= dp[n][s];
	ans %= mod, ans += mod, ans %= mod;
	cout << ans << ln;
}

Measured memory_bytes: 20736
n = int(input())
a = list(map(int, input().split()))
d = {}

for ai in a:
    if ai in d:
        d[ai] += 1
    else:
        d[ai] = 1

cnt = sum([value*(value-1)//2 for value in d.values()])

for i in range(n):
    val = d[a[i]]
    res = cnt - val*(val-1)//2

    if val >= 3:
        res += (val-1)*(val-2)//2

    print(res)

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

int main() {
  long long a, b, c, d, ans = 0;

  cin >> a >> b >> c >> d;

  long long cn = b/c - ((a-1) / c);
  long long dn = b/d - ((a-1) / d);

  long long x = c*d;
  long long r = c%d;
  while(r != 0){
    c = d;
    d = r;
    r = c%d;
  }
  x /= d;

  long long cdn = b/x - (a-1) / x;

  cout << b - a + 1 - (cn + dn - cdn) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e6+3;
const int N=1e6+10;
ll fac[N];
ll ifac[N];
ll quick_pow(ll a,ll b){
    ll ans=1;a%=mod;
    while(b){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}
ll inv(ll x){
    return quick_pow(x,mod-2);
}
bool check(ll now_t,ll n){
    if(now_t%mod==0 || (now_t+n-1)%mod==0) return true;
    ll p1=now_t/mod;
    ll p2=(now_t+n-1)/mod;
    return p2>p1;
}
int main(){
    fac[0]=1;
    for(int i=1;i<N;++i){
        fac[i]=fac[i-1]*i%mod;
    }
    //ifac[N-1]=inv(fac[N-1]);
    //for(int i=N-1;i>=1;--i) ifac[i-1]=ifac[i]*i%mod;
    int q;
    scanf("%d",&q);
    while(q--){
        ll a,d,n;scanf("%lld %lld %lld",&a,&d,&n);
        if(a==0){
            puts("0");continue;
        }
        if(d==0){
            printf("%lld\n",quick_pow(a,n));
            continue;
        }
        ll now_t=1ll*a*inv(d)%mod;
        if(check(now_t,n)){
            puts("0");continue;
        }
        //cout<<"now_t: "<<now_t<<"\n";
        //cout<<fac[now_t+n-1]<<" "<<inv(fac[now_t-1])<<" "<<quick_pow(d,n)<<"\n";
        printf("%lld\n",fac[(now_t+n-1)%mod]*inv(fac[(now_t-1)%mod])%mod*quick_pow(d,n)%mod);
    }
}


Measured memory_bytes: 10368
#include<stdio.h>
#include<stack>
#include<string>
#include<iostream>
using namespace std;
int main()
{
	stack<char> S;
	int count=0;
	string arr;
	getline(cin,arr,'\n');
	for(int i=0;i<arr.size();i++)
	{
		char temp;
		if(!S.empty()) temp=S.top();
		if(arr[i]!=temp&&!S.empty())
		{
			S.pop();
			count+=2;
		}
		else
		{
//			printf("*");
			S.push(arr[i]);	
		}
	}
	printf("%d\n",count);
	return 0;
} 

Measured memory_bytes: 512
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


int main(){
    ll n,m;
    cin>>n>>m;
    vector<vector<pll>> A(n+1);
    for(int i=0;i<m;i++){
        ll l,r,x;
        cin>>l>>r>>x;
        A[r].push_back({l,x});
        if(l==1 && r==1 && x>1){cout<<0<<endl; return 0;}
    }
    vector<vector<ll>> dp(n+1,vector<ll>(n+1,0));
    vector<vector<ll>> next(n+1,vector<ll>(n+1,0));
    dp[0][0]=3;
    for(int i=1;i<n;i++){
        for(auto &I:next){for(auto &T:I){T=0;}}
        for(int h=0;h<i;h++){
            for(int t=0;t<=h;t++){
                next[h][t]+=dp[h][t];
                next[i][t]+=dp[h][t];
                next[i][h]+=dp[h][t];
                next[h][t]%=MOD;
                next[i][t]%=MOD;
                next[i][h]%=MOD;
            }
        }
        for(auto &I:A[i+1]){
            for(int h=0;h<=i;h++){
                for(int t=0;t<=h;t++){
                    ll cnt=1;
                    if(h>=I.F){cnt++;}
                    if(t>=I.F){cnt++;}
                    if(cnt!=I.S){next[h][t]=0;}
                }
            }
        }
        for(int h=0;h<=i;h++){
            for(int t=0;t<=h;t++){
                dp[h][t]=next[h][t];
            }
        }
    }
    ll ans=0;
    for(auto &I:dp){
        for(auto &T:I){ans+=T; ans%=MOD;}
    }
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 1664
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; i++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	int N; cin >> N;
	if (N % 2 == 0)cout << N / 2 << endl;
	else cout << (N + 1) / 2 << endl;
}

Measured memory_bytes: 256
n = int(input())
li = [list(map(int,input().split())) for _ in range(n)]
c = 0
ans = 0
for a,b in li:
    if a==b:
        c+=1
        ans = max(c,ans)
    else:
        ans = max(c,ans)
        c=0
if ans >= 3:print('Yes')
else:print('No')

Measured memory_bytes: 62480
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

constexpr ll MOD = 1000000007;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  ll n, l;
  cin >> n >> l;
  vector<ll> a(n);
  for (ll& x : a) cin >> x;

  int left = -1;
  rep(i, 0, n - 1) {
    if (a[i] + a[i + 1] >= l) {
      left = i;
      break;
    }
  }
  if (left != -1) {
    cout << "Possible" << '\n';
    rep(i, 0, left) cout << i + 1 << '\n';
    rrep(i, left, n - 1) cout << i + 1 << '\n';
  } else
    cout << "Impossible" << '\n';
  return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long N;
	cin >> N;
	long long ans = 0;
	for(long long i=1;i<=N;i++){
		if(i % 3 > 0 && i % 5 > 0) ans+=i;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main(){
  int D;
  cin >> D;
  if(D == 25) cout << "Christmas" << endl;
  else if(D == 24) cout << "Christmas Eve" << endl;
  else if(D == 23) cout << "Christmas Eve Eve" << endl;  
  else cout << "Christmas Eve Eve Eve" << endl;  
}

Measured memory_bytes: 256
#import
#import math
#import numpy as np
#= int(input())
#= input()
K, S = map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
#= [list(map(int, input().split())) for _ in range(N)]
#= {i:[] for i in range(N)}

r = 0

for i in range(K + 1):
    for j in range(K + 1):
        z = S - (i + j)
        if z >= 0 and z <= K:
            r += 1

print(r)

Measured memory_bytes: 9108
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner inputs = new Scanner(System.in);
    int seconds = inputs.nextInt();
    int minutes = seconds / 60;
    seconds = seconds % 60;
    int hours = minutes / 60;
    minutes = minutes % 60;
    System.out.println(hours + ":" + minutes + ":" + seconds);
  }
}

Measured memory_bytes: 17356
<?php

	list( $n, $m ) = explode( ' ', trim( fgets( STDIN ) ) );
	$a = array();
	$b = array();
	for( $i=0; $i<$n; $i++ ) {
		array_push( $a, explode( ' ', trim( fgets( STDIN ) ) ) );
	}
	for( $i=0; $i<$m; $i++ ) {
		array_push( $b, trim( fgets( STDIN ) ) );
	}
	$c = array();
	for( $i=0; $i<$n; $i++ ) {
		$res = 0;
		for( $j=0; $j<$m; $j++ ) {
			$res += $a[$i][$j]*$b[$j];
		}
		array_push( $c, $res );
	}
	print implode( "\n", $c );
?>

Measured memory_bytes: 8388
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
}

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

using namespace std;

void Main() {
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int l, r;
        cin >> l >> r;
        ans += (r + 1) - l;
    }
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3572
#-----------------------------
#https://atcoder.jp/contests/agc008/submissions/15248942
import sys
 
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))
#-----------------------------
X = ini()

if 400 <= X <= 599:
    print(8)
elif 600 <= X <= 799:
    print(7)
elif 800 <= X <= 999:
    print(6)
elif 1000 <= X <= 1199:
    print(5)
elif 1200 <= X <= 1399:
    print(4)
elif 1400 <= X <= 1599:
    print(3)
elif 1600 <= X <= 1799:
    print(2)
elif 1800 <= X <= 1999:
    print(1)


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define IN freopen("perimetric_chapter_1_input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)

#define pb push_back
#define mp make_pair
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG printf("Hi\n")
#define i64 long long int
#define ui64 unsigned long long int
#define xx first
#define yy second
#define ln 17
#define off 2002

#define sq(x) ((x)*(x))

#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace __gnu_pbds;
using namespace std ;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<int,int> pii;

#define log 20
#define mod 1000000007LL
#define INF 1000000000000000000LL
#define maxn 300005

const long double eps = 1e-9 ;

class numberTheory{

public:
    numberTheory(){}

    pii extendedEuclid(i64 a, i64 b) { // returns x, y | ax + by = gcd(a,b)

        if(b == 0) return pii( a >= 0 ? 1 : -1 , 0LL);
        else {
            pii d = extendedEuclid(b, a % b);
            return pii(d.yy, d.xx - d.yy * (a / b));
        }

    }

    i64 modularInverse(i64 a, i64 n) {
        pair<i64,i64> ret = extendedEuclid(a, n);
        return ((ret.xx % n) + n) % n;
    }


    i64 bigMod(i64 a, i64 n , i64 m)
    {
        if(n==0) return 1 ;
        i64 ret = bigMod(a,n/2,m) ;
        ret = (ret*ret)%m ;
        if(n%2) ret = (ret*a)%m ;
        return ret ;
    }
};

const i64 N = 5000000 ;

i64 fact[N+5] , invFact[N+5] ;

i64 C(i64 n, i64 r)
{
    if( n<0 || r<0 || r>n ) return 0 ;
    i64 ret = (fact[n]*invFact[r])%mod ;
    return (ret*invFact[n-r])%mod ;
}

void preprocess()
{
    numberTheory nt ;

    fact[0] = 1 ;
    for(i64 x=1 ; x<=N ; x++) fact[x] = (fact[x-1]*x)%mod ;

    invFact[N] = nt.modularInverse(fact[N],mod) ;

    for(i64 x=N-1 ; x>=0 ; x--) invFact[x] = (invFact[x+1]*(x+1) )%mod ;
}


int dp[2005][2005] ;

int main()
{
    preprocess() ;

    int n , k ;

    scanf("%d %d",&n,&k) ;

    k-- ;

    if(k==0)
    {
        printf("1\n") ;
        return 0 ;
    }

    dp[0][0] = 1 ;

    for(int i=1 ; i<=n ; i++)
    {
        dp[i][0] = (1LL*i*((1LL*dp[i-1][0]*C( i*k - 1 , k-1 ))%mod))%mod ;
     //   dp[i][0] = ( dp[i][0] + dp )

        for(int j=1 ; j<=i ; j++)
        {
            dp[i][j] = (1LL*i*((1LL*dp[i-1][j]*C( i*k + j - 1 , k-1 ))%mod))%mod ;
            dp[i][j] = ( dp[i][j] + dp[i][j-1] )%mod ;
        }
    }

    printf("%d\n",dp[n][n]) ;

    return 0;
}


Measured memory_bytes: 95756
#include<bits/stdc++.h>
using namespace std;
long long q,h,s,d,n,mina,minb;
int main(){
	cin>>q>>h>>s>>d;
	cin>>n; 
	mina=min(q*4,h*2);
	mina=min(mina,s);
	minb=min(mina*2,d);
	cout<<n/2*minb+n%2*mina<<endl;	
}

Measured memory_bytes: 256
N = gets.to_i
val = 0
nega = 0
min = 1000000000
A = gets.split(' ').map { |item|
  item = item.to_i
  nega += 1 if item < 0
  min = item.abs if item.abs < min
  val += item.abs
}

puts val if nega % 2 == 0
puts val-min*2 if nega % 2 == 1


Measured memory_bytes: 8580
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

int main() {
    string s;
    ll result = 0;
    ll now = 0;
    std::cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if(s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C' ){
            now++;
            result = max(now,result);
        }else{
            now = 0;
        }
    }
    std::cout << result << std::endl;
}


Measured memory_bytes: 256
import fractions

def main29():
    data = input().split()
    nx = []
    for i in range(2):
        nx.append(int(data[i]))
    data2 = input().split()
    zahyo = []
    for i in range(nx[0]):
        kari = int(data2[i])
        kari = int(abs(nx[1]-kari))
        zahyo.append(kari)
    result = zahyo[0]
    if nx[0] == 1:
        print(zahyo[0])
        return
    for i in range(1,nx[0],1):
        result = fractions.gcd(result,zahyo[i])
    print(result)

if __name__ == "__main__":
    main29()

Measured memory_bytes: 16280
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
a=i2()
import heapq
q=a[:n]
rq=[-a[i] for i in range(2*n,3*n)[::-1]]
dd=sum(q)
rdd=sum(rq)
d=[dd]
rd=[rdd]

heapq.heapify(q)
heapq.heapify(rq)

for i in range(n,2*n):
 heapq.heappush(q, a[i])
 x=heapq.heappop(q)
 dd=dd+a[i]-x
 d.append(dd)
for i in range(n,2*n)[::-1]:
 heapq.heappush(rq, -a[i])
 x=heapq.heappop(rq)
 rdd=rdd-a[i]-x
 rd.append(rdd)
c=-float("inf")
for i in range(len(d)):
  c=max(c,d[i]+rd[len(rd)-1-i])
print(c)

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

#include <atcoder/all>
using namespace atcoder;
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = (ll)1e18;
const ll MOD = 1000000007;
int main() {
  int N, M;
  cin >> N >> M;
  dsu uf(N);
  REP(i, M) {
    int a, b;
    cin >> a >> b, a--, b--;
    uf.merge(a, b);
  }
  ll ans = 0;
  map<ll, ll> mp;
  REP(i, N) {
    if (mp[uf.leader(i)] == 0) ans++;
    mp[uf.leader(i)] += 1;
  }
  cout << ans - 1 << endl;
}

Measured memory_bytes: 8888
#include<stdio.h>

int main(void){
  int e[4]={};
  for(int i=0;i<4;i++){ scanf("%d",&e[i]); }

  for(int i=0;i<4;i++){
    for(int j=i+1;j<4;j++){
      if(e[i]>e[j]){
        int a=e[i];
        e[i]=e[j];
        e[j]=a;
      }
    }
  }

  if(e[0]==e[1] && e[2]==e[3]) printf("yes\n");
  else printf("no\n");
  return 0;
}



Measured memory_bytes: 2136
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    if(n == 1){
        if(a == b) cout << 1 << endl;
        else cout << 0 << endl;
    }
    else if(b < a) cout << 0 << endl;
    else cout << (n - 2) * (b - a) + 1 << endl;
}

Measured memory_bytes: 256
import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

while 1:
    m, f = map(int, readline().split())
    if m == 0 and f == 0:
        break
    ans = 0
    A = [(i, j, k) for i, j, k in list(itertools.combinations(range(1, m + 1), 3)) if i + j + k == f]
    print(len(A))



Measured memory_bytes: 19716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define all(x) x.begin(),x.end()
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL);
#define N 105
bool b[N];
int main(){
	FIO;
	int n,k; cin >> n >> k;
    for(int i = 0 ; i < k ; i++){
        int d; cin >> d;
        for(int j = 0 ;  j < d ; j++){
            int x; cin >> x;
            b[x] = 1;
        }
    }
    int ans = 0;
    for(int i = 1 ; i <= n ; i++) ans += (b[i]==0);
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <random>

int main() {
	int a, b; std::cin >> a >> b;
	std::cout << (b + a - 3) / (a - 1) << std::endl;
}


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

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var buymax = int.Parse(line[1]);
            if (n == 0 && buymax == 0) break;
            string[] line2 = Console.ReadLine().Trim().Split(' ');
            var items = Array.ConvertAll(line2, int.Parse).Where(x=>x<buymax).OrderBy(x => x).ToArray();
            var icount = items.Count();
            if (icount < 2)   { Console.WriteLine("NONE");    continue;}
            var wanttobuy = 0;
            for (int i = 0; i < icount-1; i++)
                for (int j = i+1; j < icount; j++)
                {
                    if (items[i] + items[j] > buymax) break;
                    if (items[i] + items[j] > wanttobuy) wanttobuy = items[i] + items[j];
                }
            if (wanttobuy ==0) Console.WriteLine("NONE");
            else   Console.WriteLine(wanttobuy);
        }
    }
}

Measured memory_bytes: 10596
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
typedef long double ld;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int main(){
  string s; cin>>s;
  map<char, int> ma;
  int n=s.size();
  int a=0, b=0, c=0;
  rep(i,0,n){
    if(s[i]=='a') a++;
    else if(s[i]=='b') b++;
    else c++;
  }
  if(min(a,min(b,c))+1>=max(a,max(b,c))){
    cout << "YES" << endl;
  }else{
    cout <<"NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3005;
const int Mod=1e9+7;
const int pw=(Mod+1)>>1;
int n,q,now,inv,a[N];
int dp[N][N],f[N][N];
int s[N],t[N];
inline int read(){
	int x=0,w=1;
	char ch=0;
	while (ch<'0' || ch>'9'){
		ch=getchar();
		if (ch=='-') w=-1;	
	}
	while (ch<='9' && ch>='0'){
		x=(x<<1)+(x<<3)+ch-'0';
		ch=getchar();
	}
	return x*w;
}
inline int Pow(int x,int y){
	int res=1;
	while (y){
		if (y&1) res=1ll*res*x%Mod;
		x=1ll*x*x%Mod;
		y>>=1;
	}
	return res;
}
inline void ad(int &x,int y){
	x+=y;
	if (x>=Mod) x-=Mod;
}
int main(){
	//freopen("d.in","r",stdin);
	n=read(),q=read();
	for (int i=1;i<=n;++i) a[i]=read();
	for (int i=1;i<=q;++i)
		s[i]=read(),t[i]=read();
	for (int i=1;i<=n;++i)
		for (int j=1;j<=n;++j)
			if (a[i]<a[j]) dp[i][j]=1;
	now=1,inv=1;
	for (int i=1;i<=q;++i){
		f[t[i]][s[i]]=f[s[i]][t[i]]=(1ll*now*(dp[s[i]][t[i]]+dp[t[i]][s[i]]))%Mod;
		for (int j=1;j<=n;++j){
			if (j==t[i] || j==s[i]) continue;
			f[t[i]][j]=(1ll*now*(dp[s[i]][j]+dp[t[i]][j]))%Mod;
			f[j][t[i]]=(1ll*now*(dp[j][s[i]]+dp[j][t[i]]))%Mod;
		}
		for (int j=1;j<=n;++j){
			if (j==s[i] || j==t[i]) continue;
			f[s[i]][j]=(1ll*now*(dp[t[i]][j]+dp[s[i]][j]))%Mod;
			f[j][s[i]]=(1ll*now*(dp[j][t[i]]+dp[j][s[i]]))%Mod;
		}
		now=2ll*now%Mod;
		inv=1ll*inv*pw%Mod;
		for (int j=1;j<=n;++j){
			dp[j][s[i]]=1ll*inv*f[j][s[i]]%Mod;
			dp[j][t[i]]=1ll*inv*f[j][t[i]]%Mod;
			dp[s[i]][j]=1ll*inv*f[s[i]][j]%Mod;
			dp[t[i]][j]=1ll*inv*f[t[i]][j]%Mod;
		}
		for (int j=1;j<=n;++j)
			f[s[i]][j]=f[j][s[i]]=f[j][t[i]]=f[t[i]][j]=0;
	}
	int Ans=0;
	for (int i=1;i<=n;++i)
		for (int j=1;j<i;++j){
			ad(Ans,1ll*now*dp[i][j]%Mod);
			//printf("%d %d %lld\n",i,j,1ll*now*dp[i][j]%Mod);	
		}	
	printf("%d\n",Ans);
	return 0;
}

Measured memory_bytes: 70912