akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top=0,S[1000];
void push(int x) {
  S[++top] = x;
}

int pop(void) {
  top--;
  return S[top+1];
}

int main(void) {
  int a, b;
  top = 0;
  char s[100];
  while(scanf("%s",s) != EOF) {
    if(s[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    } else if(s[0] == '-') {
      b = pop();
      a = pop();
      push(a - b);
    } else if(s[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    } else {
      push(atoi(s));
    }
  }
  printf("%d\n",pop());

  return 0;
}


Measured memory_bytes: 2100
#include <stdio.h>

int main(){
	int n, s = 0;
	scanf("%d", &n);
	int aux = n;
	while(n != 0) {
		s = s + n %10;
		n = n/10;
	}
	if(aux%s == 0)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision;
// #define int cpp_int
using namespace std;

#define fastio 			ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int 			long long
#define ll 				long long
#define ld 				long double
#define vi 				vector<int>
#define pii 			pair<int,int>
#define vpii 			vector< pair<int,int> >
#define uset			unordered_set
#define umap 			unordered_map
#define maxpq 			priority_queue<int>
#define minpq			priority_queue<int,vi,greater<int>()>

#define all(v) 			v.begin(),v.end()
#define part(v,s,e)		v.begin()+s,v.begin()+e
#define rev(v)			reverse(v.begin(),v.end())
#define sz(x)			(int)x.size()
#define def(v)			memset(v,-1,sizeof(v));
#define def0(v)			memset(v,0,sizeof(v));
#define minv(a)			*min_element(all(a))
#define maxv(a)			*max_element(all(a))
#define sumv(a)			accumulate(all(a),0)

#define	lb				lower_bound
#define	ub				upper_bound
#define	desc			greater<int>()
#define	pb				emplace_back
#define	mp				make_pair
#define	F				first
#define	S				second

#define	mod 			1000000007
#define	inf 			1000000000000000
#define infty			1000000000000000000LL
#define	md				998244353
#define	PI				acos(-1.0)
#define	endl 			"\n"
#define	rr				return
#define	br				cout<<"\n";

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a/(__gcd(a,b)))*b

#define setbits(x) 		__builtin_popcountll(x)
#define zerobits(x)		__builtin_ctzll(x)

#define ip(v)	 		for(auto& i:v)	cin>>i;
#define op(v) 			for(auto i:v)	cout<<i<<" ";cout<<endl;
#define deb(x) 			cout <<"Value of " #x << " : " << x << endl;



void solve()
{	

	string s;
	cin>>s;

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

}	

int32_t main()
{

	fastio
	cout<<setprecision(15)<<fixed;


	int t=1;
	// cin>>t;
	
	for(int i=1;i<=t;i++)
	{
		// cout<<"Case "<<i<<" : "<<endl;
		solve();
	}
	
	#ifndef ONLINE_JUDGE	
		cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
	#endif

	return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

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

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    string a, b, c;
    cin >> a >> b >> c;

    if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0])
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
int wsum[200005]={0},bsum[200005]={0};
int main(){
  int k;
  cin>>k;
  string s;
  cin>>s;
  for(int i=1;i<=s.length();i++){
    bsum[i]=bsum[i-1];
    wsum[i]=wsum[i-1];
    if(s[i-1]=='.') wsum[i]++;
    else bsum[i]++;
  }
  int ans=1e6;
  for(int i=0;i<=s.length();i++){
    ans=min(ans,bsum[i]+wsum[s.length()]-wsum[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2180
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 100001
#define INF (ll)1e18
#define pll pair<ll,ll>
#define pii pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define repr(i,n) repr2(i,n,0)
#define repr2(i,m,n) for(ll i=m;i>=(n);i--)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define pi 3.1415926535897

bool compare(vector<ll> &A, vector<ll> &B) {
    if(A[0]+A[1]<B[0]+B[1])
        return 1;
    return 0;
}

int main() {

    get(n);

    vector<vector<ll>> A;
    rep(i,n) {
        get3(a,b,c);
        A.pb(vector<ll> {a,b,c});

    }

    sort(ALL(A), compare);

    vector<vector<ll>> dp(n+1, vector<ll>(50001,0));

    ll maxi = 0;
    rep(i,n) {
        rep(j,50001) {
            dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
            if(j+A[i][0]>50001)
                continue;
            if(j<=A[i][1] || i==0) {
                dp[i+1][j+A[i][0]] = max(dp[i+1][j+A[i][0]], dp[i][j]+A[i][2]);
                // cout<<i+1<< " " <<j<<" "<<dp[i+1][j+A[i][1]] <<endl;
                maxi = max(maxi, dp[i+1][j+A[i][0]]);
            }   
        }
    }
    
    // for(auto i:A)
    //     cout<<i[0]<<" "<<i[1]<<" "<<i[2]<<endl;

    

    // rep(i,n+1) {
    // rep(j,n+1)
    // cout<<dp[i][j]<<" ";
    // cout<<endl;
    // }
    printf("%lld\n", maxi);

    return 0;  
}

Measured memory_bytes: 394744
import java.util.Scanner;

//AtCoder Beginner Contest 141
//B	Tap Dance
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();

		for (int i = 0; i < S.length(); i++) {
			char c = S.charAt(i);
			if (i % 2 == 0) {
				if (c != 'R' && c != 'U' && c != 'D') {
					System.out.println("No");
					return;
				}
			} else {
				if (c != 'L' && c != 'U' && c != 'D') {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 23764
d, g = map(int, input().split())
pc = []
for _ in range(d):
    p, c = map(int, input().split())
    pc.append((p, c))
ans = 1000
for i in range(2**d):
    score = 0
    k = 0
    for j in range(d):
        if i>>j&1:
            score += pc[j][0]*100*(j+1) + pc[j][1]
            k += pc[j][0]
    if score>=g:
        ans = min(ans, k)
        continue
    for j in range(d-1, -1, -1):
        if i>>j&1:
            continue
        if score+(pc[j][0]-1)*100*(j+1)<g:
            score += (pc[j][0]-1)*100*(j+1)
            k += pc[j][0]-1
            continue
        k += (g-score+100*(j+1)-1)//(100*(j+1))
        ans = min(ans, k)
        break
print(ans)

Measured memory_bytes: 68020
import math
sin60 = math.sin(60*math.pi/180)
def koch(n,p1,p2):
    if n==0:
        return
    s = [(2*p1[0]+1*p2[0])/3., (2*p1[1]+1*p2[1])/3.]
    t = [(1*p1[0]+2*p2[0])/3., (1*p1[1]+2*p2[1])/3.]
    u = [(t[0]-s[0])*0.5 - (t[1]-s[1])*sin60+ s[0],
        (t[0]-s[0])*sin60 + (t[1]-s[1])*0.5 + s[1]]
    koch(n-1,p1,s)
    print s[0],s[1]
    koch(n-1,s,u)
    print u[0],u[1]
    koch(n-1,u,t)
    print t[0],t[1]
    koch(n-1,t,p2)
        
n = int(raw_input())
p1 = (0,0)
p2 = (100,0)
print p1[0],p1[1]
koch(n,p1,p2)
print p2[0],p1[1]

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

using namespace std;
using pii = pair<int, int>;

int main()
{
  int n, required;
  cin >> n >> required;

  vector<pii> points(n);

  for (int i = 0; i < n; ++i)
    cin >> points[i].first >> points[i].second;

  vector<pii> ypoints(points);

  sort(points.begin(), points.end());
  sort(ypoints.begin(), ypoints.end(), [] (const pii a, const pii b) {
      return a.second < b.second;
      });

  /*
   *  --k--
   *  |   |
   *  i   j
   *  |   |
   *  --l--
   */

  auto contained = [&points, &ypoints](int i, int j, int k, int l)-> int {
    int contained = 0;

    for (auto point : points)
      if ((point.first  >= points[i].first)  &&
          (point.first  <= points[j].first)  &&
          (point.second >= ypoints[k].second) &&
          (point.second <= ypoints[l].second))
        contained++;

    return contained;
  };

  auto area = [&points, &ypoints](int i, int j, int k, int l)-> long long {
    return (long long)(points[j].first - points[i].first) *
                      (ypoints[l].second - ypoints[k].second);
  };

  long long best = area(0, n-1, 0, n-1);

  for (int i = 0; i < n; ++i)
    for (int j = i+1; j < n; ++j)
      for (int k = 0; k < n; ++k)
        for (int l = k+1; l < n; ++l)
          if (contained(i, j, k, l) >= required)
            best = min(best, area(i, j, k, l));

  cout << best << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

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

const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
struct L : public vector<P> {
  L() {}
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
bool intersectSP(const L &s, const P &p) {
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS; // triangle inequality
}
P projection(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}
double distanceSP(const L &s, const P &p) {
  const P r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}
typedef  vector<P> polygon;
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
enum { OUT, ON, IN };
int contains(const polygon& Po, const P& p) {
  bool in = false;
  for (int i = 0; i < Po.size(); ++i) {
    P a = curr(Po,i) - p, b = next(Po,i) - p;
    if (imag(a) > imag(b)) swap(a, b);
    if (imag(a) <= 0 && 0 < imag(b))
      if (cross(a, b) < 0) in = !in;
    if (cross(a, b) == 0 && dot(a, b) <= 0) return ON;
  }
  return in ? IN : OUT;
}
int main() {
  while(1) {
    P p[3];
    bool f=0;
    REP(i,3) {
      int x, y;
      cin >> x >> y;
      if (x==0&&y==0){ f=1;break;}
      p[i] = P(x,y);
    }
    if (f) break;
    P c;
    int x, y;
    cin >> x >> y;
    c = P(x,y);
    double r;
    cin >> r;

    polygon Po;
    REP(i,3) {
      Po.push_back(p[i]);
    }
    L l[3];
    REP(i,3)
      l[i] = L(p[i], p[(i+1)%3]);
    double d[3];
    REP(i,3) {
      d[i] = distanceSP(l[i], c);
    }
    if (abs(p[0]-c) < r+EPS && abs(p[1]-c) < r+EPS && abs(p[2]-c) < r+EPS) {
      cout << "b" << endl;
    } else if (contains(Po, c) == IN && d[0] > r-EPS && d[1] > r-EPS && d[2] > r-EPS) {
      cout << "a" << endl;
    } else if (d[0] < r+EPS || d[1] < r+EPS || d[2] < r+EPS) {
      cout << "c" << endl;
    } else
      cout << "d" << endl;
  }

}

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

using namespace std;

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

    int one = n % 10;

    switch (one) {
    case 1:
        cout << "pon";
        break;
    case 2:
        cout << "hon";
        break;
    case 3:
        cout << "bon";
        break;
    case 4:
        cout << "hon";
        break;
    case 5:
        cout << "hon";
        break;
    case 6:
        cout << "pon";
        break;
    case 7:
        cout << "hon";
        break;
    case 8:
        cout << "pon";
        break;
    case 9:
        cout << "hon";
        break;
    case 0:
        cout << "pon";
        break;
    }


    

    return 0;
}

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

int main() {
  int k,n;
  cin>>k>>n;
  vector<int> a(n),dif(n);
  rep(i,n){
    cin>>a[i];
  }
  rep(i,n){
    if(i==n-1){
      dif[i]=k-a[i]+a[0];
      break;
    }
    dif[i]=a[i+1]-a[i];
  }
  sort(dif.begin(),dif.end());
  dif.pop_back();
  int ans=0;
  rep(i,dif.size()){
    ans+=dif[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){

    int n;
    while(cin>>n,n){

        int a[120]={0};
        for(int i=0;i<=n;i++)cin>>a[i];

        for(int i=0;i<=n;i++){
            bool flg = true;
            int b[120];
            for(int j=0,t=0;j<=n;j++){
                if(j==i)continue;
                b[t] = a[j];
                t++;
            }
            int value = b[1] - b[0];
            for(int j=1;j<n;j++){
                if(b[j]-b[j-1]!=value){
                    flg = false;
                    break;
                }
            }
            if(flg){
                cout<<a[i]<<endl;
                break;
            }
        }


    }
    return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());

            var valuess = Console.ReadLine()
               .Split(' ')
               .Select(x => int.Parse(x))
               .ToArray();

            var cost = Console.ReadLine()
                .Split(' ')
                .Select(x => int.Parse(x))
                .ToArray();

            int profit = 0;
            for(var i=0;i< num; i++)
            {
                if (valuess[i] - cost[i] > 0) profit += valuess[i] - cost[i];
            }
            Console.WriteLine(profit);
        }
    }
}

Measured memory_bytes: 13396
N,Y = map(int, input().split())
res = [-1,-1,-1]
for x in range(N+1):
    for y in range(N+1-x):
        if 10000*x + 5000*y +1000*(N-x-y) == Y:
            res =[x,y,N-x-y]
print(res[0],res[1],res[2])


Measured memory_bytes: 2940
#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;
    cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];
    int count = 0;
    while (true) {
        bool flag = false;
        rep(i, N) {
            if (A[i] % 2 == 0) {
                A[i] /= 2;
            }
            else {
                flag = true;
                break;
            }
        }
        if (flag) break;
        count += 1;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3592
a = int(input())

btc = 0
yen = 0

for i in range(a):
    a = input().split()
    if a[1] == 'BTC':
        btc += float(a[0])
    else:
        yen += int(a[0])

btc = btc * 380000

print(float(btc + yen))

Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}
//---------------------------------------------------
int n;
string s, t;
signed main() {
	cin >> n >> s >> t;
	string h = "";
	for (int i = 0; i < n; i++) {
		h += s[i];
		h += t[i];
	}
	cout << h << endl;
}

Measured memory_bytes: 256
n=int(input())
li=[]
ans=0
fl=1

for i in range(n):
    li.append(int(input()))

li.sort()

for j in range(n-1):
    if li[j]!=li[j+1]:
        if fl%2==1:
            ans+=1
            fl=1
        else:
            fl=1
    else:
        fl+=1


if fl%2==1:
    ans+=1

print(ans)

Measured memory_bytes: 7388
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
a = [list(map(int, readline().split())) for _ in range(n)]
q = list(range(n))
for cnt in range(1, n ** 2 + 2):
    qq = set()
    while q:
        x = q.pop()
        if a[a[x][0] - 1][0] == x + 1:
            qq.add(x)
            qq.add(a[x][0] - 1)
    if qq:
        for x in qq:
            a[x].pop(0)
            if a[x]:
                q.append(x)
    else:
        print(-1)
        break
    if not q:
        print(cnt)
        break


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

using namespace std;

const int N = 51;

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

bool isvalid(int x, int y, int h, int w){
    return (x<w && x>=0 && y<h && y>=0);
}

int main(){
    ios_base::sync_with_stdio (false);
    cout << fixed;
    cout.precision(10);
    //freopen ("joke.in","r",stdin);
	//freopen ("joke.out","w",stdout);
    
    int h, w;
    cin >> h >> w;
    char c[N][N];
    for(int i=0; i<h; ++i){
        for(int j=0; j<w; ++j){
            cin >> c[i][j];
        }
    }
    for(int y=0; y<h; ++y){
        for(int x=0; x<w; ++x){
            if(c[y][x]=='.') continue;
            int cnt = 0;
            for(int i=0; i<4; ++i){
                int xx = x + dx[i];
                int yy = y + dy[i];
                if(isvalid(xx, yy, h, w)){
                    if(c[yy][xx]=='#'){
                        cnt++;
                    }
                }
            }
            if(cnt==0){
                cout << "No";
                return 0;
            }
        }
    }
    
    cout << "Yes";
    return 0;
}


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

int main() {
	char c;
	map<char, char> enki;
	enki['A'] = 'T';
	enki['T'] = 'A';
	enki['G'] = 'C';
	enki['C'] = 'G';
	cin >> c;
	cout << enki[c] << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
tmp = 0
for i in range(N):
    if S[i] == '.': tmp += 1
minVal = tmp
#S[p] -> w
for p in range(N):
    if S[p] == '.': tmp -= 1
    else: tmp += 1
    minVal = min(minVal, tmp)
print(minVal)


Measured memory_bytes: 3500
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=1000000007;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n,m;
cin>>n>>m;
vector<p>v;
ll cor=0;
ll pen=0;
for(ll i=0;i<m;i++)
{
    ll a;
    cin>>a;
    string x;
    cin>>x;
    ll b;
    if(x=="WA")
    {
        b=0;
    }else
    {
        b=1;
    }
    v.pb({a,b});
}
map<ll,ll>mp;
for(ll i=0;i<m;i++)
{
    ll x=v[i].fi;
    ll y=v[i].se;
    if((y==1ll)&&(mp.find(x)==mp.end()))
    {
        //cout<<x<<" "<<y<<endl;
        cor++;
        mp[x]=i;
    }
}
for(ll i=0;i<m;i++)
{
    ll x=v[i].fi;
    ll y=v[i].se;
    if(y==0)
    {
        if(mp.find(x)!=mp.end())
        {
            if(i<mp[x])
            {
                pen++;
            }
        }
    }
}
cout<<cor<<" "<<pen<<endl;
return 0;
}


Measured memory_bytes: 8048
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
	String S = stdIn.next();
	int min = 0;
	for(int i=0;i<S.length()/2;i++){
	    if(S.charAt(i)!=S.charAt(S.length()-i-1)){
		min++;
	    }
	}
	System.out.println(min);
    }
}


Measured memory_bytes: 21844
# -*- 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

N=int(input())
edge=[[] for _ in range(N*2+2)]
a,b=[0]*N,[0]*N
for i in range(N):
    a[i],b[i]=map(int,input().split())
for i in range(N):
    c,d=map(int,input().split())
    for j in range(N):
        if c>a[j] and d>b[j]:
            edge[i].append([j+N,1,len(edge[j+N])])
            edge[j+N].append([i,0,len(edge[i])-1])
for i in range(N):
    edge[N*2].append([i,1,len(edge[i])])
    edge[i].append([N*2,0,len(edge[N*2])-1])
    edge[N*2+1].append([i+N,0,len(edge[i+N])])
    edge[i+N].append([N*2+1,1,len(edge[N*2+1])-1])

def dfs(v,t,f):
    if v==t:
        return f
    used[v]=True
    for i,(nv,cap,rev) in enumerate(edge[v]):
        if not used[nv] and cap>0:
            d=dfs(nv,t,min(f,cap))
            if d>0:
                edge[v][i][1]-=d
                edge[nv][rev][1]+=d
                return d
    return 0

flow=0
while True:
    used=[False]*(N*2+2)
    f=dfs(N*2,N*2+1,INF)
    if f==0:
        break
    flow+=f
print(flow)

Measured memory_bytes: 47964
import math
import decimal
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

class Library():
    @staticmethod
    def Swap(a,b):
        return [b,a]

    @staticmethod
    def myRound(a,dig=0): # 四捨五入
        p = 10 ** dig
        return (a * p * 2 + 1) // 2 / p

    @staticmethod
    def Roundup(a,dig=0): # 切り上げ
        if a < 0:
            return int(a)
        else:
            return int(a + 0.9)

    @staticmethod
    def Gcd(a,b): #最大公約数
        if (a<b):
            a,b = Library.Swap(a,b)
        if (b==0):
            return a
        else:
            return Library.Gcd(b,a%b)

    @staticmethod
    def Lcm(a,b): #最小公倍数
        return a//Library.Gcd(a,b)*b

    @staticmethod
    def Divisors(a): # 約数列挙
        divisors = []
        for i in range(1,int(a**0.5)+1):
            if a%i==0:
                divisors.append(i)
                if i!=a//i:
                    divisors.append(a//i)
        divisors.sort()
        return divisors

class Prime():
    # コンストラクタ
    # エラストテネスの篩
    def __init__(self,num):
        self.num = num
        self.sieve = [0] * (self.num + 1)
        self.sieve[0] = -1
        self.sieve[1] = -1
        for i in range(2,self.num + 1):
            if not self.sieve[i]:
                self.sieve[i] = i
                for j in range(i * i,self.num + 1,i):
                    if self.sieve[j]:
                        self.sieve[j] = i
    
    # 素数判定
    def isPrime(self,num = None):
        if num is None:
            num = self.num
        if self.sieve[num] == num:
            return True
        else:
            return False
    
    # 素数列挙
    def PrimeNum(self,num = None):
        if num is None:
            num = self.num
        prime = []
        for i in range(2,num):
            if self.sieve[i] == i:
                prime.append(i)
        return prime
    
    # 素因数分解
    def PrimeFact(self,num = None):
        if num is None:
            num = self.num
        fact = []
        while self.sieve[num] != num:
            fact.append(self.sieve[num])
            num //= self.sieve[num]
        fact.append(num)
        return fact

def main():
    h,n = map(int,input().split())
    a = list(map(int,input().split()))
    if h <= sum(a):
        print('Yes')
    else:
        print('No')
    return

if __name__=='__main__':
    main()


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

#define EPS 1e-6
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using namespace std; 

using ll = long long;
using ii = pair<int,int>;

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

  int n; cin >> n;
  vector<ii> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i].fi;
    v[i].se = i + 1;
  }

  sort(all(v));
  for (auto i : v)
    cout << i.se << " ";
  cout << ende;

  return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>
#include <algorithm>
#include <vector>

const int kN = 100000 + 5;
int t[kN], a[kN], x, k, q;
int result[kN];

int main()
{
    scanf("%d%d", &x, &k);
    std::vector<std::pair<int, int>> events;
    for (int i = 0; i < k; ++ i) {
        int r;
        scanf("%d", &r);
        events.emplace_back(r, -1);
    }
    scanf("%d", &q);
    for (int i = 0; i < q; ++ i) {
        scanf("%d%d", t + i, a + i);
        events.emplace_back(t[i], i);
    }
    std::sort(events.begin(), events.end());
    int t0 = 0, dir = -1, i = 0, j = x, yi = 0, yj = x;
    for (const auto &e: events) {
        int t = e.first;
        int id = e.second;
        if (t0 < t) {
            int dt = t - t0;
            if (dir == -1) {
                if (dt < yi) {
                    yi -= dt;
                    yj -= dt;
                } else if (dt > yj) {
                    i = j = yi = yj = 0;
                } else {
                    i += dt - yi;
                    yi = 0;
                    yj -= dt;
                }
            } else {
                if (dt < x - yj) {
                    yj += dt;
                    yi += dt;
                } else if (dt > x - yi) {
                    i = j = yi = yj = x;
                } else {
                    j -= dt - (x - yj);
                    yj = x;
                    yi += dt;
                }
            }
        }

        t0 = t;
        if (id == -1) {
            dir = -dir;
        } else {
            if (a[id] <= i)
                result[id] = yi;
            else if (a[id] >= j)
                result[id] = yj;
            else
                result[id] = yi + a[id] - i;
        }
    }
    for (int i = 0; i < q; ++ i)
        printf("%d\n", result[i]);
}


Measured memory_bytes: 4080
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define llINF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
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;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
	x=modpow(x,MOD-2);
	return x;
}
string s;
int up[500010],down[500010],sum;
signed main(){
	cin>>s;
	int n=s.size()+1;
	rep(i,s.size()){
		if(s[i]=='<')up[i+1]=up[i]+1;
		else up[i+1]=0;
	}
	for(int i=s.size()-1;i>=0;i--){
		if(s[i]=='>')down[i]=down[i+1]+1;
		else down[i]=0;
	}
	rep(i,n)sum+=max(up[i],down[i]);
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 9092
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
    unsigned int N;
        cin >> N;
    long long * sum = new long long [N+1];
    long long nn,min1;
    sum[0] = 0;
    for(int i=1; i<=N; i++){
            cin >> nn;
            sum[i] = sum[i-1] + nn;
        }
    min1 = abs(sum[N] - 2*sum[1]);
    for(int i=2;i < N; i++){
        min1 = (min1 < abs(sum[N]-2*sum[i])) ? min1 : abs(sum[N]-2*sum[i]);
    }
    cout << min1 << endl;
    return 0;
}




Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class NIneNine
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');

        var first = int.Parse(input[0]);

        var second = int.Parse(input[1]);

        var ans = 0;

        if(first > 9 || second > 9)
        {
            ans = -1;
        }
        else
        {
            ans = first * second;
        }

        Console.WriteLine(ans);


    }
}

Measured memory_bytes: 13140
#import numpy as np
#T= str(input())
#K = int(input())
#x1,y1,x2,y2= map(int,input().split())
#A = list(map(int,input().split()))
#B = list(map(int,input().split()))
S= str(input())
a=[]
for i in S:
    if i not in a:
        a.append(i)
    else:
        print('no')
        exit()
print('yes')


Measured memory_bytes: 2940
import java.util.*;
public class Main{
  static long aa[][];
	static long maxx(int[] ww,int[] v,int ind,int w){
    	  if(ind>=v.length || w==0 ){return 0;}
            if(aa[ind][w]!=-1){return aa[ind][w];}
          if(w-ww[ind]<0){
          	return aa[ind][w]=maxx(ww,v,ind+1,w); 
          }
          else{
          return aa[ind][w]=Math.max( maxx(ww,v,ind+1,w-ww[ind])+(long)v[ind],
                                     maxx(ww,v,ind+1,w));
          }
      
    }
  public static void main(String[] args){
  	Scanner s=new Scanner(System.in);
    int n=s.nextInt();
    int w=s.nextInt();
    int[] ww=new int[n],v=new int[n];
    aa=new long[n][w+1];
    for(int j=0;j<n;j++){
    	ww[j]=s.nextInt();
        v[j]=s.nextInt();
      for(int i=0;i<=w;i++){aa[j][i]=-1; }
    }
    System.out.println(maxx(ww,v,0,w)); 
  
  }

}

Measured memory_bytes: 127700
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        for(int i=0; i<n-k; i++) {
            if(a[i]<a[i+k]) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }


        }

    }


}

Measured memory_bytes: 60088
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")

#include <iostream>
#include <string>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <queue>
#define PII pair<int, int>
#define T3I tuple<int, int, int>
#define STA(a, b) min(a, b), max(a, b)
using namespace std;

typedef long long ll;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;

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

    vector<int> A = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << A[k-1] << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

n = int(input())
l = list(map(int, input().split()))
ans = 0 

for i in range(n):
    for j in range(i+1, n): 
        for k in range(j+1, n): 
            if l[i] != l[j] and l[j] != l[k] and l[i] != l[k]:
                s = l[i] + l[j] + l[k]
                if max([l[i], l[j], l[k]]) < s - max([l[i], l[j], l[k]]):
                    ans += 1
print(ans)


Measured memory_bytes: 9208
#include <bits/stdc++.h>
//#include <iostream>
//#include <stdlib.h>
//#include <string>
using namespace std;

struct Node{
  int key;
  Node *right;
  Node *left;
  Node *parent;
};

Node *NIL;
Node *root;
void insert(int);
void inorder(Node*);
void preorder(Node*);

int main(){
  int i,n,x;
  string comment;
  cin >> n;
  for(i = 0; i < n; i++){
    cin >> comment;
    if(comment == "insert"){
      cin >> x;
      insert(x);
    }
    else if(comment == "print"){
      inorder(root);
      cout << endl;
      preorder(root);
      cout << endl;
    }
  }
  return 0;
}

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  //z = (Node*)malloc(sizeof(Node));
  z = new Node;
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL){
    y = x;
    if((z->key) < (x->key)){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }else{
    if((z->key) < (y->key)){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}

void inorder(Node *u){
  if(u == NIL){
    return;
  }
  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);
}

void preorder(Node *u){
  if(u == NIL){
    return;
  }
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);
}

Measured memory_bytes: 26564
#include <stdio.h>
#include <sstream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#include <ctype.h>
#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, char> pic;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

ll bit[200010];
int max_n = 200000;
int pm = 0;
void add(int x) {

	while (max_n >= x)
	{
		bit[x]++;
		x += x & -x;
	}
}
void sub(int x) {
	while (max_n >= x)
	{
		bit[x]--;
		x += x & -x;
	}
}


void solv() {
	
	int n;
	cin >> n;
	int dq[2000100];

	int l = 0,t = 0;
	for (int i = 0; i < n; i++)
	{
		char s[128];
		scanf("%s", s);
		int v;
		if (!strncmp(s,"insert",strlen("insert"))) {
			cin >> v;
			dq[t] = v;
			t++;
		}
		else if (!strcmp(s, "delete")) {
			cin >> v;
			for (int p = t - 1; p >= l; p--) {
				if (dq[p] == v) {
					dq[p] = -1;
					break;
				}
			}
		}
		else if (!strcmp(s, "deleteFirst")) {
			while (dq[--t] == -1) {  }
		}
		else while (dq[l++] == -1) { };
	}
	int c = 0;
	for (int i = t - 1; i >= l; i--)
	{
		if (dq[i] == -1) continue;
		if (c > 0) cout << " ";
		cout << dq[i];
		c++;
	}
	cout << endl;
}
int main() {
	//	COMinit();
	solv();
	return 0;
}



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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(auto& x : a){
        cin >> x;
    }
    cout << *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end()) << endl;
}


Measured memory_bytes: 256
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

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

	string ans;

	int amari = N % 10;

	if (amari == 3) {
		ans = "bon";
	} else if (amari == 0 || amari == 1 || amari == 6 || amari == 8) {
		ans = "pon";
	} else {
		ans = "hon";
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
  int M1, D1, M2,D2;
  cin >> M1 >> D1 >> M2 >>D2;

 if(D2 == 1){ 
  cout << 1 << endl;
}else{
  cout << 0 << endl;
}
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<array>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;

static const int MAX=1000000;
static const int nil=-1;
int n;
vector<int> g[MAX];
int color[MAX];

void dfs(int r,int c){
    stack<int> s;
    s.push(r);
    color[r]=c;
    while(!s.empty()){
        int u=s.top();s.pop();
        for(int i=0;i<g[u].size();i++){
            int v=g[u][i];
            if(color[v]==nil){
                color[v]=c;
                s.push(v);
            }
        }
        
    }
    
    
    
}
void assignColor(){
    
    int id=1;
    rep(i,n)color[i]=nil;
    rep(i,n){
        if(color[i]==nil)dfs(i,id++);
    }
    
    
}

int main(){
    int s,t,m,q;
    cin>>n>>m;
    rep(i,m){
        cin>>s>>t;
        g[s].push_back(t);
        g[t].push_back(s);
    }
    assignColor();
    
    cin>>q;
    
    rep(i,q){
        cin>>s>>t;
        if(color[s]==color[t]){
            cout<<"yes"<<endl;
        }else{
            cout<<"no"<<endl;
        }
    }
    

return 0;
}



Measured memory_bytes: 30092
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <stack>
#include <queue> 
using namespace std;
int main(void){
    string s,t;
    cin>>s>>t;
    int a[30]={},b[30]={};
    for(int i=0;i<s.size();i++){
        a[s[i]-'a']++;
    }
    for(int i=0;i<t.size();i++){
        b[t[i]-'a']++;
    }
    string ss,tt;
    for(int i=0;i<26;i++){
        for(int j=0;j<a[i];j++){
            ss+=i+'a';
        }
    }
    for(int i=25;i>=0;i--){
        for(int j=0;j<b[i];j++){
            tt+=i+'a';
        }
    }
    if(ss<tt)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

int main(){
    string s;
    ll a=0,b=0;
    cin>>s;
    rep(i,3) {
        if(s.at(i)=='A') a++;
        else b++;
        }
    if(a==0 || b==0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)

def solve(N):
    s = 0
    for i in range(1, N+1):
        if i % 3 != 0 and i % 5 != 0:
            s += i
    return s

if __name__ == "__main__":
    N = int(input())
    print(solve(N))


Measured memory_bytes: 9168
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define repf(i, n) for(int i=1; i<(int)(n+1); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli a, b, k;
    cin >> a >> b >> k;
    if(a < k){
        k -= a;
        a = 0;
        (b >= k) ? b -= k : b = 0;
    }
    else a -= k;
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    s = '0' + s;
    int n = size(s);
    ll dp[n+1][2];
    repn(i, n) rep(j, 2) dp[i][j] = INF;
    dp[0][0] = 0;
    rep(i, n) {
        int x = s[i] - '0';
        chmin(dp[i+1][0], dp[i][0]+x);
        chmin(dp[i+1][1], dp[i][0]+x+1);
        chmin(dp[i+1][0], dp[i][1]+(10-x));
        chmin(dp[i+1][1], dp[i][1]+(9-x));
    }
    cout << dp[n][0] << endl;
}

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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

const int N = 105;
const int mod = 1e9 + 7;

int n, c[N][N], f[N][N];

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  Read(n);
  for (int i = 0; i <= n; ++i) {
    c[i][0] = 1;
    for (int j = 1; j <= i; ++j) {
      c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
    }
  }
  f[1][n] = f[1][n - 1] = n;
  for (int i = 1; i <= n; ++i) {
    for (int j = -n; j <= n; ++j) {
      if (f[i][j + n]) {
        for (int k = max(1, abs(j)); k <= n - i; ++k) {
          if (!(j + k & 1)) {
            for (int l = 0; l <= k; ++l) {
              int t = (j + k >> 1) - l;
              if (t >= -n && t <= n) {
                f[i + k][t + n] = (1LL * f[i][j + n] * c[n - i][k] % mod * c[k][l] + f[i + k][t + n]) % mod;
              }
            }
          }
        }
      }
    }
  }
  printf("%d\n", f[n][n]);
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>
#include<string>

using namespace std;

char cap( char c )
{
  if ( c >= 'a' && c <= 'z' )
    return c - 0x20;
  else if ( c >= 'A' && c <= 'Z' )
    return c + 0x20;
  else
    return c;
}

int main()
{
  string s;
  
  getline( cin, s );

  for ( auto i = 0; i < s.size(); ++i )
    s[i] = cap( s[i] );
  
  cout << s << endl;
  
  return 0;
}

Measured memory_bytes: 1176
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		ArrayList<Integer> Kind = new ArrayList<Integer>();
		for(int i = 0; i < N; i ++) {
			int length = stdIn.nextInt();
			if(Kind.contains(length)) {
				map.replace(length, map.get(length) + 1);
			}else {
				Kind.add(length);
				map.put(length, 1);
			}
		}
		
		int ans = 0;
		
		for(int i = 0; i < Kind.size(); i ++) {
			for(int j = i + 1; j < Kind.size(); j ++) {
				for(int k = j + 1; k < Kind.size(); k ++) {
					int a = Kind.get(i);
					int b = Kind.get(j);
					int c = Kind.get(k);
					int longest = Math.max(a, Math.max(b, c));
					if(longest < a + b + c - longest) {
						ans += map.get(a) * map.get(b) * map.get(c);
					}
				}
			}
		}
		
		System.out.println(ans);
		
	}
}

Measured memory_bytes: 46904
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repm(i, m, n) for (int i = (m); i < (int)(n); i++)
#define repr(i, n) for (int i = (n); i < 0; i--)
#define all(vec) vec.begin(), vec.end()
using namespace std;
int sum(vector<int> vec){
  int s = 0;
  rep(i, vec.size()) s += vec.at(i);
  return s;
}

int main(){
  int a, b;
  cin >> a >> b;
  int ans = 0;
  vector<int> r(a);
  rep(i, a) cin >> r.at(i);
  b -= sum(r);
  ans = a + b / *min_element(all(r));
  cout << ans << endl;
}

Measured memory_bytes: 256