akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<(int)c;i++)
#define print(var) cout<<var<<endl;
#define DEBUG(var) cerr<<var<<endl;
// puts("str");

const int inf = 1000000000;//10^9

int main (){

  string S;
  vector<char> A;
  int it=0;

  cin >>S;
  rep(i,S.size()){
    if(S[i]=='0'){
      A.push_back('0');
      it++;
    }else if(S[i]=='1'){
        A.push_back('1');
        it++;
    }else{
      if(A.size()>0){
        A.pop_back();
      }
    }
  }

  rep(i,A.size()){
    cout<<A[i];
  }
  cout <<endl;




  return 0;

}


Measured memory_bytes: 256
alpha2num = lambda c: ord(c) - ord('a') + 1
c = [0] * 27

h, w = map(int, input().split())
s = [[] for _ in range(h)]
for i in range(h):
    s[i] = list(input())
    for j in range(w):
        c[alpha2num(s[i][j])] += 1

if h % 2 == 0 and w % 2 == 0:
    flag = 1
elif h % 2 == 0 and w % 2 == 1:
    flag = 2
elif h % 2 == 1 and w % 2 == 0:
    flag = 3
elif h % 2 == 1 and w % 2 == 1:
    flag = 4


#print(c)
c1 = 0
c2 = 0
for i in range(len(c)):
    if c[i] % 4 == 1:
        c1 += 1
    elif c[i] % 4 == 2:
        c2 += 1
    elif c[i] % 4 == 3:
        c1 += 1
        c2 += 1

#print(c1, c2)

ans = 'No'
if flag == 1:
    if c1 == c2 == 0:
        ans = 'Yes'
elif flag == 2:
    if c1 == 0 and c2 <= h//2:
        ans = 'Yes'
elif flag == 3:
    if c1 == 0 and c2 <= w//2:
        ans = 'Yes'  
else:
    if c1 == 1 and c2 <= h//2 + w//2:
        ans = 'Yes'

print(ans)

Measured memory_bytes: 3188
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>


using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i*i<=n; i++) {
    if(n%i==0) {
      ret.push_back(i);
      if(i*i!=n)ret.push_back(n/i);
    }
  }
  return ret;
}


void solve(long long N){
  vector<ll> v = divisor(N);
  ll ans = 0;
  for(auto &x : v) {
    if(x-1>0 and N/(x-1) == N%(x-1)) {
      ans+=x-1;
    }
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  solve(N);
  return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
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;
}

signed main()
{
    int A, B;
    cin >> A >> B;
    cout << A - B + 1 << endl;
    // system("pause");
}

Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<vector>
#include<set>
#include<cstring>
#include<string>
#include<map>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<bitset>
#include<queue>
#include<sstream>
#include<climits>
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1e9;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
int main(){
	int a,b,ans=0;
	cin>>a>>b;
	for(int i=a;i<=b;i++){
		if(i/10000==i%10){
			if(i/1000%10==i/10%10){
				ans++;
			}
		}
	}
	cout<<ans;
	return 0;
}
 

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

int main() {
  int n;
long long X=0,x=0,ans=1000000000000000000LL;
cin>>n;
vector<long long> a(n);
for(int i=0;i<n;i++){
cin>>a[i];
X+=a[i];
}
for(int i=0;i<n;i++){
x+=a[i];
if(i+1<n)ans=min(ans,abs(X-2*x));
}
cout<<ans<<endl;
  return 0;
}


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


map<int,int> mp;

int main(){
	int n,x;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> x;
		mp[x]++;
	}
	
	int sum=0;
	for(auto a:mp){
		if(a.first<a.second) sum+=a.second-a.first;
		else if(a.first>a.second) sum+=a.second;
	}
	cout << sum << endl;
	return 0;
}

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

int main() {
  long K,n,m;
  cin >> K;
  cout << 50 << endl;
  n = K%50;
  m = K/50;
  for (int i=0; i<50-n; i++) {
    cout << 49+m-n;
    if (i == 49) {
      break;
    }
    cout << ' ';
  }
  for (int i=50-n; i<50; i++) {
    cout << 50+m;
    if (i == 49) {
      break;
    }
    cout << ' ';
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vp = vector<pii>;
using vs = vector<string>;
using qi = queue<int>;
using qp = queue<pii>;
using pqi = priority_queue<int>;
using pqim = priority_queue<int, vector<int>, greater<int> >;
using ppp = pair<int, pair<int, int>>;
#define all(vec) vec.begin(), vec.end()
#define rall(vec) vec.rbegin(), vec.rend()
#define pb push_back
const ll mod = 998244353;
//const ll inf = 1e18;
const int inf = 1e9 + 7;
const int mxn = 2e5;

int n;
vl a;


void input() {

	cin >> n;
	a = vl(n);
	for (ll& x : a) cin >> x;

}

void solve() {

	ll tot = 0;
	for (ll x : a) tot ^= x;

	for (ll x : a) {
		cout << (x ^ tot) << ' ';
	}

	return;
}

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

	input();
	solve();
}

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


int main(){
  char A[11], copy;
  int i, j;

  //  for(j = 0; j < 3; j ++){
    i = scanf("%s", A);
    copy = A[strlen(A) - 1];

    for(j = 1; j < 3; j ++){
      i = scanf("%s", A);
      if(copy != A[0]){
	printf("NO\n");
	return 0;
      }
      copy = A[strlen(A) - 1];
    }
    printf("YES\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int b,c,e;
int main() {
    int n1,n2;
    cin>>n1;
    vector<int> a(n1);
    for(int i=0;i<n1;i++){
        cin>>a[i];
    }
    cin>>n2;
    while(n2--){
        int b,c;
        cin>>b>>c;
        reverse(a.begin()+b,a.begin()+c);
    }
    for(int i=0;i<n1;i++){
        if(i) cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
}



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

#define ll long long 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
#define push push_back
#define cini(i) int i;cin >> i;

using namespace std;

int main(){
	fastio
	cini(k);
	cini(n);
	vector<int> v;
	for(int i = 0;i < n;i++){
		int temp;
		cin >> temp;
		v.push(temp);
	}
	int ma = 0;
	for(int i = 1;i < v.size();i++){
		ma = max(ma,abs(v[i-1]-v[i]));
	}
	cout << k - max(ma,k-v.back()+v[0]);
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")



int main()
{

string s;
	cin >> s;
	if (s=="ABC") {
		ce("ARC")
	}
	else {
		ce("ABC")
	}
    return 0;
}



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

#define FRE(i,a,b)  for(i = a; i <= b; i++)
#define FRL(i,a,b)  for(i = a; i < b; i++)
#define mem(t, v)   memset ((t) , v, sizeof(t))
#define all(x)      x.begin(),x.end()
#define un(x)       x.erase(unique(all(x)), x.end())
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sl(n)       scanf("%lld", &n)
#define sll(a,b)    scanf("%lld %lld", &a, &b)
#define slll(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define D(x)        cerr << #x " = " << (x) << '\n'
#define DBG         cerr << "Hi" << '\n'
#define pb          push_back
#define PI          acos(-1.00)
#define xx          first
#define yy          second
#define eps         1e-9

typedef unsigned long long int ULL;
typedef long long int LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;


inline int setBit(int N, int pos) { return N=N | (1<<pos); }
inline int resetBit(int N, int pos) { return N= N & ~(1<<pos); }
inline bool checkBit(int N, int pos) { return (bool)(N & (1<<pos)); }

//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction

int edge[110][110], dist[110][110], n, m;
const int inf = 1e9;
bool ok(int a, int b)
{
//    cout << a << " " << b << endl;
    for(int i = 1; i<=n; i++)
    {
        for(int j = 1; j<=n; j++)
        {
            if(dist[i][a] + edge[a][b] + dist[b][j] == dist[i][j])
                return true;
        }
    }
//    cout << a << " " << b << endl;
    return false;
}
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int i, j, cs, t,  u, v, c;
    sff(n,m);
    for(int i = 1; i<=n; i++)
    {
        for(int j = 1; j<=n; j++)
        {
            edge[i][j] = inf;
            if(i == j)
                continue;
            dist[i][j] = inf;
        }
    }
    FRE(i,1,m)
    {
        sfff(u,v,c);
        dist[u][v] = dist[v][u] = edge[u][v] = edge[v][u] = c;
    }
    for(int k = 1; k<=n; k++)
    {
        for(int i = 1; i<=n; i++)
        {
            for(int j = 1; j<=n; j++)
            {
                dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
            }
        }
    }
//    for(int i = 1; i<=n; i++)
//    {
//        for(int j = 1; j<=n; j++)
//            cout << dist[i][j] << " ";
//        puts("");
//    }
//    while(true);
    int ans = 0;
    for(i = 1; i<=n; i++)
    {
        for(j = 1; j<i; j++)
        {
            if(edge[i][j] != inf)
                ans += !ok(i,j);
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 384
s = input()
l = len(s)
ans = ""

for bit in range(2**(l-1)):
  formula = ""
  for i in range(l):
    formula += s[i]
    if ((bit>>i) & 1) > 0:
      formula += "+"
    else:
      formula += "-"
  formula = formula[:len(formula)-1]
  if eval(formula) == 7:
    ans = formula+"=7"
    break
print(ans)


      
    
    

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
string N;
  cin>>N;
  int n=N.size();
  bool ans=true;
  for(int i=0;i<n/2;i++){
  if(N.at(i)!=N.at(n-1-i)){
    ans=false; break;
  }
  
  }if(ans)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
struct edge{
	int k,w,next;
}e[1005];
int n,m,f[100005][20],home[20],cnt=-1,sum[100005],ed[20];
void add(int x,int y,int w){
	cnt++;
	e[cnt].k=y;
	e[cnt].w=w;
	e[cnt].next=home[x];
	home[x]=cnt;
}
int main(){
	memset(home,-1,sizeof(home));
	scanf("%d%d",&n,&m);
	for(int i=1,x,y,w;i<=m;i++){
		scanf("%d%d%d",&x,&y,&w);
		add(x,y,w);add(y,x,w);
		ed[x]|=(1<<y-1);
		ed[y]|=(1<<x-1);
	}
	for(int i=0;i<(1<<n);i++){
		for(int p=1;p<=n;p++) if(i&(1<<p-1)){
			for(int j=home[p];~j;j=e[j].next) if(i&(1<<e[j].k-1)){
				if(e[j].k<p) sum[i]+=e[j].w;
			}
		}
	}
	for(int i=1;i<(1<<n);i++){
		for(int p=1;p<=n;p++) f[i][p]=-1e9;
	}
	f[1][1]=0;
	int ans=1e9;
	for(int i=1;i<(1<<n);i+=2){
		for(int p=1;p<=n;p++)if(i&(1<<p-1)){
			for(int j=home[p];~j;j=e[j].next) if(!(i&(1<<e[j].k-1))){
				f[i|(1<<e[j].k-1)][e[j].k]=max(f[i|(1<<e[j].k-1)][e[j].k],f[i][p]+e[j].w);
			}
			int S=((1<<n)-1)^i;
			for(int j=S;j;j=(j-1)&S){
				f[i|j][p]=max(f[i|j][p],f[i][p]+sum[j|(1<<p-1)]);
			}
		}
		if(i&(1<<n-1)) ans=min(ans,sum[(1<<n)-1]-f[i][n]);
	}
	printf("%d",ans);
	return 0;
}

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

bool tsort(vector<int> &S, const vector<vector<int>> &edges) {
    int V = edges.size();

    vector<int> indeg(V, 0);
    for(int i = 0; i < V; ++i) {
        for(int to : edges[i]) ++indeg[to];
    }

    stack<int> done;
    for(int i = 0; i < V; ++i) {
        if(indeg[i] == 0) done.push(i);
    }

    while(!done.empty()) {
        int cur = done.top();
        done.pop();
        S.push_back(cur);
        for(int to : edges[cur]) {
            --indeg[to];
            if(indeg[to] == 0) done.push(to);
        }
    }

    return S.size() == V;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> edges(N);
    for(int i=0; i<N-1+M; ++i) {
      int a, b;
      cin >> a >> b;
      --a; --b;
      edges[a].push_back(b);
    }

    vector<int> order;
    tsort(order, edges);

    vector<int> par(N);
    vector<int> depth(N);
    par[order[0]] = -1;
    depth[order[0]] = 0;
    for(int i=0; i<N; ++i) {
        int cur = order[i];
        for(int to : edges[cur]) {
            if(depth[to] < depth[cur] + 1) {
                par[to] = cur;
            }
            depth[to] = depth[cur] + 1;
        }
    }

    for(int i=0; i<N; ++i) {
        cout << par[i] + 1 << endl;
    }
}

Measured memory_bytes: 7408
#include<iostream>
 
using namespace std;
 
int main()
{
int a,b;
  cin>>a>>b;
  string c=to_string(a),d=to_string(b);
 	if(a==0 || b==0){cout<<-1<<endl;return 0;}
 	if(c.size()>1 || d.size()>1){cout<<-1<<endl; return 0;}
  cout<<a*b<<endl;
  return 0;}

Measured memory_bytes: 256
//他の人の提出は大体において天才的ということですか
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
inline ll getll() {
	ll A = 0;
	if (ci - cn + 24 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	ll N = getint(), K = getll();
	int A[200000], F[200000];
	rep(i, N) A[i] = getint();
	rep(i, N) F[i] = getint();
	pakuri_sort(N, A);
	pakuri_sort(N, F);

	ll L = -1, R = 1e12;
	while (L + 1 < R) {
		ll M = (L + R) / 2;

		ll kazu = 0;
		rep(i, N) {
			kazu += max(0ll, A[i] - M / F[N - i - 1]);
			if (kazu > K) break;
		}
		if (kazu > K) L = M;
		else R = M;
	}

	printf("%lld", R);


	Would you please return 0;
}

Measured memory_bytes: 2688
extern crate core;

use std::io::{self, Read};
use std::collections::HashMap;

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input.trim().to_string());
    println!("{}", output);
}

fn run(input: String) -> String {
    let n = input
        .split_whitespace()
        .skip(1)
        .map(|x| x.parse::<i32>().unwrap())
        .fold(HashMap::new(), |mut map, x| {
            let v = map.get(&x).map(|i| i + 1).unwrap_or(1);
            map.insert(x, v);
            map
        })
        .into_iter()
        .filter(|&(_, x)| x % 2 != 0)
        .count();
    n.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!(super::run($input.to_string()), $output.to_string());
                }
            )*
        }
    }
}

tests! {
    test1: "3
6
2
6" => "1",
    test2: "4
2
5
5
2
" => "0",
test3:"6
12
22
16
22
18
12"=>"2",
}


Measured memory_bytes: 10492
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int n = 100;
        /*
        long n = long.Parse(Console.ReadLine());
        long[] input = new long[5];
        for(int a = 0; a < 5; a++)
        {
            input[a]=long.Parse(Console.ReadLine());
        }
        */
        string[] input = Console.ReadLine().Split().Select(i => (i)).ToArray();

        Console.WriteLine(input[0][0]+""+input[1][0]+""+input[2][0]);

        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法

        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();
        
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n; cin>>n;
    string s; cin>>s;
    vector <int> w(n);
    vector <int> e(n);
    for(int i=0;i<n;i++){
        w[i]=w[i-1];
        if(s[i]=='W') w[i]++;
    }
    for(int i=n-1;i>=0;i--){
        e[i]=e[i+1];
        if(s[i]=='E') e[i]++;
    }
   /* for(int i=0;i<n;i++){
        cout<<w[i];
    }
    cout<<endl;
    for(int i=0;i<n;i++){
        cout<<e[i];
    }*/
    int ans=5000000;
    for(int i=0;i<n;i++){
        int tmp;
        if(i==0) tmp=e[1];
        else if(i==n-1) tmp=w[n-2];
        else tmp=w[i-1]+e[i+1];
        if(tmp<ans) ans=tmp;
    }
    cout<<ans<<endl;
}

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

using namespace std;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, A, B;
    cin >> N >> A >> B;
    ll ans = 0;
    ll q = N / (A + B);
    ans += A * q;
    ll rest = N - (A + B) * q;
    ans += min(rest, A);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
int main()
{
	for(int N, W;;){
		std::cin >> N >> W;
		if(N == 0 and W == 0){break;}
		std::vector<int> num(101,0);
		int max = 0;
		for(int i = 0, a; i < N; i++){std::cin >> a, num[a/W]++, max = std::max(max,a/W);}
		if(max == 0){std::cout << 1<< std::endl; continue;}
		std::vector<double> h(max+1, 0);
		const int M = *std::max_element(num.begin(),num.end());
		double ans = 0;
		const double d = 1.0/(max);
		for(int i = 0;i <= max; i++){ans += (double)num[i]/M * d*(max-i);}
		std::cout << std::fixed << std::setprecision(10) << ans+0.01 << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3232
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
#include <unordered_map>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
typedef __int128 bi;
const bi MOD=1000000000000000003LL;
bi qp(bi a,bi b)
{
	bi x=1; a%=MOD;
	while(b)
	{
		if(b&1) x=x*a%MOD;
		a=a*a%MOD; b>>=1;
	}
	return x;
}
const bi g=233,rg=qp(g,MOD-2);
pair<bi,bi> operator +
(pair<bi,bi> a,pair<bi,bi> b)
{return mp((a.fi+a.se*b.fi)%MOD,a.se*b.se%MOD);}
#define SZ 666666
int n; char str[SZ];
pair<bi,bi> sg[SZ],tg(0,1),qz[SZ];
ll ans=0;
int main()
{
	scanf("%d%s",&n,str+1);
	for(int i=1;i<=n;++i)
	{
		if(str[i]=='+') sg[i]=mp(1,1);
		else if(str[i]=='-') sg[i]=mp(MOD-1,1);
		else if(str[i]=='>') sg[i]=mp(0,g);
		else sg[i]=mp(0,rg); tg=tg+sg[i];
	}
	qz[0]=mp(0,1);
	for(int i=1;i<=n;++i) qz[i]=qz[i-1]+sg[i];
	map<ll,int> ms;
	for(int i=n;i>=0;--i)
	{ 
		//A.fi+tg.fi*A.se=C.fi
		ans+=ms[(qz[i].fi+tg.fi*qz[i].se)%MOD];
		++ms[qz[i].fi];
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 48128
fn main() {
	use std::io::Read;
	let mut s = String::new();
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let p: Vec<i8> = s.map(|a| a.parse().unwrap()).collect();
	let ans = (1..n - 1).filter(|&i| (p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1])).count();
	println!("{}", ans);
}


Measured memory_bytes: 4352
unittest
{
	assert( [ "atcoder beginner contest" ].parse.expand.solve == "ABC" );
	assert( [ "resident register number" ].parse.expand.solve == "RRN" );
	assert( [ "k nearest neighbor" ].parse.expand.solve == "KNN" );
	assert( [ "async layered coding" ].parse.expand.solve == "ALC" );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ss = input.front.split;
	return tuple( ss );
}

auto solve( string[] ss )
{
	auto r = "";
	foreach( s; ss )
	{
		r ~= s[ 0 ].toUpper;
	}
	return r;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cassert>
#include <stdlib.h>
#include <string.h>
#include <sstream>
#include <iostream>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <algorithm>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <string>
#include <iomanip>
 
#ifdef LOCAL_CODE
	#define DEBUG(x) cerr << "[" << #x << '=' << x << "]" << endl;
#else
	#define DEBUG(x) do {} while(0);
#endif
 
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define PER(i, N) for(int i = (N)-1; i >= 0; i--)
#define REP(i, N) for(int i = 0; i < (int)(N); i++)
using namespace std;
typedef long long ll;
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.first >> p.second; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.first << ' ' << p.second; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}
template<typename T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using maxheap = priority_queue<T, vector<T>, less<T>>;
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

ll n,m,k;//A,B,C,D;
void solve(istream& cin, ostream& cout) {
	int h1,m1, h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	int T1 = h1*60+m1, T2 = h2*60+m2;
	cout << max(0, (T2-T1)-k) << endl;
}


int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	solve(cin, cout);
	/*
	{
		istringstream instr("2\n2\n14");
		solve(instr, cout);
	}
 */
	return 0;
}


Measured memory_bytes: 3648
import java.util.*;
public class Main {
	public static void main(String[] args) {
		int ct[] = new int [26];
		int i;
		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		char[] c = S.toCharArray();
		for(i = 0; i < c.length; i++) {
			ct[c[i] - 'a']++;
		}
		for(i = 0; i < ct.length; i++) {
			if(ct[i] == 0) break;
		}
		if(i == 26) System.out.println("None"); 
		else {
			char s = (char) i;
			s = (char) (s + 'a');
			System.out.println(s);
		}
		scan.close();
	}
}

Measured memory_bytes: 26244
import Data.List

main = do
  n <- readLn :: IO Int

  mapM_ print $ solve n

  where
    solve n = if m-n == 0 then [1..length xs] else delete (m-n) [1..length xs]
      where
        xs = takeWhile' (<n) (scanl1 (+) [1..])
        m = last xs
    takeWhile' f (x:xs) = x : (if f x then takeWhile' f xs else [])


Measured memory_bytes: 1276
import java.util.Scanner;

public class Main {

    public Main(){
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        String S = sc.next();

        if(S.length() <= K){
            System.out.println(S);
        } else {
            for (int i = 0; i < K; i++) {
                System.out.print(S.charAt(i));
            }
            System.out.println("...");
        }
    }

    public static void main(String[] args) {
        Main M = new Main();
    }
}


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

int main()
{
	int h,w;
	cin >> h >> w;
	vector<vector<int>> a(h,vector<int>(w));
	for(int i = 0;i<h;i++)
		for(int j = 0;j<w;j++)cin >> a[i][j];

	vector<tuple<int,int,int,int>> ans;
	for(int i = 0;i<h;i++)
		for(int j = 0;j<w-1;j++)
		{
			if(a[i][j]%2==1)
			{
				a[i][j+1]++;
				ans.push_back(make_tuple(i,j,i,j+1));
			}
		}

	for(int i = 0;i<h-1;i++)
	{
		if(a[i].back()%2==1)
		{
			a[i+1][w-1]++;
			ans.push_back(make_tuple(i,w-1,i+1,w-1));
		}
	}
	cout<<ans.size()<<endl;
	for(int i = 0;i<ans.size();i++)
	{
		cout<<get<0>(ans[i])+1<<' '<<get<1>(ans[i])+1<<' '<<get<2>(ans[i])+1
			<<' '<<get<3>(ans[i])+1<<endl;
	}
	return 0;
}


Measured memory_bytes: 5232
#include <stdio.h>

void print(int n,int a[]){

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

    if(i) printf(" ");
    printf("%d",a[i]);

  }

  puts("");

}

int main(){

  int n,i;
  int a[1000];

  scanf("%d",&n);

  for(i=0;i<n;i++) scanf("%d",&a[i]);

  for(i=0;i<n;i++){

    int v=a[i];
    int j=i-1;

    for(;j>=0 && a[j]>v;j--) a[j+1]=a[j];

    a[j+1]=v;

    print(n,a);

  }

  return 0;

}



Measured memory_bytes: 2072
n=int(input())
a=input()
b=input()
c=input()
ans=0
for i in range(n):
    if a[i]==b[i]==c[i]:
        continue
    elif a[i]!=b[i] and a[i]!=c[i] and b[i]!=c[i]:
        ans+=2
    else:
        ans+=1
print(ans)


Measured memory_bytes: 9180
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int[] vs = Console.ReadLine().Split().Select(p => int.Parse(p)).OrderBy(p => p).ToArray();

			int sum = vs[0] + vs[1];

			Console.WriteLine(sum);
		}
	}
}


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

using namespace std;

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

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

int main()
{

    int n, p, a[100];
    bool gu = true;
    cin >> n >> p;
    ll ans = 1;

    REP(i, n)
    {
        cin >> a[i];
        if (a[i] % 2 != 0)
            gu = false;

        ans *= 2;
    }

    if (gu)
    {
        if (p == 0)
            cout << ans << endl;
        else
            cout << 0 << endl;
    }
    else
        cout << ans / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define endl '\n'
#define mod 1000000007
#define inf 1000000000000000000
const double pi = acos(-1);
const int sz = 100002;
int n, m, w, h,s;
vector<int>graph[sz];
vector<ll>d, p;
vector<bool>vis;
void bfs(int i) {
	vis[i] = true;
	queue<int>q;
	q.push(i);
	d[i] = 0;
	while(!q.empty()) {
		int u = q.front();
		q.pop();
		for(auto v : graph[u]) {
			if(!vis[v]) {
				d[v] = d[u] + 1;
				vis[v] = true;
				p[v] = u;
				q.push(v);
			}
		}
	}
}
int main() {
	io
	cin>>n>>m;
	for(int i = 0; i<m; i++) {
		int a, b;
		cin>>a>>b;
		graph[a].pb(b);
		graph[b].pb(a);
	}
	d.assign(n+1, inf);
	p.assign(n+1, -1);
	vis.assign(n+1, false);
	bfs(1);
	bool can = true;
	for(int i = 1; i<=n; i++) {
		if(d[i] == inf) {
			can  = false;
			break;
		}
	}
	if(can) {cout<<"Yes"<<endl;
	for(int i = 2; i<=n; i++) {
		cout<<p[i]<<endl;
	}}
	else cout<<"No"<<endl;
}





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

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

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

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

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

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

// dp[i][j]: i人未満のグループだけでj人振り分ける場合の数 i人のグループをk個作るとすると遷移は
// dp[i+1][j+ik] += dp[i][j] * (n-j)Ci * (n-j-i)Ci * ... * (n-j-i(k-1))Ci / k! (グループ自体は区別しないため)
// 後半部分は (n-j+ik)Pik / i!^k / k! とまとまる 階乗と逆元を事前計算しとけばいい
ll n, a, b, c, d, dp[1010][1010], f[1010], fin[1010], inv[1010];

ll mpow(ll x, ll n) {
	ll res = 1;
	while (n>0) {
		if (n&1) res = res * x %mod;
		x = x * x %mod;
		n >>= 1;
	}
	return res;
}

ll comb(ll n, ll k) {return f[n] * fin[k] %mod *fin[n-k] %mod;}

signed main() {
	cin >> n >> a >> b >> c >> d;
	rep(i,1010) dp[i][0] = 1;
	// f[i]==i! fin[i]==i!^(mod-2) inv[i]==i^(mod-2)
	f[0] = fin[0] = 1;
	reps(i,1,1010) {
		inv[i] = mpow(i,mod-2);
		f[i] = f[i-1]*i %mod;
		fin[i] = fin[i-1]*inv[i] %mod;
	}
	repst(i,a,b) {
		rept(j,n) {
			if (dp[i][j]==0) continue;
			// i人のグループを一つも作らない
			if (j!=0) dp[i+1][j] = (dp[i+1][j] + dp[i][j]) %mod;
			ll p = 1;
			repst(k,1,d) {
				if (j+i*k>n) break;
				p = p * comb(n-j-i*(k-1), i) %mod * inv[k] %mod;
				if (c<=k) dp[i+1][j+i*k] = (dp[i+1][j+i*k] + dp[i][j]*p) %mod;
			}
		}
	}
	cout << dp[b+1][n] << ln;
}

Measured memory_bytes: 8192
fn main() {
    let mut input_iter = read_line_as_vector::<usize>().into_iter();
    let n = input_iter.next().unwrap();
    let m = input_iter.next().unwrap();
    let prices: Vec<i64> = read_line_as_vector();

    let mut heap = std::collections::BinaryHeap::new();
    for price in prices {
        heap.push(price);
    }

    for _ in 0..m {
        let target = heap.pop().unwrap();
        heap.push(target / 2);
    }
    println!("{}", heap.iter().sum::<i64>());
}

fn read_line_as_vector<T: std::str::FromStr>() -> Vec<T> {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().split_whitespace().map(|x| x.parse()).collect::<Result<Vec<T>, _>>() {
        Ok(vec) => vec,
        _ => panic!("error while parsing input: {}", input)
    }
}

Measured memory_bytes: 4068
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////



int main() {
	ll N;
	string s;
	cin >> N >> s;
	ll K = s.size();

	vector<vector<mint>> dp(N + 1, vector<mint>(N + 2, 0));
	dp[0][0] = 1;

	repn(i, N) {
		dp[i][0] = dp[i - 1][0] + dp[i - 1][1];

		repn(j, N) {
			dp[i][j] =  dp[i - 1][j - 1]*2 + dp[i - 1][j + 1];
		}
	}

	mint ans = dp[N][K];

	repn(i, K) ans /= 2;
	cout << ans << endl;
	
	system("PAUSE");
}


Measured memory_bytes: 196096
import java.util.Scanner;
class Main{
    public void kozueteacher() {
    Scanner sc = new Scanner(System.in); 
    int x = sc.nextInt();
        int y = x * x;
        int z = y * x;
        System.out.println(z);
    }
    public static void main(String[] args) {
        new Main().kozueteacher();
    }
}

Measured memory_bytes: 17156
n,m=[int(i) for i in input().split()]
datalist=[[int(j) for j in input().split()] for i in range(m)]
# print(datalist)


#先頭と末尾の値を取得
head=1
tail=n

#全てのゲートについて、範囲を狭めていく
for data in datalist:
    
    if data[0]>head:
        head=data[0]
    if data[1]<tail:
        tail=data[1]
        
ans=tail-head+1
if ans<0:
    print(0)
else:
    print(ans)

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

int main() {
  char S[100010];
  scanf("%s", S);
  int len = strlen(S);
  
  int ans1 = 0, ans2 = 0;
  for (int i = 0; i < len; i++) {
    if (i % 2 == S[i] - '0') {
      // 黒色スタート時の塗り替え数を検証
      ans1++;
    } else {
      // 白色スタート時の塗り替え数を検証
      ans2++;
    }
  }

  printf("%d", min(ans1, ans2));
  return 0;
}

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

using namespace std;

int idconv(string s)
{
	int res = 0;
	for (int i = 0; i < 3; i++)
	{
		res += (s[i] - '0');
	}
	return res;
}

int timeconv(string s)
{
	int res = 0;
	res += ((s[0] - '0') * 10 + (s[1] - '0'));
	res *= 60;
	res += ((s[3] - '0') * 10 + (s[4] - '0'));
	return res;
}

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

	int n;
	while (true)
	{
		cin >> n;
		if (n == 0)
			break;
		vector<int> sum(1000, 0);
		bool exist = false;
		vector<int> intime(1000, -1);
		for (int i = 0; i < n; i++)
		{
			string md, hm, e, p;
			cin >> md >> hm >> e >> p;
			int time = timeconv(hm), id = idconv(p);
			if (id == 0)
			{
				if (e == "I")
				{
					exist = true;
					for (int j = 1; j < 1000; j++)
					{
						if (intime[j] > 0)
							intime[j] = time;
					}
				}
				else
				{
					exist = false;
					for (int j = 1; j < 1000; j++)
					{
						if (intime[j] > 0)
						{
							sum[j] += (time - intime[j]);
						}
					}
				}
			}
			else
			{
				if (e == "I")
				{
					if (exist)
					{
						intime[id] = time;
					}
					else
					{
						intime[id] = time;
					}
				}
				else
				{
					if (exist)
					{
						sum[id] += time - intime[id];
					}
					else
					{
					}
					intime[id] = -1;
				}
			}
		}
		int ma = -1;
		for (int i = 1; i < 1000; i++)
		{
			if (sum[i] > ma)
			{
				ma = sum[i];
			}
		}
		cout << ma << endl;
	}
}


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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;
}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    ll h, w, m; cin >> h >> w >> m;
    vector<Pll> H(h, Pll(0, 0)), W(w, Pll(0, 0));
    map<Pll, ll> mp;
    REP(i, 0, h){
        H[i].second = i;
    }
    REP(i, 0, w){
        W[i].second = i;
    }
    REP(i, 0, m){
        ll x, y; cin >> x >> y;
        x--; y--;
        H[x].first++;
        W[y].first++;
        mp[Pii(x, y)]++;
    }
    sort(ALL(H), [](auto &x, auto &y){return x.first > y.first;});
    sort(ALL(W), [](auto &x, auto &y){return x.first > y.first;});
    ll Hmax = H[0].first, Wmax = W[0].first, i = 0;
    //cout << Hmax << Wmax << endl;
    ll ans = 0;
    while(i < h && Hmax - H[i].first < 1){
        int l = 0;
        while(l < w &&  Wmax - W[l].first < 1){
            if(mp[Pii(H[i].second, W[l].second)] == 1){
                chmax(ans, H[i].first + W[l].first - 1);
            }else{
                cout << H[i].first + W[l].first << endl;
                return 0;
            }
            l++;
        }
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 31520
#include <iostream>
#include <cstdio>
#include <map>
#include <vector>
#include <cstring>
#include <algorithm>
#include <list>
#include <stack>
#include <queue>
using namespace std;

typedef list<int> L;
typedef pair <int,int> P;
typedef vector<int> V;
typedef queue<int> Q;
typedef stack<int> S;
typedef map<string,int> M;

const int MAX = 21;
const int INF = 999999;

int n, m, f[MAX][MAX];
V d[MAX];

int sreach (int start, int goal) {
    int res = 0;

    int s[MAX];
    memset(s, INF, sizeof(s));
    Q q;
    q.push(start);
    s[start] = 0;

    while (q.size()) {
        int t1 = q.front(); q.pop();

        for (int i = 0; i < d[t1].size(); i++) {
            int t2 = d[t1][i];
            if (s[t2] > s[t1] + f[t1][t2]) {
                s[t2] = s[t1] + f[t1][t2];
                q.push(t2);
            }
        }
    }

    return s[goal];
}

int main()
{
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b, c, dd;
        scanf("%d,%d,%d,%d", &a, &b, &c, &dd);
        f[a][b] = c;
        f[b][a] = dd;

        d[a].push_back(b);
        d[b].push_back(a);
    }
    int x1, x2, y1, y2;
    scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);

    int res = y1 - y2;
    res -= sreach(x1, x2);
    res -= sreach(x2, x1);

    cout << res << endl;

    return 0;
}

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

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back

using namespace std;

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

typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	int n;
	cin >> n;
	
	vector<vector<pll>> g(n + 1);
	for (int i = 1; i < n; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		g[x].pb({y, z}), g[y].pb({x, z});
	}
	
	vector<ll> d(n + 1, INF);
	{
		set<pll> q;
		
		q.insert({0, 1});
		d[1] = 0;
		
		while (sz(q)) {
			int v = q.begin()->se;
			q.erase(q.begin());
			
			for (auto edge: g[v]) {
				ll to = edge.fi, len = edge.se;
				
				if (d[to] > d[v] + len) {
					q.erase({d[to], to});
					d[to] = d[v] + len;
					q.insert({d[to], to});
				}
			}
		}
	}
	
	vector<int> col(n + 1);
	for (int i = 1; i <= n; i++) {
		col[i] = !(d[i] & 1);
	}
	for (int i = 1; i <= n; i++) cout << col[i] << '\n';
	
	return 0;
}




Measured memory_bytes: 9460
// itne me hi thakk gaye?
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")
#define ll long long 
#define ull unsigned long long
using ld = long double;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const ll rk = 256;
const ld PI = 3.141592653589793;
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define print(a) for(auto j:a) {cout<<j<<",";} cout << "\n";
#define endl '\n'
#define whatis(x) cout << "> "<<#x << " ==> " << x << endl;
#define lwi(x) cout << " your " << #x << " is ---> " << x << " ";
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
// // Printing pair
ostream & operator << (ostream & os, pair <ll, ll> const& x) {
    os << x.first << "," << x.second;
    return os;
}
 
// printing vector
template <class T>
ostream & operator << (ostream & os, vector <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
// printing set
template <class T>
ostream & operator << (ostream & os, set <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
const int mxn = 1e6+5;
map<ll, ll> pfs(ll n) {
    map<ll, ll> pf;
    while(n%2 == 0) {
        n/=2;
        pf[2]++;
    }
    for(ll i=3; i<=sqrt(n); i+=2) {
        while(n%i == 0) {
            n /= i;
            pf[i]++;
        }
    }
    if(n > 2) {
        pf[n]++;
    }
    return pf;
}
int32_t main(){
    FastIO;
    ll n;
    cin >> n;
    auto pf = pfs(n);
    vc <ll> values;
    for(ll i=1; i<= 15; i++) {
        values.pb((i*(i+1)) / 2);
    }
    ll ans = 0;
    for(auto i: pf) {
        auto x = ub(all(values), i.sec);
        ans += x - values.begin();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3684
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

vector<int> primes;

bool isPrime(int i){
  if(i<=1)return false;
  for(int p:primes){
    if(p>=i)break;
    if(i%p==0)return false;
  }
  return true;
}

int main(){ _;
  primes.push_back(2);
  for(int i=3;i<10000;i+=2)
    if(isPrime(i))
      primes.push_back(i);
  int a,d,n;
  while(cin>>a>>d>>n,(a|d|n)!=0){
    int count=0;
    for(int i=0;;i++){
      if(isPrime(a+d*i)){
	count++;
	if(count==n){
	  cout<<a+d*i<<endl;
	  break;
	}
      }
    }
  }
}

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

const int mod = 1e9+7;
int main()
{
	int k ;
	cin >> n >> k ;
	char d[k];
	rep(i,k) cin >> d[i];

	for(int i = n ; i < 100000 ; i ++){
		s =to_string(i);
		int N = s.size();
		int flag = 1 ;
		rep(j,N){
			char now = s[j];
			rep(K,k){
				if (now ==d[K]){
					flag = 0 ;
					break;
				}
			}
		}
		if(flag){
			cout << s << endl;
			return 0;
		}
	}

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

class Program {
    static int Main(string[] args) {
        List<decimal[]> list = new List<decimal[]>();

        while (true) {
            string v = Console.ReadLine();
            if (string.IsNullOrEmpty(v) == true) { break; }

            string[] vs = v.Split(' ');
            decimal[] vd = new decimal[6];

            for (int i = 0; i < 6; i++) {
                vd[i] = decimal.Parse(vs[i]);
            }
            list.Add(vd);
        }

        for (int i = 0; i < list.Count; i++) {
            Calc(list[i]);
        }

        return 0;
    }

    static void Calc(decimal[] v) {
        decimal a = v[0];
        decimal b = v[1];
        decimal c = v[2];
        decimal d = v[3];
        decimal e = v[4];
        decimal f = v[5];

        decimal x = Math.Round((b * f - c * e) / (b * d - a * e), 3, MidpointRounding.AwayFromZero);
        decimal y = Math.Round((a * f - c * d) / (a * e - b * d), 3, MidpointRounding.AwayFromZero);

        Console.WriteLine(string.Format("{0:f3} {1:f3}", x, y));
    }
}

Measured memory_bytes: 9604