akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int dp[10001];

struct M {
	int v;
	int c;
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int h, n; cin >> h >> n;

	vector<M> ms(n);
	FOR_LT(i, 0, n) {
		cin >> ms[i].v >> ms[i].c;
	}

	FOR_LE(i, 0, h) {
		dp[i] = INT_MAX;
	}
	dp[h] = 0;

	FOR_DW(i, h, 1) {
		if (dp[i] == INT_MAX) continue;

		FOR_LT(j, 0, n) {
			int v = max(i - ms[j].v, 0);
			dp[v] = min(dp[v], dp[i] + ms[j].c);
		}
	}

	cout << dp[0] << endl;

	return 0;
}

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

int main (){
    int n,m,c;cin>>n>>m>>c;
	vector<int>vec;
	for(int i=0;i<m;i++){
		int x;cin>>x;
		vec.push_back(x);
	}
	int ans=0;
	for(int i=0;i<n;i++){
		int tmp=c;
		for(int j=0;j<m;j++){
			int x;cin>>x;
			tmp+=x*vec[j];
		}
		ans+=tmp>0;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
N = int(input())
xy = [list(map(int, input().split())) for _ in range(N)]
def nasu(a, b, c):
  A = a[0] ** 2 - b[0] ** 2 + a[1] ** 2 - b[1] ** 2
  B = b[0] ** 2 - c[0] ** 2 + b[1] ** 2 - c[1] ** 2
  x = [2 * (b[0] - a[0]), 2 * (c[0] - b[0])]
  y = [2 * (b[1] - a[1]), 2 * (c[1] - b[1])]
  k = x[1] * y[0] - x[0] * y[1]
  if k == 0:
    return 10 ** 10
  Cx = -(y[0] * B - y[1] * A) / k
  Cy = (x[0] * B - x[1] * A) / k
  return honyamorake(Cx, Cy)

def honya(x, y, Cx, Cy):
  return ((x - Cx) ** 2 + (y - Cy) ** 2) ** (1 / 2)

def honyaraka(a, b):
  Cx = (a[0] + b[0]) / 2
  Cy = (a[1] + b[1]) / 2
  return honyamorake(Cx, Cy)

def honyamorake(Cx, Cy):
  r = honya(xy[0][0], xy[0][1], Cx, Cy)
  for i in range(1, N):
    r = max(r, honya(xy[i][0], xy[i][1], Cx, Cy))
  return r

ans = 10 ** 10
for i in range(N - 2):
  for j in range(i + 1, N - 1):
    for k in range(j + 1, N):
      ans = min(ans, nasu(xy[i], xy[j], xy[k]))
for i in range(N - 1):
  for j in range(i + 1, N):
    ans = min(ans, honyaraka(xy[i], xy[j]))

print(ans)


Measured memory_bytes: 51800
#include<bits/stdc++.h>
using namespace std;
const long long N = 50000, mod = 1e9 + 7;
long long power(long long a, long long p){
    long long res = 1ll;
    while(p > 0){
        if(p % 2 == 1) res = (res * a) % mod;
        p /= 2;
        a = (a * a) % mod;
    }
    return res;
}
int main(){
    long long n;
    cin >> n;
    vector<long long> fact(N);
    fact[0] = 1ll;
    for(long long i = 1; i < N; i++){
        fact[i] = (fact[i - 1] * i) % mod;
    }
    long long m = n;
    long long ans = 0;
    for(long long i = 1; i <= n; i++){
        m -= 3;
        if(m >= 0){
            long long ans1 = fact[m + i - 1];
            ans1 = (ans1 * power(fact[i - 1], mod - 2)) % mod;
            ans1 = (ans1 * power(fact[m], mod - 2)) % mod;
            ans += ans1;
            ans %= mod;
            //cout << ans1 << endl;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3780
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn binary_search<T: Ord>(v: &Vec<T>, x: T) -> usize {
    let mut ok: isize = -1;
    let mut ng: isize = v.len() as isize;
    while ng - ok > 1 {
        let m = (ok + ng) / 2;
        if v[m as usize] >= x {
            ok = m;
        } else {
            ng = m;
        }
    }
    ng as usize
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (n, M): (usize, usize) = parse!(it, 2);
    let mut a: Vec<usize> = parse!(it, n);
    a.sort();
    a.reverse();
    let b = a
        .iter()
        .scan(0, |s, &x| {
            *s += x;
            Some(*s)
        })
        .collect::<Vec<_>>();
    let p = |i: usize, x: usize| binary_search(&a, if x > a[i] { x - a[i] } else { 0 });
    let mut ok = 0usize;
    let mut ng = std::usize::MAX / 10;
    while ng - ok > 1 {
        let m = (ok + ng) / 2;
        let mut s = 0;
        for i in 0..n {
            let pi = p(i, m);
            s += pi;
        }
        if s >= M {
            ok = m;
        } else {
            ng = m;
        }
    }

    let mut s = 0;
    let mut ret = 0;
    for i in 0..n {
        let pi = p(i, ok);
        s += pi;
        ret += if pi > 0 { b[pi - 1] } else { 0 } + pi * a[i];
    }
    ret -= (s - M) * ok;
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        5 3
10 14 19 34 33
        ";
        solve(s);
    }
}


Measured memory_bytes: 8444
from functools import reduce
import operator as op

n = int(input().split(' ')[0])
ds_str = input().split(' ')
ds = set(map(int, ds_str))

for m in range(n, 100000):
    mlist = map(int, list(str(m)))
    if reduce(op.or_, map(lambda x:x in ds, mlist)):
        continue
    else:
        print(m)
        break


Measured memory_bytes: 3700
s = list(input())
n = len(s)
ans = True

for i in range((n-1)//2):
    head = i
    tail = ((n-3)//2) - i

    
    if s[head] != s[tail]:
        ans = False
        
    head2 = i + (n+1)//2
    tail2 = - i + n - 1
    if s[head2] != s[tail2]:
        ans = False
        
    if s[head] != s[tail2] or s[tail] != s[head2]:
        ans = False
        
    if ans == False:
        break
    
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>

using namespace std;

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

    vector<char> characters(s.begin(), s.end());
    char prev;
    for (const char& c : characters) {
        if (c == prev) {
            cout << "Bad" << endl;
            return 0;
        }

        prev = c;
    }


    cout << "Good" << endl;

    return 0;
}

Measured memory_bytes: 888
import java.util.Scanner;
import java.util.Arrays;
public class Main
{
	public static void main(String args[])
	{
		Scanner input = new Scanner(System.in);
		int [] array = new int[10];
        for(int i = 0 ; i < array.length ; i++) {
            array[i] = input.nextInt();
        }
        Arrays.sort( array );
        for ( int i = 9 ; i > 6 ; i-- ) {
            System.out.println(array[i]);
        }
	}
}

Measured memory_bytes: 26220
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n,k;
  cin>>n>>k;
  vector<ll> v;
  for(int i=0;i<n;i++){
    ll h;
    cin>>h;
    v.push_back(h);
  }

  sort(v.begin(),v.end());
  ll ans=1e10;
  for(int i=k-1;i<n;i++){
    ll tmp=v[i]-v[i-k+1];
    ans=min(ans,tmp);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1400
N = int(input())
A = [int(x) for x in input().split()]
a = 0
for i, x in enumerate(A):
    if (i % 2 == 0):
        a += x
    else:
        a -= x
for x in A:
    print(int(a), end=" ")
    a = x*2 - a
print("")

Measured memory_bytes: 14092
#include<iostream>
#include<list>
#include<vector>
#include<string>
#include<cmath>

using namespace std;

int main(){
  	int W, H, N;
    cin >> W;
    cin >> H;
    cin >> N;
    int x[N], y[N], a[N] = {};
    for (int i = 0; i < N; i++){
      cin >> x[i];
      cin >> y[i];
      cin >> a[i];
    }
    
    bool rect[W][H];
    for (int i = 0; i < W; i++){
      for (int j = 0; j < H; j++){
        rect[i][j] = true;
      }
    }
  
  	for (int n = 0; n < N; n++){
      if (a[n] == 1){
        for (int i = 0; i < x[n]; i++){
          for (int j = 0; j < H; j++){
            rect[i][j] = false;
          }
        }
      }
      else if (a[n] == 2){
        for (int i = x[n]; i < W; i++){
          for (int j = 0; j < H; j++){
            rect[i][j] = false;
          }
        }
      }
      else if (a[n] == 3){
        for (int i = 0; i < W; i++){
          for (int j = 0; j < y[n]; j++){
            rect[i][j] = false;
          }
        }
      }
      else if (a[n] == 4){
        for (int i = 0; i < W; i++){
          for (int j = y[n]; j < H; j++){
            rect[i][j] = false;
          }
        }
      }
	}
   
    int area = 0;
    for (int i = 0; i < W; i++){
      for (int j = 0; j < H; j++){
        if (rect[i][j]){
          area++;
        }
      }
    }

    cout << area <<endl;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

ll opt=0;
vector<vector<ll>>g;
vector<ll>cnt;
vector<bool>ch;
void dfs(ll v,ll p=-1){
    for(auto u:g[v]){
        if(u==p)continue;
        if(ch[u])continue;
        ch[u]=true;
        dfs(u,v);
    }
}

int main(){
    ll ans=0;
    ll n,m;cin >>n>>m;
    g.resize(n);
    cnt.assign(n,0);
    ch.assign(n,false);
    for (int i = 0; i < m; ++i) {
        ll x,y,z;cin >>x>>y>>z;
        x--;y--;
        cnt[x]++;
        cnt[y]++;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for (int i = 0; i < n; ++i) {
        if(ch[i])continue;
        ans++;
        dfs(i);
//        cout <<ans <<endl;
//        cout <<opt<<endl;
    }
    cout <<ans <<endl;
    return 0;
}



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

const int N = 2e5 + 100;

ll h[N], dp[N];

int main() {
    ios::sync_with_stdio(false);
    int n;
    ll c;
    cin >> n >> c;
    for (int i=0; i<n; i++) {
        cin >> h[i];
    }
    auto cost = [&](int i, int j) -> ll {
        ll d = h[j] - h[i];
        return dp[j] + d*d + c;
    };
    auto better_at = [&](int i, int j) -> int {
        int lo = 0, hi = i;
        while (lo < hi) {
            int mid = (lo + hi) / 2;
            if (cost(mid, i) < cost(mid, j)) {
                lo = mid + 1;
            }
            else {
                hi = mid;
            }
        }
        return lo - 1;
    };
    deque<int> s;
    s.push_back(n-1);
    for (int i=n-2; i>=0; i--) {
        while (s.size() >= 2 && better_at(s[1], s[0]) >= i) {
            s.pop_front();
        }
        dp[i] = cost(i, s[0]);
        while (s.size() >= 2) {
            int ss = s.size();
            int old = better_at(s[ss-1], s[ss-2]);
            int cur = better_at(i, s[ss-1]);
            if (cur < old) {
                s.push_back(i);
                break;
            }
            s.pop_back();
        }
        if (s.size() == 1) {
            s.push_back(i);
        }
    }
    cout << dp[0] << '\n';
}


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

string s;

int main() {
  cin >> s;
  string t="AKIHABARA";
  rep(i,9){
    if(s[i]!=t[i]) 
    s.insert(i,"A");
  }
  cout << (s==t?"YES":"NO") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n;
ll t[110];

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

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

int main() {
	cin >> n;
  	for (int i = 0; i < n; i++) cin >> t[i];
  	
  	ll ans = 1;
  	for (int i = 0; i < n; i++) ans = lcm(ans, t[i]);
  	cout << ans << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()      //昇順
#define RALL(obj) (obj).rbegin(), (obj).rend()   //降順
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    int a, b;
    cin >> a >> b;
    int ans = 0;
    if(a > b){
        ans += a;
        a--;
    } else{
        ans += b;
        b--;
    }
    print(ans + max(a, b));
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 *
 * @author k16075kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] x = new int[3];
        x[0] = sc.nextInt();
        x[1] = sc.nextInt();
        x[2] = sc.nextInt();
        java.util.Arrays.sort(x);
        System.out.println(x[0] + " " + x[1] + " " + x[2]);
    }

}



Measured memory_bytes: 26376
n,h = gets.split.map(&:to_i)
a = []
b = []
n.times do
  ai,bi = gets.split.map(&:to_i)
  a << ai
  b << bi
end
a.sort!
b.sort!
max_a = a[-1]
#puts max_a
k = -1
ans = 0
while k >= -n && b[k] > max_a && h > 0
  h -= b[k]
  k -= 1
  ans += 1
end
if h > 0
  ans += (h/max_a.to_f).ceil
end
puts ans


Measured memory_bytes: 4620
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
--import Data.Array.Unboxed
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
-- templete

f :: Int -> Int -> [String] -> Int
f h w a = runST $ do
    arr <- newListArray ((1,1),(h,w)) $ concat a :: ST s (STArray s (Int,Int) Char)
    res <- newSTRef 0
    forM_ [(y,x) | y <- [1..h], x <- [1..w]] $ \p -> do
        c <- readArray arr p
        when (c/=' ') $ do
            modifySTRef res (+1)
            fill arr c p
    readSTRef res
  where
    fill :: STArray s (Int,Int) Char -> Char -> (Int,Int) -> ST s ()
    fill arr c p@(y,x) = do
      bounds <- getBounds arr
      when (inRange bounds p) $ do
          d <- readArray arr p
          when (c==d) $ do
              writeArray arr p ' '
              fill arr c (y-1,x)
              fill arr c (y+1,x)
              fill arr c (y,x-1)
              fill arr c (y,x+1)

main = do
    [h,w] <- getInts
    unless (h==0 && w==0) $ do
        ds <- replicateM h getLine
        print $ f h w ds
        main


Measured memory_bytes: 6616
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e5+10;
string s[maxn],pre;
int n,ans;
inline bool cmp(char x[],char y[])
{
	return strcmp(x,y)<0;
}
signed main()
{
	scanf("%lld",&n);
	for(register int i=1;i<=n;i++)
	{
		cin>>s[i];
		sort(s[i].begin(),s[i].end());
	}
	sort(s+1,s+n+1);
	int cnt=0;
	for(register int i=1;i<=n;i++)
		if(pre==s[i])
			cnt++;
		else
		{
			ans+=cnt*(cnt-1)/2;
			cnt=1;
			pre=s[i];
		}
	ans+=cnt*(cnt-1)/2;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 7296
s = str(input()) + 'R'
rcnt = 0
lcnt = 0
flag = 0
ans = [0]*(len(s)-1)
rpos = 0
lpos = 0

for i in range(len(s)):
    if s[i] == 'R':
        if flag == 1:
            if rcnt % 2 == 0:
                ans[rpos] += rcnt//2
                ans[lpos] += rcnt//2
            else:
                ans[rpos] += rcnt//2 + 1
                ans[lpos] += rcnt//2
            if lcnt % 2 == 0:
                ans[rpos] += lcnt//2
                ans[lpos] += lcnt//2
            else:
                ans[rpos] += lcnt//2
                ans[lpos] += lcnt//2 + 1
            rcnt = 0
            lcnt = 0
        flag = 0
        rcnt += 1
        rpos = i
    elif s[i] == 'L':
        if flag == 0:
            lpos = i
        flag = 1
        lcnt += 1
print(*ans)
        

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
int n,x;
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(x);
	if (n>=10) printf("%d\n",x);
	else printf("%d\n",x+100*(10-n));
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 1000
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int c[N][N],f[N][N],s[N][N];
int main()
{	int n,K,mod; cin>>n>>K>>mod; n++;
	for(rint i=0,j;i<=n;i++)
	for(c[i][0]=1,j=1;j<=i;j++) c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	for(rint i=0;i<=K;i++) f[1][i]=1,s[1][i]=K-i+1;
	for(rint i=2;i<=n;i++)
	{	for(rint j=0;j<=K;j++)
		for(rint k=1;k<i;k++) f[i][j]=(f[i][j]+(ll)c[i-2][k-1]*s[k][j+1]%mod*f[i-k][j]%mod)%mod;
		for(rint j=K;j>=0;j--) s[i][j]=(s[i][j+1]+f[i][j])%mod;
	}
	cout<<f[n][0];
	return 0;
}


Measured memory_bytes: 9600
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

struct link{
    char name[10];
    int time;
    struct link *next;
};

int main (void)
{
    int n,q;
    int now=0;
    int i;
    scanf("%d %d",&n,&q);

    struct link *Q[n];
    
    for(i=0;i<n;i++)
    {
        Q[i]=(struct link *)malloc(sizeof(struct link));
        if(Q[i]==NULL)
        {
            printf("error\n");
            exit(1);
        }
    }

    struct link *END;
    END=(struct link *)malloc(sizeof(struct link));
    if(END==NULL)
    {
        printf("error\n");
        exit(1);
    }
    END->time=0;

    for(i=0;i<n;i++)
    {
        char a[10];
        int t;
        struct link *q;
        scanf("%s %d",a,&t);
        strncpy(Q[i]->name,a,10);
        Q[i]->time=t;
        if(i==n-1)
        {
            Q[i]->next=END;
        }else
        {
            Q[i]->next=Q[i+1];
        }
    }

    struct link *que;
    que=(struct link *)malloc(sizeof(struct link));
    if(que==NULL)
    {
        printf("error\n");
        exit(1);
    }
    struct link *btm;
    btm=(struct link *)malloc(sizeof(struct link));
    if(btm==NULL)
    {
        printf("error\n");
        exit(1);
    }

    que=Q[0];
    btm=Q[n-1];

    while(1)
    {
        //printf("que(%s %d) next(%s %d) now %d\n",que->name,que->time,que->next->name,que->next->time,now);
        if((que->time)>q)
        {
            //printf("big\n");
            now+=q;
            que->time-=q;
            btm->next=que;
            //printf("btm(%s %d) next(%s %d) now %d\n",btm->name,btm->time,btm->next->name,btm->next->time,now);            
            //printf("now que(%s %d) next(%s %d) now %d\n",que->name,que->time,que->next->name,que->next->time,now);
            
            btm=que;
            que=que->next; 
            btm->next=END;
            //printf("btm(%s %d) now %d\n",btm->name,btm->time,now);
            //printf("now que(%s %d) now %d\n",que->name,que->time,now);
        }else
        if((que->time)<=q)
        {
            //printf("small\n");
            now+=que->time;
            printf("%s %d\n",que->name,now);
            if(que->next==END)
            {
                break;
            }else
            {
                que=que->next; 
            }
        }
        //printf("que(%s %d)\n",que->name,que->time);
    }
}




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

using namespace std;

int main(){
  int N; cin >> N;
  vector<int> V(N);
  for (int i = 0; i < N; i++){
    cin >> V[i];
  }
  vector<int> C(N);
  for (int i = 0; i < N; i++){
    cin >> C[i];
  }
  
  int ans = 0;
  for ( int i = 0; i < N; i++){
    if ( V[i] > C[i] ){
      ans += V[i] - C[i];
    }
  }
  cout << ans << endl;
}

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  std::vector<std::string> s(3);
  std::cin >> s;
  int i = 0;
  while (true) {
    auto j = s[i].front() - 'a';
    if (s[i].empty()) {
      std::cout << static_cast<char>('A' + i) << std::endl;
      return 0;
    }
    s[i].erase(0, 1);
    i = j;
  }
  return 0;
}


Measured memory_bytes: 256
<?php
$n = intval(fgets(STDIN));
$a = array_map("intval", explode(" ", trim(fgets(STDIN))));
$b = array_map("intval", explode(" ", trim(fgets(STDIN))));
$c = array_map("intval", explode(" ", trim(fgets(STDIN))));
$s = array_sum($b);
for($i = 0; $i < $n-1; $i++){
  if($a[$i]+1 == $a[$i+1])$s+=$c[$a[$i]-1];
}
echo $s;


Measured memory_bytes: 4856
#include "bits/stdc++.h"
using namespace std;

int main(){
	long long int n;
	cin>>n;
	vector<long long int> a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	
	long long int p=0;
	map<long long int,long long int> mp;
	mp[0]++;
	for(int i=0;i<n;i++){
		p+=a[i];
		mp[p]++;
	}
	
	long long int ans=0;
	
	for(auto itr = mp.begin();itr != mp.end();++itr){
		//cout<<itr->second<<endl;
		if(itr->second>1){
			long long int tmp=1;
			tmp*=itr->second;
			tmp*=itr->second-1;
			ans+=tmp/2;
		}
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 14336
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll a,b,t,n;
    cin>>a>>b>>t;
    n=t/a;
    cout<<n*b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int m, f, r, i, all;
  char sei;

  for(i = 0; i < 1; i--){

    scanf("%d%d%d", &m, &f, &r);

    all = m + f;

    if(m + f + r == -3) break;

    if(all >= 80){
      sei = 'A';
    } else if(m == -1 || f == -1){
      sei = 'F';
    } else if(all < 80 && 65 <= all){
      sei = 'B';
  } else if((all < 65 && 50 <= all) || r >= 50){
      sei = 'C';
    } else if((all < 50 && 30 <= all) && r < 50){
      sei = 'D';
    } else if(all < 30) sei = 'F';
     
     printf("%c\n", sei);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main() {
    bool ans = true;
    
    int N;
    cin >> N;
    vector<string> W(N);
    for(int i = 0; i < N; i++) cin >> W.at(i);
    
    //条件1
    for(int i = 0; i < N-1; i++) {
        for(int j = i + 1; j < N; j++) {
            if(W.at(j)==W.at(i)) ans = false;
        }
    }
    
    //条件2
    for(int i = 0; i < N-1; i++) {
        if(W.at(i).at(W.at(i).size()-1)!=W.at(i+1).at(0)) ans = false;
    }
    
    cout << (ans ? "Yes" : "No") << endl;
    
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int a[5000];
int main(){
int n;
while(true){
cin>>n;
if(n==0)
break;
long long best=-1000000000;
for(int i=0;i<n;i++)
 cin>>a[i];
 
for(int start=0;start<n;start++){
 long long count=0;
 for(int len=start;len<n;len++){
  count+=a[len];
  best=max(best,count);
 }
}

cout<<best<<endl;
}
return 0;   
}

Measured memory_bytes: 1168
import math
while True:
    try:
        x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
    except:
        break
    x = [x1, x2, x3, x1]
    y = [y1, y2, y3, y1]
    x = list(map(lambda i: i - xp, x))
    y = list(map(lambda i: i - yp, y))
    s = lambda a1, a2, b1, b2: abs(a1 * b2 - a2 * b1)
    S3 = sum(s(x[i], y[i], x[i + 1], y[i + 1]) for i in range(3))
    S = s(x[1] - x[0], y[1] - y[0], x[2] - x[0], y[2] - y[0])
    if S3 == S:
        print('YES')
    else:
        print('NO')

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

const long long INF = 1LL << 60;

int main() {
  int a,b,c,x,y,res=10000000000;
  cin >> a >> b >> c >> x >> y;
  
  rep(i,100001){
    res=min(res,i*c*2+max(0,x-i)*a+max(0,y-i)*b);
  }
  
  cout << res << endl;
}

Measured memory_bytes: 256
var
	N,K,i,u,v:Longint;
begin
	read(N,K);
	if (N-1)*(N-2)<K*2 then begin
		writeln(-1);
		exit;
	end;
	K:=(N-1)*(N-2)div 2-K;
	writeln(K+N-1);
	for i:=2 to N do begin
		write('1 ');
		writeln(i);
	end;
	u:=2;
	v:=3;
	for i:=1 to K do begin
		write(u);
		write(' ');
		writeln(v);
		inc(v);
		if v>N then begin
			inc(u);
			v:=u+1;
		end;
	end;
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int m1,m2,d1,d2;
  cin >> m1 >> d1 >> m2 >> d2;
  
  if(m1==m2)cout << 0 << endl;
  else cout << 1 << endl;
  
}



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

 using namespace std;

 int main() {
   string s;
   int i, digit;

   cin >> s;

   string ans;

   digit = 0;

   ans = "XXXXXXXXXX";
   for (i = 0; i < s.length(); i++) {
     if (s.at(i) != 'B') {
       ans.at(digit) = s.at(i);
       digit++;
     }
     else {
       if (digit != 0) digit--;
     }
   }

   for (i = 0; i < digit; i++) cout << ans.at(i);

   cout << endl;
 }


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

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

#define all(x)          x.begin(), x.end()
#define kill(x)         return cout << x << endl, 0
#define X               first
#define Y               second
#define sep             ' '
#define endl            '\n'

ll pw(ll a, ll b, ll mod) {
    if (!b)    return 1;
    if (b & 1) return a * pw(a * a % mod, b / 2, mod) % mod;
    return pw(a * a % mod, b / 2, mod) % mod;
}

const ll N    = 310;
const ll MOD  = 1e9 + 7;
const ll INF  = 1e18;

int n, k, dp[N][N][N];
string s;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> s >> k;
    n = s.size();
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= k; j++) {
            dp[i][i][j] = 1;
        }
    }
    for (int len = 2; len <= n; len++) {
        for (int l = 1; l + len - 1 <= n; l++) {
            int r = l + len - 1, d = s[l - 1] != s[r - 1];
            for (int j = 0; j <= k; j++) {
                dp[l][r][j] = max(dp[l + 1][r][j], dp[l][r - 1][j]);
                if (j - d >= 0)
                    dp[l][r][j] = max(dp[l][r][j], dp[l + 1][r - 1][j - d] + 2);
            }
        }
    }
    cout << dp[1][n][k] << endl;
    return 0;
}


Measured memory_bytes: 59356
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	ll h, w; cin >> h >> w;
	ll ans = 0;
	if( h == 1 || w == 1 ) ans = 1;
	else if( h%2 == 0 ) ans = h/2 * w; 
	else ans = h/2*w + (w+1)/2;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n,d;
	cin>>n>>d;
	ll x[n];
	ll y[n];
	int c=0;
	for(int i=0;i<n;i++)
	{
		cin>>x[i]>>y[i];
		if(sqrt(x[i]*x[i]+y[i]*y[i])<=d)
			c++;
	}
	cout<<c<<"\n";
}

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

public class Main {
    long a, b, x;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        a = sc.nextLong();
        b = sc.nextLong();
        x = sc.nextLong();
        solve();
    }

    void solve() {
        long removedNum = (a % x == 0) ? a / x - 1 : a / x;
        System.out.println(b / x - removedNum);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            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());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

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

int main(){
    double R;
    cin>>R;
    double ans=2.0*R*3.141592;
    cout<< std::setprecision(3) <<ans<<endl;
    return 0;
}

Measured memory_bytes: 3784
#include<cstdio>
#define mo 1000000007
int max(int a,int b){return a>b?a:b;}
bool cant[305][305][305];int n,m,f[305][305][305],ans;
void add(int&a,int b){a+=b;if(a>=mo)a-=mo;}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1,l,r,t;i<=m;i++)
	{
		scanf("%d%d%d",&l,&r,&t);
		for(int j=l+1;j<=r;j++)
		 if(t==1)
		 {
		 	for(int y=l;y<j;y++)
		 	 for(int x=0;x<y;x++)
			  cant[x][y][j]=1; 
		 }else if(t==2)
		 {
		 	for(int y=l+1;y<j;y++)
		 	 for(int x=l;x<y;x++)
		 	  cant[x][y][j]=1;
		 }
		if(t==2)
		{
			for(int y=0;y<l;y++)
			 for(int x=0;x<=max(y-1,0);x++)
			  cant[x][y][r]=1;
		}else
		if(t==3)
		{
			for(int y=0;y<l;y++)
			 for(int x=0;x<=max(y-1,0);x++)
			  cant[x][y][r]=1;
			for(int y=l;y<r;y++)
			 for(int x=0;x<l;x++)
			  cant[x][y][r]=1;
		}
	}f[0][0][0]=1;
	for(int k=0;k<n;k++)
	 for(int j=0;j<=max(k-1,0);j++)
	  for(int i=0;i<=max(j-1,0);i++)
	   if(!cant[i][j][k]&&f[i][j][k])
	    add(f[i][j][k+1],f[i][j][k]),
	    add(f[j][k][k+1],f[i][j][k]),
	    add(f[i][k][k+1],f[i][j][k]);
	for(int j=0;j<=max(n-1,0);j++)
	 for(int i=0;i<=max(j-1,0);i++)
	  if(!cant[i][j][n]&&f[i][j][n])add(ans,f[i][j][n]);
	printf("%d\n",ans);
}

Measured memory_bytes: 137344
#include<bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define lli long long int
#define f(i,a,b) for(i=a;i<b;i++)
#define ff first
#define sc second
#define pb push_back
#define full(v) v.begin(),v.end()
#define ms(a) memset(a,0,sizeof(a))
#define mod 1000000007
#define mod2 998244353
#define msb(b) memset(b,true,sizeof(b))
#define msf(b) memset(b,false,sizeof(b))
#define MAXN 100005
// bool prime[1000000]; // 10**6
// lli pri[100000],x=0;
/*void sieve()
{
  msb(prime);
  prime[0]=prime[1]=false;
  for(int p=2;p*p<=1000000;p++)
  {
    if(prime[p])
    {
      for(int i=p*2;i<=1000000;i+=p)
        prime[i]=false;
      // a[x++]=p;
    }
  }
} */

int main()
{
    fio;
    int t,n,i,m;
    cin >> n >> m;
    bool flag = false;
    f(i,0,n+1)
    {
        int j = n - i;
        if(2*i + 4*j == m)
        {
            flag = true;
            break;
        }
    }

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


Measured memory_bytes: 3524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,ans=0;
    cin>>n;
    while(n){
      ans+=n%10;
      n/=10;
    }
  if(ans==1){cout<<10;}
  else{cout<<ans;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll m=pow(2,n);
    ll a;
    ll ma=0;
    multiset<ll> ms;
    for(int i=0;i<m;i++){
        cin>>a;
        ma=max(ma,a);
        ms.insert(a);
    }
    vector<ll> q;
    queue<ll> s;
    multiset<ll>::iterator itr;
    itr=ms.lower_bound(ma);
    ms.erase(itr);
    q.push_back(ma);
    ll maki;
    /*itr=ms.begin();
    cout << ma<<endl;
    while(itr!=ms.end()){
        cout << *itr<<endl;
        itr++;
    }*/
    int niko;
    while(!ms.empty()){
        niko=q.size();
        for(int i=0;i<niko;i++){
            maki=q[i];
            //cout <<maki<<" ";
            itr=ms.lower_bound(maki);
            if(itr==ms.begin()){
                
                cout << "No"<<endl;
                return 0;
            }
            itr--;
            //cout <<*itr<<" ";
            s.push(*itr);
            ms.erase(itr);
            if(ms.empty()){
                cout << "Yes"<<endl;
                return 0;
            }
        }
        // << endl;
        while(!s.empty()) {
            q.pb(s.front());
            //cout << (s.front())<<" ";
            s.pop();
        }
        //cout << endl;
    }
    cout <<"Yes"<<endl;
    return 0;
}



Measured memory_bytes: 14072
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define vl vector<ll>
#define pll pair<ll,ll>
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i= 0;i < a;i++)
#define rep1(i,a) for(ll i= 1;i < a;i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define pb push_back
#define sz(v) v.size()
#define all(a) a.begin(), a.end()
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000005
#define MOD 1000000007
#define el "\n"
  
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll isPrime(ll n){if(n<=3) return 1;if(n%2==0||n%3==0) return 0;
for(ll j=5;j*j<=n;j+=6){if(n%j == 0||n%(j+2) == 0) return 0;}return 1;}
 
using namespace std;
void solve(){
   ll n;
   cin>>n;
   vl h(n);
   rep(i,n)cin>>h[i];
   ll dp[n+2];
   dp[0] = 0;
   dp[1] = abs(h[1]-h[0]);
   foi(i,2,n+1){
      dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
   }
   cout<<dp[n-1];

}
 
int main() {
   #ifndef ONLINE_JUDGE
      freopen("input.txt", "r" , stdin);
      freopen("output.txt", "w" , stdout);
   #endif
   ios::sync_with_stdio(0); 
   cin.tie(0); cout.tie(0);   
   ll t;
   // cin>>t;
   t = 1;
   ll tc=0;
   while(tc++<t){
      // cout<<"Case #"<<tc<<": ";
      solve();
   }
   cerr<<"Time taken : "<<(double)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
   return 0;
}

Measured memory_bytes: 4744
#!/usr/bin/python

import sys
import math 

#Input Functions
#===============

input = sys.stdin.readline

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

#===============

def run_test() :
    N = int(input())
    A = list(map(int,input(). split ()))
    if 0 in A:
        print(0)
        return
    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)

def main() :
	run_test()

if __name__ == '__main__' :
	main()


Measured memory_bytes: 22012
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        mut s: chars,
    }
    for i in 0..s.len() {
        match s[i] {
            'A' | 'C' | 'G' | 'T' => s[i] = 'A',
            _ => s[i] = 'B',
        }
    }
    let iter = s.split(|c| *c == 'B');
    let ans = iter.map(|x| x.len()).max().unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 4352
class Move
  attr_accessor :a, :b # move a to b
  def initialize(a,b)
    @a = a
    @b = b
    raise "bad ord" if a >= b
  end

  def intersect(other)
    c,d = other.a,other.b
    return nil if b < d
    other
  end
end

# a = Move.new(1,10)
# b = Move.new(5,12)
# c = Move.new(4,2)

# pp a.overwrap(b)
# pp a.intersect(b)
# pp a.exchange(b)
# pp a.overwrap(c)
# pp a.intersect(c)
# pp a.exchange(c)

class Problem
  attr_accessor :a, :b, :c, :d, :k, :n, :m, :h, :w, :s, :x, :y
  def initialize
    @n,@a,@b,@c,@d = gets.to_s.split.map{ |v| v.to_i }
    @s = gets.chomp
  end

  # 追い越しが無いなら、#が2個以上連続しなければよい
  # 追い越しがあるなら、上の条件に加えて、3つの連続した.が必要
  def solve
    if d < c # 追い越しあり
      !has_double(a,c) && !has_double(b,d) && triple_space(b-1,d+1)
    else
      !has_double(a,c) && !has_double(b,d)
    end
  end

  def substr(a,b)
    a -= 1
    b -= 1
    s[a..b]
  end

  def has_double(a,b)
    substr(a, b) =~ /##/
  end
  
  def triple_space(a,b)
    substr(a, b) =~ /\.\.\./   
  end

  def show(ans)
    puts ans ? "Yes" : "No"
  end
end

Problem.new.instance_eval do
  # pp s.index("##")
  # pp s.index("...")
  # pp s[64402,10]
  show(solve)
end

Measured memory_bytes: 14788
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	int a,b,c,d;
	a=b=c=d=0;
	for(int i=0;i<n;i++)
	{
		cin>>s;
		if(s=="AC")a++;
		else if(s=="WA")b++;
		else if(s=="TLE")c++;
		else d++;
	}
	cout<<"AC"<<" x "<<a<<endl;
		cout<<"WA"<<" x "<<b<<endl;
			cout<<"TLE"<<" x "<<c<<endl;
				cout<<"RE"<<" x "<<d<<endl;
	
	
 } 

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(ll i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
#define MOD 1000000007
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

  ll N,K; cin>>N>>K;
  vector<ll> A(N);
  rep(i,N){cin>>A[i]; --A[i];}

  ll next = 0;
  vector<bool> visit(N, false); visit[0] = true;
  while(1) {
    --K;
    next = A[next];
    if(visit[next])break;
    else visit[next] = true;
    
    if(K==0) {
      cout<<next+1<<endl;
      return 0;
    }
  }

  ll start = next;
  ll count = 0;
  while(1) {
    ++count;
    next = A[next];
    if(next==start)break;
  }

  K%=count;
  rep(i,K) {
    next = A[next];
  }
  cout<<next+1<<endl;

  return 0;
}

Measured memory_bytes: 4772
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cfenv>
using namespace std;
int main(){
    
    int n,k,ns,na=1;
    cin>>n>>k;
    ns=n/k;
    while(1){
        
        if(k==1){
            na=1;
            break;
        }
        
        if(ns>0){
            //cout<<"na"<<na<<endl;
            na++;
        }
        else{
            break;
        }
        ns=ns/k;
    }
    //cout<<"kotae"<<na<<endl;
    cout<<na<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define PB push_back
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define mod 100000000
// #define int ll

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n,k;cin >> n >> k;
	int ks = k;
	string s;cin >> s;
	int ans = 0;
	for(int i=0;i<n;i++) if(s[i]=='L') s[i]='0'; else s[i] = '1'; 
	for(int i=0;i<2;i++){
		k = ks;
		int h = 0;
		int st = 0;
		int pre = -1;
		while(st<n){
			int g = st;
			if(s[st]-'0'==(!i)){
				if(pre==(!i)) h++;
				else pre = !i;
				st++;
			}else{
				if(k){
					while(st<n&&s[st]-'0'==i) st++;
					h += st-g-1;
					if(pre==(!i)) h++;
					k--;
				}else{
					if(pre==s[st]-'0') h++;
					else pre = s[st]-'0';
					st++;
				}
			}	
		}
		ans = max(ans,h);
	}
	cout << ans << endl;
	
 	return 0;
}

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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<vector<long long>> mll;
typedef vector<pair<long long, long long>> vpl;
typedef pair<long long, long long> pll;
#define minimize(var, val) (var = min((val), var))
#define maximize(var, val) (var = max((val), var))
const long long MOD = 1e9 + 7;

struct Box {
    ll weight = 0, strength = 0, value = 0;
    friend bool operator<(Box a, Box b) {
        return (a.strength + a.weight) < (b.strength + b.weight);
    }
};

int main() {
    ll n;
    cin >> n;
    vector<Box> b(n);
    for (ll i = 0; i < n; i++)
        cin >> b[i].weight >> b[i].strength >> b[i].value;
    sort(b.begin(), b.end());
    mll dp(n + 1, vll(20001, 0));
    for (ll i = 0; i < n; ++i) {
        for (ll net_weight = 0; net_weight <= 20000; ++net_weight) {
            if (b[i].strength >= net_weight &&
                net_weight + b[i].weight <= 20000)
                maximize(dp[i + 1][net_weight + b[i].weight],
                         dp[i][net_weight] + b[i].value);
            maximize(dp[i + 1][net_weight], dp[i][net_weight]);
        }
    }
    cout << *max_element(dp[n].begin(), dp[n].end()) << endl;
}


Measured memory_bytes: 160640
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;
#define nl endl

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
bool mark[100005];vi prime;
void seive(ll N){for(int i=2;i<=N;i++){if(mark[i]==false){prime.pb(i);for(int j=i+i;j<N;j+=i)mark[j]=true;}}}
//freopen("input.txt", "r", stdin);

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll a,b;
    cin>>a>>b;
    a=a*3;
    a+=b;
    cout<<a/2<<endl;
    End;
}


Measured memory_bytes: 256