akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
 
 
using namespace std;
 
#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;
 
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const int mod = 1e9+9;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}
 
//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1
 
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}

int main(){

	#ifdef LOCAL_TEST
    freopen("in.txt","r",stdin);
    //freopen("out.txt", "w", stdout);
    #else
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #endif
    ll a;
    string s;
    cin>>a>>s;

    if(a>=3200)cout << s << "\n";
    else cout << "red\n";
}

Measured memory_bytes: 764
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int n;
    cin >> n;
    auto p = vector<int>(n);
    for (auto &p_i : p)
        cin >> p_i;

    auto count = 0;
    auto p_min = p[0];
    for (int i = 0; i < n; ++i) {
        p_min = min(p[i], p_min);
        if (p[i] <= p_min)
            ++count;
    }

    cout << count;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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_MAX	2,147,483,647 = 2*1.0e9

int main(){
  int K;
  cin >> K;

  int ans = 0;
  if(K%2 == 0) ans = K * K / 2 / 2;
  else ans = (K/2 +1) * (K/2);

  cout << ans << endl; 

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100100
using namespace std;
int a[N],id[N];
bool cmp(int i,int j){
	return a[i]<a[j];
}
int main(){
	int n,ans=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		id[i]=i;
	}
	sort(id,id+n,cmp);
	for(int i=0;i<n;i+=2){
		if(id[i]&1) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
    int a;
    int b;
    cin >> a;
    cin >> b;

    int pl = 0;
    int pr = 1250;
    do {
        int pc = (pl + pr) / 2;
        if ((int)(pc * 0.08) == a && (int)(pc * 0.1) == b) {
            while ((int)(pc * 0.08) == a && (int)(pc * 0.1) == b) {
                pc--;
            }
            pc++;
            cout << pc << endl;
            return 0;
        } else if ((int)(pc * 0.08) < a || (int)(pc * 0.1) < b) {
            pl = pc + 1;
        } else if ((int)(pc * 0.08) > a || (int)(pc * 0.1) > b) {
            pr = pc - 1;
        }
    } while (pl <= pr);

    cout << -1 << endl;
}

Measured memory_bytes: 256
import math

n, d = map(int, input().split())
count = 0
nums = []

for i in range(n):
    num = list(map(int, input().split()))
    nums.append(num)

for i in range(len(nums)):
    for j in range(i+1, len(nums)):
        total = 0
        for a, b in zip(nums[i],nums[j]):
            total += abs(a - b) ** 2
        if math.sqrt(total).is_integer():
            count += 1

print(count)

Measured memory_bytes: 38384
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
  int N, L;
  cin >> N >> L;

  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S[i];
  }
  sort(S.begin(), S.end());

  string ans;
  for (int i = 0; i < N; i++) {
    ans += S[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())

name = []
time = []
for _ in range(n):
    tmp = input().split()
    name.append(tmp[0])
    time.append(int(tmp[1]))

s = input()

i = name.index(s) + 1
ans = 0
while i < n:
    ans += time[i]
    i += 1

print(ans)


Measured memory_bytes: 3060
dig2rad x = x / 360.0 * 2 * pi

ans :: [Float] -> Int
ans [a, b, c, d] =
  round $ r * acos( sin(a')*sin(c') + cos(a')*cos(c')*cos(dx) )
  where
    r  = 6378.1
    a' = dig2rad a
    b' = dig2rad b
    c' = dig2rad c
    d' = dig2rad d
    dx = d' - b'
    
main = do
  c <- getContents
  let i = map (map read) $ map words $ lines c :: [[Float]]
      o = map ans $ takeWhile (/= [-1,-1,-1,-1]) i
  mapM_ print o



Measured memory_bytes: 4444
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using static System.Console;
using static System.Math;

class Program
{
    void Solve()
    {
        var N = io.Int;
        var M = io.Int;
        var L = new int[M];
        var R = new int[M];
        for (var i = 0; i < M; i++)
        {
            L[i] = io.Int;
            R[i] = io.Int;
        }

        var foo = new int[(int) 1e5 + 10];
        for (var i = 0; i < M; i++)
        {
            foo[L[i]]++;
            foo[R[i] + 1]--;
        }

        for (var i = 0; i < foo.Length - 1; i++)
        {
            foo[i + 1] += foo[i];
        }


        WriteLine(foo.Count(x => x == M));
    }


    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) => new Program().Stream();

    private void Stream()
    {
        //var exStdIn = new System.IO.StreamReader("stdin.txt");
        //SetIn(exStdIn);
        Solve();
        io.Flush();
    }
}

class SimpleIO
{
    string[] _nextBuffer;
    int _bufferCnt;
    char[] cs = new char[] {' ', '"', ','};

    StreamWriter sw = new StreamWriter(OpenStandardOutput())
    {
#if DEBUG
        AutoFlush = true
#else
        AutoFlush = false
#endif
    };

    public SimpleIO()
    {
        _nextBuffer = new string[0];
        _bufferCnt = 0;
        SetOut(sw);
    }

    string Next()
    {
        if (_bufferCnt < _nextBuffer.Length) return _nextBuffer[_bufferCnt++];
        var st = ReadLine();
        while (st == string.Empty) st = ReadLine();
        _nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        _bufferCnt = 0;
        return _nextBuffer[_bufferCnt++];
    }

    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void Flush() => Out.Flush();
}

Measured memory_bytes: 17300
#include<bits/stdc++.h>
using namespace std;
char a[10],l;
int main(){
gets(a);
l=strlen(a);
for(int i=0;i<l-1;i++){
if(a[i]=='A'&&a[i+1]=='C'){
printf("Yes");
return 0;
}
}
printf("No");
return 0;}

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

int main()
{
    ll n,i,sum=0;
    cin>>n;i=n;
    while(n)
    {
        sum+=n%10;
        n/=10;
    }
    if(i%sum==0) cout<<"Yes";
    else cout<<"No";
    cout<<endl;
}


Measured memory_bytes: 3588
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
 
// solution 
use std::collections::HashSet;
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        N: usize,
        S: [chars; N],
    }
 
    let mut counts = [0_usize; 5];
 
    for s in S.iter() {
        match s[0] {
            'M' => counts[0] += 1,
            'A' => counts[1] += 1,
            'R' => counts[2] += 1,
            'C' => counts[3] += 1,
            'H' => counts[4] += 1,
             _  => (),
        }
    }
    let mut sum = 0_usize;
    for first in 0..3 {
        for second in first+1..4 {
            for third in second+1..5 {
                sum += counts[first] * counts[second] * counts[third];
            }
        }
    }
 
    println!("{}", sum);
}

Measured memory_bytes: 12540
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}


int main(){
        char A;
        cin >> A;
        char B=A+1;
        cout << B;
}

Measured memory_bytes: 256
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


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

	ll ans1 = 0;
	char po[2] = {'0', '1'};
	rep(i, (ll)s.size()) if (s[i] != po[i % 2])++ans1;
	ll ans2 = 0;
	rep(i, (ll)s.size()) if (s[i] != po[(i + 1) % 2])++ans2;
	cout << min(ans1, ans2) << endl;
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  vector<int> a(4, 0);
  for (int i = 0; i < s.size(); i++) {
    a[s[i] - 'a']++;
  }
  if (abs(a[0] - a[1]) <= 1 && abs(a[0] - a[2]) <= 1 && abs(a[1] - a[2]) <= 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
#define N 100005 
using namespace std;
int n,m,c[N];
void Add(int x,int d){
	for(int i=x;i<=n+1;i+=i&-i)c[i]+=d;
}
int sum(int x){
	int ans=0;
	for(int i=x;i;i-=i&-i)ans+=c[i];
	return ans;
}
int main()
{	
	scanf("%d%d",&n,&m);
	int tot=0;
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		Add(x,1);Add(y+1,-1);
	}
	for(int i=1;i<=n;i++){
		if(sum(i)==m)tot++;
	}
	cout<<tot;
}

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

int main()
{
	long long int n,m;
	bool flag=true;
	cin>>n>>m;
	vector<long long int>v(n,-1);
	
	for(long long int i=0;i<m;i++)
	{
		long long int s,c;
		cin>>s>>c;
		
		if(c<0)
		{
			flag=false;
		}
		if(v[s-1]==-1)
		{
			v[s-1]=c;
		}
		else{
			if(v[s-1]!=c)
			{
				flag=false;
			}
		}
	}
	if(n==1 && (v[0]==0 || v[0]==-1))
	{
		cout<<0;
		return 0;
	}
	if(n!=1 && v[0]==0)
	{
		flag=false;
	}
	
	if(flag)
	{
		for(long long int i=0;i<n;i++)
		{
			if(v[i]==-1)
			{
				if(i!=0)
				{cout<<0;}
				else{
					cout<<1;
				}
			}
			else{
				cout<<v[i];
			}
		}
	}
	else{
		cout<<-1;
	}
	return 0;
	
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	map<string, int> mp[10];
	rep(i, 0, N) {
		string s; int a;
		cin >> s >> a;
		mp[s.size()][s] += a;
	}
	rep(i, 1, 6) {
		for (auto it = mp[i].begin(); it != mp[i].end(); it++) {
			cout << it->first << " " << it->second << endl;
		}
	}
	return 0;
}

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

static const int N = 100;

int main()  {
	int n, p[N + 1], m[N + 1][N + 1];
	cin >> n;
	for (int i = 1; i <= n; i++)	{
		cin >> p[i - 1] >> p[i];
	}
	
	for (int i = 1; i <= n; i++)
		m[i][i] = 0;
	for (int l = 2; l <= n; l++)	{
		for (int i = 1; i <= n - l + 1; i++)	{
			int j = i + l - 1;
			m[i][j] =  (1 << 21);
			for (int k = i; k <= j - 1; k++)	{
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
			}
		}
	}
	
	cout << m[1][n] << endl;
	
	return 0;
}			

Measured memory_bytes: 3128
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <stdarg.h>
#include <algorithm>
#include <iostream>

using namespace std;

int
main() {
 
  int64_t n;
  cin>>n;

  if (n==1)
    cout<<0<<endl;
  else
    cout<<n*(n-1)/2<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
 
int main() {
 
    int N, K;
    cin >> N >> K;
 
    vector<int> h;
 
    for(int i = 0; i < N ; i++) {
        int in; cin >> in;
        h.push_back(in);
    }
 
    // sort
    sort(h.begin(), h.end());
 
    int diff = INT_MAX;
    for(size_t i = 0; i < (h.size() - K + 1); i++) {
        int d = h[i+K-1] - h[i];
        if(d < diff) {
            diff = d;
        }
    }
    cout << diff << endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  ll A, B, K;
  cin >> A >> B >> K;
  if (K < A) {
    cout << A - K << " " << B << endl;
  } else if (K < A + B) {
    cout << 0 << " " << B - (K - A) << endl;
  } else {
    cout << 0 << " " << 0 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
W,H,N = map(int,input().split())

x1 = 0
x2 = W
y1 = 0
y2 = H

for n in range(N):
    x,y,a = map(int,input().split())
    if a == 1:
        x1 = max(x,x1)
    elif a == 2:
        x2 = min(x,x2)
    elif a == 3:
        y1 = max(y,y1)
    elif a == 4:
        y2 = min(y,y2)

print(max(x2-x1,0)*max(y2-y1,0))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int n, sum = 0;
    cin >> n;
    vector<int> v1{0}, v2{0};
    for (int i = 0; i < n; ++i) {
        int k;
        cin >> k;
        sum += k;
        v1.emplace_back(sum);
    }
    sum = 0;
    for (int i = 0; i < n; ++i) {
        int k;
        cin >> k;
        sum += k;
        v2.emplace_back(sum);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans = max(ans, v1[i]+v2[n]-v2[i-1]);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
SIZE=300000; MOD=998244353 #ここを変更する

inv = [0]*(SIZE+1)# inv[j] = j^{-1} mod MOD
fac = [0]*(SIZE+1)# fac[j] = j! mod MOD
finv = [0]*(SIZE+1)# finv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE+1):
    inv[i] = MOD -(MOD//i)*inv[MOD%i]%MOD
    fac[i] = fac[i-1]*i%MOD
    finv[i]= finv[i-1]*inv[i]%MOD

def choose(n,r): # nCk mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0
    

n,a,b,k = [int(i) for i in input().split()]
ans=0
for i in range(n+1):
    if (k-i*a)%b == 0:
        ans = (ans + choose(n,i)*choose(n,(k-i*a)//b)%MOD)%MOD
print(ans)




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

template<class T> long long largest_rectangle (vector<T> a) {
    a.emplace_back(0);
    int n = a.size(); T ret = 0;
    stack<pair<T, int>> sta;
    for (int i = 0; i < n; i++) {
        if (sta.empty()) sta.emplace(a[i], i);
        else if (sta.top().first < a[i]) sta.emplace(a[i], i);
        else if (sta.top().first > a[i]) {
            int idx = i;
            while (!sta.empty()) {
                if (sta.top().first < a[i]) break;
                T h; int t; tie(h, t) = sta.top(); sta.pop();
                T s = h * (i - t); idx = t;
                if (ret < s) ret = s;
            }
            sta.emplace(a[i], idx);
        }
    }
    return ret;
}



int main() {
    int n;
    cin >> n;
    vector<long long> a(n);
    for (auto& e : a) cin >> e;
    cout << largest_rectangle(a) << endl;
    return 0;
}


Measured memory_bytes: 5916
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define INF 1e9
const double EPS = 1e-9;
typedef complex<double> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()

VP crosspointCC(Point a, double ar, Point b, double br){
  double d = abs(b-a);
  if(abs(ar-br)>d || abs(ar+br)<d) return {};
  double t = acos(double((d*d+ar*ar-br*br)/(2*d*ar)));
  Point p1 = a+polar(ar,arg(b-a)+t);
  Point p2 = a+polar(ar,arg(b-a)-t);
  if(abs(p1-p2) < EPS) return {p1};
  return {p1,p2};
}

double dot(Point a, Point b) {
  return a.X*b.X + a.Y*b.Y;
}

double cross(Point a, Point b) {
  return a.X*b.Y - a.Y*b.X;
}

int ccw(Point a, Point b, Point c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on ps
  if (norm(b) < norm(c)) return -2;  // a--b--c on ps or a==b
  return 0;                          // a--c--b on ps or a==c or b==c
}

bool isecSS(Point a1, Point a2, Point b1, Point b2) {
  return ccw(a1, a2, b1)*ccw(a1, a2, b2) <= 0 &&
  ccw(b1, b2, a1)*ccw(b1, b2, a2) <= 0;
}

int main(void){
    int n;
    while(cin>>n, n){
        VP c(n);
        vector<double> r(n);
        rep(i,n){
            double x,y;
            cin>>x>>y>>r[i];
            c[i] = {x,y};
        }

        vector<VP> ps(n+1);
        ps[0] = {c[0],c[0]};
        ps[n] = {c[n-1],c[n-1]};
        rep(i,n-1){
            ps[i+1] = crosspointCC(c[i],r[i],c[i+1],r[i+1]);
            assert(ps[i+1].size()==2);
        }

        vector<vector<double>> d((n+1)*2,vector<double>((n+1)*2,INF));
        rep(i,n) for(int j=i+1;j<=n;j++) rep(i2,2) rep(j2,2) {
            bool connect=true;
            for(int k=i+1;k<j;k++) {
                connect &= isecSS(ps[i][i2],ps[j][j2],ps[k][0],ps[k][1]);
            }
            if(connect){
                d[i*2+i2][j*2+j2] = abs(ps[i][i2]-ps[j][j2]);
            }
        }

        rep(k,(n+1)*2) rep(i,(n+1)*2) rep(j,(n+1)*2)
            d[i][j] = min(d[i][j], d[i][k]+d[k][j]);

        printf("%.9f\n",d[0][n*2]);
    }
    return 0;
}

Measured memory_bytes: 3792
N = int(input())
*h, = map(int, input().split())
dp = [0] * N
for i in range(1, N):
    if i == 1:
        dp[i] = dp[i-1] + abs(h[i] - h[i-1])
    else:
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
print(dp[-1])

Measured memory_bytes: 20704
#include <stdio.h>
#define N 45

void makeFibonacci(int);

int F[N];

int main() { 

  int n;

  scanf("%d", &n);

  makeFibonacci(n);

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

  return 0;
}

void makeFibonacci(int n) {

  int i;

  F[0] = 1;
  F[1] = 1;
  
  for( i = 2; i <= n; i++) {
    F[i] = F[i-1] + F[i-2];
  }

  return ;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rng(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int num = 1e9;


int main() {
  ll n;
  cin >> n;
  int x = (num-n%num)%num;
  int y = (n+x)/num;
  printf("0 0 %d 1 %d %d \n", num, x, y);
  return 0;
}

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

#define int long long
#define ll long long
#define pb push_back

main(){
    string h;
    cin >> h;
    int n = h.size();
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        a[i] = h[i] - '0';
    }
    vector<int> c(2019);
    int ost = 0;
    int ans = 0;
    c[0]++;
    int uy = 1;
    for(int i = n - 1; i >= 0; i--){
        ost += a[i] * uy;
        uy *= 10;
        ost %= 2019;
        uy %= 2019;
        ans += c[ost];
        c[ost]++;
    }
    cout << ans;
}


Measured memory_bytes: 5176
#Union Find
n,m,k=map(int, input().split())

#xの根を求める, #parents[i]＝h　はiの親はjという意味、parents[i]=iはiが根という意味
def find(x):
    if parents[x] < 0: # 負なら根
        return x
    else:
        parents[x] = find(parents[x])
        return parents[x]
    
#xとyの属する集合の併合
def unite(x,y):
    x = find(x) # x,yは根の番号にする。
    y = find(y)
    
    if x == y:
        return False
    else:
        if parents[x] > parents[y]: # sizeの大きいほうがx
            x,y = y,x
        parents[x] += parents[y]
        parents[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)


#xが属する集合の個数
def size(x):
    return -parents[find(x)]

#初期化
#根なら-size,子なら親の頂点
parents=[-1]*n

friend = [set() for _ in range(n)]

for i in range(m): # 友達リスト
    a,b=map(int,input().split())
    unite(a-1,b-1)
    friend[a-1].add(b-1)
    friend[b-1].add(a-1)
    
a=[size(i)-len(friend[i])-1 for i in range(n)]

for i in range(k):
    c,d=map(int,input().split())
    if same(c-1,d-1):
        a[c-1]-=1
        a[d-1]-=1
print(*a)

Measured memory_bytes: 112416
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
int gcd(int a,int b){return b?gcd(b,a%b):a;}    //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数

int main()
{
    long long n;
    cin >> n;
    cout << n*(n-1)/2 << endl;
}

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


int main(){
	int a, b, c, ta = 0;
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++) {
		if (c%i == 0)ta++;
	}
	cout << ta << endl;
}


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

#define pb push_back
#define all(v) ((v).begin(), (v).end())
#define sortv(v) sort(all(v))
#define sz(v) ((int)(v).size())
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define umax(a, b) (a)=max((a), (b))
#define umin(a, b) (a)=min((a), (b))
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define rep(i,n) FOR(i,1,n)
#define rep0(i,n) FOR(i,0,(int)(n)-1)
#define FI first
#define SE second
#define INF 2000000000
#define INFLL 1000000000000000000LL


using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int N;
vector<pii> v;

int main(){
	scanf("%d", &N);
	if(N%2==1){
		for(int i=1; i<N; i++){
			for(int j=i+1; j<=N; j++){
				if(j==N-i)	continue;
				v.pb({i, j});
			}
		}
	}else{
		for(int i=1; i<=N; i++){
			for(int j=i+1; j<=N; j++){
				if(j==N+1-i)	continue;
				v.pb({i, j});
			}
		}
	}
	printf("%d\n", v.size());
	for(int i=0; i<v.size(); i++){
		printf("%d %d\n", v[i].first, v[i].second);
	}
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	scan(N);
	int sanka=(N/111-(N%111==0)+1)*111;
	prin(sanka);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

  int a, b;
  int menseki, syu;

  scanf("%d %d", &a, &b);
  menseki = a * b;
  syu = a * 2 + b * 2;
  printf("%d %d\n", menseki, syu);

  return 0;

}


Measured memory_bytes: 2036
import math

def ave(A,n):
    sum=0
    for i in range(n):
        sum+=A[i]
    return (sum/n)

def stdev(A,ave,n):
    sum=0
    for i in range(n):
        sum+=(A[i]-ave)**2
    return ((sum/n)**0.5)

n=int(input())
while n!=0:
    A=list(map(float,input().split()))
    Ave=ave(A,n)
    print(stdev(A,Ave,n))
    n=int(input())


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    long long int n;
    cin>>n;
    long long int d;
    cin>>d;
    
    long long int i,x,y,cnt=0;
    
    long double ans=0.0;
    for(i=0;i<n;++i)
    {
        cin>>x>>y;
        
        ans=sqrt((long double)x*x +(long double)y*y);
        if(ans<=d)
           cnt++;
    }
    
    cout<<cnt;    

    return 0;
}

Measured memory_bytes: 3644
def main():
    s = input()
    odds = ("R", "U", "D")
    even = ("L", "U", "D")
    ans = True
    for index, i in enumerate(s, 1):
        if index % 2 == 0 and not i in even:
            ans = False
        if index % 2 != 0 and not i in odds:
            ans = False

    print("Yes" if ans == True else "No")


main()

Measured memory_bytes: 9084
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[n-1-i];
    }
    for (int i = 0; i < n; i++) {
        cout << a[i];
        if (i != n-1) cout << " ";
    }
    puts("");
    return 0;
}

Measured memory_bytes: 3064
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main() {

	string a, b;
	cin >> a >> b;

	int n = a.length();
	int m = b.length();

	if(n>m){
		ANS("GREATER");
	}
	else if (n < m) {
		ANS("LESS");
	}
	else {
		REP(i,n){
			if (a[i] != b[i]) {
				if (a[i] < b[i]) {
					ANS("LESS");
					return 0;
				}
				else if (a[i] > b[i]) {
					ANS("GREATER");
					return 0;
				}
			}

		}
		ANS("EQUAL");
	}

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long
#define rep0(i,j) for(int i=0; i<j; i++)
#define rep1(i,j) for(int i=1; i<=j; i++)
#define all(a) a.begin(), a.end()
using namespace std;

void dfs(lli ed, lli num, vector<map<lli,lli>>& vec){
    lli n=1;
    for(auto e: vec[num]){
        if(n == ed)n++;
        if(e.second != -1)continue;
        vec[num][e.first] = n;
        vec[e.first][num] = n;   
        dfs(n, e.first, vec);
        n++;
    }
}

int main(){
    lli n, x;
    cin >> n >> x;
    vector<lli> vec(n+1);
    lli size=1;
    vec[0] = 1;
    rep1(i,n){
        vec[i] = 2 * vec[i-1] + 1;
        size = 2*size + 3;
    }
    lli ans=0;
    size = (size-3)/2;
    int i=n;
    while(x>0){
        if(x == 2*size+3){
            ans += vec[i];
            break;
        }
        else if(x>1+size){
            ans += vec[i-1]+1;
            x-=size+1;
        }
        i--;
        x-=1;
        size = (size-3)/2;
    }
    printf("%lld", ans);


}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;

int main() {
    cout.precision(21);
    double a, b;
    cin >> a >> b;
    double c, d;
    cin >> c >> d;
    int m = c * 60 + d;
    double da = m / 2.0;
    double db = (m * 6) % 360;
    if(da == db){
        cout << abs(a - b) << endl;
        return 0;
    }

    double di = db - da;

    if(abs(di) == 180){
        cout << a + b << endl;
        return 0;
    }

    long double ans = 0;

    if(di > 0){
        if(di < 180){
            ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(di * M_PI / 180.0));
        } else {
            ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos((360 - di) * M_PI / 180.0));
        }
    }
    else {
        di = da - db;
        if(di < 180){
            ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(di * M_PI / 180.0));
        } else {
            ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos((360 - di) * M_PI / 180.0));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4232
#include <iostream>
#include <queue>
using namespace std;
#define PIAR pair<int, int>

int main(){
    int w, h;
    while(cin >> w >> h, w != 0 && h != 0){
        int field[52][52] = {{0}};
        for(int i = 1; i <= h; i++){
            for(int j = 1; j <= w; j++){
                cin >> field[i][j];
            }
        }

        queue<PIAR> st;
        int island = 0;
        int dx[] = {-1,  0, 1, 0, -1,  1, 1, -1};
        int dy[] = {0 , -1, 0, 1, -1, -1, 1,  1};
        for(int i = 1; i <= h; i++){
            for(int j = 1; j <= w; j++){
                //島を探す
                if(field[i][j] == 1){
                    st.push(PIAR(i, j));
                    field[i][j] = 0;
                    while(!st.empty()){
                    	int x = st.front().first;
                    	int y = st.front().second;
                        st.pop();
                        for(int k = 0; k < 8; k++){
                            int nextX = x + dx[k];
                            int nextY = y + dy[k];
                            if(field[nextX][nextY] == 1){
                                st.push(PIAR(nextX, nextY));
                                field[nextX][nextY] = 0;
                            }
                        }
                    }
                    island++;
                }

            }
        }

        cout << island << endl;
    }
}

Measured memory_bytes: 1228
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <utility>
#include <cstdlib>
#include <cmath>
#define INF 987654321
#define INT_MAX 2147483647
#define MIN(a, b) ((a) < (b) ? a : b)
#define MAX(a, b) ((a) > (b) ? a : b)
 
using namespace std;

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

    int N;
    cin >> N;
    unsigned long int mod = 1000000007;
    vector<unsigned long int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];

    unsigned long int segsum, ret;
    segsum = 0;
    ret = 0;

    for(int i = N-1; i > 0; i--) {
        segsum = (segsum + A[i]) % mod;
        ret = (ret % mod + (segsum * A[i-1]) % mod) % mod;
    }
    cout << ret;
}

Measured memory_bytes: 4424
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
#define endl "\n"
//#define int long long
#define ALL(x) begin(x),end(x)
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
//const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return ((fact(i - 1)) * i) % MOD;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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;
}
char toSmall(char c) { // 大文字を小文字へ
    return (c + 0x20);
}
char toLarge(char c) { // 小文字を大文字へ
    return (c - 0x20);
}
float myPower(int a, int n) { // aのn乗の計算
    float x = 1;
    while (n > 0) { // 全てのbitが捨てられるまで
        if (n & 1) { // 一番右のbitが１のとき
            x *= a;
        }
        a *= a;
        n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
    }
    return x;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である
    // 6の倍数前後の数を使って試し割りをする
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
/*signed*/int main(void) {
    ll n, h, w;
    ll ans = 0;
    cin >> n >> h >> w;
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        if (h <= a && w <= b) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<queue>
using namespace std;
#define rep(i, n) for (int i=0; i<(int) (n);i++)
using ll = long long;
using P = pair<int,int>;

void solve_8(){//7m
    string a, b;
    cin >> a >> b;
    string tmp =  a+b;
    int c = atoi(tmp.c_str());
    //cout << c << endl;
    int c_square = sqrt(c);
    cout << (c_square * c_square == c? "Yes": "No") << endl;
    
}

void solve_8re(){
    string a, b;
    cin >> a >> b;
    //stoi -> int
    //stol -> long
    //stof -> float
    int c = stoi(a+b);
    int c_square = sqrt(c);
    cout << (c_square * c_square == c? "Yes": "No")<< endl;
}

void solve_9(){//12m
    int n,k;
    cin >> n >> k;
    int sum_distance = 0;
    rep(i, n){
        int x;
        cin >> x;
        sum_distance += 2 * min(x, k-x);
    }
    cout << sum_distance;
}

void solve_10(){//7m
    int n;
    cin >> n;
    priority_queue<int> pq;
    int a;
    rep(i, n){
        cin >> a;
        pq.push(a);
    }
    int alice = 0, bob = 0;
    int turn = 0;
    while(!pq.empty()){
        a = pq.top();
        pq.pop();
        if (turn % 2 == 0){
            alice += a;
        }
        else{
            bob += a;
        }
        turn += 1;
    }
    cout << alice - bob;
    
}
#include<algorithm>
void solve_10re(){
    int n;
    cin >> n;
    vector<int> a;
    int a_;
    rep(i, n){
        cin >> a_;
        a.push_back(a_);
    }
    sort(a.begin(), a.end(), greater<int>());
    int total = 0;
    rep(i, n){
        total += (i%2==0?a[i]:-a[i]);
    }
    cout << total;
}

void solve_11(){
    int n;
    cin >> n;
    int score;
    rep(i,7){
        if (n >= pow(2, i))
        {
            score = pow(2,i);
        }
    }
    cout << score;
}

void solve_E(){
    
}

void solve_F(){
    
}

int main(){
    //solve_8re();
    //solve_9();
    //solve_10re();
    solve_11();
    //solve_E();
    //solve_F();
    return 0;
}

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

using namespace std;
using ll = long long;

const int maxn = 1e5+10;

int ps[maxn];

void solve(){
	int n,ans=0;
	cin >> n;
	vector<int> v(n);
	for(int i=0;i<n;++i){
		cin >> v[i];
		ps[v[i]]++;
	}
	for(int i=maxn-1;i>=0;--i){
		ps[i]+=ps[i+1];
		if(ps[i] == n-ps[i])
			++ans;
	}
	cout << ans << '\n';
}

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

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

int wa[1000000] ;
bool ac[1000000] ;
int main() {
	ll n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		wa[i] = 0;
		ac[i] = false;
	}
    int wacnt = 0, accnt = 0;
	while(m--){
		int x;
		string s;
		cin>>x>>s;
		if(ac[x]) continue;
		if(s == "AC"){
			ac[x] = true;
			accnt++;
			wacnt += wa[x];
		}
		else if(s == "WA"){
			wa[x]++;
		}
	}

	cout<<accnt << " " << wacnt;
	
    

	return 0;
}
/*6 20
1 WA
1 WA
1 WA
1 WA  
2 WA
2 WA
2 WA 
3 AC
4 WA
5 AC
5 AC
5 WA
5 AC
5 WA
6 AC
6 AC
6 WA
6 WA
6 AC
6 WA*/

Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>

using namespace std;


#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;


/*vectorの要素を全部確認するやつだよ。普通に拡張for文したほうがいいよ。

for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}

*/


/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

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


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}

*/


/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/


/*実行開始からの経過時間を表すよ。

while (clock() < 1900000) {  }

*/


/*まだ使えないテクニックのメモだよ。

for (int bit = 0; bit < (1<<n); ++bit)//bit全探索用のfor文だよ

*/


/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/

int main() {
	int W, H, x, y; cin >> W >> H >> x >> y;

	cout << setprecision(20) << W * 1.0 * H / 2.0 << " ";

	if (W % 2 == 0 && H % 2 == 0) {
		if (W / 2 == W - x && H / 2 == H - y) {
			cout << 1 << endl; return 0;
		}
	}

	cout << 0 << endl;



	return 0;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

static const ll INF = 1e15;

const ll mod = 1000000007;

bool ok(const char* c, int size) {
	for (int i = 0; i < size / 2; i++) {
		if (c[i] != c[size - 1 - i]) {
			return false;
		}
	}
	return true;
}

int main(void)
{
	int n;
	cin >> n;
	vector<ll> vs(n);
	rep(i, n) cin >> vs[i];
	map<ll, ll> m;
	rep(i, n) {
		m[vs[i]]++;
	}
	ll sums = 0;
	for (auto c : m) {
		sums += (c.second) * (c.second - 1) / 2;
	}
	vector<ll> ans(n);
	rep(i, n) {
		auto c = m[vs[i]];
		auto k = sums - (c * (c - 1)) / 2 + (c - 1) * (c - 2) / 2;
		ans[i] = k;
	}
	rep(i, n) {
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 12672
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
vector<int>edge[10];
bool seen[8];
int dfs(int s,int n,bool seen[8]){
    bool ful =true;
    rep(i,n){
        if(!seen[i])ful=false;
    }
    if(ful)return 1;
    int sum =0;
    for(int ne:edge[s]){
        if(seen[ne])continue;
        seen[ne]=true;
        sum +=dfs(ne,n, seen);
        seen[ne]=false;
    }
    return sum;
}
int main(){
   int n,m;cin>>n>>m;
   rep(i,m){
       int a,b;
       cin>>a>>b;
       a--;b--;
       edge[a].push_back(b);
       edge[b].push_back(a);
   }
   bool seen[n];
   rep(i,n)seen[i]=false;
   seen[0]=true;
   cout<<dfs(0,n,seen)<<endl;
}

Measured memory_bytes: 256
import sys

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

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    H, W, N = in_nn()
    sy, sx = in_nn()
    S = in_s()
    T = in_s()

    # left
    now_x = sx
    for i in range(N):
        if S[i] == 'L':
            now_x -= 1
        if now_x == 0:
            print('NO')
            exit()
        if T[i] == 'R' and now_x < W:
            now_x += 1

    # right
    now_x = sx
    for i in range(N):
        if S[i] == 'R':
            now_x += 1
        if now_x == W + 1:
            print('NO')
            exit()
        if T[i] == 'L' and now_x > 1:
            now_x -= 1

    # up
    now_y = sy
    for i in range(N):
        if S[i] == 'U':
            now_y -= 1
        if now_y == 0:
            print('NO')
            exit()
        if T[i] == 'D' and now_y < H:
            now_y += 1

    # down
    now_y = sy
    for i in range(N):
        if S[i] == 'D':
            now_y += 1
        if now_y == H + 1:
            print('NO')
            exit()
        if T[i] == 'U' and now_y > 1:
            now_y -= 1

    print('YES')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9964
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define pp pair<int,int>
#define ll long long
#define ld long double
int inf=100000000;
ll INF=4000000000000000000;
ll MOD=1000000007;


int main() {
   ll n,k;
   cin >> n >> k;
   vector<vector<int>> d(n+1,vector<int>(0));
   rep(i,n-1){
       int a,b;
       cin >> a >> b;
       d.at(a).push_back(b);
       d.at(b).push_back(a);
   } 
   ll ans=k;
   vector<int> c(n+1);
   rep(i,n+1) c.at(i)=0;
   queue<int> q;
   q.push(1);
   while(!q.empty()){
       int p=q.front();
       ll g=0,h=0;
       q.pop();
       c.at(1)=1;
       rep(i,d.at(p).size()){
        if (c.at(d.at(p).at(i))==0) {g++;c.at(d.at(p).at(i))=1;q.push(d.at(p).at(i));}
        else h++;
       }
       if (g==0) continue;
       if (k-h-1<g) {cout << 0 << endl;return 0;}
       if (g==1 && p==1) ans=(ans*(k-1))%MOD;
       else if (g==1) ans=(ans*(k-2))%MOD; 
       else {
           ll e=1;
           for (ll j=0;j<g;j++){
               ans=ans*(k-h-1-j)%MOD;
           }
       } 
       //ans=ans*combination(k-h-1,g)%MOD;
       //cout << combination(k-h-1,g)%MOD << endl;
   }
   cout << ans << endl;
}


Measured memory_bytes: 6904
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int A = sc.nextInt();
    if (X < A) {
      System.out.println(0);
    } else {
      System.out.println(10);
    }
  }
}


Measured memory_bytes: 23252