akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        String S = scan.next();
        char[] d = S.toCharArray();
        int[][] dp = new int[N+1][N+1];
        for (int i = N-1; 0 <= i; i--) {
            for (int j = N-1; i < j; j--) {
                if (d[i] == d[j]) {
                    dp[i][j] = Math.max(dp[i][j], dp[i+1][j+1] + 1);
                    continue;
                }
            }
        }
        long ans = 0;
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                ans = Math.max(ans, Math.min(j - i, dp[i][j]));
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 167064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtcoderTemplateForCSharp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var a = Console.ReadLine()
                .Split(' ')
                .Select(int.Parse);

            var result1 = a.OrderBy(x => x);

            var ans = 0;

            for (int i = 1; i < result1.Count(); i++)
            {
                ans += result1.ElementAt(i) - result1.ElementAt(i - 1);
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11348
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N;
  cin >> N;
  VEC<int> D(N);
  REP(i, 0, N) cin >> D[i];
  sort(ALL(D));
  int diff = D[N / 2] - D[N / 2 - 1];
  int ans = 0;
  if (diff != 0) {
    cout << diff << endl;
  } else {
    cout << 0 << endl;
  }
  // DUMP(D);

  return 0;
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	s := IOInitialize()
	s.Buffer([]byte{}, math.MaxInt64)
	N := Int(s)
	if N == 1 {
		fmt.Println("Hello World")
	} else {
		A := Int(s)
		B := Int(s)
		fmt.Println(A + B)
	}
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func String(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan error")
	}

	return s.Text()
}

func scanNums(s *bufio.Scanner, len int) (nums []int) {
	for i := 0; i < len; i++ {
		num := Int(s)
		nums = append(nums, num)
	}
	return
}

func scanstrings(s *bufio.Scanner, len int) (strs []string) {
	for i := 0; i < len; i++ {
		str := String(s)
		strs = append(strs, str)
	}
	return
}


Measured memory_bytes: 640
#include<stdio.h>
#define MAX 100000

int parent(int i) {return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

int main()
{
int kazu,i,A[MAX+1];
scanf("%d",&kazu);
for(i=1;i<=kazu;i++)
scanf("%d",&A[i]);
for(i=1;i<=kazu;i++)
{
  printf("node %d: key = %d, ",i,A[i]);
  if(parent(i)>=1)printf("parent key = %d, ",A[parent(i)]);
  if(left(i)<=kazu)printf("left key = %d, ",A[left(i)]);
  if(right(i)<=kazu)printf("right key = %d, ",A[right(i)]);
  printf("\n");
}
return 0;
}



Measured memory_bytes: 2048
#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 all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

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

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

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,m;
	cin >> n >> m;
	ll sum=0;
	rep(i,m){
		ll a;
		cin >> a;
		sum+=a;
	}
	if(sum>n) cout<< -1 << endl;
	else cout << n-sum << endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
//C++11
#if __cplusplus == 201103L
#include <tuple>
#endif

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
vector<int> adj[50];
int power[50];
bool used[50];
int ans, rest, sum;
int N;
vector<int> per;
void dfs(int k_){
  if(k_ == N){
    ans = max(ans,  sum);
    return ;
  }
  int k = per[k_];
  //printf("%d:%d %d %d\n", k,sum , rest, ans);
  if(sum + rest <= ans){
    ans = max(ans,  sum);
    return;
  }
  bool usedtmp[50];
  REP(i, 50) usedtmp[i] = used[i];
  int sumtmp = sum;
  int resttmp = rest;
  if(!used[k]){
    used[k] = true;
    sum += power[k];
    rest -= power[k];
    FORIT(it, adj[k])if(!used[*it]){
      rest -= power[*it];
      used[*it] = true;
    }
    dfs(k_ + 1);
    REP(i, 50) used[i] = usedtmp[i];
    sum = sumtmp;
    rest = resttmp;
  }
  if(k != 0){
    if(!used[k])rest -= power[k];
    used[k] = true;
    dfs(k_ + 1);
    rest += power[k];
    used[k] = false;
  }
}

typedef pair<int, int> P;
int main(){
  while(cin>>N && N){
    ans = 0, rest = 0, sum = 0;
    REP(i, 50) adj[i].clear();
    memset(used, 0, sizeof(used));
    map<string, int> id;
    vector<string> adjstr[50];
    REP(i, N){
      string s; cin>>s; id[s] = i;
      cin>>power[i];
      rest += power[i];
      int k; cin>>k;
      while(k--){
        string str; cin>>str;
        adjstr[i].push_back(str);
      }
    }
    REP(i, N){
      REP(j, adjstr[i].size()){
        adj[i].push_back(id[adjstr[i][j]]);
      }
    }
    vector<P> ps(N-1);
    REP(i, N-1)ps[i] = P(-power[i+1], i+1);
    sort(ps.begin(), ps.end());
    per = vector<int>(N, 0);
    REP(i, N-1) per[i+1] = ps[i].second;
    dfs(0);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1024
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	if len(res)==0:
		res = [n]
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	data = [2]
	#data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	ans = [x for x in data if x!=0]
	#ans = data[:]
	return ans

n = readInt()
a = readInts()

d = defaultdict(int)

for i in a:
	d[i]+=1

arr = []
remain = set()
for i in d:
	if d[i]!=1:
		remain.add(i)
arr = list(set(a))
arr.sort()

maxa = 10**6+1
ans = [0]*(maxa+1)
for i in arr:
	ans[i]=1

for i in arr:
	if ans[i]:
		for j in range(i*2,len(ans),i):
			ans[j]=0

tyo = 0

for i in remain:
	if ans[i]==1:
		tyo+=1

print(ans.count(1)-tyo)

Measured memory_bytes: 44644
#include <iostream>
#include <string>
#include<algorithm>
using namespace std;


int main(){

    string str;
    int n;
    cin>>str>>n;
    string com;
    for(int i=0;i<n;i++){
        cin>>com;
        if(com=="replace"){
            string str1;
            int a,b;
            cin>>a>>b;
            cin>>str1;
            str.replace(a,b-a+1,str1);
            //if(b!=str.size())str+=str.substr(b+1);
            
        }else if(com=="reverse"){
            int a,b;
            cin>>a>>b;
            reverse(&str[a],&str[b]+1);
        }else if(com=="print"){
            int a,b;
            cin>>a>>b;
            b=b-a+1;
            cout<<str.substr(a,b)<<endl;
        }
        
        //cout<<str<<endl;
        
    }
        
        
    
    

return 0;
}


Measured memory_bytes: 3240
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
count = 0
ad = 0

for i in range(N):
  if A[i] <= B[i] + ad:
    count += A[i]
    ad = max(0, B[i] - max(A[i] - ad, 0))
    #print(count, ad)
  else:
    count += B[i] + ad
    ad = 0
    #print(count, ad)

count += min(A[N], ad)     

print(count)

Measured memory_bytes: 18476
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ul unsigned long long int
#define vi vector<int>
#define vl vector<int64_t>
#define all(x) x.begin(),x.end()
#define pb push_back
#define fo(x,a,b) for(int x=a; x<b; x++)
#define rfo(x,a,b) for(int x=a; x>=b; x--)
#define fi first
#define sec second
#define mp make_pair
int sgn(int x) { return x>0 ? 1 : ( x<0 ? -1 : 0); }
typedef pair<int,int> pairs;
double pi = 3.14159265358979323846;
ll mod = 1000000007;

void solve()
{
    ll n,k;
    cin>>n>>k;
    int l=1,r=1;
    vi a(n);
    fo(i,0,n) { cin>>a[i]; r=max(r,a[i]); }
    while(l!=r)
    {
        int mid = (l+r)/2;
        int cnt=0;
        for(int i=0;i<n;i++) cnt+=(a[i]-1)/mid;
        if(cnt>k) l=mid+1;
        else r=mid;
    }
    cout<<l;
    cout<<"\n";
    return;
}
int main()
{
#ifdef _DEBUG
    freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t;
    //cin>>t;
    //while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3976
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = (1ll<<31)-1;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a = 0,b = 0;
    cin >> n;
    vector<int> s(n);
    rep(i,n){
        cin >> s[i];
    }
    RSORT(s);
    rep(i,n){
        if (i%2 == 0) a += s[i];
        else b += s[i];
    }
    PRINT(a-b);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n,m;
  scanf("%d%d",&n,&m);
  int factor[1<<17];
  factor[0]=1;
  int len=1;
  int k;
  for(k=2;k*k<=m;k++){
    if(m%k==0){
      int c=0;
      while(m%k==0){
	m/=k;
	c++;
      }
      int i;
      int mul;
      for(i=1,mul=k;i<=c;i++,mul*=k){
	int j;
	for(j=0;j<len;j++){
	  factor[i*len+j]=mul*factor[j];
	}
      }
      len*=c+1;
    }
  }
  if(m>1){
    for(int i=0;i<len;i++){
      factor[len+i]=factor[i]*m;
    }
    len*=2;
  }
  int min=factor[len-1];
  int i;
  for(i=0;i<len;i++){
    if(factor[i]>=n){
      min=MIN(min,factor[i]);
    }
  }
  printf("%d\n",factor[len-1]/min);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
#include <iostream>

int main()
{
    int n;
    std::cin >> n;

    for (int i = 1; i <= n; i++)
    {
        int x = i;
        if (x % 3 == 0)
        {
            std::cout << " " << i;
        }
        else
        {
            do
            {
                if (x % 10 == 3)
                {
                    std::cout << " " << i;
                    break;
                }
                x /= 10;
            } while (x != 0);
        }
    }
    std::cout << std::endl;
    return 0;
}


Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		int sq = Integer.parseInt(a.concat(b));
		for (int i = 2; i < sq / 2; i++) {
			if (i * i == sq) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}

}

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

int main ()
{
   int n,i;
   string s;
   cin>>s;
   n=s.size();
   for(i=0;i<n;i++)
   {
       if(s[i]=='9')
       {
           cout<<"Yes";
           return 0;
       }
   }
   cout<<"No";
   
   
   return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            // 整数の入力
  			int i = sc.nextInt();
            String N = sc.next();
            String[] N2 = N.split("");
            // スペース区切りの整数の入力

        
        int counter = 0;
        boolean hasA = false;
        boolean hasAB = false;
        for(String each: N2){
            
            if(hasAB && each.equals("C")){
                counter++;
              	hasAB = false;
                hasA = false;
                continue;
            }else{
                hasAB = false;
            }

            if(hasA && each.equals("B")){
                hasAB = true;
              hasA = false;
                continue;
            }else{
                hasA = false;
            }
            if (each.equals("A")){
                hasA = true;
                continue;
            }else {
                hasA = false;
                hasAB = false;
            }
        }
          System.out.println(counter);
    }
}

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

int main()
{
    ll int s;
    cin>>s;
    ll int dp[s];
    dp[0]=0, dp[1]=0, dp[2]=1;
    for(ll int i=3; i<s; i++){
        dp[i] = (dp[i-1] + dp[i-3])%1000000007;
    }
    cout<<dp[s-1];
    return 0;
}

Measured memory_bytes: 3568
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define REP2(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; ++i)
#define REP3(i, l, r) for (int i = (l), i##_len = (int)(r); i < i##_len; ++i)
#define GET_MACRO_REP(_1, _2, _3, NAME, ...) NAME
#define REP(...) GET_MACRO_REP(__VA_ARGS__, REP3, REP2) (__VA_ARGS__)
#define RREP2(i, n) for (int i = (n - 1); i >= 0; --i)
#define RREP3(i, l, r) for (int i = (r - 1), i##_len = (l); i >= i##_len; --i)
#define GET_MACRO_RREP(_1, _2, _3, NAME, ...) NAME
#define RREP(...) GET_MACRO_REP(__VA_ARGS__, RREP3, RREP2) (__VA_ARGS__)
#define IN(type, n) type n; cin >> n
#define INALL(type, v) REP(i, v.size()) { IN(type, _tmp); v.at(i) = _tmp; }
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#ifdef _DEBUG
#define DEBUG(x) cout << #x << ": " << x << endl
#else
#define DEBUG(x)
#endif

template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#pragma endregion

int main() {
  IN(string, S);
  bool flag = false;
  int count = 0;
  int tmp_count = 0;
  REP(i, S.size()) {
    if (S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'G' || S.at(i) == 'T') {
      if (!flag) {
        flag = true;
      }
      tmp_count++;
    } else {
      if (flag) {
        chmax(count, tmp_count);
        flag = false;
        tmp_count = 0;
      }
    }
  }
  chmax(count, tmp_count);

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 3596
/*author:revolIA*/
/*明日を変えるなら今日変えなきゃ*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+7;
int n = 6,m;
int A[10];
int dp[maxn];
int main(){
    for(int i=1;i<=n;i++)A[i] = 100+i-1;
    scanf("%d",&m);
    for(int i=1;i<=n;i++){
        for(int j=A[i];j<=m;j++){
            dp[j] = max(dp[j],dp[j-A[i]]+A[i]);
        }
    }
    printf("%d\n",dp[m] == m);
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>
#include <vector>


using namespace std;
#define y1     y114514
#define pb     push_back
#define mkp    make_pair
#define fi     first
#define se     second
#define all(a) a.begin(), a.end()

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

const int M = 1000000007;

int         T;
ll          N;
ll          A, B, C, D;
map<ll, ll> mp;

ll solve(ll N) {
    if (N == 0) return 0;
    if (N == 1) return D;
    if (mp.find(N) != mp.end()) return mp[N];
    ll tmp1 = N % 2 == 0 ? solve(N / 2) + A :
                           min(solve(N / 2), solve(N / 2 + 1)) + A + D;
    ll tmp2 = N % 3 == 0 ? solve(N / 3) + B :
                           min(solve(N / 3) + (N % 3) * D,
                               solve(N / 3 + 1) + (3 - N % 3) * D) +
                               B;
    ll tmp3 = N % 5 == 0 ? solve(N / 5) + C :
                           min(solve(N / 5) + (N % 5) * D,
                               solve(N / 5 + 1) + (5 - N % 5) * D) +
                               C;
    ll tmp = min(min(tmp1, tmp2), tmp3);
    if (1. * D * N - 100000 < tmp) tmp = min(tmp, D * N);
    return mp[N] = tmp;
}

int main() {
    scanf("%d", &T);
    while (T--) {
        scanf("%lld%lld%lld%lld%lld", &N, &A, &B, &C, &D);
        mp.clear();
        printf("%lld\n", solve(N));
    }
    return 0;
}


Measured memory_bytes: 4052
#include<iostream>

using namespace std;

const int INF=10000003;

int main(){
	
	int e;
	while(cin>>e && e){
		int ans=INF;
		for(int i=0;i*i*i<=e;i++){
			int tmp=e-i*i*i;
			for(int j=0;j*j<=tmp;j++)ans=min(ans,i+tmp-j*j+j);
		}
	cout<<ans<<endl;
	}
}

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

const int MOD = 1000000007;

// Returns modulo inverse of a with respect
// to m using extended Euclid Algorithm
// Assumption: a and m are coprimes, i.e.,
// gcd(a, m) = 1
int modInverse(int a, int m)
{
    int m0 = m;
    int y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        // q is quotient
        int q = a / m;
        int t = m;

        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;

        // Update y and x
        y = x - q * y;
        x = t;
    }

    // Make x positive
    if (x < 0)
       x += m0;

    return x;
}

int binomialCoeff(int n, int k)
{
    long long res = 1;

    // Since C(n, k) = C(n, n-k)
    if ( k > n - k )
        k = n - k;

    // Calculate value of
    // [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]
    for (int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res %= MOD;
        res *= modInverse(i + 1, MOD);
        res %= MOD;
    }

    return res;
}

int main() {
        int X, Y;
        cin >> X >> Y;
  
  		if (X < Y) swap(X, Y);

        int cnt = 0;
        while (2 * Y > X) {
                Y -= 1;
                X += 1;
                cnt += 1;
        }

        if (2 * Y == X) {
                cout << binomialCoeff(Y, cnt) << endl;
        } else {
                cout << 0 << endl;
        }
}


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

int main(){
  int a, b;
  cin >> a >> b;
  int x = a + b;
  if (x % 2 == 0) cout << x/2 << endl;
  else cout << "IMPOSSIBLE" << endl;
  
  return 0;
}

Measured memory_bytes: 3576
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
using namespace std;

int main(void){

    char a[4];

    for(int i=0;i<4;i++){
        char x;
        cin>>x;
        a[i] = x;
    }

    for(int i=0;i<4;i++){
        int count = 1;
        for(int j=0;j<4;j++){
            if(i!=j){
                if(a[i] == a[j])count++;
            }
        }
        if(count==1 || count>=3){
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

struct P {
    bool operator<(const P &p) const {
        return r < p.r;
    }
    int l, r;
};

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

    int n;
    cin >> n;

    vector<P> p(n);
    for (int i = 0; i < n; i++) {
        int x, l;
        cin >> x >> l;
        p[i] = { x - l, x + l };
    }
    sort(p.begin(), p.end());

    int r = 0, x = (int)-2e9;
    for (int i = 0; i < n; i++) {
        if (p[i].l >= x) {
            x = p[i].r;
            r++;
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
	int n,i,s=0,a,b[100010]={};
	scanf("%d",&n);
	while(n--){
		scanf("%d",&a);
		a<100001?(b[a]++):(s++);
	}
	for(i=0;i<100001;i++)s+=b[i]<i?b[i]:b[i]-i;
	printf("%d\n",s);
	return 0;
}

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

using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'



signed main() {
    fio();
    
    int n;
    cin >> n;
    vl a(n);
    rep (i, n) cin >> a[i];

    int pre = -inf;
    ll cnt = 0;
    ll ans = 0;
    rep (i, n) {
        if (a[i] == 0) continue;
        if (i >= pre + 2) {
            ans += cnt / 2;
            cnt = 0;
        }
        pre = i;
        cnt += a[i];
    }
    ans += cnt / 2;
    cout << ans << endl;
}

Measured memory_bytes: 3932
/******************************************
* AUTHOR : SOMU KUMAR *
* INSTITUTION : IIT BHUBANESWAR *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 998244353
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
ll bit[2*N];
ll qr(int l,int r){
	return (bit[r]-bit[max(0,l-1)]+MOD)%MOD;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//code here...............//
int n,k;
cin>>n>>k;
pii arr[k];
for(int i=0;i<k;i++){
	int l,r;
	cin>>l>>r;
	arr[i].first=l;
	arr[i].second=r;
}
sort(arr,arr+k);
ll b[n+1];
memset(b,0,sizeof(b));
b[1]=1;
bit[1]=1;
for(int i=2;i<=n;i++){
    for(int j=0;j<k;j++){
    	if(i-1<arr[j].first)break;
    	else if(i-1<=arr[j].second){
    		b[i]=(b[i]+qr(1,i-arr[j].first))%MOD;
            break;
    	}
    	else{
            b[i]=(b[i]+qr(i-arr[j].second,i-arr[j].first))%MOD;
    	}
    }
    bit[i]=(b[i]+bit[i-1])%MOD;
}
cout<<b[n]%MOD<<endl;
return 0;
}

Measured memory_bytes: 6772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll x;
	cin>>x;
	ll ans;
	ans=x/11*2;
	x%=11;
	if(x!=0){
		ans++;
		if(x>6){
			ans++;
		}
	}
	cout<<ans;
	return 0;
}


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


using namespace std ; 

int n ; 

int main(){
        ios_base::sync_with_stdio(0) ; 
        cin.tie(0) ;
        //freopen("in.in" , "r" , stdin) ; 
        long long mul = 1LL ; 
        cin>>n ; 
        long double mul2 = 1ull; 
        bool ok = 0 ; 
        for(int i = 0 ;i < n;i++){
                long double x ; 
                cin>>x ; 
                mul*=x ;  
                mul2*= x ; 
                if(mul2 > 1e18 ){
                        ok =1 ; 
                }
                if(x ==0){
                        mul2 = 0 ; 
                        mul = 0 ; 
                        ok =0 ; 
                }
        }
        if( !ok )
                cout<< mul ; 
        else cout<<-1 ; 
        return 0 ; 
}

Measured memory_bytes: 3816
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n, m := scanInt(), scanInt()

	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, m)
		for j := 0; j < m; j++ {
			a[i][j] = scanInt()-1
		}
	}

	isAborted := make([]bool, m)
	next := make([]int, n)
	ans := n

	for k := 0; k < m; k++ {
		count := make([]int, m)
		arr := make([][]int, m)
		for i := 0; i < n; i++ {
			count[a[i][next[i]]]++
			arr[a[i][next[i]]] = append(arr[a[i][next[i]]], i)
		}
	
		ma := 0
		abort := 0
	
		for i := 0; i < m; i++ {
			if count[i] > ma {
				ma = count[i]
				abort = i
			}
		}

		// fmt.Println(ans, count, abort, arr)

		if ans > ma {
			ans = ma
		}
	
		isAborted[abort] = true
	
		for _, e := range arr[abort] {
			for isAborted[a[e][next[e]]] {
				next[e]++
				if next[e] == m {
					break
				}
			}
		}
	}

	fmt.Println(ans)

}


Measured memory_bytes: 5504
//E.H//
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int n,arr[100005];       
bool visited[100005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    int p=1,cnt=0;
    visited[1]=1;
    while(true){
        p=arr[p];
        if(visited[p]){
            //cout<<p<<endl;
            cout<<-1<<endl;
            return 0;
        }
        cnt++;
        visited[p]=1;
        if(p==2){
            cout<<cnt<<endl;
            break;  
        }
    }
}

Measured memory_bytes: 4076
#include <bits/stdc++.h>
using namespace std;
 
typedef long long lli;
 
const lli mod = 1000000007LL;
 
string s;
int p;
 
pair<lli,lli> exp();
pair<lli,lli> term();
pair<lli,lli> fact();
 
pair<lli,lli> exp() {
  pair<lli,lli> x = term();
  lli all = (x.first + x.second) % mod;
  lli f = x.second;
  while(s[p] == '|') {
    ++p;
    x = term();
    all = (all * (x.first+x.second)) % mod;
    f = (f * x.second) % mod;
  }
  return make_pair(((all - f) % mod + mod) % mod, f);
}
 
pair<lli,lli> term() {
  pair<lli,lli> x = fact();
  lli all = (x.first + x.second) % mod;
  lli f = x.first;
  while(s[p] == '&') {
    ++p;
    x = fact();
    all = (all * (x.first+x.second)) % mod;
    f = (f * x.first) % mod;
  }
  return make_pair(f, ((all - f) % mod + mod) % mod);
}

pair<lli,lli> fact() {
  if(s[p] == '(') {
    ++p;
    pair<lli,lli> x = exp();
    ++p;
    return x;
  } else if(s[p] == '~') {
    int cnt = 0;
    while(s[p] == '~') {
      ++cnt;
      ++p;
    }
    pair<lli,lli> x = fact();
    if(cnt & 1) swap(x.first, x.second);
    return x;
  } else if(s[p] == 'x') {
    ++p;
    while(isdigit(s[p])) ++p;
    return make_pair(1LL, 1LL);
  } else {
    //assert(false);
  }
}

string erase(string s) {
  int n = s.size();
  vector<int> use(n, 1);
  stack<pair<int,vector<int> > > pos;
  for(int i = 0; i < n; ++i) {
    if(s[i] == '(') {
      vector<int> v(3,0);
      pos.push(make_pair(i, v));
    } else if(s[i] == ')') {
      int k = pos.top().first;
      vector<int> v = pos.top().second;
      pos.pop();
      if(v[0] == 0 && v[1] == 0 && v[2] == 0) {
        use[i] = use[k] = 0;
      }
    } else {
      if(!pos.empty()) {
        pos.top().second[0] += s[i] == '|';
        pos.top().second[1] += s[i] == '&';
        pos.top().second[2] += s[i] == '~';
      }
    }
  }
  string t;
  for(int i = 0; i < n; ++i) {
    if(use[i]) t += s[i];
  }
  return t;
}
 
int main() {
  cin >> s;
  s = erase(s);
  s += "$";
  p = 0;
  cout << exp().first << endl;
  return 0;
}

Measured memory_bytes: 38936
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        char c = s.next().charAt(0);
        if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u') System.out.println("vowel");
        else System.out.println("consonant");
    }

}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25032
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

#define FOR0(var, max) for (sl (var) = 0; (var) < (max); ++(var))
#define FORi(var, min, max) for (sl (var) = (min); (var) < (max); ++(var))
#define FORi_INV(var, min, max) for (sl (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

const static ul NMAX = 100000;
const static ul AiMAX = 1000000000;

static sl N;
static sl Ai[NMAX];

template <class T>
T gcd(T a, T b) {
  while (b) {
    T t = a % b;
    a = b;
    b = t;
  }
  return a;
}

template <class T>
struct SparseTable {
  function<T(T, T)> op;
  const sl N;
  vector<vector<T>> table;

  template <class Container>
  SparseTable(const Container& arr, function<T(T, T)> _op) : SparseTable(arr, _op, arr.size()) {}

  template <sl _N>
  SparseTable(const T (&arr)[_N], function<T(T, T)> _op) : SparseTable(arr, _op, _N) {}

  template <class Container>
  SparseTable(const Container& arr, function<T(T, T)> _op, const sl& _N) : op(_op), N(_N) {
    sl M = 0;
    while ((1 << M) < N) {
      M++;
    }
    table.resize(N, vector<T>(M));
    FOR0(i, N) {
      table[i][0] = arr[i];
    }
    for (sl j = 1; (1 << j) <= N; j++) {
      for (sl i = 0; i + (1 << j) <= N; i++) {
        table[i][j] = op(table[i][j - 1], table[i + (1 << (j - 1))][j - 1]);
      }
    }
  }

  T query(sl a, sl b) {
    sl j = floor(log2(b - a));
    return op(table[a][j], table[b - (1 << j)][j]);
  }
};


void solve(void) {
  SparseTable<sl> st(Ai, gcd<sl>);
  sl res = 0;
  FOR0(i, N) {
    sl t = 0;
    if (0 != i) {
      t = st.query(0, i);
    }
    if (i + 1 != N) {
      t = gcd(t, st.query(i + 1, N));
    }
    if (res < t) {
      res = t;
    }
  }
  cout << res << endl;
}

int main(void) {
  cin >> N;
  FOR0(i, N) {
    cin >> Ai[i];
  }
  solve();
  return 0;
}

Measured memory_bytes: 17408
import math
import string
import collections
from collections import Counter
from collections import deque


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b = map(int, input().split())
print(a*b)


Measured memory_bytes: 68632
N, M = map(int, input().split())
wrongnumber = [0] * N
ACset = set()
for i in range(M):
    p, S = input().split()
    if S == "AC":
        ACset.add(int(p)-1)
    else:
        if (int(p) - 1) not in ACset:
            wrongnumber[int(p) - 1] += 1
WAnumber = 0
ACnumber = len(ACset)
for j in ACset:
    WAnumber += wrongnumber[j]

print(ACnumber, WAnumber)


Measured memory_bytes: 12652
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};
/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/

int main(){
    ll N,M; cin >> N >> M;
    vector<ll> a(N);
    priority_queue<ll> pq;
    for (int i = 0; i < N; i++){
        cin >> a[i];
        pq.push(a[i]);
    }
    for (int i = 0; i < M; i++){
        ll now = pq.top();
        pq.pop();
        now /= 2;
        pq.push(now);
    }
    ll sum = 0;
    while (pq.size()){
        sum += pq.top();
        pq.pop();
    }
    cout << sum << endl;
}

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

#define rep(i,a,b) for(int i=a;i<=b;i++)
typedef long long ll;
typedef unsigned long long ull;

const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
const int bb=13331;
ll a,b,c,d,n,m;

int main()
{
    //ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin>>n;
    m=n-1;
    cout<<n*m/2<<endl;
    
}

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

vector<string> s;

int main(){
  int N;
  long len=1;
  long count=0;
  string in;

  cin >> N;
  for(int i=0; i<N; i++){
    cin >> in;
    sort(in.begin(),in.end());
    s.push_back(in);
  }
  sort(s.begin(),s.end());
  for(int i=0; i<N-1; i++){
    if(s[i]==s[i+1]) len++;
    else{
      count += len*(len-1)/2;
      len=1;
    }
  }
  count += len*(len-1)/2;
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 5748
#include <stdio.h>
#include <string.h>

int main(void){
  char mozi[201], cpmz[201];

  while(1){
    int i=0, j, cnt=0, p; //cnt シャッフル回数
    int len;
    scanf("%s", mozi);
    if(mozi[0]=='-')   break;
    len = strlen(mozi);
    scanf("%d", &cnt);
    while(i<cnt){
      scanf("%d", &p);
      for(j=0; j<p; j++)
        cpmz[j+len-p] = mozi[j];
      for(j=p; j<len; j++)
        cpmz[j-p] = mozi[j];
      i++;
      for(j=0;j<len;j++)
        mozi[j] = cpmz[j];
    }
    printf("%s\n", mozi);
  }

  return 0;
}



Measured memory_bytes: 1976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  string a,b,c;
  cin>>a>>b>>c;
  int x=0;
  int y=0;
  int z=0;
  char cur='a';
  while(true){
    if(cur=='a'){
      if(x==a.size()){
        cout<<'A'<<endl;
        break;
      }
      cur=a[x];
      x++;
    }
    else if(cur=='b'){
      if(y==b.size()){
        cout<<'B'<<endl;
        break;
      }
      cur=b[y];
      y++;
    }
    else{
      if(z==c.size()){
        cout<<'C'<<endl;
        break;
      }
      cur=c[z];
      z++;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
int n,a,b;
cin>>n>>a>>b;
int s[n];
for(int i=0;i<n;i++)cin>>s[i];
int ac[n]={},bc[n]={},asum[n]={},bsum[n]={},ap[n],bp[n];
ac[0]=1;bc[0]=1;asum[0]=1;bsum[0]=1;ap[0]=0;bp[0]=0;
int ai=0,bi=0;
for(int i=1;i<n;i++){
    while(s[i]-s[ai]>=a)ai++;
    while(s[i]-s[bi]>=b)bi++;
    if(i!=ai){
        if(bp[i-1]<=ai){
            ac[i]=bsum[ai];
        }else ac[i]=0;
        asum[i]=ac[i];
        ap[i]=i;
    }else{
        ac[i]=bsum[i-1];
        asum[i]=(asum[i-1]+ac[i])%MOD;
        ap[i]=ap[i-1];
    }
     if(i!=bi){
        if(ap[i-1]<=bi){
            bc[i]=asum[bi];
        }else bc[i]=0;
        bsum[i]=bc[i];
        bp[i]=i;
    }else{
        bc[i]=asum[i-1];
        bsum[i]=(bsum[i-1]+bc[i])%MOD;
        bp[i]=bp[i-1];
    }

}
cout<<(asum[n-1]+bsum[n-1])%MOD;
return 0;
cerr<<endl;
for(int i=0;i<n;i++)cerr<<asum[i]<<' ';
cerr<<endl;
for(int i=0;i<n;i++)cerr<<ac[i]<<' ';
cerr<<endl;
for(int i=0;i<n;i++)cerr<<ap[i]<<' ';
cerr<<endl;
for(int i=0;i<n;i++)cerr<<bsum[i]<<' ';
cerr<<endl;
for(int i=0;i<n;i++)cerr<<bc[i]<<' ';
cerr<<endl;
for(int i=0;i<n;i++)cerr<<bp[i]<<' ';
cerr<<endl;




return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int N=2e5+5;
const int mod=2019;
int pow(int a,int p,int m){
    int re=1;
    for(;p;p>>=1){
        if(p&1) re=1LL*re*a%m;
        a=1LL*a*a%m;
    }
    return re;
}
char s[N];
map<int,int>ma;

void init();
void work();
int ca=1;
int main(){
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
//    init();
//    int T;cin>>T;
//    while(T--)
    work();
    return 0;
}
void work(){
    cin>>s+1;
    int n=strlen(s+1);
    int inv;
    for(int i=1;i<mod;i++)if(10*i%mod==1){
        inv=i;
        break;
    }
    int sum=0,ten=1;
    ll ans=0;
    ma[0]=1;
    for(int i=1;i<=n;i++){
        sum=(sum*10+s[i]-'0')%mod;
        ten=ten*inv%mod;
        int t=sum*ten%mod;
        ans+=ma[t];
        ma[t]++;
    }
    cout<<ans;
}


Measured memory_bytes: 3848