akhauriyash/Code-Regression huggingface dataset:
#coding: utf-8
def solve(a, b, c, d, e, f):
    agn = a*e - b*d
    x = (e*c - b*f)/float(agn)
    y = (-d*c + a*f)/float(agn)
    if x == 0.: x = 0.
    if y == 0.: y = 0.
    return (x, y)
   
while 1:
    try:
        n = input()
        for i in xrange(n):
            x = [0 for i in xrange(3)]
            y = [0 for i in xrange(3)]
            a,b,t = [[0 for i in xrange(2)] for i in xrange(3)]
            p,q,s = [[0 for i in xrange(2)] for i in xrange(3)]
            x[0],y[0],x[1],y[1],x[2],y[2] = map(float, raw_input().split())
            for j in xrange(2):
                a[j] = (x[j+1] + x[j])/2
                b[j] = (y[j+1] + y[j])/2
                if x[j+1] - x[j] == 0.:
                    p[j] = 0.
                    q[j] = -1.
                    s[j] = -b[j]
                elif y[j+1] - y[j] == 0.:
                    p[j] = -1.
                    q[j] = 0.
                    s[j] = -a[j]
                else:
                    t[j] = (y[j+1] - y[j]) / (x[j+1] - x[j])
                    p[j] = -1./t[j]
                    q[j] = -1.
                    s[j] = -(a[j]/t[j])-b[j]
            c = solve(p[0], q[0], s[0], p[1], q[1], s[1])
            r = ((x[0]-c[0])**2 + (y[0]-c[1])**2)**0.5
            print "%.3f %.3f %.3f" % (c[0], c[1], r)
    except EOFError:
        break

Measured memory_bytes: 52000
S = input()
n = int(len(S))
found = False

for i in range(n-1):
    count = 0
    for j in range(i+1, n):
        if S[j]==S[i]:
            count += 1



#    print(count)
    if count > 0:
        found = True



if found:
    print("no")
else:
    print("yes")


Measured memory_bytes: 2940
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

A,B,C,D = map(int,input().split())
A -= 1

E = lcm(C,D)

print(B - B // C - B // D + B // E - (A - A // C - A // D + A // E))

Measured memory_bytes: 5692
#include <iostream>

int main() {
  char input = 0;
  int ans = 0;
  for (int i=0; i<4; i++) {
    std::cin >> input;
    if (input == '+') ans++;
    if (input == '-') ans--;
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define print(ele) cout << ele << endl
#define print10(ele) cout << fixed << setprecision(10) << ele << endl

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

int main() {
  int n, m;
  cin >> n >> m;
  ivec f(m);
  REP(i, n) {
    int k;
    cin >> k;
    REP(j, k) {
      int a;
      cin >> a;
      a--;
      f[a]++;
    }
  }
  int ans = 0;
  REP(i, m) {
    if (f[i] == n) {
      ans++;
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    static int n, k;
    
    static double p(int x)
    {
	double ans = 1.0;

	while (x < k)
	{
	    ans /= 2.0;
	    x *= 2;
	}

	return ans/(double)n;
    }

    public static void Main()
    {
	var tmp = ReadIntArray();
	n = tmp[0]; k = tmp[1];

	double ans = 0.0;

	for (int i = 1; i <= n; i++)
	{
	    ans += p(i);
	}

	WriteLine(ans.ToString("F12"));
    }
}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<ll> A(N); REP(i, N) cin >> A[i];
	sort(A.begin(), A.end(), greater<ll>());


	ll res{0};
	ll NN = N-2;
	if (N & 1)
	{
		ll i{0};
		ll tmp{0};
		for (; i < NN/2; ++i) tmp += 2*A[i];
		tmp += A[i++];
		tmp += A[i++];
		for (; i < N; ++i) tmp -= 2*A[i];
		res = max(res, tmp);

		tmp = 0;
		i = 0;
		for (; i < NN/2+1; ++i) tmp += 2*A[i];
		tmp -= A[i++];
		tmp -= A[i++];
		for (; i < N; ++i) tmp -= 2*A[i];
		res = max(res, tmp);
	}
	else
	{
		ll i{0}, tmp{0};
		for (; i < NN/2; ++i) tmp += 2*A[i];
		tmp += A[i++];
		tmp -= A[i++];
		for (; i < N; ++i) tmp -= 2*A[i];
		res = max(res, tmp);
	}

	std::cout << res << std::endl;
}


Measured memory_bytes: 1024
/* 
 * Created by solzard on 2020-03-05.
 * 
 */
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

bool is_bingo(int player) {
  std::unordered_set<int> winnable_conditions
      {0b111000000, 0b000111000, 0b000000111, 0b100100100, 0b010010010, 0b001001001, 0b100010001, 0b001010100};
  for (const auto &condition : winnable_conditions) {
    if ((player & condition) == condition) return true;
  }
  return false;
}

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

  std::vector<int> sheet;
  std::unordered_set<int> bingo;
  int a, n, b;
  rep(_, 9) {
    std::cin >> a;
    sheet.emplace_back(a);
  }
  std::cin >> n;
  rep(_, n) {
    std::cin >> b;
    bingo.emplace(b);
  }
  int player = 0;
  rep(i, 9) {
    if (bingo.find(sheet[i]) != std::end(bingo)) {
      player |= 1 << i;
    }
  }
  std::cout << (is_bingo(player) ? "Yes" : "No") << "\n";
}



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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> x(N,0);
  for(int i=0;i<M;i++){
    int A,B;
    cin >> A >> B;
    x.at(A-1)++;
    x.at(B-1)++;
  }
  
  for (int i=0;i<N;i++){
    cout << x.at(i) << endl;
  }
  
}
    

Measured memory_bytes: 3612
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define umii            unordered_map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define rep(i,st,end)   for(int i=st;i<end;i++)
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

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

void s_g_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	s_g_c();
	string s;
	cin >> s;
	int ans = 0;
	rep(i, 0, s.size())
	{
		ans += (s[i] - '0');
		ans %= 9;
	}
	if (ans % 9 == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3768
#include<stdio.h>
int main()
{
    int a,b,c;
    char ch;
    while(scanf("%d %c %d",&a,&ch,&b)==3)
    {
        if(ch=='+') c=a+b;
        else c=a-b;
        printf("%d\n",c);
    }
    return 0;
}


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

#define ll long long

using namespace std;

int main(){

	ll n,x;
	cin >> n >> x;

	vector<ll> v(n+1);
	vector<ll> w(n+1);

	v[0] = 0;
	w[0] = 0;
	ll sum = 0;
	for(int i = 1; i <= n; i++){
		cin >> w[i] >> v[i];
		sum += v[i];	
	}
	
	

	ll INF = 1e10;
	vector<vector<ll>> dp(sum+1, vector<ll>(n+1));

	for(int i = 0; i <= sum; i++){
		for(int j = 0; j <= n; j++){
			dp[i][j] = INF;
		}
	}

	//base case: all zero sum states require 0 cost
	for(int i = 0; i <= n; i++){
		dp[0][i] = 0;
	}
	
	for(int i = 0; i <= sum; i++){
		// i sum state
		// j item number	
		for(int j = 1; j <= n; j++){
			if(v[j] > i){
				dp[i][j] = dp[i][j-1];
				//cout << "set dp[" <<i << "]["<<j<<"] to " << dp[i][j-1] << "\n";
			}
			else{
				dp[i][j] = min(dp[i][j-1],dp[i-v[j]][j-1] + w[j]);
				//cout << "set dp[" <<i << "]["<<j<<"] to " << min(dp[i][j-1],dp[i-v[j]][j-1] + w[j]) << "\n";
			}			
			
		}
	}

	ll ans = 0;

	for(int i = 0; i <= sum; i++){
		if(dp[i][n] <= x){
			ans = i;
		}
	}

	cout << ans << "\n";
	
}

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

int main(){
    int n,a=0,x;
    vector<int>v;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
        if(i&1){
            a+=v[i];
        }else{
            a-=v[i];
        }
    }
    cout<<abs(a)<<'\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main()
{int n;
 cin >> n;
 vector<int> p(n);
 rep(i,n) cin >> p.at(i);
 
 int check = 0;

  for (int i = 1 ; i < n - 1 ; i++){
    if ( p.at(i-1) < p.at(i) && p.at(i) < p.at(i+1)) check++;   
  }
 
  for (int i = 1 ; i < n - 1 ; i++){
    if ( p.at(i-1) > p.at(i) && p.at(i) > p.at(i+1)) check++;   
  }
  
  
  cout << check << endl;
  
  
  
  
  
  
  
  
    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
map <ll ,int > ma;
const int M=3005,N=100005;
int p[M],tot=0;bool notp[M];
ll a[N];ll c1[N],c2[N];
int cnt[N];
map <ll,bool > used;
inline void getp(){
	for (int i=2;i<=3000;i++){
		if (!notp[i]) p[++tot]=i;
		for (int j=1;i*p[j]<=3000&&j<=tot;j++){
			notp[i*p[j]]=true;
			if (i%p[j]==0) break;
		}
	}
}
int main (){
	int n;scanf ("%d",&n);
	getp();bool flag=false;
	for (int i=1;i<=n;i++) scanf ("%lld",&a[i]);
	for (int i=1;i<=n;i++){
		for (int j=1;j<=tot;j++) cnt[j]=0;
		ll hash=1,hash2=1;
		for (int j=1;j<=tot;j++)
			while (a[i]%p[j]==0) a[i]/=p[j],cnt[j]++;
		for (int j=1;j<=tot;j++) {
			cnt[j]%=3;
			for (int k=1;k<=cnt[j];k++) hash*=p[j];
			if (cnt[j]) for (int k=2;k>=cnt[j];k--) hash2*=p[j];
		}
		if (a[i]==1) c1[i]=hash,c2[i]=hash2;
		else {
			ll t=(ll)sqrt(a[i]);
			if (t*t==a[i]) hash*=t,hash*=t,hash2*=t;
			else hash*=a[i],hash2*=a[i],hash2*=a[i];
			c1[i]=hash,c2[i]=hash2;
		}
	}
	int ans=0;
	for (int i=1;i<=n;i++) ma[c1[i]]++;
	for (int i=1;i<=n;i++){
        ll x=c1[i],y=c2[i];
        if (used[x]||used[y]) continue;
        ll t=ma[x]>ma[y]?x:y;used[t]=1;
        ans+=(t==1)?1:ma[t];
    }
	printf ("%d",ans);
	return 0;
}


Measured memory_bytes: 27648
#include <iostream>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;

using Weight = int;
using Capacity = int;
struct Edge {
    int src, dst; Weight weight;
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

vector<int> tsort(const Graph &g){
    int n = g.size();
    vector<int> ord(n), indeg(n);
    for(auto &es : g) for(auto &e : es) indeg[e.dst]++;
    queue<int> q;
    for(int i = 0; i < n; ++i) if (indeg[i] == 0) q.push(i);
    int k = 0;
    while(q.size()){
        int v = q.front(); q.pop();
        ord[k++] = v;
        for(auto &e : g[v]) {
            indeg[e.dst]--;
            if(indeg[e.dst] == 0) q.push(e.dst);
        }
    }
    return ord;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n,m;
    cin >> n >> m;
    Graph g(n);
    for(int i = 0; i < m; i++){
        int s,t;
        cin >> s >> t;
        g[s].emplace_back(s,t,0);
    }
    vector<int> ord = tsort(g);
    for(int i = 0; i < n; ++i){
        cout << ord[i] << '\n';
    }
}

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

using namespace std;

const int N = 500005;
const int inf = 1e9+7;

int n, m, timer, dst[N];
vector<pair<int,int>> g[N];
map<pair<int,int>, int> mp;

void add(int x, int y, int c) {
    --x; --y;
    pair<int, int> first = {x, c};
    pair<int, int> second = {y, c};
    if (!mp.count(first)) {
        g[timer].emplace_back(x, 1);
        g[x].emplace_back(timer, 0);
        mp[first] = timer++;
    }
    if (!mp.count(second)) {
        g[timer].emplace_back(y, 1);
        g[y].emplace_back(timer, 0);
        mp[second] = timer++;
    }
    int a = mp[first], b = mp[second];
    g[a].emplace_back(b, 0);
    g[b].emplace_back(a, 0);
}

int main() {
    scanf("%d %d", &n, &m);
    timer = n;
    for (int i = 0; i < m; ++i) {
        int x, y, c;
        scanf("%d %d %d", &x, &y, &c);
        add(x, y, c);
    }
    set<pair<int,int>> s;
    fill(dst, dst + N, inf);
    dst[0] = 0;
    s.insert({0, 0});
    while (!s.empty()) {
        int v = s.begin()->second;
        s.erase(s.begin());
        for (auto& item : g[v]) {
            int to = item.first, cost = item.second;
            if (dst[to] > dst[v] + cost) {
                s.erase({dst[to], to});
                dst[to] = dst[v] + cost;
                s.insert({dst[to], to});
            }
        }
    }
    int result = dst[n - 1] == inf ? -1 : dst[n - 1];
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 62080
n = int(input())
H = list(map(int,input().split()))
dp = [0]*n
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2,n):
    dp[i] = min(dp[i-2]+abs(H[i]-H[i-2]),dp[i-1]+abs(H[i]-H[i-1]))
print(dp[-1])

Measured memory_bytes: 13928
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>

using namespace std;


int main()
{
	string S;

	cin >> S;	

	if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) printf("Bad");
	else printf("Good");



	return 0;
}



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

int main(){
    long long int x, k, d;
    scanf("%lld%lld%lld", &x, &k, &d);
    x = (x > 0) ? x : -x;
    long long int t = x / d;
    if(t>=k){
        printf("%lld", x - d * k);
    }else if((k-t)%2){
        printf("%lld", d * (t + 1) - x);
    }else{
        printf("%lld", x - d * t);
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

bool reversecompare(int a, int b)
{
    return a > b;
}

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

    int N, x, final;
    int mochi[105];

    for (int i = 0; i < 101; i++)
        mochi[i] = 0;

    cin >> N;

    while(N--)
    {
        cin >> x;
        mochi[x]++;
    }

    final = 0;
    for (int i = 0; i < 101; i++)
        if (mochi[i] != 0)
            final ++;

    cout << final << endl;
    
    return 0;
}

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

using namespace std;

#define N 100000

int a[N + 1];
int dp[N + 1][2];
int n;

int solve(int x, bool par){
	if (x > n){
		return par;
	}

	if (dp[x][par] != -1){
		return dp[x][par];
	}

	return dp[x][par] = solve(x + 1, par or (a[x] - 1) % 2 == 0) + solve(x + 1, par or a[x] % 2 == 0) + solve(x + 1, par or (a[x] + 1) % 2 == 0);
}

int main(){
	int i;

	scanf("%d", &n);

	for (i = 1; i <= n; i++){
		scanf("%d", a + i);
	}

	memset(dp, -1, sizeof(dp));

	printf("%d\n", solve(1, false));

	return 0;
}

Measured memory_bytes: 1024
// スタックサイズ: 100MB

#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1e18;
const double EPS = 1e-10;
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }



int main() {
	fastio;
	
	ll N;
	cin >> N;
	ll ans = 0;
	rep(i, N) {
		ll l, r;
		cin >> l >> r;
		ans += r - l + 1;
	}
	cout << ans << endl;
}

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

#lines = stdin.readlines()
def rint():
    return map(int, sys.stdin.readline().split())

def input():
    return sys.stdin.readline().rstrip('\n')

def oint():
    return int(input())

N = oint()

ans = N//2

if N%2== 0:
    ans -= 1

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef double db;

void file_put() {
    freopen("filename.in", "r", stdin);
    freopen("filename.out", "w", stdout);
}

const int N=2e5+5;
int n,X,Y,d[N],f[N],ret=0,x,y; vi R[N],B[N];

bool check(int x,int y) {
	if (!y) return 1;
	if (f[x]==y || f[y]==x) return 1;
	if (f[f[x]]==y || f[f[y]]==x) return 1;
	return f[x]==f[y];
}

void dfs(int x,int p) {
	d[x]=d[p]+1,f[x]=p;
	for (auto y: B[x]) if (y!=p) dfs(y,x);
}

void dfs(int x,int p,int k) {
	ret=max(ret,d[x]);
	for (auto y: R[x]) if (y!=p) {
		if (!check(x,y)) {
			printf("-1\n");
			exit(0);
		}
		if (d[y]>k+1) dfs(y,x,k+1);
	}
}

int main() {
//	file_put();
	
	scanf("%d%d%d",&n,&X,&Y),d[0]=-1;
	rep(i,1,n) scanf("%d%d",&x,&y),R[x].pb(y),R[y].pb(x);
	rep(i,1,n) scanf("%d%d",&x,&y),B[x].pb(y),B[y].pb(x);
	dfs(Y,0),dfs(X,0,0);
	printf("%d\n",ret<<1);
	
	return 0;
}



Measured memory_bytes: 32252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dbl;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<long long> vl;
typedef vector< pair<int, int> > vii;
#define mp make_pair
#define pb push_back
#define invec(a, n) for(ll i = 0; i < n; i++) {cin >> a[i];}
#define rep(n) for(ll i = 0; i < n; i++)
#define fr(i,j,k) for(ll i = j; i < k; i++)
#define FR(i,j,k) for(ll i = j; i >= 0; i--)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define INF 1000000
#define xx first
#define yy second
#define pl cout<<endl;
template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
        return os<<"("<< p.first << "," << p.second<<")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
os << "{";
typename vector< T > :: const_iterator it;
for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
}
return os << "}";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
os << "[";
typename set< T > :: const_iterator it;
for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
os << *it;
}
return os << "]";
}
template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
        os << "[";
        typename map< F , S >::const_iterator it;
for( it = v.begin(); it != v.end(); it++ ) {
if( it != v.begin() ) os << ", ";
os << it -> first << " = " << it -> second ;
}
return os << "]";
}
#define deb(x) cout << #x << " = " << x << endl;

#define er(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << endl;
err(++it, args...);
}
 
void fast()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}


ll knapSack(ll W, vl wt, vl val, ll n) 
{ 
   ll i, w; 
   ll K[n+1][W+1]; 
  
   for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
  
   return K[n][W]; 
} 
 
 
int main()
{
    ll n,s;
    cin>>n>>s;
    
    vl w(n);
    vl v(n);


    for(ll i=0;i<n;i++)
    {
        cin>>w[i];
        cin>>v[i];
    }

    ll ans=knapSack(s,w,v,n);

    cout<<ans<<endl;

    
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> mt;

ll h;
mt f;


int main(){
  while(cin >> h){
    if(h == 0) return 0;
    f = mt(h+1,vl(6));
    ll ans = 0;
    for(ll i = 1;i <= h;i++){
      for(ll j = 0;j < 5;j++) cin >> f[i][j];
    }
    bool flag;
    do{
      flag = false;
      for(ll i = 1;i <= h;i++){
        ll cnt = 0;
        ll prev = 0;
        for(ll j = 0;j <= 5;j++){
          if(f[i][j] == prev) cnt++;
          else{
            if(cnt >= 3 && prev != 0){
              flag = true;
              // cerr << cnt << " " << prev << " " << j << " " << i << endl;
              for(ll k = j-1,l = 0;l < cnt;l++,k--){
                ans += f[i][k];
                f[i][k] = 0;

              }
            }
            prev = f[i][j];
            cnt = 1;
          }
        }
      }
      for(ll s = 0;s <= h+5;s++){
        for(ll i = h;i > 0;i--){
          for(ll j = 0;j < 5;j++){
            if(f[i][j] == 0) swap(f[i][j],f[i-1][j]);
          }
        }
      }
      // for(ll i = 1;i <= h;i++){
      //   for(ll j = 0;j < 5;j++){
      //     cerr << f[i][j] << " ";
      //   }
      //   cerr << endl;
      // }

    }while(flag);

    cout << ans << endl;

  }
}



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

long long int n,k,x[52][2],y[52][2],d[52][2],ans=0;
vector<long long int> zx,zy,zd;

vector<long long int> f(vector<long long int> a){
	sort(a.begin(),a.end());
	int s=a.size();
	vector<long long int> ret;
	ret.push_back(a[0]);
	for(int i=1;i<s;i++){
		if(a[i]!=a[i-1])ret.push_back(a[i]);
	}
	return ret;
}

long long int find_x(int a){
	//cout<<"f(x)"<<a<<endl;
	long long int l=0,r=zx.size()-1;
	while(l<=r){
		//cout<<"l="<<l<<"r="<<r<<endl;
		int s=(l+r)/2;
		if(zx[s]==a)return s;
		if(zx[s]<a)l=s+1;
		else r=s-1;
	}
	return -1;
}

long long int find_y(int a){
	long long int l=0,r=zy.size()-1;
	while(l<=r){
		int s=(l+r)/2;
		if(zy[s]==a)return s;
		if(zy[s]<a)l=s+1;
		else r=s-1;
	}
	return -1;
}

long long int find_d(int a){
	long long int l=0,r=zd.size()-1;
	while(l<=r){
		int s=(l+r)/2;
		if(zd[s]==a)return s;
		if(zd[s]<a)l=s+1;
		else r=s-1;
	}
	return -1;
}


int main(){
	zx.push_back(0);
	zx.push_back(1000000+2);
	zy.push_back(0);
	zy.push_back(1000000+2);
	zd.push_back(0);
	zd.push_back(1000000+2);
	scanf("%lld%lld",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%lld%lld%lld%lld%lld%lld",&x[i][0],&y[i][0],&d[i][0],&x[i][1],&y[i][1],&d[i][1]);
		zx.push_back(x[i][0]);
		zx.push_back(x[i][1]);
		zy.push_back(y[i][0]);
		zy.push_back(y[i][1]);
		zd.push_back(d[i][0]);
		zd.push_back(d[i][1]);
	}
	zx=f(zx); zy=f(zy); zd=f(zd);
	/*sort(zx.begin(),zx.end());
	sort(zy.begin(),zy.end());
	sort(zd.begin(),zd.end());*/
	static long long int imos[105][105][105]={0};
	int siz=zx.size();
	//for(int i=0;i<siz;i++)cout<<zx[i]<<endl;
	for(int i=0;i<n;i++){
		//cout<<i<<endl;
		long long int fx[2]={find_x(x[i][0]),find_x(x[i][1])},fy[2]={find_y(y[i][0]),find_y(y[i][1])},fd[2]={find_d(d[i][0]),find_d(d[i][1])};
		//cout<<fx[0]<<" "<<fx[1]<<" "<<fy[0]<<" "<<fy[1]<<" "<<fd[0]<<" "<<fd[1]<<endl;
		imos[fx[0]][fy[0]][fd[0]]++;
		imos[fx[0]][fy[0]][fd[1]]--;
		imos[fx[0]][fy[1]][fd[0]]--;
		imos[fx[1]][fy[0]][fd[0]]--;
		imos[fx[0]][fy[1]][fd[1]]++;
		imos[fx[1]][fy[0]][fd[1]]++;
		imos[fx[1]][fy[1]][fd[0]]++;
		imos[fx[1]][fy[1]][fd[1]]--;
	}
	//for(int i=0;i<8;i++){for(int j=0;j<8;j++){for(int m=0;m<8;m++)cout<<imos[i][j][m]; cout<<endl;} cout<<endl;}
	for(int i=1;i<105;i++)for(int j=0;j<105;j++)for(int m=0;m<105;m++)imos[i][j][m]+=imos[i-1][j][m];
	for(int i=0;i<105;i++)for(int j=1;j<105;j++)for(int m=0;m<105;m++)imos[i][j][m]+=imos[i][j-1][m];
	for(int i=0;i<105;i++)for(int j=0;j<105;j++)for(int m=1;m<105;m++)imos[i][j][m]+=imos[i][j][m-1];
	//for(int i=0;i<8;i++){for(int j=0;j<8;j++){for(int m=0;m<8;m++)cout<<imos[i][j][m]; cout<<endl;} cout<<endl;}
	for(int i=0;i<105;i++)for(int j=0;j<105;j++)for(int m=0;m<105;m++){
		if(imos[i][j][m]>=k){
			//cout<<"_________________________"<<i<<" "<<j<<" "<<m<<" "<<imos[i][j][m]<<endl;
			//cout<<zx[i]<<" "<<zx[i+1]<<" "<<zy[j]<<" "<<zy[j+1]<<" "<<zd[m]<<" "<<zd[m+1]<<endl;
			ans+=(zx[i+1]-zx[i])*(zy[j+1]-zy[j])*(zd[m+1]-zd[m]);
			//cout<<ans<<endl;
		}
	}
	printf("%lld\n",ans);
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] != -1 && a[a[i] - 1] == i + 1) {
            a[a[i] - 1] = -1;
            a[i] = -1;
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main() {
	int a[31],b[31];
	for(int i=1; i<=30; i++)
		a[i]=0;
	for(int i=1; i<=28; i++)
		cin>>b[i];
	for(int i=1; i<=30; i++){
		for(int j=1; j<=28; j++){
			if(i==b[j])
				a[i]=b[j];
		}
	}
	for(int i=1; i<=30; i++){
		if(a[i]==0)
			cout<<i<<endl;
	}
	return 0;
}

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

using namespace std;

#define MOD 1000000007
typedef long long ll;

string A,B,C;

void reverse(){
  reverse(A.begin(),A.end());
  reverse(B.begin(),B.end());
  reverse(C.begin(),C.end());
}

int main(){
  while(cin >> A, A != "0"){
    cin >> B >> C;
    reverse();
    int size = A.size();
    ll dp[51][2];
    memset(dp,0,sizeof(dp));
    dp[0][0] = 1;
    for(int p = 0 ; p < size ; p++){
      for(int i = 0 ; i < 10 ; i++){
        if(A[p] != '?' && (A[p]-'0') != i){
          continue;
        }
        if(p == size-1 && i == 0){ continue; }
        for(int j = 0 ; j < 10 ; j++){
          if(B[p] != '?' && (B[p]-'0') != j){
            continue;
          }
          if(p == size-1 && j == 0){ continue; }
          for(int k = 0 ; k < 2 ; k++){
            int l = (i + j + k) % 10;
            int nk = (i + j + k >= 10);
            if(C[p] != '?' && (C[p]-'0') != l){
              continue;
            }
            dp[p+1][nk] += dp[p][k];
            dp[p+1][nk] %= MOD;
          }
        }
      }
    }
    cout << dp[size][0] << endl;
  }
  return 0;
}

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> A(40, 0);
  int k, num;
  for (int i = 0; i < n; i++){
    cin >> k;
    for (int j = 0; j < k; j++){
      cin >> num;
      A[num]++;
    }
  }
  int cnt = 0;
  for (int i = 1; i <= m; i++){
    if (A[i] == n) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
module ABC136

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_B
  private :: calculate_solution

  ! contained <subroutine>s and <function>s are below
  contains
  
  subroutine task_B (val_range)

    ! arguments for this <subroutine>
    integer(INT32), intent(in) :: val_range

    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') calculate_solution(val_range)
    
    ! STEP.END
    return

  end subroutine task_B

  recursive function calculate_solution (val_range) result(num_integers_uneven)

    ! arguments for this <function>
    integer(INT32), intent(in) :: val_range

    ! return value of this <function>
    integer(INT32) :: num_integers_uneven

    if (val_range .lt. 10_INT32) then
      num_integers_uneven = val_range
    else if (val_range .lt. 100_INT32) then
      num_integers_uneven = 9_INT32
    else if (val_range .lt. 1000_INT32) then
      num_integers_uneven = calculate_solution(99_INT32) + val_range - 99_INT32
    else if (val_range .lt. 10000_INT32) then
      num_integers_uneven = calculate_solution(999_INT32)
    else if (val_range .lt. 100000_INT32) then
      num_integers_uneven = calculate_solution(9999_INT32) + val_range - 9999_INT32
    else
      num_integers_uneven = calculate_solution(99999_INT32)
    end if

  end function calculate_solution

end module ABC136

program main

  ! <module>s to import
  use,     intrinsic :: iso_fortran_env
  use, non_intrinsic :: ABC136

  ! variables for this <program>
  integer(INT32) :: N

  read(unit=INPUT_UNIT, fmt=*) N
  
  call task_B (N)

end program main

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >>N;
  int a,b;
  a = 100;
  
  for(int i=0; i<N; i++){
    
    int x;
    cin >>x;
    b=0;
    
    while(x % 2 == 0){
      b++;
      x /= 2;
    }
    
    if(b<a){
      a = b;
    }
  }
  cout <<a <<endl;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

const int MAX_N = 10;
const int MAX_LENGTH = 10;

string ans;
vector<int> p;
string words[MAX_N];
string memo[MAX_N][MAX_N];

string connect(int index_a, int index_b) {
	if(memo[index_a][index_b][0] != '#')
		return memo[index_a][index_b];
	
	const string& a = words[index_a], b = words[index_b];

	for(int i = min(a.size(), b.size()) - 1; i > 0; --i)
		if(a.substr(a.size() - i) == b.substr(0, i))
			return memo[index_a][index_b] = b.substr(i);

  return memo[index_a][index_b] = b;
}

inline void chans(string& ans, const string& candidate) {
	if(ans.size() > candidate.size() || ans.size() == candidate.size() && ans > candidate)
		ans = candidate;
}

vector<vector<string> > dp;

string dfs(int prev, int used) {
	if(used == (1 << p.size()) - 1)
		return "";

	if(dp[prev][used][0] != '#')
		return dp[prev][used];

	string res(p.size() * MAX_LENGTH, 'z');
	for(int i = 0; i < p.size(); ++i) {
		if((used >> i) & 1)
			continue;

		chans(res, connect(p[prev], p[i]) + dfs(i, used | (1 << i)));
	}

	return dp[prev][used] = res;
}

int main() {
  for(int n; cin >> n, n;) {
	  for(int i = 0; i < n; ++i)
		  cin >> words[i];

	  p.clear();
	  for(int i = 0; i < n; ++i) {
		  for(int j = 0; j < n; ++j) {
			  if(i == j)
				  continue;

			  if(words[j].find(words[i]) != string::npos) {
				  words[i] = "";
				  goto next;
			  }

			  memo[i][j] = "#";
		  }
		  p.push_back(i);

	  next:;
	  }

	  dp.clear();
	  dp.resize(n, vector<string>((1 << n), "#"));

	  ans = string(p.size() * MAX_LENGTH, 'z');
	  for(int i = 0; i < p.size(); ++i)
		  chans(ans, words[p[i]] + dfs(i, (1 << i)));

	  cout << ans << endl;
  }

  return EXIT_SUCCESS;
}

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

int main() {
  int s;
  cin >> s;
  int s1 = s / 100;
  int s2 = (s - s / 100 * 100) / 10;
  int s3 = (s - s / 10 * 10);
  cout << s1 + s2 + s3 << endl;
}

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

int main() {

  string s,t;
  cin >> s >> t;
  
  int ans = 0;
  
  if(s[0] == t[0]) ans++;
  if(s[1] == t[1]) ans++;
  if(s[2] == t[2]) ans++;
  
  cout << ans << endl;
  
  return 0;
 
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let o = scan!();
    let e = scan!();

    for (c0, c1) in o.chars().zip(e.chars()) {
        print!("{}{}", c0, c1)
    }
    if o.len() != e.len() {
        print!("{}", o.chars().last().unwrap())
    }
    println!()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
int main()
{
    fast_io
    ll t,i,j,n,a,b,c,sum=0;
    cin>>a>>b>>c;
    if(c>=a&&c<=b)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}





Measured memory_bytes: 3664
S=list(map(str,input()))
N=len(S)
Q=[0]*N
R=[]
R1=[0]*N
L1=[0]*N
L=[]
V=[0]*N
for i in range(0,N):
  if S[i]=="R" and S[i+1]=="L":
    R.append(i)
  elif S[i]=="L" and S[i-1]=="R":
    L.append(i)
  else: V[i]=1

for i in R+L:
  Q[i]=1

x=0
for r in R:
  while x!=r:
    R1[x]=r
    x=x+1
x=N-1
for l in reversed(L):
  while x!=l:
    L1[x]=l
    x=x-1

for i in range(N):
  if V[i]==1:
    if S[i]=="R":
      if (R1[i]-i)%2==0:
        Q[R1[i]]=Q[R1[i]]+1
      else:
        Q[R1[i]+1]=Q[R1[i]+1]+1
    else:
      if (i-L1[i])%2==0:
        Q[L1[i]]=Q[L1[i]]+1
      else:
        Q[L1[i]-1]=Q[L1[i]-1]+1

print(*Q)

Measured memory_bytes: 57856
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    std::string s;
    std::cin >> s;
    if(s == "AAA" or s == "BBB") {
        std::cout << "No" << std::endl;
    } else {
        std::cout << "Yes" << std::endl;
    }
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.ArrayList;
import java.util.StringTokenizer;
class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		/*
		 * 見た感じ逆順だなぁ
		 * ダブる数字は小さい方から見ていけばよさそう
		 * （条件を満たせばいいので、条件を満たせるものがあれば満たしていけば良いはず）
		 * 操作は逆順にして、大きい数から見ていけば良さそう
		 * とり方としては、
		 * 与えられた数列aに対し
		 * a_i = i を満たす最大のものを取り除いていく。
		 * 最大でないとどうなるか、 a_i > iとなり満たすはずのものが条件を満たさなくなってしまう
		 * なので、できるだけ条件を満たすように取っていった時、条件を満たさないものが出てきた時、それはできなく、
		 * 最後までできたら、OK
		 */
		ArrayList<Integer> lis=new ArrayList<Integer>();
		ArrayList<Integer> ans=new ArrayList<Integer>();
		int[] sorts=new int[N];
		for(int i=0; i<N; i++) {
			lis.add(sc.nextInt());
		}
		for(int i=N-1; i>=0; i--) {
			for(int j=i; j>=0; j--) {
				if(lis.get(j)==j+1) {
					ans.add(lis.get(j));
					lis.remove(j);
					break;
				}
				else if(lis.get(j)>j+1) {
					pl(-1);
					System.exit(0);
				}
			}
		}
		for(int i=N-1; i>=0; i--) {
			pl(ans.get(i));
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 22484
#include<stdio.h>
#include<stdlib.h>
int main()
{
     int a,b,c,d,x,y,z;
     scanf("%d %d %d %d",&a,&b,&c,&d);
     x=abs(a-c);
     y=abs(a-b);
     z=abs(b-c);
     if(x<=d)
     printf("Yes\n");
      else if(y<=d&&z<=d)
     printf("Yes\n");
     else
                printf("No\n");

    return 0;
}


Measured memory_bytes: 1656
#include<cstdio>
#include<iostream>
using namespace std;
int n, m, w[110], v[110]; 
long long f[100010];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&w[i],&v[i]);
	for(int i=1;i<=n;i++)
		for(int j=m;j>=w[i];j--)	
			f[j] = max(f[j], f[j-w[i]]+v[i]);
	printf("%lld\n",f[m]);
	return 0;
}

Measured memory_bytes: 1024
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(18);
}
signed main(){
  init_io();
  ll n,k;
  cin >> n >> k;
  vector<ll> p(n),a(n,0);
  vector<ll> G[n-k];
  set<ll> st;
  ll ans = 1;
  bool ct=false;
  for(int i=0;i<n;i++){
    cin >> p[i];
    if(i!=0){
      if(p[i-1]<p[i]) a[i]++;
      a[i] += a[i-1];
    }
  }
  if(a[k-1]==k-1){
    ct = true;
    ans = 0;
  }
  for(int i=0;i<k;i++){
    st.insert(p[i]);
  }
  for(int i=0;i+k<n;i++){
    bool can = (*st.begin()==p[i]);
    st.erase(p[i]);
    st.insert(p[i+k]);
    can = can & (*st.rbegin()==p[i+k]);
    if(a[i+k]-a[i+1]==k-1){
      ct = true;
    }else if(!can){
      ans++;
    }
  }
  cout << ans + ct << endl;
}


Measured memory_bytes: 12800
package main

import "fmt"

var subs = [...]string{"dream", "dreamer", "erase", "eraser"}

func main() {
	var s string
	fmt.Scan(&s)
	for len(s) > 0 {
		ok := false
		for i := range subs {
			if len(s) >= len(subs[i]) {
				if s[len(s)-len(subs[i]):] == subs[i] {
					ok = true
					s = s[:len(s)-len(subs[i])]
				}
			}
		}
		if !ok {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}


Measured memory_bytes: 1280
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    char c; cin >> c;
    if(islower(c)) cout << 'a' << endl;
    else cout << 'A' << endl;
    return 0;
}


Measured memory_bytes: 3616
n=int(input())
l=list(map(int,input().split()))
c=0
k=0
for i in l:
    if i%2==0:
        c+=1
        if i%3==0 or i%5==0:
            k+=1
if k==c:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int sum=a+b+c;
    if(k>=1&&k<=a)
        cout<<k<<endl;
    else if(k>a&&k<=a+b)
        cout<<a<<endl;
    else
        cout<<2*a+b-k<<endl;
}

Measured memory_bytes: 3624
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] ar)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		
		String s = br.readLine();
		int len=s.length();
		if(s.equals("AtCo"))
			out.println("AC");
		else{
		if(s.charAt(0)=='A')
		{
			int count=0,f=0,pos=0;
			for(int i=2;i<=len-2;i++)
			{
				if(s.charAt(i)=='C')
				{
					count++;
					pos=i;
				}
			}
			if(count==1)
			{
				for(int i=1;i<len;i++)
				{
					if(i==pos)continue;
					if(s.charAt(i)<97 || s.charAt(i)>122)
					{
						f=1;
						break;
					}
				}
				if(f==1)
					out.println("WA");
				else
					out.println("AC");
			}
			else
			{
				out.println("WA");
			}

		}
		else
		{
			out.println("WA");
		}
		
      	
      }
      out.flush();
    }
}

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

#define endl "\n"

#define pi 2*acos(0)
#define INF 1e16
#define MIN 1e-9
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define m_p make_pair
#define p_b push_back
#define ff first
#define ss second
#define n_p(a) next_permutation(all(a))
#define all(v) v.begin(),v.end()
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define rev(s) reverse(all(s))
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define mem(a,k) memset(a,k,sizeof a)
#define REP(i, a, b) for (int i = int(a); i <= int(b); i++)
#define u_b(X,V) upper_bound(X.begin(),X.end(),V)
#define l_b(X,V) lower_bound(X.begin(),X.end(),V)
#define cnt(s,c) count(all(s),c)

//bitwise helpers
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))

using namespace std;

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

    int t;

    //cin >> t;
    t = 1;
    for(int test = 1; test <= t ; test++) {
        int n, q;
        cin >> n >> q;
        string s;
        cin >> s;
        vi prefSum(n + 1, 0);

        prefSum[0] = 0;
        for(int i = 1; i < n; i++) {
            if(s[i - 1] == 'A' && s[i] == 'C')
                prefSum[i] = 1 + prefSum[i - 1];
            else
                prefSum[i] = prefSum[i - 1];
        }

        for(int i = 0; i < q; i++) {
            int l, r;
            cin >> l >> r;
            --l, --r;
            cout << (prefSum[r] - prefSum[l]) << endl;
        }
    }

    return 0;
}


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

using namespace std;

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

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(int i = (int)m; i < (int)n; i++)
#define rep(i,n) REP(i,0,n)
#define rep2(i,n) REP(i,1,n+1)
#define rep3(i,n) REP(i,0,n+1)
#define REPM(i,m,n) for(int i = (int)m; i >= (int)n; i--)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define repll(i,n) REPLL(i,0,n)
#define repll2(i,n) REPLL(i,1,n+1)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define Size(s) (int) s.size()

//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    set<int> p, mod1;

    REP(i, 2, 55555) {
        bool prime = true;
        for (auto s : p) {
            if (i % s == 0 && i > s) prime = false;
        }
        if (prime) {
            p.insert(i);
            if (i % 5 == 1) mod1.insert(i);
        }
    }

    auto itr = mod1.begin();

    rep(i, n) {
        cout << *itr << (i == n - 1 ? "\n" : " ");
        itr++;
    }

    return 0;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
)

func main() {
	var M, D int
	fmt.Scan(&M)
	fmt.Scan(&D)

	cnt := 0
	for m := 1; m <= M; m++ {
		for d := 1; d <= D; d++ {
			var d1, d10 int
			d1 = d % 10
			d10 = (d - d1) / 10
			if d1 >= 2 && d10 >= 2 && d1*d10 == m {
				cnt++
			}
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
import java.util.*;

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

		int N  = Integer.parseInt(sc.next());
		double sum = 0;

		for (int i=0; i<N; i++){
			double x = Double.parseDouble(sc.next());
			String u = sc.next();

			sum += u.equals("JPY") ? x : x * (double)380000 ;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 20948
<?php
    fscanf(STDIN, "%d %d %d", $a, $b, $t);
    $answer = 0;
    for($i = 1; $i <= 20; $i++){
        if($i * $a <= $t + 0.5){
            $answer += $b;
        }
    }
    echo $answer;
?>

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

void print_elements(int length, int elements[]) {
    cout << elements[0];
    for (int i = 1; i < length; i++) {
        cout << " " << elements[i];
    }
    cout << endl;
}

// Return how many times elements were swapped.
int bubble_sort(int N, int elements[]) {
    int i_sorted  = 0;
    int n_swapped = 0;
    bool swapped  = true;

    while (swapped) {
        swapped = false;
        for (int i = N - 1; i > i_sorted; i--) {
            int i_before = i - 1;
            if (elements[i] < elements[i_before]) {
                std::swap(elements[i], elements[i_before]);
                swapped = true;
                n_swapped++;
            }
        }
        i_sorted++;
    }
    return n_swapped;
}

/* ALDS1_2_A: Bubble Sort */
int main() {
    int N;
    cin >> N;

    int elements[N];
    for (int i = 0; i < N; i++) {
        cin >> elements[i];
    }

    int n_swapped = bubble_sort(N, elements);

    print_elements(N, elements);
    cout << n_swapped << endl;
    return 0;
}

Measured memory_bytes: 1164