akhauriyash/Code-Regression huggingface dataset:
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto M = RD;
	auto PY = new long[][](M, 2);
	foreach (i; 0..M)
	{
		PY[i] = [RD-1, RD];
	}
	auto index = PY.MAKE_IDX!"a[1] < b[1]"();

	auto cnt = new long[](N);
	auto ans = new long[][](M, 2);
	foreach (i; index)
	{
		auto p = PY[i][0];
		++cnt[p];
		ans[i] = [p+1, cnt[p]];
	}

	foreach (e; ans)
	{
		auto s1 = e[0].to!string;
		foreach (_; 0..6-s1.length) s1 = "0" ~ s1;
		auto s2 = e[1].to!string;
		foreach (_; 0..6-s2.length) s2 = "0" ~ s2;

		writeln(s1, s2);
	}
	stdout.flush();
	debug readln();
}

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

typedef pair<int,int> Pii;

int main(){
  int w,h;
  cin >> h >> w;

  vector<Pii> b;
  bool ok[1000][1000] = {false};
  for(int y = 0;y < h;y++){
    string s;
    cin >> s;
    for(int x = 0;x < w;x++){
      if(s[x] == '#'){
	ok[x][y] = true;
	b.push_back(Pii(x,y));
      }
    }
  }
  int cnt = b.size();
  int ret = 0;
  while(cnt < w*h){
    vector<Pii> nb;
    for(int i = 0;i < b.size();i++){
      int x = b[i].first;
      int y = b[i].second;
      if(x > 0){
	if(!ok[x-1][y]){
	  ok[x-1][y] = true;
	  cnt++;
	  nb.push_back(Pii(x-1,y));
	}
      }
      if(x < w-1){
	if(!ok[x+1][y]){
	  ok[x+1][y] = true;
	  cnt++;
	  nb.push_back(Pii(x+1,y));
	}
      }
      if(y > 0){
	if(!ok[x][y-1]){
	  ok[x][y-1] = true;
	  cnt++;
	  nb.push_back(Pii(x,y-1));
	}
      }
      if(y < h-1){
	if(!ok[x][y+1]){
	  ok[x][y+1] = true;
	  cnt++;
	  nb.push_back(Pii(x,y+1));
	}
      }
    }
    ret++;
    b = nb;
  }
  cout << ret << endl;
}


Measured memory_bytes: 13928
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> h(n);
    for(int& x : h) {
        scanf("%d", &x);
    }
    vector<int> dp(n, INF);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j : {i + 1, i + 2}) {
            if(j < n) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }
    printf("%d\n", dp[n-1]);
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    int food[M+1] = {0};
    int ans = 0;

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

    for (int i = 1; i <= M ; i++)    {
        if(food[i] == N) ans++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>
#include <vector>
#include <math.h>

using namespace std;

int main() {
	long long n;
	cin >> n;
	
	long long rt = (long long) floor(std::sqrt(n));
	long long ans = rt+2;
	
	for (long long i = 1; i<=rt; i++) {
		if (n % i == 0) {
			ans = i + n / i;
		}
	}
	
	cout << ans-2 << endl;

	return 0;
}


Measured memory_bytes: 256
/*****And nothing else matters!******/

#include<bits/stdc++.h>
using namespace std;

#define pi 3.1415926535
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ll long long
#define llu unsigned long long
#define setbits(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define tc int test_case; cin >> test_case; while(test_case--)
#define f(i,a,n) for(int i = a ; i < n ; i++)
#define rf(i,n,a) for(int i = n-1 ; i >= a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define sp(x) fixed << setprecision(10) << x
#define fast ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trace(x) cerr << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cerr<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

const int inf = 1e9;
const ll inf64 = 1e18;
const int mod = inf + 7;
const int N = 1e6 + 10;

int main()
{
    fast;
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({a*c,a*d,b*c,b*d});
}


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

ll N,M,S,T;
struct Edge{
    ll to,a,b;
};
vector<Edge> edges[100010];
ll aFromS[100010];
ll aFromT[100010];
ll bFromT[100010];
ll minCost[100010];
int main(){
    cin>>N>>M>>S>>T;
    S--;T--;
    for(ll i=0;i<M;i++){
        ll u,v,a,b;
        cin>>u>>v>>a>>b;
        u--;v--;
        edges[u].push_back(Edge{v,a,b});
        edges[v].push_back(Edge{u,a,b});
    }
    for(ll i=0;i<N;i++){
        aFromS[i]=INF;
        aFromT[i]=INF;
        bFromT[i]=INF;
    }
    priority_queue<P,vector<P>,greater<P>> pq;
    //Sからの円
    aFromS[S]=0;
    pq.push(P(0,S));
    while(!pq.empty()){
        ll now=pq.top().second;
        ll cost=pq.top().first;pq.pop();
        if(cost>aFromS[now])continue;
        for(auto e:edges[now]){
            ll newCost=aFromS[now]+e.a;
            if(newCost<aFromS[e.to]){
                aFromS[e.to]=newCost;
                pq.push(P(newCost,e.to));
            }
        }
    }

    //Tからの円
    aFromT[T]=0;
    pq.push(P(0,T));
    while(!pq.empty()){
        ll now=pq.top().second;
        ll cost=pq.top().first;pq.pop();
        if(cost>aFromT[now])continue;
        for(auto e:edges[now]){
            ll newCost=aFromT[now]+e.a;
            if(newCost<aFromT[e.to]){
                aFromT[e.to]=newCost;
                pq.push(P(newCost,e.to));
            }
        }
    }

    //Tからのスヌーク
    bFromT[T]=0;
    pq.push(P(0,T));
    while(!pq.empty()){
        ll now=pq.top().second;
        ll cost=pq.top().first;pq.pop();
        if(cost>bFromT[now])continue;
        for(auto e:edges[now]){
            ll newCost=bFromT[now]+e.b;
            if(newCost<bFromT[e.to]){
                bFromT[e.to]=newCost;
                pq.push(P(newCost,e.to));
            }
        }
    }

    set<P> minCosts;
    for(ll i=0;i<N;i++){
        minCost[i]=aFromS[i]+bFromT[i];
        minCosts.insert(P(minCost[i],i));
    }
    for(ll i=0;i<N;i++){
        cout<<1000000000000000-minCosts.begin()->first<<endl;
        minCosts.erase(P(minCost[i],i));
    }
    return 0;
}

Measured memory_bytes: 20472
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <utility>
#include <algorithm>

using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    int N;
    int H[20];
    cin>>N;
    rep(i,N) cin>>H[i];
    int ans=1;
    int temp=H[0];
    rep(i,N-1){
        if(temp<=H[i+1]) {
            ans++;
            temp=H[i+1];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    FOR(i, 0, n) {
        cin >> a[i];
    }


    // -+-+ 
    long long minx = LLONG_MAX;
    FOR(sign, 0, 2) {
        long long now = 0;
        long long cnt = 0;
        FOR(i, 0, n) {
            bool positive = ((i+sign) % 2  == 0);
            now += a[i];
            if (positive && now <= 0) {
                cnt += 1 - now;
                now = 1;
            }
            else if (!positive && now >= 0) {
                cnt += now + 1;
                now = -1;
            }
        }
        minx = min(minx, cnt);
    }

    cout << minx << endl;
    return 0;
}

Measured memory_bytes: 640
sx,sy,tx,ty = map(int,input().split())
ans = ''
for i in range(tx-sx):
    ans += 'R'
for i in range(ty-sy):
    ans += 'U'
ans += 'R'
for i in range(ty-sy+1):
    ans += 'D'
for i in range(tx-sx+1):
    ans += 'L'
ans += 'U'
for i in range(ty-sy):
    ans += 'U'
for i in range(tx-sx):
    ans += 'R'
ans += 'U'
for i in range(tx-sx+1):
    ans +='L'
for i in range(ty-sy+1):
    ans += 'D'
ans += 'R'
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
    int input[10];
    for (int i = 0; i < 10; i++) {
        scanf("%d", &input[i]);
    }
    sort(input, input+10, greater<int>());
    for (int i = 0; i < 3; i++) {
        printf("%d\n", input[i]);
    }
}


Measured memory_bytes: 2680
nnnnn = 101010
P = 10**9+7

fa = [1]
for i in range(1, nnnnn):
    fa.append(fa[-1] * i % P)
fainv = [pow(fa[-1], P-2, P)]
for i in range(1, nnnnn)[::-1]:
    fainv.append(fainv[-1] * i % P)
fainv = fainv[::-1]

N = int(input())
A = [int(a) for a in input().split()]
B = [A[i+1] - A[i] for i in range(N-1)]
S = [0]
for i in range(1, N):
    S.append((S[-1] + fainv[i] * fa[i-1]) % P)

ans = 0
for i in range(N-1):
    ans = (ans + B[i] * S[i+1]) % P

print(ans * fa[N-1] % P)



Measured memory_bytes: 68932
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
const double PI = acos(-1);
 
int main() {
	int n;
	int ans = 0;
	cin >> n;
	int a, b;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		ans += b - a + 1;
	}
	cout << ans << endl;
}

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

int main() {
    string s;
    cin >> s;
    string week[6] = {"MON", "TUE", "WED", "THU", "FRI", "SAT"};

    int ans = 0;
    rep(i, 6) {
        if (s == week[i]) {
            cout << 7 - (i + 1) << endl;
            return 0;
        }
    }
    cout << 7 << endl;

    return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/agc040/tasks/agc040_a

#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>
#include <stack>
#include <math.h>
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define RREP(i,n) for(ll i=(n)-1; i>=0; --i)
#define SREP(i,s,n) for(ll i=(s), i##_len=(n); i<i##_len; ++i)
#define ALL(v) (v).begin(),(v).end()

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

bool comp(pair<ll, ll> a, pair<ll, ll> b) {
    return a.second > b.second;
}

struct UnionFind {
    vector<int> par;
    vector<int> rank;
    
    UnionFind(int n = 1) {
        init(n);
    }
    
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            rank[i] = 0;
        }
    }
    
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

#define MOD (1000000007)
#define BIGNUM (ll(1e18))

int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string S;
    cin >> S;
    vector<ll> a(S.size()+1);
    REP(i, S.size()) {
        if (S[i] == '<') {
            if (i == 0 || S[i-1] == '>') {
                a[i] = 0;
            }
            a[i+1] = a[i]+1;
        }
    }
    REP(j, S.size()) {
        int i = S.size()-j;
        if (S[i-1] == '>') {
            if (i == S.size() || S[i] == '<') {
                a[i] = 0;
            }
            a[i-1] = max(a[i]+1, a[i-1]);
        }
    }
    
    ll score = 0;
    
    REP(i, S.size()+1) {
        score += a[i];
    }
    
    cout << score << endl;
}


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

int main() {
  int N, T;
  cin >> N >> T;
  int ans = 1001;
  vector<int> c(N);
  vector<int> t(N);
  for (int i = 0; i < N; i++) {
    cin >> c.at(i) >> t.at(i);
  }
  for (int i = 0; i < N; i++) {
    if (t.at(i) <= T)
      ans = min(ans, c.at(i));
  }
  if (ans == 1001)
    cout << "TLE" << endl;
  else
    cout << ans << endl;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

double MAXV[40010];
int T[110], V[110];

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

	int N;
	cin >> N;
	int sumt = 0;
	fill(MAXV, MAXV + 40010, (double)INF);
	rep(i, 0, N)
	{
		cin >> T[i];
		T[i] *= 2;
	}
	rep(i, 0, N)
	{
		cin >> V[i];
	}
	rep(i, 0, N)
	{
		rep(j, 1, T[i] + 1)
		{
			chmin(MAXV[sumt + j], (double)V[i]);
		}
		rep(j, 0, sumt + 1)
		{
			chmin(MAXV[j], (double)V[i] + (sumt - j) / 2.0);
		}
		sumt += T[i];
	}

	rep(j, 0, sumt + 1)
	{
		chmin(MAXV[j], (sumt - j) / 2.0);
	}

	double vel = 0.0;
	double ans = 0.0;
	rep(i, 0, sumt)
	{
		double nvel = min(MAXV[i + 1], vel + 0.5);
		ans += (vel + nvel) / 2.0;
		vel = nvel;
	}

	cout << fixed << setprecision(12) << ans/2.0 << endl;

	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

// find_by_order(k) returns the iterator to the kth largest element (start from 0)
// order_of_key(k) returns the number of elements in the set which are strictly less than the value k

using namespace std;
using namespace __gnu_pbds;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define rightmostbit(x) __builtin_ffsll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         cout << fixed; cout << setprecision(x); cout << y;
#define pi              3.141592653589793238
#define mk(a,n)         int n;cin>>n;vi a(n);for(int i=0;i<n;i++) cin>>a[i]
#define w(x)            int x; cin>>x; while(x--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

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

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void g_b()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}
int32_t main()
{
	g_b();
	string 	s; cin >> s;
	int c = 0;
	int mx = 0;
	for (int i = 0; i  < 3; ++i)
	{
		if (s[i] == 'R')c++;
		else c = 0;
		mx = max(mx, c);
	}

	cout << mx;

	return 0;
}

Measured memory_bytes: 3556
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int N, M, L, R, Lmax, Rmin;
	cin >> N >> M;
	Lmax = 1; Rmin = N;

	for(int i = 0; i < M; i++)
	{
		cin >> L >> R;
		if(Lmax < L) Lmax = L;
		if(Rmin > R) Rmin = R;
	}
	
	cout << max(Rmin - Lmax + 1, 0) << endl;

	return 0;
}

Measured memory_bytes: 256
import static java.lang.System.*;
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int ans = 0;
        String s = sc.next();
        if((s.equals("SSR")) || (s.equals("SRS")) || (s.equals("RSS")) || (s.equals("RSR"))){
            ans = 1;
        }else if((s.equals("RRS")) || (s.equals("SRR"))){
            ans = 2;
        }else if(s.equals("RRR")){
            ans = 3;
        }else if(s.equals("SSS")){
            ans = 0;
        }
        out.println(ans);
        
    }
}

Measured memory_bytes: 35636
from collections import defaultdict
N, M = map(int, input().split())
L = []
for i in range(M):
  L += [input().split()]

WA = defaultdict(lambda: 0)
cnt_AC = 0
alr = set()
for j, k in L:
  j = int(j)
  if j in alr:
    continue
  if k == 'AC':
    cnt_AC += 1
    alr.add(int(j))
  else:
    WA[j] += 1

print(cnt_AC, sum(WA[l] for l in alr))

Measured memory_bytes: 52008
// https://atcoder.jp/contests/abc147/tasks/abc147_c
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn isok(p: usize, talks: &Vec<Vec<(usize, usize)>>) -> bool {
    let n = talks.len();
    for i in 0..n {
        if (p >> i) & 1 == 0 {
            continue;
        }
        for &(j, f) in &talks[i] {
            if (p >> j) & 1 != f {
                return false;
            }
        }
    }
    true
}

fn main() {
    input! {
        n: usize,
        talks: [[next / (usize1, usize)]; n]
    };

    let mut best = 0;
    for i in 0..(1<<n) {
        if isok(i, &talks) {
            best = max(best, (i as u64).count_ones());
        }
    }

    println!("{}", best);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#include<cmath>
#include <iostream>
int main(){
    static const double pi = 3.141592653589793;
    int a,b;double h,m;cin>>a>>b>>h>>m;
    double zkaku=h*30+m*0.50;
    double hkaku=m*6;
    double kaku=abs(zkaku-hkaku);
    if(kaku>180)kaku=360-kaku;
    double ans=0;
    ans=sqrt(pow(a,2)+pow(b,2)-2*a*b*cos((kaku/180)*pi));
    cout<<setprecision(12)<<ans<<endl;
}

Measured memory_bytes: 4144
#include<stdio.h>
int main(){
    int D;
    scanf("%d",&D);
    if(D==25){
      printf("Christmas\n");
    }else if(D==24){
      printf("Christmas Eve\n");
    }else if(D==23){
      printf("Christmas Eve Eve\n");
    }else if(D==22){
      printf("Christmas Eve Eve Eve\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
// $ cp-batch  Interpretation | diff  Interpretation.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address  Interpretation.cpp && ./a.out
/*

 2018/8/12

 23:05-23:17 anslysis
 23:28 got AC after 1RE fix (path compression bug)

 Editorials:
  - http://competitive-kivantium.hateblo.jp/entry/2016/11/26/201016
  - https://kimiyuki.net/writeup/algo/atcoder/code-festival-2016-final-c/

 Summary:
  - I didn't have idea to reduce to bipartite graph

 6/22/2020

 21:17-21:30 solve again

 */


const int MAX_N=1e5+1;
int N,M;
VI L[MAX_N];

struct UF {
public:
  int N,G/* # of disjoint sets */;
  UF(int N): N(N) { init(N); }
  void init(int N) {
    par=vector<int>(N),sz=vector<int>(N,1);
    for(int i=0; i<N; ++i) par[i]=i,sz[i]=1;
    G=N;
  }
  int find(int x) { return par[x]==x?x:par[x]=find(par[x]); }
  int size(int x) { return sz[find(x)]; }
  bool sameset(int x, int y) { return find(x)==find(y); }
  int unite(int x, int y) {
    x=find(x),y=find(y);
    if(x==y) return x;
    int p=x,c=y;
    if(sz[p]<sz[c]) swap(p,c);
    G--,sz[p]=sz[c]=sz[p]+sz[c];
    par[c]=p;
    return p;
  }
private:
  vector<int> par,sz;
};

void solve() {
  UF uf(N);
  REPE(i,M) REP(j,SZ(L[i])-1) uf.unite(L[i][j],L[i][j+1]);
  cout<<(uf.G==1?"YES":"NO")<<endl;
}


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

  cin>>N>>M;
  REP(i,N) {
    int K; cin>>K;
    REP(j,K) {
      int l; cin>>l;
      L[l-1].push_back(i);
    }
  }
  solve();
  return 0;
}


Measured memory_bytes: 7920
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <sys/types.h>
#include <unistd.h>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


struct BIT{
  vector<int> bit;
  int n;
  //1-indexed
  BIT(){init(-1);}
  BIT(int n_){init(n_);}
  void init(int n_){
    n=n_;
    bit.clear();
    bit.resize(n+1,0);
  }
  int sum(int i){
    int s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }
  void add(int i,int x){
    if(i==0) return;
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
  int sum0(int i){
    return sum(i+1);
  }
  void add0(int i,int x){
    add(i+1,x);
  }
};
signed main(void) {
    int n,k;
    cin >> n >> k;
    int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  if(n == k){
      rep(i,n)if(a[i] == 1){
          rep(j,n)if(a[(i+j)%n] != a[i]+j){
              cout << "No" << endl;
              return 0;
          }
      }
      cout << "Yes" << endl;
      return 0; 
  }
  if(k%2 == 0){
      cout << "Yes" << endl;
      return 0;
  }
  reverse(a,a+n);
  BIT bit(n+10);
  int ans=0;
  for(int i=0;i<n;i++){
    ans+=bit.sum(a[i]);
    bit.add(a[i],1);
}
  if(ans%2){
      cout << "No" << endl;
  }else{
      cout << "Yes" << endl;
  }

}



Measured memory_bytes: 4388
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int n,q;
	while(cin>>n>>q,n+q){
		string s,p,g;
		cin>>s>>p>>g;
		map<string,int>m;
		int co=1;
		vvi cost(n+1,vi(n+1,inf));
		while(q--){
			string a,b;
			int d,t;
			cin>>a>>b>>d>>t;
			if(m[a]==0)m[a]=co++;
			if(m[b]==0)m[b]=co++;
			cost[m[a]][m[b]]=cost[m[b]][m[a]]=d/40+t;
		}
		rep(k,n+1)rep(i,n+1)rep(j,n+1)
			cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
		cout<<cost[m[s]][m[p]]+cost[m[p]][m[g]]<<endl;
	}
}

Measured memory_bytes: 2296
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() >> 3)*rand()
#define scan(X) do{while((X=getchar())<'0'); for(X-='0'; '0'<=(_=getchar()); X=(X<<3)+(X<<1)+_-'0');}while(0)
char _;
#define pi 3.14159265358979323846

int n, a[10005], b[10005];
ll c, c2;
int main(){
    cin >> n;
    fox(l, n) cin >> a[l];
    fox(l, n){
        cin >> b[l];
        if (a[l]>b[l]) c+=a[l]-b[l];
        else c-=((b[l]-a[l])/2);
    }
    if (c<=0) cout << "Yes";
    else cout << "No";
    return 0;
}


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

using namespace std;

char s[100005];
int main() {
    long long ans = 0;
    int w, h;
    scanf("%d %d", &w, &h);
    vector<pair<int, string>> e;
    for (int i = 0; i < w; ++i) {
        int a;
        scanf("%d", &a);
        e.push_back({a, "W"});
    }

    for (int i = 0; i < h; ++i) {
        int a;
        scanf("%d", &a);
        e.push_back({a, "H"});
    }

    sort(e.begin(), e.end());

    int cnt_w = w + 1;
    int cnt_h = h + 1;
    for (int i = 0; i < w + h; ++i) {
        auto p = e[i];
        if (p.second == "W") {
            ans += 1LL * cnt_h * p.first;
            cnt_w--;
        }
        else {
            ans += 1LL * cnt_w * p.first;
            cnt_h--;
        }
    }

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 13548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！

const ll MX = 1e18;
int main() {
    int n;
    cin >> n;
    ll ans = 1;
    bool ng = false;
    rep(i,n){
        ll a;
        cin >> a;
        if(a == 0){
            cout << 0 << endl;
            return 0;
        }
        if(ng || MX/ans < a){ //本当はMX < a*ansとやりたい
            ng = true;
        }
        ans *= a;
    }
    if(ng) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int X, Y, Z, K;
    vector<ll> A, B, C;
    vector<ll> AB;

    void input() {
        cin >> X >> Y >> Z >> K;
        A.resize(X);
        B.resize(Y);
        C.resize(Z);

        rep(i, 0, X) cin >> A[i];
        rep(i, 0, Y) cin >> B[i];
        rep(i, 0, Z) cin >> C[i];
    }

    int cnt(ll lim) {
        int ret = 0;
        for (auto e : C) {
//            ret += AB.end() - AB.begin() - (lower_bound(all(AB), lim - e) - AB.begin());
            ret += AB.end() - lower_bound(all(AB), lim - e);
        }
        return ret;
    }

    vector<ll> rekkyo(ll lim) {
        vector<ll> ret;
        sort(AB.rbegin(), AB.rend());
        sort(C.rbegin(), C.rend());

        for (auto c : C) {
            for (auto ab : AB) {
                if (ab + c >= lim) ret.push_back(ab + c);
                else break;
            }
        }
        sort(ret.rbegin(), ret.rend());
        return ret;
    }

    void solve() {
        input();

        for (auto a : A) {
            for (auto b : B) {
                AB.push_back(a + b);
            }
        }

        sort(AB.begin(), AB.end());
        sort(C.begin(), C.end());

        auto ok = 0ll;
        auto ng = INFl;

        while (ng - ok > 1) {
            ll mid = (ok + ng) / 2;
            int tmp = cnt(mid);
            if (tmp <= K) {
                //すくない
                ng = mid;
            } else {
                ok = mid;
            }
        }

        auto vec = rekkyo(ok);
//        cout << vec[K - 1] << endl;
        for (int i = 0; i < K; ++i) {
            cout << vec[i] << endl;
        }
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


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

int main(){
    int n,a[n];
    cin >> n;
    int count=0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(i%2==0 && a[i]%2==1){
            count=count+1;
        }
    }
    cout << count << endl;
    return 0;
}

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

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll A, B, C, D, E, F;
  std::cin >> A >> B >> C >> D >> E >> F;

  ll maxa = F / (A * 100);
  ll maxb = F / (B * 100);

  ld max_calc = 0.0;
  std::pair<ll, ll> ans = std::make_pair(100 * A, 0);
  for (ll a = 0; a <= maxa; a++) {
    for (ll b = 0; b <= maxb; b++) {
      ll water = (a * A + b * B) * 100;
      ll max_sugar = water * E / 100;

      if (a + b == 0 || water > F) continue;

      ll maxc = max_sugar / C;
      ll maxd = max_sugar / D;
      //print(water, max_sugar, maxc, maxd);
      for (ll c = 0; c <= maxc; c++) {
	for (ll d = 0; d <= maxd; d++) {
	  ll sugar = c * C + d * D;
	  if (sugar > max_sugar) continue;
	  if (sugar + water > F) continue;
	  ld calc = 100.0 * sugar / (water + sugar);
	  //printf("water %Ld sugar %Ld calc %.9Lf max_calc %.9Lf\n", water, sugar, calc, max_calc);
	  if (calc > max_calc) {
	    max_calc = calc;
	    ans = std::make_pair(sugar + water, sugar);
	  }
	}
      }
    }
  }

  print(ans.first, ans.second);
  return 0;
}


Measured memory_bytes: 256
def solve(n, k, d_arr, arr):
    ans = []
    for _ in range(n):
        ans.append(0)

    for i in range(k):
        ele = arr[i]
        for j in arr[i]:
            ans[j-1] += 1
    return ans.count(0)

if __name__ == "__main__":
    n, k = map(int, input().split(' '))
    d_arr = []
    arr = []
    for _ in range(k):
        d_arr.append(int(input()))
        arr.append([int(s) for s in list(input().split())])
    print(solve(n, k, d_arr, arr))

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

#define INF (1<<30)

int N;
int a[100005];
int dp[100005];

int main(){

  cin >> N;

  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  
  fill(dp,dp+N,INF);

  for(int i = 0; i < N; i++){
    *lower_bound(dp,dp+N,a[i]) = a[i];
  }

  cout << lower_bound(dp,dp+N,INF) - dp << endl;



}

Measured memory_bytes: 1940
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath> 
#include <queue>
#include <functional>

using namespace std;
//typedef long long ll;
//typedef pair<int, int> P;
//static const int dx[4] = {1, -1, 0, 0};
//static const int dy[4] = {0, 0, 1, -1};

//const ll MOD = 1e+9 + 7;

int main() {

    string S; cin >> S;
    int p, g;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == 'p') p++;
        else g++;
    }
    int max_p = S.size() / 2;
    int max_g = (S.size()+1) / 2;


    int ans = max_p - p;
    cout << ans << '\n';


}


Measured memory_bytes: 512
import * as fs from "fs";

// inputで受け取り配列化する
const [L, R, d] = fs.readFileSync("/dev/stdin", "utf8").split(" ").map(Number);

let cnt = 0;

for (let index = L; index <= R; index++) {
  if (index % d === 0) {
    cnt++;
  }
}

console.log(cnt);


Measured memory_bytes: 29708
# 木上の累積和

import sys
from collections import defaultdict
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))


def ints():
    return list(map(int, read().split()))


N, Q = ints()
tree = defaultdict(lambda: [])
for _ in range(N - 1):
    a, b = mina(*ints())
    tree[a].append(b)
    tree[b].append(a)
cnt = [0] * N
for _ in ra(Q):
    q, x = ints()
    cnt[q - 1] += x
cnt.append(0)  # -1アクセス用

# dfsでcntに木に沿った累積和をsetしていく


def dfs(u, p):  # uは現在のノード、pは親のノード
    cnt[u] += cnt[p]
    for nv in tree[u]:
        if nv == p:
            continue
        dfs(nv, u)


dfs(0, -1)

print(*cnt[:-1])


Measured memory_bytes: 232200
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

vector<int> g[100001];

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);

    vector<vector<int> > b(m, vector<int>(int(100000 + m - 1) / m));
    vector<int> s(m, 0);
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        b[x % m][x / m] += 1;
        s[x % m] += 1;
    }

    int ans = 0;
    for (int i = 0; i * 2 <= m; ++i) {
        if (i == 0 || i * 2 == m) {
            ans += s[i] / 2;
        } else {
            int mi = min(s[i], s[m - i]);
            ans += mi;
            if (s[i] - mi >= + 2) {
                for (int j = 0; j < int(100000 + m - 1) / m; ++j) {
                    for (int k = 0; b[i][j] >= 2 && s[i] - mi >= 2; ++k) {
                        b[i][j] -= 2;
                        ans += 1;
                        mi += 2;
                    }
                }
            } else if (s[m - i] - mi >= + 2) {
                for (int j = 0; j < int(100000 + m - 1) / m; ++j) {
                    for (int k = 0; b[m - i][j] >= 2 && s[m - i] - mi >= 2; ++k) {
                        b[m - i][j] -= 2;
                        ans += 1;
                        mi += 2;
                    }
                }
            }
        }
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
map<int,int>mp;
map<char,int>::iterator it;
  vector<int>v[1000];
int main()
{
string s,s1;
cin>>s>>s1;
int l,l1,c=0,f=0,d,r,m;
l=s.length();
l1=s1.length();
if(l>l1){cout<<"GREATER"<<endl;}
else if(l<l1){cout<<"LESS"<<endl;}
else
{
    for(int i=0;i<l;i++)
    {
      if(s[i]!=s1[i])
      {
          d=s[i]-'0';
          m=s1[i]-'0';
          if(d>m){f=1;}
          else{f=2;}

          break;
      }
    }
    if(f==0){cout<<"EQUAL"<<endl;}
    else if(f==1){cout<<"GREATER"<<endl;}
    else{cout<<"LESS"<<endl;}
}



}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<math.h>

int main() {
	double r,s, c;

	scanf("%lf", &r);

	s = r * r * M_PI;
	c = 2 * r * M_PI;

	printf("%f %f\n", s, c);

	return 0;

}


Measured memory_bytes: 2060
A=[]
for _ in range(3):
    A+=map(int,input().split())

N=int(input())
for _ in range(N):
    b=int(input())
    if b in A:
        A[A.index(b)]=0

for i,j,k in [
    (0,1,2),(3,4,5),(6,7,8),
    (0,3,6),(1,4,7),(2,5,8),
    (0,4,8),(2,4,6),
]:
    if A[i]==A[j]==A[k]:
        print('Yes')
        break
else:
    print('No')


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

int n, k;
long a[3010];
long dp[3010][3010];
bool done[3010][3010];

long solve(int l, int r, int cnt){
  if(done[l][r]) return dp[l][r];
  done[l][r] = true;
  if(cnt%2==0) return dp[l][r] = max(solve(l+1, r, cnt+1)+a[l], solve(l, r-1, cnt+1)+a[r]);
  return dp[l][r] = min(solve(l+1, r, cnt+1)-a[l], solve(l, r-1, cnt+1)-a[r]);
}

int main(){
  cin >> n;
  rep(i, n) cin >> a[i];
  rep(i, n){
    rep(j, n){
      dp[i][j] = 0;
      done[i][j] = false;
    }
    dp[i][i] = (2*(n%2)-1) * a[i];
    done[i][i] = true;
  }
  cout << solve(0, n-1, 0) << endl;
}

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

int main(void){
	int i ,j, k;
	long long int sum;
	int n, m, l;
	int **mat_a, **mat_b;
	long long int **mat_c;
	
	scanf("%d %d %d\n", &n ,&m, &l);
	
	mat_a = (int **)malloc(sizeof(int *) * n);
	if(mat_a == NULL){  exit(1); }
	for(i = 0; i < n; i++){
		mat_a[i] = malloc(sizeof(int) * m);
		if(mat_a[i] == NULL){ exit(1); }
	}
	
	mat_b = (int **)malloc(sizeof(int *) * m);
	if(mat_b == NULL){  exit(1); }
	for(i = 0; i < m; i++){
		mat_b[i] = malloc(sizeof(int) * l);
		if(mat_b[i] == NULL){ exit(1); }
	}

	mat_c = (long long int **)malloc(sizeof(long long int *) * n);
	if(mat_c == NULL){  exit(1); }
	for(i = 0; i < n; i++){
		mat_c[i] = malloc(sizeof(long long int) * l);
		if(mat_c[i] == NULL){ exit(1); }
	}
	
	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++){
			scanf("%d", &mat_a[i][j]);
		}
	}
	for(i = 0; i < m; i++){
		for(j = 0; j < l; j++){
			scanf("%d", &mat_b[i][j]);
		}
	}
	
	for(i = 0; i < n; i++){
		for(j = 0; j < l; j++){
			sum = 0;
			for(k = 0; k < m; k++){
				sum += mat_a[i][k] * mat_b[k][j];
			}
			mat_c[i][j] = sum;
		}
	}

	for(i = 0; i < n; i++){
		for(j = 0; j < (l-1); j++){
			printf("%lld ", mat_c[i][j]);
		}
		if(j == (l-1)) printf("%lld\n", mat_c[i][l-1]);
	}
	
	for(i = 0; i < n; i++){
		free(mat_a[i]);
	}
	free(mat_a);

	for(i = 0; i < m; i++){
		free(mat_b[i]);
	}
	free(mat_b);
	
	for(i = 0; i < n; i++){
		free(mat_c[i]);
	}
	free(mat_c);

	return 0;
}


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

int main()
{
  string S, T = "CODEFESTIVAL2016";
  cin >> S;
  int ans = 0;
  for (int i = 0; i < 16; i++)
  {
    if (S[i] != T[i])
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
use proconio::{input};
fn main() {
    input!{
        n: u64,
    }
    if n % 2 == 0 || n % 5 == 0 {
        println!("{}", -1);
    } else {
        let mut r = 0;
        for i in 1..=n {
            r = (r * 10 + 7) % n;
            if r == 0 {
                println!("{}", i);
                return;
            }
        }
    }
}


Measured memory_bytes: 2128
import sys

input = sys.stdin.readline


def main():
    N = int(input())

    f = [0] * (10000 + 1)
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                n = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
                if n <= 10000:
                    f[n] += 1

    print("\n".join(map(str, f[1:N + 1])))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9584
A, B, C, D = map(int, input().split())
count = 0
while A > 0 and C > 0:
    count += 1
    if count % 2 == 1:
        C -= B
    else:
        A -= D
if count % 2 == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 61956