akhauriyash/Code-Regression huggingface dataset:
while True:
   n,x=map(int,input().split())
   if n==0 and x==0:
      break
   else:
      count=0
      for a in range(1,n-1):
          for b in range(a+1,n):
            for c in range(b+1,n+1):
              if a+b+c==x:
                count=count+1
      print(count)


Measured memory_bytes: 5592
#include<stdio.h>

int main(void){
    int a,n,i,min = 1000000,max = -1000000;
    long int sum = 0;
    scanf("%d",&n);
    for(i = 0;i < n; i++){
        scanf("%d",&a);
        sum+=a;
        if(min > a)
            min=a;
        if(max < a)
            max=a;
    }
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vint a(N);
    REP(i,N) cin>>a[i];
    sort(ALL(a));

    int ai=a[N-1];
    int aj=-1;
    int diff_min=1e18;
    REP(j,N-1){
        int diff;
        if(ai%2==0) diff=abs(a[j]-ai/2);
        else{
            diff=min(abs(a[j]-(ai-1)/2),abs(a[j]-(ai+1)/2));
        }
        if(diff<diff_min){
            diff_min=diff;
            aj=a[j];
        }
    }
    cout<<ai<<' '<<aj<<endl;

}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    if K==1:
        print(0)
    else:
        print(N-K)

main()


Measured memory_bytes: 61728
//#define NDEBUG

#include <bits/stdc++.h>
#include <bits/extc++.h>

#define StarBurstStream ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define iter(a) a.begin(), a.end()
#define riter(a) a.rbegin(), a.rend()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(riter(a))
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define pf(a) push_front(a)
#define pob pop_back()
#define pof pop_front()
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define mt make_tuple
#define gt(t, i) get<i>(t)
#define iceil(a, b) (((a) + (b) - 1) / (b))
#define tomax(a, b) ((a) = max((a), (b)))
#define printv(a, b) {bool pvaspace=false; \
for(auto pva : a){ \
    if(pvaspace) b << " "; pvaspace=true;\
    b << pva;\
}\
b << "\n";}

//#define TEST

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using tiii = tuple<int, int, int>;

const ll MOD = 1000000007;
const ll MAX = 2147483647;

template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.F << ',' << p.S << ')';
}

int main(){
    StarBurstStream

    string s;
    cin >> s;
    int k;
    cin >> k;

    int n = s.size();
    set<string> st;
    for(int i = 0; i < n; i++){
        for(int j = 1; i + j <= n && j <= k; j++){
            st.insert(s.substr(i, j));
            if(st.size() > k) st.erase(prev(st.end()));
        }
    }
    cout << *st.rbegin() << "\n";

    return 0;
}

Measured memory_bytes: 256
A, B, K = map(int, input().split())
divisor_A = [A] 
divisor_A_count = 2 
divisor_B = [B]
divisor_B_count = 2
for i in range(A-1,1,-1):
    if (A % i) == 0:
        divisor_A.append(i)
        divisor_A_count += 1
divisor_A.append(1) 
for i in range(B-1,1,-1):
    if (B % i) == 0:
        divisor_B.append(i)
        divisor_B_count += 1
divisor_B.append(1) 
a_num = 1   
a = divisor_A[a_num-1]   
b_num = 1   
b = divisor_B[b_num-1]   
c_divisor_count = 0  
for i in range(divisor_A_count * divisor_B_count):
    
    if divisor_A[a_num-1] == divisor_B[b_num-1]:
        c_divisor_count += 1
        if c_divisor_count == K:
            break
        else:
            a_num += 1
            b_num += 1
    
    elif divisor_A[a_num-1] > divisor_B[b_num-1]:
        a_num += 1
    else: 
        b_num += 1
print(divisor_A[a_num-1]) 


Measured memory_bytes: 3064
N = int(input())
S = [''] * N
A = []
B = []
AB = []
cnt = 0
for i in range(N):
  S[i] = input()
  cnt += S[i].count('AB')
  if S[i][0] == 'B' and S[i][-1] == 'A':
    AB.append(i)
  elif S[i][-1] == 'A':
    A.append(i)
  elif S[i][0] == 'B':
    B.append(i)
cnt += max(len(AB) - 1, 0)
cnt += min(len(A), len(B))
if (len(A) or len(B)) and len(AB):
  cnt += 1
print(cnt)


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

namespace YahooProCon
{
    class B
    {
        static void Main(string[] args)
        {

            int[] num = new int[4];

            for(int i = 0; i < 3; i++)
            {
                int[] c = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                int a = c[0]-1; int b = c[1]-1;
                num[a]++;num[b]++;
            }
            int max = num.Max();
            string s= (max <= 2)? "YES" : "NO";
            Console.WriteLine(s);
        }

    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define rer(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<pi, int> ppi;
typedef vector<ll> vi;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest) { 
	cout << arg << " "; Debug(rest...); }
template<class T>ostream& operator<< (ostream& out, const vector<T>& v) {
	out << "[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<< ", ";out<<v.back();}out << "]";return out;}
template<class S, class T>ostream& operator<< (ostream& out, const pair<S, T>& v) {
	out << "(" << v.first << ", " << v.second << ")";return out;}
const int MAX_N = 600100;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int A, B;
ll C[2020][2020];
ll CS[2020][2020];
ll dp[2020][2020];

void C_init(int n) {
	n++;
	rep(i, 0, n) C[i][0] = 1;
	rep(i, 1, n) {
		rep(j, 1, i + 1) {
			C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
			C[i][j] %= mod;
		}
	}
}

void solve() {
	cin >> A >> B;
	C_init(2010);
	rep(i, 0, 2010) {
		rep(j, 0, 2010) {
			CS[i][j + 1] = CS[i][j] + C[i][j];
			CS[i][j + 1] %= mod;
		}
	}
	rep(i, 0, A + 1) dp[i][0] = 1;
	rep(j, 0, B + 1) dp[0][j] = 1;
	rep(i, 1, A + 1) {
		rep(j, 1, B + 1) {
			dp[i][j] = (dp[i - 1][j] + CS[j - 1][min(i, j - 1) + 1]) % mod;
		}
	}
	ll res = 0;
	rep(i, 0, A + 1) {
		rep(j, 0, B) {
			if(i + j > A) continue;
			res += dp[i][j] * C[B - 1][j];
			res %= mod;
		}
	}
	cout << res << "\n";
}


int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(5);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 95744
#include <algorithm>
#include <bitset>
#include <cfloat>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps DBL_EPSILON
#define mod (ll)1000000007
#define INF INT_MAX/10
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n;
string s[100010];
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}
	sort(s, s + n);
	int ans = 0;
	rep(i, n) {
		ans += upper_bound(s, s + n, s[i]) - lower_bound(s, s + n, s[i]) - 1;
	}
	cout << ans / 2 << endl;
	return 0;
}


Measured memory_bytes: 7296
from heapq import heapify, heappushpop

n = int(input())
xs = [int(x) for x in input().split()]

xs1 = xs[:n]
heapify(xs1)
r1 = [sum(xs1)]
for x in xs[n:2*n]:
    r1.append(r1[-1] + x - heappushpop(xs1, x))

xs2 = [-x for x in xs[2*n:]]
heapify(xs2)
r2 = [sum(xs2)]
for x in reversed(xs[n:2*n]):
    r2.append(r2[-1] + (-x) - heappushpop(xs2, -x))

print(max(a+b for a,b in zip(r1, reversed(r2))))

Measured memory_bytes: 40340
#include <iostream>
#include <map>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	int n;
	cin >> n;
	map<string, int> m;
	while (n--) {
		string s;
		cin >> s;
		m[s]++;
	}
	cout << "AC x " << m["AC"] << '\n'
		<< "WA x " << m["WA"] << '\n'
		<< "TLE x " << m["TLE"] << '\n'
		<< "RE x " << m["RE"] << '\n';
	return 0;
}


Measured memory_bytes: 3188
n, m = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
A.reverse()
while m > 0:
    A[0] = A[0] // 2
    m -= 1
    i = 1
    while m > 0 and i < n:
        if A[i] > A[0]:
            A[i] = A[i] // 2
            m -= 1
            i += 1
        else:
            break
    A.sort()
    A.reverse()
print(sum(A))

Measured memory_bytes: 14224
function Main(input) {
	input = input.trim().split("\n").map(function(x) { return x.split(" ")});    
	let N = parseInt(input[0][0], 10);
	let Q = parseInt(input[0][1], 10);
	let uf = new UnionFind(N);
	let line;
	let v_ans = [];
	for (let i = 0; i < Q; i++){
		line = input[i + 1].map(e => parseInt(e, 10));
		if (line[0] === 0) uf.union(line[1], line[2]);
		else (uf.find(line[1]) === uf.find(line[2])) ? v_ans.push(1) : v_ans.push(0);
	}
	console.log(v_ans.join("\n"));
}

function UnionFind (n) {
	this.parents = [];
	for (let i = 0; i < n; i++) {
		this.parents.push(-1);
	}
}

UnionFind.prototype.find = function (x) {
	if (this.parents[x] < 0) return x;
	return this.parents[x] = this.find(this.parents[x]);	
}

UnionFind.prototype.union = function (x, y) {
	x = this.find(x);
	y = this.find(y);
	if (x === y) return;
	if (this.parents[x] > this.parents[y]) [x, y] = [y, x];
	
	this.parents[x] += this.parents[y];
	this.parents[y] = x;
}

UnionFind.prototype.size = function (x) {
	x = this.find(x);
	while (x >= 0) {
		x = this.parents[x];
	}
	return x * -1;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 68660
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define tri pair<pll, ll>
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll cpow(ll a, ll b, ll M){ll ans = 1;while(b){if(b&1) ans = ans*a%M; b/=2;a=a*a%M;}return ans;}
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}
ll fexp(ll a, ll b) {return cpow(a, b, MOD);}
ll cinv(ll a, ll p){return cpow(a, p-2, p);} 
ll inverse(ll a)    {return cinv(a, MOD);}

bool dp[2][20000];
ll N = 8000;

bool can(vl& vec, ll x, ll id){
    dp[1][N] = 1;
    ll n = s(vec);
    ll idx = 0;
    rep(i, n){
        rep(j, 2*N + 1){
        	dp[idx][j] = 0;
            if(j - vec[i] >= 0)  dp[idx][j] |= dp[1-idx][j-vec[i]];
            if((id || i) && j + vec[i] <= 2*N)   dp[idx][j] |= dp[1-idx][j+vec[i]];
        }
        idx = 1-idx;
   		if(!i)	dp[1][N] = 0;
    }
    return dp[1-idx][x+N];
}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
        string str;
        cin>>str;
        ll u, v;cin>>u>>v;
        ll n = s(str);
        vl v1, v2;
        ll cur = 0;
        bool x = 0;
        rep(i, n){
            if(str[i] == 'F')   cur++;
            else{
                if(x)   v2.pb(cur);
                else v1.pb(cur);
                x ^= 1;
                cur = 0; 
            }
        }
        if(x)   v2.pb(cur);
        else v1.pb(cur);
        // for(ll v : v1)  cout<<v<<" ";cout<<endl;
        if(can(v1, u, 0)){
            rep(i, 20000)   dp[0][i] = 0, dp[1][i] = 0;
            if(can(v2, v, 1))  cout<<"Yes";
            else cout<<"No";
        }else cout<<"No";
    }
}


Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int main() {
	int a, b, x;
	cin >> a >> b >> x;
	puts(a <= x && a + b >= x ? "YES" : "NO");
	return 0;
}


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

struct FastIO {
  FastIO() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
  }
} fast_io;

#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define rd(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define wt(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;
#include <math.h>

template <typename T, class DS>
class Mo {
 public:
  Mo(DS& ds) : ds_(ds) {}
  void AddQuery(int begin, int end) {
    int index = queries_.size();
    queries_.push_back({begin, end, index});
  }
  std::vector<T> ProcessQueries() {
    int bin = sqrt(queries_.size());
    sort(queries_.begin(), queries_.end(),
         [&bin](const Query& a, const Query& b) {
           int c = a.begin / bin, d = b.begin / bin;
           if (c != d) return c < d;
           if (c % 2 == 0) {
             return a.end < b.end;
           }
           return a.end > b.end;
         });
    std::vector<T> ret(queries_.size());
    Query p = {0, 0, 0};
    for (std::size_t i = 0; i < queries_.size(); ++i) {
      const Query& c = queries_[i];
      Add(c.begin, p.begin);
      Del(p.begin, c.begin);
      Add(p.end, c.end);
      Del(c.end, p.end);
      ret[c.index] = ds_.Get();
      p = c;
    }
    return ret;
  }

 private:
  struct Query {
    int begin, end, index;
  };
  void Add(int begin, int end) {
    for (int i = begin; i < end; ++i) {
      ds_.Add(i);
    }
  }
  void Del(int begin, int end) {
    for (int i = begin; i < end; ++i) {
      ds_.Del(i);
    }
  }
  DS& ds_;
  std::vector<Query> queries_;
};

using namespace std;

struct DS {
  DS(int n) : c(n), kinds(n), unique_kinds(0) {}
  void Add(int i) {
    if (kinds[c[i] - 1]++ == 0) {
      ++unique_kinds;
    }
  }
  void Del(int i) {
    if (--kinds[c[i] - 1] == 0) {
      --unique_kinds;
    }
  }
  int Get() const { return unique_kinds; }
  V<int> c;
  V<int> kinds;
  int unique_kinds;
};

int main() {
  rd(int, n, q);
  DS ds(n);
  rep(i, n) cin >> ds.c[i];

  Mo<int, DS> mo(ds);
  rep(i, q) {
    rd(int, l, r);
    mo.AddQuery(l - 1, r);
  }

  for (int ans : mo.ProcessQueries()) {
    wt(ans);
  }
}


Measured memory_bytes: 15496
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

VI calc(int n)
{
    VI ret(4, 0);
    ret[3] = n / 500;
    n %= 500;
    ret[2] = n / 100;
    n %= 100;
    ret[1] = n / 50;
    n %= 50;
    ret[0] = n / 10;
    n %= 10;
    return ret;
}

VI ans;
int cost = IINF;
int value[4] = {10, 50, 100, 500};
int n;
void dfs(VI &curnum, int depth, VI &num)
{
    if (depth == 4)
    {
        int cur = 0;
        int curcost = 0;
        rep(i, 4)
        {
            cur += value[i] * curnum[i];
        }
        if (cur >= n)
        {
            auto ret = calc(cur - n);
            int curcost = 0;
            rep(i, 4)
            {
                curcost += ret[i] + num[i] - curnum[i];
                if (curnum[i] != 0 && ret[i] != 0)
                {
                    curcost = IINF;
                    break;
                }
            }
            if (curcost < cost)
            {
                cost = curcost;
                ans = curnum;
            }
        }
    }
    else
    {
        curnum.push_back(0);
        dfs(curnum, depth + 1, num);
        rep(i, num[depth])
        {
            curnum.back()++;
            dfs(curnum, depth + 1, num);
        }
        curnum.pop_back();
    }
}

void solve()
{
    cost = IINF;
    VI num(4);
    rep(i, 4)
    {
        cin >> num[i];
    }
    VI curnum;
    dfs(curnum, 0, num);
    rep(i, 4)
    {
        if (ans[i] != 0)
        {
            cout << value[i] << " " << ans[i] << endl;
        }
    }
}

int main()
{
    cin >> n;
    solve();
    while (cin >> n, n)
    {
        cout << endl;
        solve();
    }
    return 0;
}


Measured memory_bytes: 3072
# coding: utf-8
import sys
input = sys.stdin.readline

def f(n, wlimit):
    dp = [-1] * (wlimit + 1)
    dp[0] = 0
    for i in range(1, n + 1):
        wi, vi = map(int, input().rstrip().split())
        dp_ = list(dp)
        for w in range(wlimit + 1):
            if dp[w] >= 0:
                w_ = w + wi
                v_ = dp[w] + vi
                if w_ <= wlimit and dp[w_] < v_:
                    dp_[w_] = v_
        dp = dp_
    return(max(dp))

n, w = map(int, input().rstrip().split()) # 1 <= n <= 100, 1 <= w <= 10^5

print(f(n, w))


Measured memory_bytes: 13028
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr ll MOD = 1000000007;
using std::cout;
using std::endl;
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::multiset;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b % 2 == 1) {
			ans *= a;
			ans %= MOD;
		}
		b /= 2;
		a *= a;
		a %= MOD;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a - b < b) { return comb(a, a - b); }
	ll c = 1;
	FOR(i, a - b + 1, a + 1) {
		c *= i;
		c %= MOD;
	}
	ll k = 1;
	FOR(i, 2, b + 1) {
		k *= i;
		k %= MOD;
	}
	c *= pow(k, MOD - 2);
	return c % MOD;
}
multiset<ll> prime_decomposition(ll n) {
	ll i = 2;
	multiset<ll> table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace(n);
		return table;
	}
	return table;
}

int main() {
	int n;
	cin >> n;
	VL v(10e5+1);
	REP(i, n) {
		int t;
		cin >> t;
		++v[t];
	}
	ll max = 0;
	FOR(i, 1, 10e5) {
		max = std::max(v[i - 1] + v[i] + v[i + 1], max);
	}
	cout << max << endl;

}

Measured memory_bytes: 8064
#include <stdio.h>

#define N 100

int main() {
	static char s[N + 1];
	int n, i;

	scanf("%d%s", &n, s);
	if (n % 2) {
		printf("No\n");
		return 0;
	}
	for (i = 0; i < n / 2; i++)
		if (s[i] != s[i + n / 2]) {
			printf("No\n");
			return 0;
		}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

int main()
{
    int S, A, B;
    cin >> S;
    A = S / 100;
    B = S % 100;
    if(A >= 1 && A <= 12 && B >= 1 && B <= 12) cout << "AMBIGUOUS" << endl;
    else if(A >= 1 && A <= 12 && B > 12) cout << "MMYY" << endl;
    else if(A >= 1 && A <= 12 && B == 0) cout << "MMYY" << endl;
    else if(A > 12 && B >= 1 && B <= 12) cout << "YYMM" << endl;
    else if(A == 0 && B >= 1 && B <= 12) cout << "YYMM" << endl;
    else cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

using lint = long long;
using plint = pair<double, lint>;

int N;
lint L;

// deque<plint> deq;

array<plint, 500000> deq;
int s = 0;
int t = -1;

double Qsum = 0;
lint Vnow = 0;

void trim()
{
    while (Vnow > L)
    {
        lint nuku = min(Vnow - L, deq[s].second);
        deq[s].second -= nuku;
        Vnow -= nuku;
        Qsum -= nuku * deq[s].first;
        if (deq[s].second == 0) s++;
    }
}

void add(double tadd, lint vadd)
{
    if (deq[t].first < tadd) // 追加するほうが高温の場合、先頭から余剰分を抜いていく
    {
        t++; deq[t] = plint(tadd, vadd);
        Qsum += tadd * vadd;
        Vnow += vadd;
        trim();
    }
    else // 低温の場合、うしろとくっつけていく
    {
        if (deq[t].second + vadd >= L)
        {
            Qsum = deq[t].first * (L - vadd) + tadd * vadd;
            Vnow = L;
            s = 0, t = -1;
            t++; deq[t] = plint(Qsum / L, L);
        }
        else
        {
            double Qaddnew = deq[t].first * deq[t].second + tadd * vadd;
            lint vaddnew = deq[t].second + vadd;
            Qsum -= deq[t].first * deq[t].second;
            Vnow -= deq[t].second;
            t--;
            add(Qaddnew / vaddnew, vaddnew);
        }
    }
}

void print()
{
    cout << setprecision(12) << Qsum / L << endl;
}
int main()
{
    cin.tie(0); ios::sync_with_stdio(0);
    cin >> N >> L;
    REP(_, N)
    {
        double tmp;
        lint v;
        cin >> tmp >> v;
        if (_ == 0)
        {
            t++; deq[t] = plint(tmp, v);
            Qsum = tmp * v;
            Vnow = v;
            print();
        }
        else
        {
            add(tmp, v);
            print();
        }
    }
}


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

int main() {
    string s,t;cin>>s>>t;
    int s1 = s.size();
    int t1 = t.size();
    int ans = t1;
    
    rep(i,s1-t1+1){
        int tmp=0;
        rep(j,t1){
            if(s[i+j]!=t[j])++tmp;
        }
        ans = min(ans,tmp);
    }
    cout<<ans<<endl;
	return 0;
}

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

int main()
{
	string s[3];
	cin >> s[0] >> s[1] >> s[2];
	int n[3] = {}, now = 0;
	while (1) {
		if (n[now] == s[now].size()) {
			cout << (char)('A' + now) << endl;
			return 0;
		}
		n[now]++;
		now = s[now][n[now] - 1] - 'a';
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main(){
    int N, M; cin >> N >> M;
    if(M%N==0){
        cout << N + M << endl;
        return 0;
    } else {
        cout << M - N << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static class Point{
		int x, y, zero, minus;
		public Point(int x, int y) {
			this.x = x;
			this.y = y;
			zero = x + y;
			minus = x - y;
		}
		public int manhattan(Point p) {
			int tmpx = Math.abs(this.x - p.x);
			int tmpy = Math.abs(this.y - p.y);
			return tmpx + tmpy;
		}
	}
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Point p[] = new Point[n];
		for(int i = 0; i < n; ++i){
			p[i] = new Point(sc.nextInt(), sc.nextInt());
		}
		sc.close();
		int zmax = 0, zmin = Integer.MAX_VALUE, wmax = Integer.MIN_VALUE, wmin = Integer.MAX_VALUE;
		for(int i = 0; i < n; ++i){
			Point tmp = p[i];
			int tmpz = tmp.zero;
			int tmpw = tmp.minus;
			zmax = Math.max(zmax, tmpz);
			zmin = Math.min(zmin, tmpz);
			wmax = Math.max(wmax, tmpw);
			wmin = Math.min(wmin, tmpw);
		}
		int ans = Math.max((zmax - zmin), (wmax - wmin));
		System.out.println(ans);
	}
}


Measured memory_bytes: 67052
#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() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> num(n);
  rep(i, n) cin >> num[i];
  map<ll, ll> mp;
  ll res = 0;
  rep(i, n) {
    res += mp[i + 1 - num[i]];
    mp[i + 1 + num[i]]++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 26696
import java.util.Scanner;

public class Main{
    public static void main (String[] args){
        try(Scanner sc = new Scanner(System.in)){
            int n = sc.nextInt();
            int [] rooms = new int[500];
            for(int i=0;i<n;i++){
                int b = sc.nextInt();
                int f = sc.nextInt();
                int r = sc.nextInt();
                int v = sc.nextInt();
                rooms[getIndex(b,f,r)] += v;
            }
            String lineDelimiter = "";
            for(int b = 1; b<=4; b++){
                System.out.print(lineDelimiter);
                for(int f=1; f<=3; f++){
                    for(int r=1;r<=10;r++){
                        System.out.print(' ');
                        System.out.print(rooms[getIndex(b,f,r)]);
                    }
                    System.out.println();
                }
                lineDelimiter = "####################" + System.lineSeparator();
            }
        }
    }

    private static int getIndex(int b, int f, int r) {
        return(b-1)*100+(f-1)*10+(r-1);
    }
}


Measured memory_bytes: 29232
#include <iostream>
#include <vector>
#include <cassert>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int k, n;
  string s;
  cin >> k >> s;
  n = s.size();
  combination c(n+k);
  mint ans = 0;
  for (int i = 0; i <= k; ++i) {
    mint now = mint(26).pow(k-i);
    now *= c(i+n-1, n-1);
    now *= mint(25).pow(i);
    ans += now;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 35184
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
#define TSUKASA_DIARY_S_TEMPLATE
// define
#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) int((a).size())
#define cauto const auto
// typedef
typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;
template< typename T > using Vec = vector< T >;
template< typename T > using Matrix = Vec< Vec< T > >;
template< typename T > using USet = unordered_set< T >;
template< typename T, class C > using MyUSet = unordered_set< T, C >;
template< typename T, typename F > using UMap = unordered_map< T, F >;
template< typename T, typename F, class C > using MyUMap = unordered_map< T, F, C >;
// hash
class PiiHash { public: size_t operator () (const pii& p) const { return (p.first << 16) | p.second; } };
// popcount
inline int POPCNT(int x) { return __builtin_popcount(x); }
inline int POPCNT(lint x) { return __builtin_popcount(x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
const Double EPS = 1e-9;
const Double PI = acos(-1);
// inrange
template< typename T >
inline bool in_range(T v, T mi, T mx) { return mi <= v && v < mx; }
template< typename T >
inline bool in_range(T x, T y, T W, T H) { return in_range(x,0,W) && in_range(y,0,H); }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
template< typename T > inline void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }
template< typename T > inline void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > inline void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > inline void maxUpdate(T& a, T b) { a = max(a, b); }
// converter
template< typename F, typename T >
inline void convert(F& from, T& to) {
	stringstream ss;
	ss << from; ss >> to;
}



int main() {
	int N, A, B;
	cin >> N >> A >> B;
	
	if (A > B) puts("0");
	else {
		if (N == 1) {
			if (A < B) puts("0");
			else puts("1");
		} else {
			int x = B - A;
			cout << (lint)x * lint(N - 2) + 1 << endl;
		}
	}
}

Measured memory_bytes: 256
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        a: usize, b: usize,
        s: chars,
    }
    let is_ok = s.len() == a + b + 1
        && s[a] == '-'
        && s.split(|&c| c == '-').count() == 2;
    println!("{}", if is_ok { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
dice1 = gets.split.map(&:to_i)
dice2 = gets.split.map(&:to_i)
throw = {E: [3, 2, 6, 1, 5, 4], N: [5, 1, 3, 4, 6, 2],
         S: [2, 6, 3, 4, 1, 5], W: [4, 2, 1, 6, 5, 3]}
th = {}
throw.each_key {|k| th[k] = throw[k].map(&:pred)}

rotate = ->(dir, dice) {
  next_dice = Array.new(6, 0)
  dice.each_with_index do |d, i|
    next_dice[th[dir][i]] = d
  end
  next_dice
}

stack = []
dice = dice2
next_dice = loop do
  [:E, :N, :S, :W].each {|d| stack << [dice, d]}
  dice, dir = stack.shift
  next_dice = rotate.(dir, dice)
  if next_dice[1] == dice1[1]
    break next_dice
  else
    dice = next_dice
  end
end

result = "No"
4.times do
  if next_dice == dice1
    result = "Yes"
    break
  end
  next_dice = rotate.(:E, next_dice)
end
puts result



Measured memory_bytes: 8904
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}



int main() {
	while (1) {
		string input;
		getline(cin,input);
		if (input == ".") break;
		stack<char> st;
		for (auto c : input) {
			if (c == '('||c=='[') {
				st.push(c);
			}
			else if (c == ')') {
				if (st.empty()||st.top()!='(') {
					st.push('!');
					break;
				}
				else {
					st.pop();
				}
			}
			else if (c == ']') {
				if (st.empty() || st.top() != '[') {
					st.push('!');
					break;
				}
				else {
					st.pop();
				}
			}
		}
		if (st.empty()) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}
}



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
char s[110];int c=0;
  cin>>s;
for(int i=0;i<strlen(s)/2;i++)
{
  if(s[i]!=s[strlen(s)-i-1])
  {
 c++; }
}cout<<c;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<queue>
#include<list>
#include<stack>
#include<cstdio>
#include<fstream>
#include<numeric>
#include<functional>
#include<utility>
#include<memory>
#include <cstring>
#include<bits/stdc++.h>
using namespace std;   
int main()
{
	int a,b;
	cin>>a>>b;
	if (a<=b) cout<<a<<endl;
	else
	cout<<a-1<<endl;
	return 0;
} 

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int A, B, K;

int main() {
    cin >> A >> B >> K;
    int start = min(A, B);
    int count = 0;
    FORR(i, start, 0) {
        if(A % i || B % i)
            continue;
        else
            count++;
        if(count == K) {
            cout << i << "\n";
            return 0;
        }
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  int ans = 0;
  vector<int> T(N, 0);
  REP(i, N){
    int tmp; cin >> tmp;
    T[i] = tmp;
    ans += tmp;
  }
  int M; cin >> M;
  vector<pair<int, int> > PX(M, pair<int, int>());
  REP(i, M){
    int tmp1, tmp2; cin >> tmp1 >> tmp2; tmp1--;
    PX[i] = {tmp1, tmp2};
  }
  REP(i, M){
    cout << ans - T[PX[i].first] + PX[i].second << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef long long ll;

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

  vector<int> cnt(4);
  vector<string> testcase = {"AC", "WA", "TLE", "RE"};
  rep(i,N){
    string s;
    cin >> s;
    if(s == testcase[0]) cnt[0]++;
    else if(s == testcase[1]) cnt[1]++;
    else if(s == testcase[2]) cnt[2]++;
    else cnt[3]++;
  }
  rep(i,4){
    cout << testcase[i] << " x " << cnt[i] << endl;;
  }
}


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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	for(int i = 0 ; i < n ; ++i)
		cin>>arr[i] ;
	sort(arr , arr + n) ;
	int ans = 0 ;
	for(int i = 0 ; i < n ; ++i)
	{
		for(int j = i+1 ; j < n ; ++j)
		{
			for(int k = j+1 ; k < n ; ++k)
			{
				if(arr[i] == arr[j] || arr[i] == arr[k] || arr[j] == arr[k])
					continue ;
				if(arr[i] + arr[j] > arr[k])
					ans++ ;
			}
		}
	}
	return cout<<ans<<"\n" , 0 ;
}		

Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int n;
int L[250000],R[250000];
 long long merge(int A[],int left,int mid,int right){
    int n1=mid-left,n2=right-mid;
    long long cnt=0;
     for(int i=0;i<n1;i++)L[i]= A[left+i];
     for(int i=0;i<n2;i++)R[i]=A[mid+i];
     L[n1]=R[n2]=2000000000;
     int i=0,j=0;
     for(int k=left;k<right;k++){
         if(L[i]<=R[j]){
             A[k]=L[i++];
         }
         else{
             A[k]=R[j++];
             cnt+=n1-i;
         }
     }
     return cnt;
}
long long mergeSort(int A[],int left,int right){
    long long t1,t2,t3;
    int mid;
    if(left+1<right){
        mid=(left+right)/2;
        t1=mergeSort(A,left,mid);
        t2=mergeSort(A,mid,right);
        t3=merge(A,left,mid,right);
        return t1+t2+t3;
    }
    return 0;
}
int main(){
   int A[500000];
   cin>>n;
   for(int i=0;i<n;i++)cin>>A[i];
   long long sum=mergeSort(A,0,n);
   cout<<sum<<endl;
   return 0; 
}


Measured memory_bytes: 4644
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<P> v(n);
    FOR(i,0,n)cin>>v[i].second>>v[i].first;
    sortAl(v);
    ll cost = 0;
    string ans = "Yes";
    FOR(i,0,n){
      cost += v[i].second;
      if(cost>v[i].first) ans = "No";
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int N, M;

vector<vector<int> > mp;
vector<bool> explored;


int explore(int i){
	
	explored[i] = true;

	int total = 1;
	for (int j = 0; j < (int)mp[i].size(); j++){
		if(!explored[mp[i][j]]) total += explore(mp[i][j]);
	}

	return total;
}

int main(){
	cin >> N >> M;
  
  	mp.resize(N+2);
  	explored.resize(N+2, false);

	while(M--){
		int A,B;
		cin >> A >> B;

		mp[A].push_back(B);
		mp[B].push_back(A);
	}

	int maxx = -1;

	for (int i = 1; i < N; i++){
		if (explored[i] == false) { 
			int res = explore(i); 
			maxx = max(res, maxx); 
		}
	}

	cout << maxx << endl;

	return 0;
}

Measured memory_bytes: 23456
import java.awt.*;
import java.awt.geom.*;
import java.io.*;
 
import java.util.*;
class Main {
 
    static char[] xx = new char[] {'S','H','C','D'};
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
            String in = sc.next();
            if(in.equals("0")) break;
            char[] x = in.toCharArray();
            int sum = 0;
            for(int i = 0; i < x.length; i++) {
                sum += x[i] - '0';
            }
            System.out.println(sum);
             
        }
 
    }
}


Measured memory_bytes: 26216
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


int main() {
  string s; cin >> s;
  cout << s.substr(0, 3) << "\n";
  return 0;
}


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

const ll p = 1e9+7;
const int MAXN = 1e5+5;

ll n, a[MAXN], ans, part[MAXN];

ll exp(ll x, ll k) {
	if (k == 0)
		return 1;
	if (k%2 == 1)
		return x*exp(x, k-1)%p;
	ll y = exp(x, k/2);
	return y*y%p;
}

ll inv(ll x) {
	return exp(x, p-2);
}

ll sum(ll a, ll b) {
	return (part[b+1]-part[a])%p;
}

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

	cin >> n;
	part[0] = 0;

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

	ll s = 0;

	for (int l = n-1; l >= 0; --l) {
		if (l == n-1) {
			ans += sum(0, n-1);
			ans %= p;
			continue;
		}
		ans += inv(l+2)*(sum(0, l)+sum(n-l-1, n-1));
		ans %= p;
		ll f = 2*inv(l+2)*inv(l+3)%p;
		if (l == n-2)
			continue;
		s += part[l+2];
		s -= part[n-l-2];
		s %= p;
		s += p;
		s %= p;
		ans += s*f;
		ans %= p;
	}

	for (int i = 1; i <= n; ++i)
		ans = ans*i%p;
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
typedef long long ll;
char mat[1001][1001];
int main()
{
	ll h,w;
	cin>>h>>w;
	ll dp[h+1][w+1];
	for(ll i=1;i<=h;i++)
	{
		for(ll j=1;j<=w;j++)
		{
			cin>>mat[i][j];
			dp[i][j]=0;
		}
	}
	dp[1][1]=1;
	for(ll i=1;i<=h;i++)
	{
		for(ll j=1;j<=w;j++)
		{
			if(mat[i][j]=='#')
				dp[i][j]=0;
			else
			{
				if(i>1 && mat[i-1][j]=='.')
					dp[i][j]=dp[i-1][j];
				if(j>1 && mat[i][j-1]=='.')
					dp[i][j]+=dp[i][j-1];
				dp[i][j]%=mod;
			}
		}
	}
	cout<<dp[h][w];
}

Measured memory_bytes: 12336