akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

typedef long long ll;
using std::min;
const int N = 710;
const int INF = 1e9;
int _w;
     
int n, m, g[N][N], vis[N];
     
int q[N], begin, end;
bool bfs( int s, int &a, int &b ) {
	begin = end = 0, q[end++] = s, vis[s] = 1;
	while( begin != end ) {
		int u = q[begin++];
		if( vis[u] == 1 ) ++a;
		else ++b;
		for( int v = 1; v <= n; ++v )
			if( g[u][v] ) {
				if( vis[v] == vis[u] ) return false;
				if( vis[v] == 3 - vis[u] ) continue;
				vis[v] = 3 - vis[u];
				q[end++] = v;
			}
	}
	return true;
}
     
int f[2][N][N];
     
int main() {
	_w = scanf( "%d%d", &n, &m );
	for( int i = 1; i <= n; ++i )
		for( int j = 1; j <= n; ++j )
			g[i][j] = 1;
	for( int i = 1; i <= m; ++i ) {
		int u, v;
		_w = scanf( "%d%d", &u, &v );
		g[u][v] = g[v][u] = 0;
	}
	for( int i = 1; i <= n; ++i ) g[i][i] = 0;
	f[0][0][0] = 1;
	for( int i = 1; i <= n; ++i )
		if( !vis[i] ) {
			int a = 0, b = 0;
			if( !bfs(i, a, b) )
				return puts("-1"), 0;
			for( int x = 0; x <= n; ++x )
				for( int y = 0; y <= n; ++y )
					f[1][x][y] = 0;
			for( int x = 0; x <= n; ++x )
				for( int y = 0; y <= n; ++y )
					if( f[0][x][y] )
						f[1][x+a][y+b] = f[1][x+b][y+a] = 1;
			for( int x = 0; x <= n; ++x )
				for( int y = 0; y <= n; ++y )
					f[0][x][y] = f[1][x][y];
		}
	int ans = INF;
	for( int i = 0; i <= n; ++i )
		for( int j = 0; j <= n; ++j )
			if( f[0][i][j] )
				ans = min( ans, i*(i-1)/2 + j*(j-1)/2 );
	printf( "%d\n", ans );
	return 0;
}


Measured memory_bytes: 6144
#include<iostream>
#include<vector>
using namespace std;
typedef vector<int> BigDecimal;

int n,k,m,r;
BigDecimal tmp(10010);

void Div(int x){
  int now = 1;
  for(int i=0;i<r+10;i++){
    tmp[i] = now/x;
    now %= x;
    now *= 10;
  }
}

void print(const BigDecimal &b){
  cout << b[0] << ".";
  for(int i=1;i<=r;i++)cout << b[i];
  cout << endl;
}

int main(){
  while(cin >> n >> k >> m >> r,n){
    Div(n);
    BigDecimal res = tmp;
    if(m==1){
      for(int i=1;i<n;i++){
	Div(i*n);
	for(int j=0;j<r+10;j++)res[j] += tmp[j];
      }
      for(int j=r+10-1;j>0;j--){
	res[j-1] += res[j]/10;
	res[j] %= 10;
      }
    }

    print(res);
  }
}

    

Measured memory_bytes: 1292
#include <bits/stdc++.h>
 
using namespace std;
 
#define f0r(a, b) for (long long a = 0; a < (b); a++)
#define f1r(a, b, c) for (long long a = (b); a < (c); a++)
#define f0rd(a, b) for (long long a = (b); a >= 0; a--)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define mp make_pair
#define f first
#define s second
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vpl = vector<pll>;
 
void fio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); 
  cout.tie(0);
}
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const long double pi = 3.14159265358979323846;

ll mpow(ll base, ll exp, ll mod) {
  ll res = 1;
  while (exp) {
  if (exp % 2 == 1){
    res = (res * base) % mod;
  }
  exp >>= 1;
  base = (base * base) % mod;
  }
  return res;
}

ll f(ll n) {
  if (n == 0) return 0;
  return 1 + f(n % __builtin_popcount(n));
}

void solve() {
  ll n; cin >> n;
  string s; cin >> s;

  ll c[2] = {0};
  f0r(i, n) ++c[s[i] - '0'];

  ll a[n];
  if (c[0] > 0) {
    ll m = c[1] + 1;
    ll v = 0, r = 1;
    f0rd(i, n - 1) {
      v = (v + (s[i] - '0') * r) % m;
      r = (r * 2) % m;
    }

    f0r(i, n) {
      if (s[i] == '0') {
        ll k = (v + mpow(2, n - i - 1, m)) % m;
        a[i] = 1 + f(k);
      }
    }
  }
  if (c[1] > 0) {
    ll m = c[1] - 1;
    if (m == 0) {
      f0r(i, n) if (s[i] == '1') a[i] = 0;
    } else {
      ll v = 0, r = 1;
      f0rd(i, n - 1) {
        v = (v + (s[i] - '0') * r) % m;
        r = (r * 2) % m;
      }

      f0r(i, n) {
        if (s[i] == '1') {
          ll k = (v - mpow(2, n - i - 1, m)) % m;
          k = (k + m) % m;
          a[i] = 1 + f(k);
        }
      }
    }
  }

  f0r(i, n) cout << a[i] << '\n';
}
 
int main() {
  fio();
  
  int T = 1;
  // cin >> T;
  while (T--) solve();
} 

Measured memory_bytes: 5256
n, k = gets.split.map(&:to_i)
hs = Array.new(n) { gets.to_i }
# require 'tapp'
hs.sort!
min = 999999999
(n - k + 1).times do |i|
  # i.tapp
  v = hs[i + k - 1] - hs[i]
  min = [min, v].min
end
puts min

Measured memory_bytes: 3688
#include <iostream>
#include <vector>
using namespace std;

int main(){
    int n;
    cin >> n;
    long long sum = 0;
    for (int i = 1; i <= n; i++){
        if(i % 3 == 0 || i % 5 == 0){
        }else{
            sum += i;
        }
    }
    cout << sum << endl;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];
    int res = 0;
    for (int h = 0; h <= 28; h++)
    {
        vector<int> v[2], cnt(2, 0);
        for (int i = 0; i < n; i++)
        {
            if (b[i] & (1 << h))
                v[1].push_back(b[i] & ((1 << h) - 1));
            else
                v[0].push_back(b[i] & ((1 << h) - 1));
        }
        sort(v[0].begin(), v[0].end());
        sort(v[1].begin(), v[1].end());
        for (int i = 0; i < n; i++)
        {
            int val = ((1 << h) - 1) ^ (a[i] & ((1 << h) - 1));
            if (a[i] & (1 << h))
            {
                int a = v[1].end() - upper_bound(v[1].begin(), v[1].end(), val), b = (int)v[1].size() - a;
                int c = v[0].end() - upper_bound(v[0].begin(), v[0].end(), val), d = (int)v[0].size() - c;
                cnt[1] += a, cnt[0] += b;
                cnt[1] += d, cnt[0] += c;
            }
            else
            {
                int a = v[1].end() - upper_bound(v[1].begin(), v[1].end(), val), b = (int)v[1].size() - a;
                int c = v[0].end() - upper_bound(v[0].begin(), v[0].end(), val), d = (int)v[0].size() - c;
                cnt[1] += b, cnt[0] += a;
                cnt[1] += c, cnt[0] += d;
            }
        }
        if (cnt[1] & 1)
            res |= (1 << h);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3612
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    ll n,l;
    cin>>n>>l;
    vector<ll> a(n);
    for(auto &i:a){cin>>i;}
    ll k=-1;
    for(int i=1;i<n;i++){
        if(a[i-1]+a[i]>=l){k=i; break;}
    }
    if(k==-1){cout<<"Impossible"<<endl;}
    else{
        cout<<"Possible"<<endl;
        for(ll i=n-1;i>k;i--){
            cout<<i<<endl;
        }
        for(ll i=1;i<=k;i++){
            cout<<i<<endl;
        }
    }
    
    
    
    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
const int MAXN=2e5+5;
long long a[MAXN];
long long b[MAXN];
long long ans=0;
int main()
{
    int n;
    cin >>n;    
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        b[i]=b[i-1]+a[i];
        ans+=a[i];
    }
    long long cmin=INT_MAX;
    for(int i=1;i<n;i++)
    {
        if(cmin>abs(2*b[i]-ans))
            cmin=abs(2*b[i]-ans);
    }
    cout<<cmin<<endl;
    return 0;
}


Measured memory_bytes: 3328
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    string s;
    R(s);
    if(s=="SUN")W(7);
    if(s=="MON")W(6);
    if(s=="TUE")W(5);
    if(s=="WED")W(4);
    if(s=="THU")W(3);
    if(s=="FRI")W(2);
    if(s=="SAT")W(1);
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    vl W(N);
    ll sum = 0;
    REP(i, N){
        cin >> W[i];
        sum += W[i];
    }
    
    ll s = 0; ll ans = LINF;
    REP(i, N-1){
        s += W[i];
        ll tmp = sum-s;
        ans = min(ans, abs(s-tmp));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 200005
#define __TRUE "Yes"
#define __FALSE "No"
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  int count=a;
  if(a > b) {
    count--;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
/*
    Author: Shivam Shukla
    Title : DP_J_Modified.cpp
    Date : 29/08/2020   >> 17:22:14
*/

#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pair<ll,ll> > vpll;
 
const int MOD=1e9+7;
const int MAX=1e5+5;
const double PI= acos(-1.0);
const long double EPS=1e-10;
const int64_t INF=1e18+10;
 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0)
#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vi vector<int>
#define vl vector<ll>
#define vs vector<str>
#define vc(x) vector<x>
#define mapll map<ll,ll>
#define mapib map<int,bool>
#define mapiv map<int,vector>
#define mapsi map<string,int>
#define rep(i,j,k) for(ll i=j;i<k;i++)
#define down(i,j,k) for(ll i=j;i>=k;i--)
#define repa(i,n) for(ll i=0;i<n;i++)
#define dowa(i,n) for(ll i=n;i>=0;i--)
#define reps(i,j,k,s) for(ll i=j;i<k;i+=s)
#define downs(i,j,k,s) for(ll i=j;i>=k;i-=s)
#define trv(i,x) for(auto i:x)
#define pb push_back
#define eb emplace_back
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define str string 
#define dub double
#define pqmax priority_queue<ll>
#define pqmin priority_queue<ll,vl,greater<ll> >
#define INF(x) numeric_limits<x>::max()
 
template<typename t> t lcm(t a, t b) {return (a*b)/__gcd(a,b);}
template<typename t> t gcd(t a, t b) {return __gcd(a,b);}
template<typename t> t mul_mod(t a, t b, t m){t res=((a%m)*(b%m)%m); return res;}
template<typename t> t add_mod(t a, t b, t m){t res=((a%m)+(b%m))%m; return res;}
template<typename t> t pow_mod(t a,t b,t m) {t res=1;while(b){if(b&1) res=mul_mod(res,a,m);a=mul_mod(a,a,m), b>>=1;} return res%m;}
template<typename t> vc(t) num_vec(t num) {t res; while (num) res.pb(num%10), num/=10; return res;}
template<typename t> t vec_num(t vec) {t res=0; ll mul=1; repa(i,sz(vec)) res=vec[i]*mul, mul*=10; return res;}

long double dp[302][302][302];

long double E(int n1, int n2, int n3, int n) {
    if (n1 == 0 && n2 == 0 && n3 == 0)  
        return 0.0;

    if (dp[n1][n2][n3] > 0)
        return dp[n1][n2][n3];

    long double ans = 1.0 * n;
    int t = n1 + n2 + n3;

    ans += n1 ? E(n1 - 1, n2, n3, n) * n1 : 0.0;
    ans += n2 ? E(n1 + 1, n2 - 1, n3, n) * n2: 0.0;
    ans += n3 ? E(n1, n2 + 1, n3 - 1, n) * n3: 0.0;

    ans /=  t;
    dp[n1][n2][n3] = ans;
    return dp[n1][n2][n3];
} 

int32_t main(int argc,char** argv){
    fastio();
    auto tstart= clock();
 
    #ifndef ONLINE_JUDGE
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
      freopen("error.txt","w",stderr);
    #endif   

    int n; cin >> n;
    int n1 = 0, n2 = 0, n3 = 0;
    vi a(n); repa(i, n) cin >> a[i], n1 += (a[i] == 1), n2 += (a[i] == 2), n3 += (a[i] == 3);
    
    
    memset(dp, -1, sizeof(dp));
    cout << setprecision(12) << E(n1, n2, n3, n) << endl;

    cerr << setprecision(2) << fixed<<"Time elapsed: " << (double)(clock() - tstart)/CLOCKS_PER_SEC << endl; 
    return 0; 
}

Measured memory_bytes: 434192
from collections import Counter


def solve(N, Ps):
    C = Counter(Ps)
    M = 10 ** 5 + 1
    counts = [0 for i in range(M)]
    for d, c in sorted([(d, c) for d, c in C.items()], key=lambda x: x[0]):
        counts[d] += c

    for i in range(1, M):
        counts[i] += counts[i - 1]

    return len([c for c in counts if c == N // 2])


if __name__ == "__main__":
    N = int(input())
    Ds = list(map(int, input().split(" ")))
    print(solve(N, Ds))


Measured memory_bytes: 16728
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,b,c,d;
  cin>>a>>b>>c;
  d=max(a,max(b,c));
  a+=b+c;
  cout<<a-d;
}


Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>

using namespace std;

int main(){

    int ans=0;

    string s,t;
    cin>>s>>t;

    for(int i=0;i<3;i++){
        if(s[i]==t[i]){
            ans++;
        }
    }
    
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
for j in range(n):
  print(a[j], end="")
  if j < n-1:
    print(" ", end="")
  else:
    print("")

for i in range(1, n):
  v = a[i]
  j = i -1
  while(j >= 0 and a[j] > v):
    a[j+1] = a[j]
    j = j - 1
  a[j+1] = v

  for j in range(n):
    print(a[j], end="")
    if j < n-1:
      print(" ", end="")
    else:
      print("")


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

const int INF = 1000000000;
int dp[105][105][2], pa[105][105];
char grid[105][105];

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

    int h, w;
    cin >> h >> w;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> grid[i][j];
        }
    }
    for(int i = h - 1; i >= 0; i--) {
        for(int j = w - 1; j >= 0; j--) {
            if(i == h - 1 && j == w - 1) {
                dp[i][j][0] = (grid[i][j] == '#' ? INF : 0);
                dp[i][j][1] = INF - dp[i][j][0];
                if(dp[i][j][1] == 0)
                    dp[i][j][1]++;
                continue;
            }
            dp[i][j][0] = (grid[i][j] == '#' ? INF : 0);
            dp[i][j][1] = INF - dp[i][j][0];
            if(dp[i][j][1] == 0)
                dp[i][j][1]++;
            if(dp[i][j][0] < INF)
                dp[i][j][0] += min((i == h - 1 ? INF : min(dp[i + 1][j][0], dp[i + 1][j][1])), (j == w - 1 ? INF : min(dp[i][j + 1][0], dp[i][j + 1][1])));
            else {
                pa[i][j] = dp[i][j][1];
                dp[i][j][1] = INF;
                for(int i1 = i; i1 < h; i1++) {
                    for(int j1 = j; j1 < w; j1++) {
                        if(i1 == i && j1 == j) {
                            dp[i][j][1] = 1 + min((i == h - 1 ? INF : min(dp[i + 1][j][0], dp[i + 1][j][0])), (j == w - 1 ? INF : min(dp[i][j + 1][0], dp[i][j + 1][1])));
                            //cout << pa[i][j] << " ";
                            continue;
                        }
                        pa[i1][j1] = (grid[i1][j1] == '.');
                        pa[i1][j1] += min((i == i1 ? INF : pa[i1 - 1][j1]), (j == j1 ? INF : pa[i1][j1 - 1]));
                        //cout << pa[i1][j1] << " ";
                        if(i1 == h - 1 && j1 == w - 1)
                            dp[i][j][1] = min(dp[i][j][1], pa[i1][j1]);
                        dp[i][j][1] = min(dp[i][j][1], pa[i1][j1] + min((i1 == h - 1 ? INF : min(dp[i1 + 1][j1][0], dp[i1 + 1][j1][0])), (j1 == w - 1 ? INF : min(dp[i1][j1 + 1][0], dp[i1][j1 + 1][1]))));
                    }
                    //cout << endl;
                }
            }
        }
    }
    /*for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cout << dp[i][j][0] << " ";
        }
        cout << endl;
    }
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cout << dp[i][j][1] << " ";
        }
        cout << endl;
    }*/
    cout << min(dp[0][0][0], dp[0][0][1]) << '\n';
}

Measured memory_bytes: 384
module Main where

import Data.Functor
import Data.List

main :: IO ()
main =  do
 { [n] <- getInts
 ; hs  <- loop n iHouses
 ; putStr $ showHouses hs
 }

loop :: Int -> [House] -> IO [House]
loop 0 hs = return hs
loop n hs = do
  { u <- getInts
  ; loop (n-1) (updateHs u hs)
  }

type House = [[Int]]

showHouse :: House -> [String]
showHouse = map ((' ':) . unwords . map show)

showHouses :: [House] -> String
showHouses = unlines . concat . intersperse [replicate 20 '#'] . map showHouse

iHouses :: [House]
iHouses = replicate 4 iHouse

iHouse :: House
iHouse = replicate 3 (replicate 10 0)

updateH :: [Int] -> House -> House
updateH [b,f,r,v] h = case splitAt (f-1) h of
  (xs,fl:ys) -> case splitAt (r-1) fl of
    (zs,rm:ws) -> xs ++ (zs ++ (rm + v) : ws) : ys

updateHs :: [Int] -> [House] -> [House]
updateHs [b,f,r,v] hs = case splitAt (b-1) hs of
  (xs,h:ys) -> xs ++ updateH [b,f,r,v] h : ys

getInts :: IO [Int]
getInts = map read . words <$> getLine

Measured memory_bytes: 4108
S = list(input())
N = len(S)

ans = 0
# if S[0] == 'B':
#     tmp = 1
# else:
#     tmp = 0

tmp = 1 if S[0] == 'B' else 0

for i in range(1, N):
    if S[i] == 'B':
        tmp += 1
    else:
        ans += tmp

print (ans)

Measured memory_bytes: 4840
n=input()
m=len(n)
n=int(n)

if n%2==1:
    print(0)
else:
    if m==1:
        print(0)
    else:
        ans=0
        i=1
        while True:
            ans_plus=n//(2*5**i)
            if ans_plus==0:
                break
            ans+=ans_plus

            i+=1
        print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <sstream>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)
#define rrep(i, a) RREP(i, a, 0)
#define RREP(i, a, b) for(int i = a; i >= b; --i)
#define repll(i, a) REPLL(i, 0, a)
#define REPLL(i, a, b) for(ll i = a; i < b; ++i)
#define rrepll(i, a) RREPLL(i, a, 0)
#define RREPLL(i, a, b) for(ll i = a; i >= b; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<int, P> PP;
const double PI = 3.14159265358979323846;
const double eps = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;

int n;
ll a[2001];
ll dp[2001][2001];

ll calc(int l, int r, bool joi) {
	if (dp[l][r] != -1)return dp[l][r];
	if (l == r) {
		if (joi)return dp[l][r] = a[l];
		else return dp[l][r] = 0;
	}
	if (joi)return dp[l][r] = std::max(calc((l + 1) % n, r, false) + a[l], calc(l, (r + n - 1) % n, false) + a[r]);
	else {
		if (a[l] > a[r])return dp[l][r] = calc((l + 1) % n, r, true);
		else return dp[l][r] = calc(l, (r + n - 1) % n, true);
	}
}

int main() {
	std::cin >> n;
	rep(i, n)std::cin >> a[i];

	rep(i, 2001)rep(j, 2001)dp[i][j] = -1;

	ll max = -1;
	rep(i, n)max = std::max(max, calc((i + 1) % n, (i + n - 1) % n, false) + a[i]);
	std::cout << max << std::endl;

	return 0;
}

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

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

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	string pre = "";
	string suf = "";
	int count = 0;
	rep(i, n) {
		if (count <= 0 && s[i] == ')') pre.push_back('(');
		if (count > 0 && s[i] == ')') count--;
		if (s[i] == '(') count++;
	}
	count = 0;
	reverse(s.begin(), s.end());
	rep(i, n) {
		if (count <= 0 && s[i] == '(') suf.push_back(')');
		if (count > 0 && s[i] == '(') count--;
		if (s[i] == ')') count++;
	}
	reverse(s.begin(), s.end());
	string ans = pre + s + suf;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n, qq = list(map(int, input().rstrip('\n').split()))

    ls = collections.defaultdict(list)
    ls[1]
    for i in range(n-1):
        a, b = map(int, input().rstrip('\n').split())
        ls[a] += [b]
        ls[b] += [a]

    ans = [0] * n
    for i in range(qq):
        p, x = map(int, input().rstrip('\n').split())
        ans[p-1] += x

    q = collections.deque()
    q.append(1)
    fq = collections.defaultdict(list)
    while True:
        if len(q) != 0:
            p = q.popleft()
            fq[p]
            for i in ls[p]:
                if i not in fq:
                    q.append(i)
                    ans[i-1] += ans[p-1]
        else:
            break
    print(*ans)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 98244
import std.algorithm;
import std.stdio;
import std.string;

void main() {
  bool[string] cups = ["A": true, "B": false, "C": false];

  foreach (string line; stdin.lines) {
    string[] cup = line.chomp.split(",");
    swap(cups[cup[0]],cups[cup[1]]);
  }

  foreach (k; cups.keys) {
    if (cups[k] == true) {
      k.writeln;
      break;
    }
  }
}

Measured memory_bytes: 1068
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	_, _ = fmt.Scan(&n)
	arr := make([]int, n)
	dp := make([]int, n)
	for i := 0; i < n; i++ {
		var tmp int
		_, _ = fmt.Scan(&tmp)
		arr[i] = tmp
		dp[i] = math.MaxInt32
	}
	dp[0] = 0
	for i := 1; i < n; i++ {
		a := dp[i - 1] + abs(arr[i] - arr[i - 1])
		b := math.MaxInt32
		if i > 1 {
			b = dp[i - 2] + abs(arr[i] - arr[i - 2])
		}
		if a > b {
			dp[i] = b
		} else {
			dp[i] = a
		}
	}
	fmt.Println(dp[n - 1])
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

Measured memory_bytes: 5504
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    S=input()
    ans=0
    for i,s in enumerate(S):
        if i%2==0 and s=='p':
            ans-=1
        if i%2==1 and s=='g':
            ans+=1
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 39920
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>

using namespace std;
using ll = long long int;

ll k;

ll calcBit(ll target)
{
  ll count = 1;
  while(target > 1)
  {
    target /= 2;
    count++;
  }
  return count;
}

ll calcCount(vector<ll> &x, ll offset, ll target)
{
  ll count = 0;
  ll index = 1ll << offset;
  for(ll i = 0; i < x.size(); i++)
  {
    if(x[i] & index)
    {
      count++;
    }
  }
  if(target == 0)
  {
    return x.size() - count;
  }else{
    return count;
  }
}

int main()
{
  ll n;
  cin >> n >> k;
  vector<ll> x(n);
  for(ll i = 0; i < n; i++)
  {
    cin >> x[i];
  }  
  ll maxLen = calcBit(k);
  /*
   * X < K のとき必ずXi < Kiとなるiが存在する
   * Xi+1 以降は何でもいい
   * すべてのKi=1のiについてXi=0としたときの最大の和を求める
   * 答えはその中の最大値
   * */
  vector<ll> memoCount(maxLen, 0);
  for(ll i = 0; i < maxLen; i++)
  {
    ll count0 = calcCount(x, i, 0);
    ll count1 = calcCount(x, i, 1);
    //cout << count0 << " " << count1 << endl;
    if(count0 < count1)
    {
      memoCount[i] = 0;
    }else{
      memoCount[i] = 1;
    }
  } 
  ll result = 0;
  for(ll i = 0; i < n; i++)
  {
    result += (k ^ x[i]);
  }
  for(ll i = 0; i < maxLen; i++)
  {
    if(!(k & (1ll << i))) continue;
    /*
     * Kiが0の場合はスキップ
     * Ki=1の場合
     * Ki=0としX0からXi-1までをmemoCountの値に設定
     * その後fを計算
     * */
    ll tempx = k;
    for(ll j = i; j >= 0; j--)
    {
      if(k & (1ll << j))
      {
        tempx -= 1ll << j;
      }
    }
    for(ll j = 0; j < i; j++)
    {
      tempx += memoCount[j] << j;
    }
    ll temp = 0;
    for(ll i = 0; i < n; i++)
    {
      temp += (tempx^x[i]);
      //cout << (tempx^x[i]) << endl;
    }
    result = max(result, temp);
    //cout << i << " " << tempx << " "<< result << endl;
  }
  cout << result << endl;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
typedef long long ll;

string s;
int N;
ll m,a,r,c,h;
ll D[5];
int P[10]={0,0,0,0,0,0,1,1,1,2};
int Q[10]={1,1,1,2,2,3,2,2,3,3};
int R[10]={2,3,4,3,4,4,3,4,4,4};
int main(){
    cin>>N;
    while(N--){
        cin>>s;
        if(s[0]=='M')m++;
        if(s[0]=='A')a++;
        if(s[0]=='R')r++;
        if(s[0]=='C')c++;
        if(s[0]=='H')h++;
    }
    ll x=0;
    D[0]=m,D[1]=a,D[2]=r,D[3]=c,D[4]=h;
    for(int i=0;i<10;i++){
        x+=D[P[i]]*D[Q[i]]*D[R[i]];
    }
    cout<<x<<"\n";
    return 0;
                                                           

}


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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    if (s.size() < 4) {
        cout << "No" << endl;
    } else if (s.substr(0, 4) == "YAKI") {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

using namespace std;

using ll = long long;

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

    bool coffee = false;

    if (S[2] == S[3] && S[4] == S[5]) coffee = true;

    cout << ((coffee) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll n; cin >> n;
    ll a[100001]; INITA(a, 0, 100000, 0);
    ll b[100001]; INITA(b, 0, 100000, 0);

    ll a_tot = 0;
    ll b_tot = 0;
    REP(i, n) { cin >> a[i]; a_tot += a[i]; }
    REP(i, n) { cin >> b[i]; b_tot += b[i]; }

    if (a_tot < b_tot) {
        cout << -1 << endl;
    } else {
        // a - bの差分を取得する (plus, minusにわける)
        vector<ll> plus;
        ll minus_tot = 0;
        ll res = 0;
        REP(i, n) {
            ll diff = a[i] - b[i];
            if (diff < 0) {
                minus_tot -= diff;
                res++;
            } else if (diff > 0) {
                plus.push_back(diff);
            }
        }
        sort(ALL(plus));
        while (minus_tot > 0) {
            ll p = plus[plus.size()-1];
            plus.pop_back();
            res++;
            minus_tot -= p;
        }
        cout << res << endl;
    }

    return 0;
}


Measured memory_bytes: 5432
#include <iostream>
#include <stack>
using namespace std;

int main() 
{ 
    int a1, a2;
    char c[3];
    stack<int> s;
    while(cin >> c)
    {
        if (isdigit(c[0]))
        {
            s.push(atoi(c));
        }
        else
        {
            a1 = s.top(); s.pop();
            a2 = s.top(); s.pop();
            if (c[0]=='+') s.push(a2+a1);
            else if (c[0]=='-') s.push(a2-a1);
            else if (c[0]=='*') s.push(a2*a1);
        }
    }
    printf("%d\n", s.top());
}


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

int a, b;
char c;

int main() {
	cin >> a;

	while (1)
	{
		cin >> c;

		if (c == '='){
			break;
		}

		if (c == '+') {
			cin >> b;
			a = a + b;
		}
		if (c == '-') {
			cin >> b;
			a = a - b;
		}
		if (c == '*') {
			cin >> b;
			a = a * b;
		}
		if (c == '/') {
			cin >> b;
			a = a / b;
		}
	}

	cout << a <<endl;

	return 0;

}


Measured memory_bytes: 3096
#include <iostream>
#include <cmath>
using namespace std;

// https://apc001.contest.atcoder.jp/tasks/apc001_b
int main(){
	
	long long n;
	cin>>n;
	long long a[n+1],b[n+1], sa=0, sb=0, k,t=0;
	for(int i=1; i<=n; i++){
		cin>>a[i];
		sa+=a[i];
	}
	for(int i=1; i<=n; i++){
		cin>>b[i];
		sb+=b[i];
	}
	k=sb-sa;

	for(int i=1; i<=n; i++){
		if(a[i]<b[i]){
			t+=ceil((b[i]-a[i])/2.0);
		}
	}
	if(t<=k){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 384
n=int(input())
ab=[list(map(int,input().split())) for i in range(n)]
ans='Yes'
work=0
sab=sorted(ab, key=lambda x: x[1])
for i in sab:
    if work+i[0]>i[1]:
        ans='No'
        break
    else:
        work+=i[0]
print(ans)

Measured memory_bytes: 55196
//  Copyright © 2020 Kavish Lodha. All rights reserved.
#include <bits/stdc++.h>
using namespace std;
#define vll vector<long long>
#define mll map<long long,long long>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define pb push_back
#define prll pair<long long,long long>
typedef long long ll;
typedef long double ld;
#define rep(i,a,n)   for(ll i=a; i<n; i++)
#define rrep(i,a,n)  for(ll i=n-1; i>=a; i--)
typedef map<string,ll> msl;
#define mx 100001
#define mod 1000000007
ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll extgcd(ll a,ll b,ll& x,ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = extgcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}
ll revrsno(ll n){
    ll k=0;
    vll z;
    while(n>0){
        z.pb(n%10);
        n/=10;
    }
    rep(i,0,z.size()) k=k*10+z[i];
    return k;
}
bool isPrime(ll n){
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}
bool isPowerOfTwo(ll n) { 
   if(n==0) 
   return false; 
   return (ceil(log2(n)) == floor(log2(n))); 
}
ll powm(ll a,ll b) {
	ll res = 1;
	while (b) {
		if (b & 1)
			res = (res * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return res;
}
ll divide(ll a,ll b) {
	return (a % mod) * powm(b, mod - 2) % mod;
}
ll mul(ll a,ll b) {
	return ((a % mod) * (b % mod)) % mod;
}
 
ll add(ll a,ll b) {
	return (a % mod + b % mod) % mod;
}
ll Totfun(ll n){
    ll z=n;
    if(n%2==0){
        while(n%2==0){
            n/=2;
        }
        z/=2;
    }
    for(ll i=3;i<=sqrt(n);i+=2){
        if(isPrime(i)&&n%i==0){
          while(n%i==0){
            n/=i;
          }
        z-=z/i;  
        }
    }
    if(n>1){
        z-=z/n;
    }
    return z;
}
ll maxPrimeFactor(ll n) { 
    ll maxPrime=-1; 
    while(n%2==0){
        maxPrime=2; 
        n>>=1; 
    } 
    for (ll i=3;i<=sqrt(n);i+=2) { 
        while(n%i==0){ 
            maxPrime=i; 
            n=n/i; 
        } 
    } 
    if (n>2) maxPrime=n; 
    return maxPrime; 
} 
ll nCr(ll n,ll r){
    if(r>n||r<0) return 0;
    ll z=1;
    for(ll i=n-r+1;i<=n;i++){
        z*=i;
        z/=(i+r-n);
    }
    return z;
}
vll a[mx];
ll l[mx];
int main(){
   ios_base::sync_with_stdio(false); 
   cin.tie(NULL);
   cout.tie(NULL);
    ll n,k,x,y,ans=0;
    bool z;
    cin>>n>>k;
    rep(i,1,n+1) cin>>l[i];
    rep(i,0,k){
        cin>>x>>y;
        a[x].pb(y);
        a[y].pb(x);
    }
    rep(i,1,n+1){
        bool z=1;
        rep(j,0,a[i].size()){
            if(l[a[i][j]]>=l[i]) z=0;
        }
        ans+=z;
    }
    cout<<ans;
   return 0;
}

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

int main() {
  int n, x, cnt = 0; cin >> n >> x;
  vector<int> l(n); rep(i, n) cin >> l[i];
  vector<int> s(n+1); rep(i, n) s[i+1] = s[i] + l[i];
  rep(i, n+1) if (s[i] <= x) cnt++;
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f(a, b) for (ll i = a; i <= b; i++)
#define pb push_back
#define pf push_front
#define mp make_pair
using namespace std;
#define N 100005
const int INF = 1000000001;
const int MOD = 998244353 ; //1e9+7;

//vector< vector<ll> > g(N);
//vector< pair<ll, pair< ll, ll > > > g(N);
//ll vis[N] = {0}, par[N] = {0}, child[N] = {0}, cnt = 0;
ll dp[N] = {0}, n, k, a[N] = {0};

void solve(){
    cin >> n >> k;
    f(0,n-1) cin >> a[i];
    dp[0] = 0; dp[1] = abs(a[0] - a[1]);
    f(2,n-1){
        ll cnt= 0, mn = INF;
        for(ll j = i-1; j >= 0 and cnt < k; j--, cnt++){
            mn = min(mn, dp[j] + abs(a[i] - a[j])) ;
        }
        dp[i] = mn;
    }
    cout << dp[n-1] << "\n";
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ll t;cin >> t;for(ll index=1; index<=t; index++){
        //cout << "Case #" << index << ": " ;
        solve();
   // }
    return 0;
}

Measured memory_bytes: 5188
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;


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

	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}

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

int gcd(int a, int b) {
    if(a < b)
        gcd(b, a);
    int r;
    while((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int A, B;
    cin >> A >> B;
    cout << A * B / gcd(A, B) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,M;cin >> N >> M;
  vector<bool> AC(N+1,false);
  vector<int> count(N+1,0);
  rep(i,M){
    int x;cin >> x;
    string y;cin >> y;
    if(AC[x])continue;
    if(y == "AC") AC[x] = true;
    else ++count[x];
  }
  int n_AC = 0;
  int n_WA = 0;
  rep(i,N+1) if(AC[i]){
    ++n_AC;
    n_WA += count[i];
  }
  cout << n_AC SP n_WA << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

     static Scanner scanner;

     public static void main(String[] args) {
         scanner = new Scanner(System.in);

         long N=gl();
         long K=gl();

         long ans=0;
         for (long b=K+1; b<=N;b++) {
        	 long s=Math.floorDiv(N, b);
        	 ans+=(b-K)*s;
        	 long t=N%b;
        	 ans+=Math.max(0, t-(K-1));
        	 if(K==0)ans--;
         }
         System.out.println(ans);
     }

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 35644
#include <iostream>
#include <vector>
#include <bitset>
#include <cmath>

int main() {
    int n;
    std::cin >> n;
    std::vector<int> A;
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        int tmp;
        std::cin >> tmp;
        A.push_back(tmp);
        sum += tmp;
    }
    std::bitset<2000*2000> dp;
    for (auto &&a : A) {
        std::bitset<2000*2000> t = (dp << a);
        dp |= t;
        dp[a] = 1;
    }
    int med = 0;
    int i = std::ceil(sum/2.);
    while(true){
        if(dp[i] == 1){
            med = i;
            break;
        }
        i++;
    }
    std::cout << med << std::endl;
}


Measured memory_bytes: 1792
n, p = map(int, input().split())
d = {}
while p % 2 == 0:
    if 2 not in d:
        d[2] = 1
    else:
        d[2] += 1
    p //= 2
f = 3
while f * f <= p:
    if p % f == 0:
        if f not in d:
            d[f] = 1
            p //= f 
        else:
            d[f] += 1
            p //= f
    else:
        f += 2
if p != 1:
    if p not in d:
        d[p] = 1
    else:
        d[p] += 1
d = sorted(d.items(), key=lambda x:x[1], reverse=True)
ans = 1
for k, v in d:
    if v < n:
        break
    else:
        ans *= k ** (v // n)
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define INF 1e15
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
typedef long long ll;
typedef pair<int, int> P;
#define END system("PAUSE");return 0
int n, m;
char c[11][11];
signed main() {
	cin >> n >> m;
	rep(i, n) {
		rep(j, m) {
			cin >> c[i][j];
		}
	}
	if (c[0][0] == '.') {
		puts("Impossible");
		END;
	}
	int x = 0, y = 0;
	c[x][y] = '.';
	while (x < n&&y < m) {
		if (c[x + 1][y] == '#') {
			x++;
			c[x][y] = '.';
		}
		else if (c[x][y + 1] == '#') {
			y++;
			c[x][y] = '.';
		}
		else if (x == n - 1 && y == m - 1)break;
		else{
			puts("Impossible");
			END;
		}
	}
	rep(i, n) {
		rep(j, m) {
			if (c[i][j] == '#') {
				puts("Impossible");
				END;
			}
		}
	}
	puts("Possible");
	END;
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long int
int main()
{
    double x,n,a;
    cin>>n;
    vector<double>v;
    while(n--)
    {
        cin>>a;
        v.pb(a);
        sort(v.begin(),v.end());

    }
    x=v[0];
    for(int i=1; i<v.size(); i++)
    {

        x=(v[i]+x)/2;

    }
    cout<<x<<endl;

    return 0;
}

Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S = iss()
    NUM = [0] * (N+1)

    for n in range(N):
        NUM[n+1] += NUM[n]
        if S[n] == 'W':
            NUM[n+1] += 1

    ret = MAX
    for n in range(N+1):
        ret = min(ret, NUM[n] + N - n - (NUM[-1] - NUM[n]))
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 26992
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using Graph = vector<vector<ll>>;

Graph g;

vector<ll> color; 
bool dfs(ll v, int c = 0){
  color[v] = c;
  for(auto nv : g[v]){
    if(color[nv] != -1){ // 色が確定している場合
      if(color[nv] == c)return false; // 同じ色の場合
    }
    else if(!dfs(nv, 1 - c))return false;
  }

  return true;
}

int main(){
  ll n, m;
  cin >> n >> m;

  g.resize(n);
  for(int i = 0; i < m; ++i){
    ll a, b;
    cin >> a >> b;
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  color.assign(n, -1);
  if(dfs(0)){
    int whiteCount = 0;
    for(int i = 0; i < n; ++i){
      if(color[i] == 0)++whiteCount;
    }
    cout << whiteCount * (n - whiteCount) - m << endl;
  }
  else cout << n * (n - 1) / 2 - m << endl;
}


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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int n, m, a[100001];
string s;

int main(){
	cin >> n >> m;
	
	if((n * m) % 2) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int min(int a, int  b){return a>b?b:a;}
int dp[1001][1001];
int main(){
    char s1[1001];
    char s2[1001];
    scanf("%s",&s1);
    scanf("%s",&s2);
    dp[0][0] = 0;
    for(int i = 1; i<=strlen(s1); i++){
        dp[i][0] = i;
    }
    for(int i = 1; i<=strlen(s2); i++){
        dp[0][i] = i;
    }
    for(int i = 1; i<=strlen(s1); i++){
        for(int j = 1; j<=strlen(s2); j++){
            if(s1[i-1]==s2[j-1]) dp[i][j] = dp[i-1][j-1];
            else {
                dp[i][j] = min(dp[i-1][j-1], min(dp[i-1][j],dp[i][j-1]))+1;
            }
        }
    }
     
    printf("%d\n",dp[strlen(s1)][strlen(s2)]);
    return 0;
}



Measured memory_bytes: 6616
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    while(n>0)
    {
        int d=n%10;
        n=n/10;
        if(d==7){cout<<"Yes";exit(0);}
    }
    cout<<"No";
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define lowbit(x)  ((x)&(-(x)))
using namespace std;

const int mo=int(1e9+7);
int n,m,k,a[20][20],f[1<<19],ans;

void upd(int &x,int y){if ((x+=y)>=mo)  x-=mo;}

void work()
{
	scanf("%d %d %d",&n,&m,&k);
	for (int i=0; i<m; i++)
		for (int j=0; j<n-1; j++)
			a[i][j]=3;
	for (int i=1,x,y,z; i<=k; i++)
		scanf("%d %d %d",&x,&y,&z),a[x-1][y-1]=1<<z;
	f[0]=1;
	for (int i=0; i<m; i++)
		for (int j=0; j<n-1; j++)
			for (int k=(1<<(n-1))-1; ~k; k--)
				if (f[k])
					{
						if (k&(1<<j))
							{
								if (!(a[i][j]&2))  f[k]=0;
							}else
							{
								if (a[i][j]&2)  upd(f[k^((lowbit(k>>j)|1)<<j)],f[k]);
								if (!(a[i][j]&1))  f[k]=0;
							}
					}
	for (int i=0; i<(1<<(n-1)); i++)  upd(ans,f[i]);
	printf("%d",ans);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define SIZE 26 
int main()
{
  //FAST IO       
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
string s;
cin>>s;
if(s=="ABC")
cout<<"ARC"<<"\n";
else
cout<<"ABC"<<"\n";

return 0;
}

Measured memory_bytes: 3544