akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
#define mod 1000000007
//#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT{
    __INIT(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout<<fixed<<setprecision(15);
    }
}__init;


int main(){
    ll h,w,m;
    cin>>h>>w>>m;
    vector<pl> ngo;
    vl tate(h,0);
    vl yoko(w,0);
    ll tatemax = 0;
    ll yokomax = 0;
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        a--,b--;
        ngo.push_back({a,b});
        tate[a]++;
        yoko[b]++;
        tatemax = max(tatemax,tate[a]);
        yokomax = max(yokomax,yoko[b]);
    }
    vl tatems,yokoms;
    rep(i,h) if(tate[i] == tatemax) tatems.push_back(i);
    rep(i,w) if(yoko[i] == yokomax) yokoms.push_back(i);
    ll kosu = (ll)(tatems.size())*(ll)(yokoms.size());
    rep(i,m){
        if(binary_search(all(tatems),ngo[i].first) && binary_search(all(yokoms),ngo[i].second)){
            kosu--;
        }
    }
    if(kosu == 0){
        cout<<(tatemax+yokomax-1)<<endl;
    }
    else{
        cout<<(tatemax+yokomax)<<endl;
    }
    return 0;
}

Measured memory_bytes: 21452
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in sys.stdin.readline().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    H, W = li_input()
    h, w = li_input()

    S = H * W
    S -= h * W
    S -= w * (H - h)

    print(S)


main()


Measured memory_bytes: 4788
// https://atcoder.jp/contests/abc157/tasks/abc157_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    cout << DIV(N, 2) << endl;

    return 0;
}


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

int main(){
    int N; cin >> N;
    int C[N];
    for(int i = 0;i < N;i++){
        cin >> C[i];
    }

    int all = 0;

    for(int i = 0;i < N-1;i++){
        for(int j = i+1; j < N;j ++){
            all += C[i]*C[j];
        }
    }

    cout << all << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int keta(int n){
  int ans=0;
  while(n !=0){
    n /= 10;
    ans++;
  }
  return ans;
}


int main(){
  int a,b;
  cin >> a>>b;
  int k = keta(b);
  for(int i =0;i<k;i++){
    a *= 10;
  }
  for(int i=0;i<1000;i++){
    if(i*i == a+b){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" <<endl;
}

  

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

ll GCD(ll a, ll b) { if(b==0) return a; else return GCD(b, a%b); }
ll LCM(ll a, ll b) { return a/GCD(a,b)*b; }

class AFiveVariables {
public:
	void solve(std::istream& in, std::ostream& out) {
	    rep(i,5){
	        ll x;in>>x;
	        if(x==0) out<<i+1<<endl;
	    }


	}
};


int main() {
	AFiveVariables solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3136
N = input()
A = input().split(' ')
N = int(N)
ans = 'APPROVED'
for ii in range(N):
  Ai = A[ii]
  Ai = int(Ai)
  
  if Ai%2 == 0:
    if Ai%3 != 0 and Ai%5 !=0:
      ans = 'DENIED'


print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cctype>
int main(void){
  int turn,length;
  int taro_point=0,hana_point=0;
  std::string str_toro,str_hana;

  std::cin>>turn;

  for(int i=0;i<turn;i++){
    std::cin>> str_toro>>str_hana;
    length= str_toro.size()<str_hana.size()?str_hana.size():str_hana.size();
    for(int j=0;j<length;j++){
      if(std::isupper(str_toro[j])) str_toro[j]=std::tolower(str_toro[j]);
      if(std::isupper(str_hana[j])) str_hana[j]=std::tolower(str_hana[j]);
      int taro=str_toro[j]-'a';
      int hana=str_hana[j]-'a';

      if(taro>hana){
        taro_point+=3;
        break;
      }
      else if(hana>taro){
        hana_point+=3;
        break;
      }
      else if(j==length-1){
         if(str_toro.size()<str_hana.size()) hana_point+=3;
         else if( str_toro.size()>str_hana.size()) taro_point+=3;
         else {
           taro_point++;hana_point++;
         }
      }
    }
  }
  std::cout<<taro_point<<" "<<hana_point<<std::endl;
  return 0;

}



Measured memory_bytes: 3164
ans = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 8, 8, 11, 11, 11, 11, 14, 14, 32, 32, 35, 35, 35, 35, 42, 42, 42, 42, 49, 49, 49, 49, 49, 49, 75, 75, 86, 86, 86, 86, 86, 86, 123, 123, 131, 131, 131, 131, 148, 148, 153, 153, 170, 170, 170, 170, 170, 170, 227, 227, 227, 227, 227, 227, 250, 250, 323, 323, 324, 324, 324, 324, 354, 354, 354, 354, 384, 384, 384, 384, 384, 391, 491, 491, 529, 529, 529, 529, 529, 529, 543]
print(ans[int(input())])


Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).bigin(), (c).end())

typedef long long ll;

int main()
{
    int n, a[100010], ans;
    cin >> n;
    ans = 0;
    REP(i, n)
    cin >> a[i],
        ans += a[i];
    cout << ans - n << endl;

    return 0;
}

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

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

fn main() {
    let n: usize = read();
    println!("{}", n / 3);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
  cin >> n;
  vector<int> a(n),b(n),c(n);
  for(int i=0;i<n;++i)
    cin >> a[i] >> b[i] >> c[i];
  int dp[3][n];
  dp[0][0]=a[0];
  dp[1][0]=b[0];
  dp[2][0]=c[0];
  for(int i=1;i<n;++i)
  {
  	dp[0][i]=max(dp[1][i-1],dp[2][i-1])+a[i];
    dp[1][i]=max(dp[0][i-1],dp[2][i-1])+b[i];
    dp[2][i]=max(dp[0][i-1],dp[1][i-1])+c[i];
  }
  cout << max({dp[0][n-1],dp[1][n-1],dp[2][n-1]}) << endl;
}

Measured memory_bytes: 5644
#include<cstdio>
#include<algorithm>
#include<string>
#include<iostream>
#include<string.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	const char* str=s.c_str();
	int a=0;
	for(int i = 0;i<4;i++){
		a*=10;
		a+=(str[0] - '0');
		str++;
	}
	str++;
	int b = 0;
	for(int i = 0;i<2;i++){
		b*=10;
		b+=(str[0] - '0');
		str++;
	}
	str++;
	int c = 0;
	for(int i = 0;i<2;i++){
		c*=10;
		c+=(str[0] - '0');
		str++;
	}
	if(a<2019){
		printf("Heisei\n");
	}else if(a == 2019){
		if(b<5){
			printf("Heisei\n");
		}else{
			printf("TBD\n");
		}
	}else{
		printf("TBD\n");
	}
//	printf("%d %d %d\n",a,b,c);	
	return 0;
}


Measured memory_bytes: 256
loop do
  n = gets.to_i
  break if n == 0
  c = gets.chomp.split

  if n == 1
    puts "#{c[0]} 1"
    next
  end

  res = []
  solved = false
  c.each_with_index do |ch, i|
    res[ch.ord-65] ||= 0
    res[ch.ord-65] += 1
    rest = c.size - i - 1

    res = res.map {|a| a ? a : 0 }
    t = res.sort
    if t[-2] && t[-1] - rest > t[-2] # t[-1] == t[-2] ?????´?????????????????§??????(????????????)
      puts "#{(res.index(t[-1])+65).chr} #{i+1}"
      solved = true
      break
    end
  end

  puts "TIE" unless solved
end

Measured memory_bytes: 10608
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int i=1;
  while(++i<=n){
    int x=i;
    if(x%3==0){
      cout << " " << i;
      continue;
    }
    while(x){
      if(x%10==3){
	cout << " " << i;
	break;
      }
      x/=10;
    }
  }
  cout << endl;
  return 0;
}




Measured memory_bytes: 3076
z;t[99],k;char s[99];f(int*x){z=x[1]-1[&x][1];}main(n){for(;scanf("%d",&n),z=n*=2;){for(;z;t[--z]=*s)for(t[--z]=z,scanf(" %[^\n]",s),k=n;k-=2;)t[z]+=s[k]&2?30:s[k]&1?0:999;for(qsort(t,n/2,8,f);n;puts(t+n))n-=2;}}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))
const int INF = 1e9;

#define debug(...) recursive_debug(#__VA_ARGS__, __VA_ARGS__)

void recursive_debug(string) { cerr << endl; }

template<class H,class... T>
void recursive_debug(string s, H h, T... t) {
    int comma = s.find(',');
    cerr << s.substr(0,comma) << " = " << h << ", ";
    recursive_debug(s.substr(comma+1), t...);
}

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

template<class T>
ostream& operator<<(ostream &ost, const vector<T> &v) {
    ost << "[";
    for(T t : v) ost << t << ",";
    ost << "]";
    return ost;
}

struct State {
    ll score;
    vector<int> last;
    vector<int> types;
    bool operator<(const State& rhs) const {
        return (score < rhs.score);
    }
    bool operator>(const State& rhs) const {
        return (score > rhs.score);
    }
};


int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int D, M = 26;
    cin >> D;
    vector<ll> c(M);
    rep(m,M) cin >> c[m];
    vector<vector<ll>> s(D, vector<ll>(26));
    rep(d,D) rep(m,M) cin >> s[d][m];

    set<State> cur_states = {{0, vector<int>(M, -1), {}}};
    size_t SIZE = 840;

    rep(d,D) {
        set<State> nxt_states;
        for (auto &cur_itr : cur_states) {
            State state = cur_itr;
            rep(m,M) {
                State nxt_state;
                nxt_state.score = state.score + s[d][m];
                nxt_state.last = state.last;
                nxt_state.last[m] = d;
                nxt_state.types = state.types;
                nxt_state.types.push_back(m);

                rep(i,M) {
                    nxt_state.score -= c[i] * (d - nxt_state.last[i]);
                }
                nxt_states.insert(nxt_state);
                if (nxt_states.size() > SIZE) {
                    nxt_states.erase(nxt_states.begin());
                }
            }
        }

        cur_states = std::move(nxt_states);
    }

    for (int t : cur_states.begin()->types) {
        cout << t+1 << endl;
    }
    // debug(cur_states[0].score);

    return 0;
}


Measured memory_bytes: 6960
#include <stdio.h>
#include <stdlib.h>

/*
*
*/

int partition(int A[], int p, int r);

int main(int argc, char** argv) {
int n;
scanf("%d", &n);
int A[n];
for (int i = 0; i < n; i++) scanf("%d", &A[i]);

int q = partition(A, 0, n-1);

for (int ix = 0; ix < n; ix++)
{
if (ix) printf(" ");
if (ix == q) printf("[");
printf("%d", A[ix]);
if (ix == q) printf("]");
}

printf("\n");

return (EXIT_SUCCESS);
}

int partition(int A[], int p, int r)
{
int temp;
int x = A[r];
int i = p - 1;
for (int j = p; j < r; j++)
{
if (A[j] <= x)
{
i++;
temp = A[i];
A[i] = A[j];
A[j] = temp;
}
}
temp = A[i + 1];
A[i + 1] = A[r];
A[r] = temp;

return i + 1;
}


Measured memory_bytes: 2256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;
vector<int> fibo(44,-1);

int fibonacci1(int n){
    if(n == 1 || n == 0){
        return fibo[n] = 1;
    }
    if(fibo[n] != -1){
        return fibo[n];    
    }
    return fibo[n] = fibonacci1(n-1) + fibonacci1(n-2);
}

int fibonacci2(int n){
    fibo[0] = 1;
    fibo[1] = 1;
    for(int i = 2; i < n+1;i++){
        fibo[i] = fibo[i-1] + fibo[i-2];
    }
    return fibo[n];
}


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    // cout << fibonacci1(n) << endl;
    cout << fibonacci2(n) << endl;
    
    

    return 0;
}


Measured memory_bytes: 3156
fun main(args: Array<String>) {
    val (H, W) = readLine()!!.split(" ").map(String::toInt)
    val grid = Array(H) { readLine()!! }
    var newLine = false
    for (h in 0 until H) {
        var skip = true
        for (w in 0 until W) {
            var put: Boolean = '#' in grid[h]
            for (i in 0 until H) {
                if (grid[i][w] == '#') break
                if (i == H - 1) put = false
            }


            if (put) {
                if (newLine) {
                    println()
                    newLine = false
                }
                print(grid[h][w])
                skip = false
            }
        }
        if (!skip) newLine = true
    }
}

Measured memory_bytes: 38968
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		char c = sc.next().charAt(0);
		c ++ ;
		System.out.println(c);
		//int n = sc.nextInt();
		//int k = sc.nextInt();
		//int m = sc.nextInt();
		////n-1 回テストを受けている。目標は、sum(n-1個)+ 取る点 =  m * n にすること。
		////取る点は k イカじゃないとだめ
		//int[] a = new int[n-1] ;
		//int sum = 0 ;
		//for(int i = 0 ; i < n -1 ; i ++){
		//	a[i] = sc.nextInt();
		//	sum += a[i] ;
		//}
		//int need =  m * n - sum ;
		//if(need <= k) {
		//	System.out.println(Math.max(0,need));
		//} else {
		//	System.out.println(-1);
		//}
	}
}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
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; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll monster(ll h)
{
    if (h == 1) return h;

    return 2 * monster(h/2) + 1;
}

int main()
{
    ll h; cin >> h;
    cout << monster(h) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

inline int getint()
{
	static char c;
	while ((c = getchar()) < '0' || c > '9');

	int res = c - '0';
	while ((c = getchar()) >= '0' && c <= '9')
		res = res * 10 + c - '0';
	return res;
}

const int MaxN = 100000;

int n;
int a[MaxN + 2];

inline bool solve()
{
	for (int i = 1; i <= n; ++i)
		if (i + 1 > a[i + 1])
		{
			if (a[i] - i & 1)
				return true;

			bool v = false;
			for (int k = i + 1; a[k] == i; ++k)
				v = !v;
			return v;
		}
}

int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i)
		a[i] = getint();

	sort(a + 1, a + n + 1, greater<int>());

	puts(solve() ? "First" : "Second");

	return 0;
}

Measured memory_bytes: 640
N = int(input())


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

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

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

    return arr


bunkai = factorization(N)
count = 0

prime_flag = False
for x in bunkai:
    if x[0] == 1:
        prime_flag = True
        break
    else:
        check = x[1]
        current = 2
        while True:
            check -= current
            if check > 0:
                current += 1
            else:
                break
        count += current - 1
if prime_flag:
    print(0)
else:
    print(count)


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

#define MOD 1000000007
#define MODSET(d) if ((d) >= MOD) d %= MOD;

using namespace std;

vector<int> graph[4000];
bool visited[4000];
int subtreeSize[4000];
int n, k;

int dfsTree(int u, int distance, bool isRoot)
{
	visited[u] = true;
	subtreeSize[u] = 1;
	
	if (distance == (k+1)/2)
	{
		return 1;
	}
	
	int total = 0;
	int maxK = 0;
	
	for (auto v: graph[u])
	{
		if (!visited[v])
		{
			int curr = dfsTree(v, distance + 1, false);
			total += curr;
			maxK = max(maxK, curr);
			subtreeSize[u] += subtreeSize[v];
		}
	}
	
	if (isRoot)
	{
		return n - (subtreeSize[u] - (k % 2 ? (total - maxK) : 0));
	}
	else
	{
		return total;
	}
}

int main()
{
    #ifdef VSP4
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

	int i, j, u, v, ans;
	
	cin >> n >> k;
	
	for (i = 0; i < n-1; i++)
	{
		cin >> u >> v;
		graph[u].push_back(v);
		graph[v].push_back(u);
	}
	
	ans = n;
	
	for (i = 1; i <= n; i++)
	{
		memset(visited, false, sizeof(visited));
		memset(subtreeSize, 0, sizeof(subtreeSize));
		ans = min(ans, dfsTree(i, 0, true));
	}
	
	cout << ans;
		
    return 0;
}

Measured memory_bytes: 3832
L, R = (int(i) for i in input().split())
i, j = 2018, 2018
imod, jmod = 2018, 2018
min_val = 2018

if L <= 2019 and 2019 < R:
    print(0)
    exit()
elif R/2019 >= 2 and L//2019 != R//2019:
    print(0)
    exit()
else:
    for k in range(L, R+1):
        for s in range(k+1, R+1):
            new = (k*s)%2019
            if new < min_val:
                min_val = new

#print(i, j)

print(min_val)


Measured memory_bytes: 40684
#include <iostream>
#include <map>
using namespace std;
int main() {
	int H, W;
	cin >> H >> W;
	int four = (H % 2 == 0 ? H : H - 1) * (W % 2 == 0 ? W : W - 1) / 4;
	int two;
	if (H % 2 == 0 && W % 2 == 0) two = 0;
	else {
		if (H % 2 == 1 && W % 2 == 1) two = (H - 1 + W - 1) / 2;
		else two = (H % 2 == 0 ? H : W) / 2;
	}
	int one = (H % 2 == 1 && W % 2 == 1);

	map<char, int> Nums;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			char c;
			cin >> c;
			Nums[c]++;
		}
	}
	bool ans = true;
	for (auto& p : Nums) {
		while (p.second >= 4 && four>0) {
			p.second -= 4;
			four--;
		}
		while (p.second >= 2 && two > 0) {
			p.second -= 2;
			two--;
		}
		if (p.second == 1 && one == 1) {
			p.second = 0;
			one = 0;
		}
		if (p.second > 0) {
			ans = false;
			break;
		}
	}
	cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	if(y==0) return x;
	return gcd(y,x%y);	
}

ll lcm(ll x, ll y) {
	ll z=gcd(x,y);
	return x/z*y;
}

int main()
{
	int n;
	bool b=true;
	cin >> n;
	int t[n],x[n],y[n];
	rep(i,n) cin >> t[i] >> x[i] >> y[i];
	if(n==1){
		if(t[0]<x[0]+y[0] || (t[0]-x[0]-y[0])%2!=0) b=false;
	}
	rep(i,n-1){
		int tt=t[i+1]-t[i];
		int d=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
		if(tt<d || (tt-d)%2!=0) b=false;
	}
	cout << (b?"Yes\n":"No\n");
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	double R;
	cin >> R;

	cout << R * 3.14159265358979 * 2.0;

	return 0;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  ll h,n;
  cin>>h>>n;
  vector<ll> a(n);
  cin>>a;

  ll mx = accumulate(a.begin(),a.end(),0ll);
  if(mx>=h)cout<<("Yes")<<endl;
  else cout<<("No")<<endl;

}

Measured memory_bytes: 1024
import io
import sys


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
5
5 2 3 4 1
'''


def MAIN():
  # T_IN()
  if A():
    print("YES")
  else:
    print("NO")


def A():
  n = IN_I()
  l = IN_L_I()
  cnt = 0
  for i, item in enumerate(l):
    if i + 1 != item:
      cnt += 1

  if cnt == 0 or cnt == 2:
    return True
  
  return False


def B():
  return None


def C():
  return None


MAIN()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k; cin >> n >> k;
  vector<ll> h(n);
  REP(i,n){
      cin >> h[i];
  }
  sort(all(h));
  ll ans = LINF;
  REP(i,n-k+1){
      ans = min(ans,h[i+k-1] - h[i]);
  }
  cout << ans << endl;

}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			string s = Console.ReadLine();

			int ans = 0;
			for (int i = 1; i < n; i++) {
				string x = s.Substring(0, i);
				string y = s.Substring(i);
				ans = Math.Max(ans, x.Intersect(y).Count());
			}

			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a[6];
	cin>>a[0]>>a[1];
	cin>>a[2]>>a[3];
	cin>>a[4]>>a[5];
	sort(a,a+6);
	if(a[0]==1&&a[1]==2&&a[2]==2&&a[3]==3&&a[4]==3&&a[5]==4)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
}


Measured memory_bytes: 256
from fractions import gcd

a, b, c, d = map(int, input().split())

lcm =  (c * d) // gcd(c, d)

ans = b - a + 1
ans -= (b // c) - ((a - 1 )// c)
ans -= (b // d) - ((a - 1) // d)
ans += (b // lcm) - ((a - 1) // lcm)
print(ans)
    


Measured memory_bytes: 5304
# coding: utf-8
# Your code here!
N=int(input())

l=[3,5,7]
l_ans=[]
l_ans+=l

if N<357:
    print(0)
else:
    for i in range(8):
        temp=[]
        for item in l:
            temp.append(item+3*10**(i+1))
            temp.append(item+5*10**(i+1))
            temp.append(item+7*10**(i+1))
        l.clear()
        l+=temp
        l_ans+=temp
    l_ans.sort()
    
    count=0
    for i in range(len(l_ans)):
        if l_ans[i]>N:
            break
        elif  ("3" in str(l_ans[i]) and "5" in str(l_ans[i]) and "7" in str(l_ans[i]))==False:
            pass
        else:
            count+=1
            
    print(count)

Measured memory_bytes: 4708
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define t1(a) cout << #a << ":" << a << endl;
#define t2(a, b) cout << #a << ":" << a << " | " << #b << ":" << b << endl;
#define t3(a, b, c) cout << #a << ":" << a << " | " << #b << ":" << b << " | " << #c << ":" << c << endl;

using namespace std;

int main()
{
  int a,b,c,k;
  cin >> a>>b>>c>>k;
    if(a>=k)
    {
     cout<<k;
     return 0;
    }
    else if(a+b>=k)
    {
        cout<<a<<endl;
    }
    else
    {
    int f=k-a-b;
    cout<< a-f<<endl;
    
    }
   
  return 0;
}

Measured memory_bytes: 3620
using System;

namespace ALDS1_1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int element = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');

            int[] seq = new int[element];

            for (int i=0; i<element; i++)
            {
                seq[i] = int.Parse(input[i]);
            }

            outputsort(seq);

            insertionsort(seq, element);

        }

        static void insertionsort(int[] a, int b)
        { 
            for (int i=1; i<=(b-1); i++)
            {
                int value = a[i];
                int j = i - 1;

                while (j >= 0 && a[j] > value)
                {
                    a[j + 1] = a[j];
                    j--;
                }
                a[j + 1] = value;

                outputsort(a);
            }
        }


        static void outputsort(int[] a)
        {
            for (int i=1; i<=a.Length; i++)
            {
                if(i != a.Length)
                {
                    Console.Write("{0} ", a[i-1]);
                }
                else
                {
                    Console.Write(a[i-1]);
                    Console.WriteLine();
                }
            }
        }
    }
}

Measured memory_bytes: 9304
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N;
string line[105];

int main(){

	scanf("%d",&N);

	bool FLG = true;

	for(int i = 0; i < N; i++){

		cin >> line[i];
		if(i == 0 || !FLG)continue;

		if(line[i-1][line[i-1].length()-1] != line[i][0]){

			FLG = false;
			continue;
		}
		for(int k = 0; k < i; k++){

			if(line[k] == line[i]){

				FLG =false;
				break;
			}
		}
	}

	if(FLG){

		printf("Yes\n");
	}else{

		printf("No\n");
	}


	return 0;
}


Measured memory_bytes: 3628
N, K = map(int, input().split())
A_LIST = list(map(int, input().split()))
MOD = 10 ** 9 + 7
t = 0
tr = 0
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        if A_LIST[i] > A_LIST[j]:
            t += 1
    for k in range(N):
        if A_LIST[i] > A_LIST[k]:
            tr += 1
ans += t * K % MOD
ans += tr * (K - 1) * K // 2 % MOD
print(ans % MOD)


Measured memory_bytes: 71540
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#define SIZE 60

using namespace std;

int main() {
    int N, K, A[SIZE];
    int sum = 0;
    cin >> N >> K;

    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    sort(A, A + N, greater<int>());

    for (int i = 0; i < K; i++) {
        sum += A[i];
    }

    cout << sum << endl;

}


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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 200010, M = 110;

int n, m;
int a[N];
double b[N];

double get(int x)
{
	return (double)(1 + x) / 2;
}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i ++ ) scanf("%d", &a[i]);
	for (int i = 1; i <= n; i ++ ) b[i] = get(a[i]);
	
	double res = 0.0, s = 0.0;
	for (int i = 1; i <= n; i ++ )
	{
		s += b[i];
		if (i >= m)
		{
			s -= b[i - m];
			res = max(res, s);
		}
	}
	
	printf("%.12f\n", res);
    return 0;
}

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

int n;
int a[100005]; 
signed main() {
	// your code goes here
	 cin >> n;
	for(int i=1; i<= n; ++i) cin >> a[i];
	sort(a+1, a+n+1);
	for(int i= n; i>1; --i) a[i] = a[i]-a[i-1], a[i]&=1;
	a[1]&=1;
	int ans = 0;
	for(int i=1; i<= n; ++i) ans^=(a[i]*(n-i+1));
	if(ans > 0) cout << "first";
	else cout << "second";
	//cerr
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
ll a,b,c,d;
ll read()
{
	ll x=0,f=1;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;	
}
ll gcd(ll a,ll b)
{
	if(!b) return a;
	return gcd(b,a%b);
}
int main()
{
	//freopen("B2.in","r",stdin);
	int T=read();
	while(T--)
	{
		a=read();b=read();c=read();d=read();
		//cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
		if(a<b||d<b){puts("No");continue;}
		if(c>=b-1) {puts("Yes");continue;}
		//puts("!!!");
		a%=b;
		if(a>c) {puts("No");continue;}
		ll g=gcd(b,d),t;
		t=(b/g-1)*g+(a%g);
		if(t<=c) {puts("Yes");continue;}
		puts("No");
	}
	return 0;
}

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

int main() {
  int dice[6];
  for (int i=0; i<6; i++) cin >> dice[i];
  int q;
  cin >> q;

  for (int i=0; i<q; i++) {
    int x, y;
    cin >> x >> y;

    int ans;
    if (x == dice[0]) {
      if (y == dice[1])
        ans = dice[2];
      else if (y == dice[2])
        ans = dice[4];
      else if (y == dice[4])
        ans = dice[3];
      else if (y == dice[3])
        ans = dice[1];
    } else if (x == dice[1]) {
      if (y == dice[5])
        ans = dice[2];
      else if (y == dice[2])
        ans = dice[0];
      else if (y == dice[0])
        ans = dice[3];
      else if (y == dice[3])
        ans = dice[5];
    } else if (x == dice[2]) {
      if (y == dice[1])
        ans = dice[5];
      else if (y == dice[5])
        ans = dice[4];
      else if (y == dice[4])
        ans = dice[0];
      else if (y == dice[0])
        ans = dice[1];
    } else if (x == dice[3]) {
      if (y == dice[1])
        ans = dice[0];
      else if (y == dice[0])
        ans = dice[4];
      else if (y == dice[4])
        ans = dice[5];
      else if (y == dice[5])
        ans = dice[1];
    } else if (x == dice[4]) {
      if (y == dice[0])
        ans = dice[2];
      else if (y == dice[2])
        ans = dice[5];
      else if (y == dice[5])
        ans = dice[3];
      else if (y == dice[3])
        ans = dice[0];
    } else if (x == dice[5]) {
      if (y == dice[4])
        ans = dice[2];
      else if (y == dice[2])
        ans = dice[1];
      else if (y == dice[1])
        ans = dice[3];
      else if (y == dice[3])
        ans = dice[4];
    }

    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 3060
n, a, b = [int(i) for i in input().split()]

mod = pow(10, 9) + 7
total = pow(2, n, mod) - 1

no = {a: 0, b:0}

for k in [a, b]:
    num = 1
    denom = 1
    for i in range(k):
        num *= n - i
        num %= mod
    
    for i in range(1, k+1):
        denom *= i
        denom %= mod
    
    no[k] = num * pow(denom, mod-2, mod)
    no[k] %= mod

print((total - no[a] - no[b]) % mod)


Measured memory_bytes: 3064
n, m = map(int, input().strip().split())

if m // 2 < n:
    # S が余っている
    ans = m // 2
else:
    # c が余っている
    ans = n
    # 余った c は 4つずつで Scc にできる
    ans += (m - 2 * n) // 4

print(ans)


Measured memory_bytes: 2940
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const double pi = acos(-1.0);
template <class A>ostream& operator<<(ostream& o, const vector<A>& p) { o << "{"; for (int i = 0; i < (int)p.size(); ++i)o << (i > 0 ? ", " : "") << p[i]; o << "}"; return o; }
template <class A, class B>ostream& operator<<(ostream& o, const pair<A, B>& p) { o << "{" << p.first << ", " << p.second << "}"; return o; }
template <class A, class B>ostream& operator<<(ostream& o, const map<A, B>& p) { o << "{"; for (auto it = p.begin(); it != p.end(); ++it) o << (it != p.begin() ? ", " : "") << *it; o << "}"; return o; }
template <class A>ostream& operator<<(ostream& o, const set<A>& p) { o << "{"; for (auto it = p.begin(); it != p.end(); ++it) o << (it != p.begin() ? ", " : "") << *it; o << "}"; return o; }
void print() { cerr << endl; }
template <class H> void print(H&& h) { cerr << h << endl; }
template <class H, class... T> void print(H&& h, T&& ... t) { cerr << h << " "; print(forward<T>(t)...); }

int main() {
	LL k, a, b; cin >> k >> a >> b;
	LL ans;
	if (a < b) {
		ans = a >= k ? 1 : -1;
	}
	else if (a == b) {
		ans = a >= k ? 1 : -1;
	}
	else {
		ans = 1;
		ans += (k - a + a - b - 1) / (a - b) * 2;
	}
	Cout(ans);
}

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

int main(){

    string s;
    cin>>s;

    if(s[0]==s[1]&&s[1]==s[2]||s[1]==s[2]&&s[2]==s[3]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;








    return 0;
}

Measured memory_bytes: 384
/*input
3 2
1 2
5 5
-2 8
*/

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <math.h>
#include <iomanip>
#include <utility>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

ll MOD = 1000000007;
const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define inv(a)      powr((a), (MOD - 2))
#define all(c)      (c).begin(),(c).end()
#define rep(i,a,b)  for(ll i = (a); i < (b); i ++)
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template<typename T> void toInt(string s, T &a) { istringstream(s) >> a; }
ll gcd(ll a, ll b) { ll t; while(a) { t = a; a = b%a; b = t; } return b; }
ll sub(ll a, ll b) { a -= b; a = (a + MOD) % MOD; return a; }
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll add(ll a, ll b) { a += b; a %= MOD; return a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/*********************************START**********************************/
const int N = 100005;
vector < int > v[20];

int main()
{
  ifalse;
  int n, d;
  cin >> n >> d; 
  for(int i = 0; i < n; i ++) {
    for(int j = 0; j < d; j ++) {
      int x;
      cin >> x;
      v[i].push_back(x);
    }
  }
  ll ans = 0;
  for(int i = 0; i < n; i ++) {
    for(int j = i + 1; j < n; j ++) {
      ll d1 = 0;
      for(int k = 0; k < d; k ++) {
        d1 += (v[i][k]-v[j][k]) * (v[i][k]-v[j][k]);
      }
      ll u = sqrt(d1);
      if(u * u == d1) {
        ans ++;
      }
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX_N 10000
#define INF 1e9

using namespace std;

typedef int long long ll;
typedef int long l;
typedef pair<int, int> Pii;
const ll MOD = 1000000007;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    int tmp = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
            tmp++;
            ans = max(tmp, ans);
            continue;
        }
        tmp = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

#define eps (1e-10)
struct Point{
    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){}
    Point operator+(Point p) {return Point(x+p.x,y+p.y);}
    Point operator-(Point p) {return Point(x-p.x,y-p.y);}
    Point operator*(Point p) {return Point(x*p.x-y*p.y,x*p.y+y*p.x);}
    Point operator*(double k){return Point(x*k,y*k);}
    double norm(){return x*x+y*y;}
    double abs(){return sqrt(norm());}
    bool operator == (const Point &p) const{return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}
    double arg(){return atan2(y,x);}
    double dot(Point p){return x*p.x+y*p.y;}
    double det(Point p){return x*p.y-y*p.x;}
};
bool cmp_x(const Point& p,const Point& q){
  if(p.x!=q.x) return p.x<q.x;
  return p.y<q.y;
}
struct Circle{
    double r;
    Point p;
    Circle(){}
    Circle(Point p,double r):p(p),r(r){}
};
bool isIntersectCC(Circle c1,Circle c2){
    return (c1.p-c2.p).abs()<=c1.r+c2.r+eps;
}
pair<Point,Point> CrossPointsCC(Circle c1,Circle c2){
    assert(isIntersectCC(c1,c2));
    double d=(c1.p-c2.p).abs();
    double k=acos((d*d+c1.r*c1.r-c2.r*c2.r)/(c1.r*d*2));
    return make_pair(c1.p+(c2.p-c1.p)*Point(cos(k),sin(k))*(c1.r/d),c1.p+(c2.p-c1.p)*Point(cos(-k),sin(-k))*(c1.r/d));
}
int main(){
    double x1,y1,r1,x2,y2,r2;
    cin>>x1>>y1>>r1>>x2>>y2>>r2;
    pair<Point,Point> pp=CrossPointsCC(Circle(Point(x1,y1),r1),Circle(Point(x2,y2),r2));
    if(!cmp_x(pp.first,pp.second)) swap(pp.first,pp.second);
    cout<<fixed<<setprecision(12)<<pp.first.x<<" "<<pp.first.y<<" "<<pp.second.x<<" "<<pp.second.y<<endl;
    return 0;
}


Measured memory_bytes: 3536
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 310;
int n;
int G[maxn];
double dp[maxn][maxn][maxn];


double dfs(const int i, const int j, const int k)
{
    if (i == 0 && j == 0 && k == 0)
        return 0;
    double& ans = dp[i][j][k];
    if (-1 == ans) {
        double r1=0, r2=0, r3=0;
        if (i)
            r1 = 1.0*i/n * dfs(i-1,j+1,k);
        if (j)
            r2 = 1.0*j/n * dfs(i,j-1,k+1);
        if (k)
            r3 = 1.0*k/n * dfs(i,j,k-1);
        ans = (1 + r1 + r2 + r3) / (1 - 1.0*(n - i - j - k) / n);
    }
    return ans;
}
    
int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    std::ios::sync_with_stdio(false);
    while (cin >> n ) {
        FOR(i,0,n)
            cin >> G[i];
        int H[3] = {0};
        FOR(j,0,n) {
            if (G[j] == 3)
                H[0] += 1;
            else if (G[j] == 2)
                H[1] += 1;
            else
                H[2] += 1;
        }
        FOR(k,0,n+1) FOR(l,0,n+1) FOR(m,0,n+1)
            dp[k][l][m] = -1;
        cout.precision(10);
        cout << fixed << dfs(H[0], H[1], H[2]) << endl;
    }
    return 0;
}


Measured memory_bytes: 227584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    if(m==1) {
        cout << 0 << endl;
        return 0;
    }
    const int NM = 1e5+10;
    vector<int> x(m);
    rep(i,m)cin>>x[i];
    sort(x.begin(), x.end());
    vector<int> y;
    rep(i, m-1) y.push_back(x[i+1]-x[i]);
    sort(y.begin(), y.end());
    ll ans = 0;
    rep(i, m-n) ans += y[i];
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 1276
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

string S;
int main(){
    cin>>S;
    ll cnt=0;
    ll ans=0;
    for(ll i=0;i<3;i++){
        if(S[i]=='R')cnt++;
        else cnt=0;
        ans=max(ans,cnt);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3636