akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

struct container{
    int key;
    container* pre;
    container* next;
    container():key(0), pre(nullptr), next(nullptr){};
};

struct linked_list{
    container *first;
    container *last;
    linked_list():first(nullptr), last(nullptr){};
    void insert(int x){
        container *newCont = new container();
        newCont->key = x;
        if(!first){
            first = newCont;
            last = newCont;
        }else{
            first->pre = newCont;
            newCont->next = first;
            first = newCont;
        }
    }
    void deleteKey(int x){
        container *temp = first;
        while(temp){
            if(temp->key == x){
                container *pre = temp->pre;
                container *next = temp->next;
                if(!pre && !next){
                    first = nullptr;
                    last = nullptr;
                }else if(!pre){
                    next->pre = nullptr;
                    first = next;
                }else if(!next){
                    pre->next = nullptr;
                    last = pre;
                }else{
                    next->pre = pre;
                    pre->next = next;
                }
                delete temp;
                break;
            }
            temp = temp->next;
        }
    }
    void deleteFirst(){
        container *temp = first;
        container *next = temp->next;
        if(!next){
            first = nullptr;
            last = nullptr;
        }else{
            next->pre = nullptr;
            first = next;
        }
        delete temp;
    }
    void deleteLast(){
        container *temp = last;
        container *pre = temp->pre;
        if(!pre){
            first = nullptr;
            last = nullptr;
        }else{
            pre->next = nullptr;
            last = pre;
        }
        delete temp;
    }
    void print_ll(){
        container *temp = first;
        int count = 0;
        while(temp != last){
            cout << temp->key << " ";
            temp = temp->next;
        }
        cout << temp->key << endl;
    }
};

int main(){
    int n;
    scanf("%d", &n);
    linked_list ll;
    for(int i=0; i<n; i++){
        char command[12];
        int x;
        scanf("%s %d", command, &x);
        if(strncmp(command, "insert", 6) == 0){
            ll.insert(x);
        }else if(strncmp(command, "deleteFirst", 11) == 0){
            ll.deleteFirst();
        }else if(strncmp(command, "deleteLast", 10) == 0){
            ll.deleteLast();
        }else if(strncmp(command, "delete", 6) == 0){
            ll.deleteKey(x);
        }
    }
    ll.print_ll();
}


Measured memory_bytes: 34384
#include<cstdio>
#include<cstring>
#include<queue>
#include<cmath>
using namespace std;
#define INF 0x3f3f3f3f3f3f3f3f
#define int long long
const int Ni = 510;
const int MAX = 1ll<<35;
struct Edge{
	int u,v,c;
	int next;
}edge[20*Ni];
int n,m;
int edn,sp,tp;
int p[Ni],d[Ni];

void addedge(int u,int v,int c)
{
	edge[edn].u=u; edge[edn].v=v; edge[edn].c=c;
	edge[edn].next=p[u]; p[u]=edn++;
	edge[edn].u=v; edge[edn].v=u; edge[edn].c=0;
	edge[edn].next=p[v]; p[v]=edn++;
}
int bfs()
{
	queue <int> q;
	memset(d,-1,sizeof(d));
	d[sp]=0;
	q.push(sp);
	while(!q.empty())
	{
		 int cur=q.front();
		 q.pop();
		 for(int i=p[cur];i!=-1;i=edge[i].next)
		 {
		     int u=edge[i].v;
		     if(d[u]==-1 && edge[i].c>0)
		     {
		         d[u]=d[cur]+1;
		         q.push(u);
		     }
		 }
	}
	return d[tp] != -1;
}

int dfs(int a,int b)
{
	int r=0;
	if(a==tp)return b;
	for(int i=p[a];i!=-1 && r<b;i=edge[i].next)
	{
		int u=edge[i].v;
		if(edge[i].c>0 && d[u]==d[a]+1)
		{
			int x=min(edge[i].c,b-r);
			x=dfs(u,x);
			r+=x;
			edge[i].c-=x;
			edge[i^1].c+=x;
		}
	}
	if(!r)d[a]=-2;
	return r;
}

int dinic(int sp,int tp)
{
	int total=0,t;
	while(bfs())
		while(t=dfs(sp,MAX)) total+=t;
	return total;
}

int a[120],sum;
signed main()
{
	memset(p,-1,sizeof(p));
	scanf("%lld",&n);
	for (int i=1;i<=n;i++) {
		scanf("%lld",&a[i]);
		if (a[i]<=0) addedge(0,i,-a[i]);
		else addedge(i,n+1,a[i]),sum+=a[i];
		for (int j=i*2;j<=n;j+=i) addedge(i,j,INF);
	}
	sp=0; tp=n+1;
	printf("%lld\n",sum-dinic(0,n+1));
	return 0;
}

Measured memory_bytes: 256
fun judge(N: Int): Boolean {
	var a = mutableListOf<Int>()
	var n = N
	while (n != 0) {
		val j = n % 10
		if (a.size == 0) {
			a.add(j)
		} else if (j != a[0]) {
			return false
		}
		n /= 10
	}
	return true
}

fun main(args: Array<String>) {
	var n = readLine()!!.toInt()
	while (!judge(n)) {
		n += 1
	}
	println(n)
}

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

typedef long long ll;

int main () {
	char S[11], T[11];
	cin >> S >> T;
	for (int i=0; S[i]!='\0'; i++) {
		if (S[i] != T[i]) {
			cout << "No"<< endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
    private static int n, cnt = 0, x = 0;
    private static int[][] targetSeq = new int[2][10];
    private static int[] vis = new int[10];
    private static int[] tempSeq = new int[10];
    private static int[] ans = new int[2];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        for(int i = 0;i < 2;i++) {
            for(int j = 0;j < n;j++) {
                targetSeq[i][j] = in.nextInt();
            }
        }
        dfs(0);
        System.out.println(Math.abs(ans[0] - ans[1]));
    }

    private static void dfs(int k) {
        if(x == 2) {
            return;
        }
        if(k == n) {
            cnt++;
            for(int i = 0;i < 2;i++) {
                boolean isOk = true;
                for(int j = 0;j < n;j++) {
                    if(tempSeq[j] != targetSeq[i][j]) {
                        isOk = false;
                        break;
                    }
                }
                if(isOk) {
                    ans[x++] = cnt;
                }
            }
            return;
        }
        for(int i = 1;i <= n;i++) {
            if(vis[i] == 0) {
                vis[i] = 1;
                tempSeq[k] = i;
                dfs(k + 1);
                vis[i] = 0;
            }
        }
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<long long int> a, b;
  
  for (int i = 0; i <= n; i++) {
    int c;
    cin >> c;
    a.push_back(c);
  }

  for (int i = 0; i < n; i++) {
    int c;
    cin >> c;
    b.push_back(c);
  }

  long long int left = 0;
  long long int res = 0;
  for (int i = 0; i < n; i++) {
    int left = min(a[i], b[i]);
    res += left;
    a[i] -= left;
    b[i] -= left;

    int right = min(a[i+1], b[i]);
    res += right;
    a[i+1] -= right;
    b[i] -= right;
  }

  cout << res << endl;

  return 0;
}


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

using namespace std;

class Job{
public:
    int a, b;

    bool operator<(const Job &j) const{
        if(b > j.b){
            return true;
        }else if(b < j.b){
            return false;
        }else{
            if(a < j.a){
                return true;
            }else{
                return false;
            }
        }
    }
};

int main(){
    long N, M;
    cin>>N>>M;
    vector<Job> job(N);
    long a, b;
    for(int i=0; i<N; ++i){
        cin>>a>>b;
        job[i] = Job{a, b};
    }

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

    vector<long> myjob(M+1, -1);
    vector<long> last(M+1, 0);

    long ans = 0;
    for(int i=0; i<N; ++i){
        if(job[i].a <= M && last[job[i].a] >= 0){
            long k = last[job[i].a];
            while(M-job[i].a-k>=0 && myjob[M-job[i].a-k] != -1){
                k++;
            }
            if(M-job[i].a-k >= 0){
                myjob[M-job[i].a-k] = job[i].b;
                ans = ans + job[i].b;
                last[job[i].a] = k+1;
            }else{
                for(int j=job[i].a; j<M+1; ++j){
                    last[j] = -1;
                }
            }
        }
    }

    cout<<ans<<endl;

    return 0;
}


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

int n;
int w[100];

int main(){
	int s1=0, s2=0, ans=0;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> w[i];
		s1 += w[i];
	}
	for(int i=0; i<n; i++){
		s1 -= w[i];
		s2 += w[i];
		if(i==0 || ans>abs(s1-s2)) ans = abs(s1-s2);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import heapq

n, k = map(int, input().split())
h = []
d = [0 for _ in range(n)]
ans = float('inf')

for _ in range(n):
    heapq.heappush(h, int(input()))

h = [heapq.heappop(h) for _ in range(n)]


for i in range(n - k + 1):
    diff = h[i + k - 1] - h[i]
    ans = min(ans, diff)

print(ans)


Measured memory_bytes: 8248
n = int(input())
p = list(map(int,(input().split())))
l= [[0]*3 for i in range(n-2)]
count = 0
j = 0

for i in range(n-2):
    l[i] = sorted([p[i],p[i+1],p[i+2]])

for i in range(1,n-1):
    if p[i]==l[j][1]:
        count += 1
    j += 1
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    
    if(a*a*b/2>x) {
        cout << setprecision(15) << atan(a*b*b/(2*x))/M_PI*180 << endl;
    } else {
        cout << setprecision(15) << atan(2*(a*a*b-x)/(a*a*a))/M_PI*180 << endl;
    }


    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000;
int a[maxn];
int b[maxn][maxn];
int main()
{
    int n,m,c;
    cin>>n>>m>>c;
    for(int i=0;i<m;i++)
    {
        scanf("%d",&a[i]);
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int sum=c;
        for(int j=0;j<m;j++)
        {
            scanf("%d",&b[i][j]);
            sum+=a[j]*b[i][j];
        }
        if(sum>0)
        {
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n, q;
string s;
set<int> x['z' - 'a' + 1];
void solve() {
    cin >> n >> s >> q;

    rep(i, n) x[s[i] - 'a'].insert(i);

    rep(_, q) {
        int t; cin >> t;
        if (t == 1) {
            int i; char c; cin >> i >> c; --i;
            x[s[i] - 'a'].erase(i);
            x[c - 'a'].insert(i);
            s[i] = c;
        }
        else {
            int l, r; cin >> l >> r; --l; --r;
            int ans = 0;
            rep(i, 'z' - 'a' + 1) {
                auto p = x[i].lower_bound(l);
                if (p != x[i].end() && *p <= r) ++ans;
            }
            cout << ans << endn;
        }
    }

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


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

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

Measured memory_bytes: 3584
#include<iostream>
#include<vector>

const int NINF = -10e5;
using namespace std;

int main() {
	int N; cin >> N;
	vector<vector<int>>arr(N, vector<int>(3));
	vector<vector<int>>dp(N, vector<int>(3,0));
	for (auto& it : arr) {
		for(auto &it2:it){
			cin >> it2;
		}
	}
	for (int i = N - 1; i >= 0; i--) {
		for (int j = 0; j < 3; j++) {
			int res = NINF;
			if (i + 1 < N) {
				for (int k = 0; k < 3; k++) {
					if (j != k && res < dp[i + 1][k])
						res = dp[i + 1][k];
				}
			}
			else
				res = 0;
			dp[i][j] = arr[i][j] + res;
		}
	}
	int res = NINF;
	for (int i = 0; i < 3; i++) {
		if (res < dp[0][i])
			res = dp[0][i];
	}
	cout << res << '\n';
	return 0;
}

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

const int MAX = 1e5 + 5;

#define dbg(a) cout << "-> " << __LINE__ << ": " << #a << " = " << a << endl

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector <int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector <vector <long long>> dp(n, vector <long long> (n, LLONG_MAX));
	for (int i = 0; i < n; i++) {
		dp[i][i] = 0;
	}
	for (int len = 0; len < n; len++) {
		for (int l = 0; l < n - len; l++) {
			long long r = l + len, cumSum = 0;
			assert(r < n);
			for (int i = l; i <= r; i++) {
				cumSum += a[i];
			}
			for (int k = l; k < r; k++) {
				dp[l][r] = min(dp[l][r], dp[l][k] + dp[k + 1][r] + cumSum);
			}
		}
	}
	cout << dp[0][n - 1] << '\n';
	return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

vector<ll> a(55), p(55);

ll func(ll n, ll x){
    if(x == 1){
        if(n == 0)return 1;
        else return 0;
    }
    else if(x <= a[n-1] + 1)return func(n-1, x-1);
    else if(x == a[n-1] + 2)return p[n-1] + 1;
    else if(x <= 2*a[n-1] + 2)return p[n-1] + 1 + func(n-1, x - (a[n-1] + 2));
    else return 2*p[n-1] + 1;
}

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

    a[0] = 1, p[0] = 1;
    rep(i, 50){
        a[i+1] = 2*a[i] + 3;
        p[i+1] = 2*p[i] + 1;
    }

    cout << func(n, x) << endl;
}

Measured memory_bytes: 3628
#include<iostream>	// 入出力
#include<stdio.h>	// printf()が使える 小数は%fで
#include<math.h>	// 数学の関数
#include<vector>	// 配列
#include<string>	// 文字列
#include<map>		// 連想配列
#include<stack>		// スタック
#include<queue>		// キュー
#include<algorithm> // ソートとか

using namespace std;

using ll = long long int;

ll gcd(ll x,ll y)
{
	ll r;

	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}


ll lcm(ll x, ll y)
{
	return (x*(y / gcd(x, y)));
}


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

	ll ans = 1;

	for (int i = 0; i < N; ++i)
	{
		ll T; cin >> T;

		ans = lcm(ans, T);

	}

	cout << ans << endl;
	

	return 0;
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

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

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    sort(ALL(a));

    // b[i] = (a[i]-1,i)のWL
    vector<ll> b(n);
    REP(i, n) {
        if(i>=1 && a[i]==a[i-1]) b[i] = 1-b[i-1];
        else b[i] = 0;
    }
    // cout << "b=" << b << endl;

    ll x=n-1, y=0;
    while(x>=1 && y+1<a[x-1]) x--, y++;
    // cout << "x=" << x << " y=" << y << endl;

    // 左に行く
    ll cnt = 0, xx = x, yy = y;
    while(xx-1 >= 0 && yy != a[xx]-1) {
        xx--;
        cnt++;
    }
    cnt += b[xx];
    ll left = cnt % 2;
    // cout << xx << " " << yy << " " << cnt << " " << left << endl;
    // 上に行く
    cnt = 0, xx = x, yy = y;
    while(yy < a[xx]-1) {
        yy++;
        cnt++;
    }
    cnt += b[xx];
    ll up = cnt % 2;
    // cout << xx << " " << yy << " " << cnt << " " << up << endl;
    // cout << left << " " << up << endl;

    if(left || up) cout << "First" << endl;
    else cout << "Second" << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#include <deque>
#pragma GCC optimize(3 , "Ofast" , "inline")
using namespace std ;
#define ios ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define x first
#define y second
#define ls rt << 1
#define rs rt << 1 | 1
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e6 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
int a[N] ;
int work()
{

  ll ans = 1000 ;
  int n ;
  scanf("%d" , &n) ;
  for(int i = 1; i <= n ;i ++ ) scanf("%d" , &a[i]) ;
  for(int i = 1; i < n ;i ++ )
   if(a[i] < a[i + 1])
    ans += 1ll * (a[i + 1] - a[i]) * (ans / a[i]) ;
  cout << ans << endl ;
  return 0 ;
}
int main()
{

  work() ;
  return 0 ;
}
/*
*/


Measured memory_bytes: 3248
import java.util.Scanner;
public class Main
{
    public static void main(String [] args)
    {
        Scanner key = new Scanner(System.in);
        int x = key.nextInt();
        int y = key.nextInt();
        int z = key.nextInt();
        int temp = 0;
        
        temp = x;
        x = y;
        y = temp;
        temp = x;
        x = z;
        z = temp;

        System.out.println(x+" " + y + " "+ z);
    }
}

Measured memory_bytes: 21844
#include<stdio.h>

int i;
int d[10];
int z;

int main(){
	for(i=1; i<=4; i++){
		d[i] = 0;
	}
	for(i=0; i<6; i++){
		scanf("%d", &z);
		d[z]++;
	}
	if(d[1]<=2 && d[2]<=2 && d[3]<=2 && d[4]<=2){
		puts("YES");
	}else{
		puts("NO");
	}
}


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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int cnt[26];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n, k; cin>>n>>k;
	for(int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		cnt[s[0]-'A']++;
	}
	int ans = 0;
	for(int i = 0; i < n; i++)
	{
		sort(cnt, cnt+26);
		bool pos = true;
		for(int j = 0; j < k; j++)
		{
			if(cnt[25-j]) cnt[25-j]--;
			else pos = false;
		}
		if(pos) ans++;
	}	
	cout<<ans<<'\n';
}


Measured memory_bytes: 384
unittest
{
	assert( [ "3 2" ].parse.expand.solve == 2 );
	assert( [ "13 3" ].parse.expand.solve == 11 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nk = input.front.split.to!( long[] );
	return tuple( nk[ 0 ], nk[ 1 ] );
}

auto solve( long n, long k )
{
	return n - ( k - 1 );
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define int long long
#define N 3002
using namespace std;
int n,mod,k,i,j,size,C[N][N],f[N][N],sum[N][N];
int read()
{
	char c=getchar();
	int w=0;
	while(c<'0'||c>'9') c=getchar();
	while(c<='9'&&c>='0'){
		w=w*10+c-'0';
		c=getchar();
	}
	return w;
}
signed main()
{
	n=read();k=read();mod=read();
	C[0][0]=1;
	for(i=1;i<=n+2;i++){
		C[i][0]=1;
		for(j=1;j<=n+2;j++) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	for(i=k;i>=0;i--) f[1][i]=1,sum[1][i]=(sum[1][i+1]+1)%mod;
	for(i=2;i<=n+1;i++){
		for(j=0;j<=k;j++){
			for(size=1;size<i;size++){
				f[i][j]=(f[i][j]+f[i-size][j]*C[i-2][size-1]%mod*sum[size][j+1]%mod)%mod;
			}
		}
		for(j=k;j>=0;j--) sum[i][j]=(sum[i][j+1]+f[i][j])%mod;
	}
	printf("%lld\n",f[n+1][0]);
	return 0;
}


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

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

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

struct town{
    ll x,y,id;
};

struct edge{
    ll u, v, cost;
};

bool comp_c(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}
bool comp_x(const town& t1, const town& t2){
    return t1.x < t2.x;
}
bool comp_y(const town& t1, const town& t2){
    return t1.y < t2.y;
}

int n, ma, mb;
int a[50], b[50], c[50];
int dp[41][401][401];

int main(){
    cin >> n >> ma >> mb;
    for(int i = 0; i < n; i++)  cin >> a[i] >> b[i] >> c[i];

    for(int i = 0; i <= n; i++){
        for(int j = 0; j < 401; j++){
            for(int k = 0; k < 401; k++){
                dp[i][j][k] = INT_INF;
            }
        }
    }
    dp[0][0][0] = 0;

    for(int i = 0; i < n; i++){
        for(int j = 0; j < 401; j++){
            for(int k = 0; k < 401; k++){
                if(dp[i][j][k] == INT_INF)  continue;
                dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
                dp[i+1][j+a[i]][k+b[i]] = min(dp[i][j][k]+c[i], dp[i+1][j+a[i]][k+b[i]]);
            }
        }
    }

    int ans = INT_INF;
    for(int i = 1; i < 401; i++){
        for(int j = 1; j < 401; j++){
            if(ma*j == mb*i)    ans = min(ans, dp[n][i][j]);
        }
    }
    if(ans == INT_INF) ans = -1;
    cout << ans << endl;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    for(int i = 0; i < s.length(); i++)
    {
            s[i] = 'x';
    }
    cout << s;
}


Measured memory_bytes: 3644
from collections import deque

N = int(input())
numbers = input().split()

d = deque()

for i in range(N):
    if i % 2 == 0:
        d.append(numbers[i])
    else :
        d.appendleft(numbers[i])
        
if N % 2 == 1:
    d.reverse()
    
output = ' '.join(d)

print(output)


Measured memory_bytes: 26564
#include <stdio.h>

int main(void){
	while(1){
		int n, i, j;
		int b[5050]={0};
		int count=0;
		
		scanf(" %d", &n);
		if(n==0) break;
		
		for(i=0; i<n; i++)
			scanf(" %d", &b[i]);
	
		int now = n;
	
		while(1){
			//printf("%d\n", now);
			int flag=0;
			
			//for(i=0; i<now; i++)
				//printf("%d ", b[i]);
			//printf("\n");
		
			if(count>10000) break;
			for(i=0; i<now; i++){
				if(b[i] != i+1) {
					flag=1;
					break;
				}
			}
			if(flag==0) break;
			
			int k = now; //変化前の値を保存
			
			for(i=0; i<k; i++)
				--b[i];
			
			++now;		
			b[now-1] = k;	
			
			for(i=0; i<now; i++){
				if(b[i]==0) {
					for(j=i; j<now; j++) b[j] = b[j+1];
					--now;
					--i;
				}
			}				
			
			++count;
		}
		
		if(count>10000) printf("-1\n");	
		else printf("%d\n", count);
	}

	return 0;
}

Measured memory_bytes: 640
object Main extends App {
    val in = io.Source.stdin.getLines.map(_.split(" ")).map(a => (a(0), a(1).toInt))
    val (_, q) = in.next
    val queue = scala.collection.mutable.Queue[(String, Int)]()
    in.foreach(queue.enqueue(_))
    var tm = 0
    while (!queue.isEmpty) {
        val (n, t) = queue.dequeue
        if (t-q <= 0) {
            tm += t
            println(n + " " + tm)
        } else {
            tm += q
            queue.enqueue((n, t-q))
        }
    }
}

Measured memory_bytes: 117784
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

#define mod 1000000007LL
#define eps 0.0001
#define pi acos(-1)
#define INF 10000000000000000

#define rep(i, n) for(int i = 0;i < n;++i)
#define rep1(i, n) for(int i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define chmin


    ll n,a;
    ll x[50]; 
    ll ans = 0;
    ll hoge[50][2500][50];

    ll sin(ll g,ll c , ll m){

        if (g==n) return 0;

        if(hoge[g][c][m]!=-1){
            return hoge[g][c][m];
        } 


        ll t =0;
        if ((c+x[g])/(m+1)==a && (c+x[g])%(m+1)==0){
            t++;
        }
        //終わり

        ll ns =t + sin(g+1,c+x[g],m+1) + sin(g+1,c,m);

        hoge[g][c][m]=ns;
        
        return ns;
    }


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------
    cin >> n >> a ;
    rep(i ,n){
        cin >> x[i];
    }

    memset(hoge, -1, sizeof(hoge));
    
    pri(sin(0,0,0));
    return 0;
}



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

int main() {

int N,A;
 cin>>N>>A;
int L=A;
 int R=A+N-1;

 int eat;
 if(R<=0)eat=R;
 else if(L>=0)eat=L;
 else eat=0;

 int answer=(R+L)*(R-L+1)/2-eat;

 cout<<answer<<endl;

 return 0;

 }

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

int main(void)
{
	int i, j, k;
	int n = 0;
	int num;
	int prime[78499] = {0};
	int a;
	
	prime[0] = 2;
	for (i = 3; i <= 1000000; i += 2){
		k = 0;
		for (j = 3; j <= sqrt(i); j += 2){
		
			if (i % j == 0){
				k = 1;
				break;
			}
		}

		if(k == 0){
			n++;
			prime[n] = i;
		}
	}
	
	while (scanf("%d", &num) != EOF){

		if (num < 999983){
			for (a = 0; num >= prime[a]; a++);
			printf("%d\n", a);
		}
		else {
			printf("78498\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2036
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
/*
fn dfs(graph: &Vec<Vec<usize>>, p: usize, x: usize, cnt: &mut Vec<usize>) -> Vec<usize> {
    cnt[p] += x;
    if graph[p].len() == 0 {
        return cnt.to_vec();
    }
    for node in &graph[p] {
        dfs(&graph, *node, x, cnt);
    }
    cnt.to_vec()
}
*/

fn main() {
    input! {
        n: usize, q: usize,
        ab: [(usize1, usize1); n-1],
        px: [(usize1, usize); q],
    }
    let mut graph = vec![vec![]; n];
    for (a, b) in ab {
        graph[a].push(b);
    }

    let mut cnt = vec![0; n];

    for (p, x) in px {
        cnt[p] += x;
    }

    for i in 0..n {
        if graph[i].len() == 0 {
            continue;
        }
        for node in &graph[i] {
            cnt[*node] += cnt[i];
        }
    }

    for i in 0..n {
        print!("{} ", cnt[i])
    }
    println!();
}


Measured memory_bytes: 24828
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.C_Challenge
{
    class ABC_112
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            var xs = new long[n];
            var ys = new long[n];
            var hs = new long[n];
            int baseIndex = 0;
            for (int i = 0; i < n; i++)
            {
                long[] input = ReadLongs();
                xs[i] = input[0];
                ys[i] = input[1];
                hs[i] = input[2];
                if (hs[i] > 0)
                {
                    baseIndex = i;
                }
            }
            for (long x = 0; x <= 100; x++)
            {
                for (long y = 0; y <= 100; y++)
                {
                    bool ok = true;
                    long h = hs[baseIndex]
                        + Math.Abs(xs[baseIndex] - x)
                        + Math.Abs(ys[baseIndex] - y);
                    for (int i = 0; i < n; i++)
                    {
                        long hTemp = h
                            - Math.Abs(xs[i] - x)
                            - Math.Abs(ys[i] - y);
                        if (hTemp < 0) hTemp = 0;
                        if (hTemp != hs[i])
                        {
                            ok = false;
                            break;
                        }
                    }
                    if (ok)
                    {
                        Console.WriteLine(x + " " + y + " " + h);
                        return;
                    }
                }
            }
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main(){
	int a,b,c,d; cin >> a >> b >> c >> d;
	cout << min(a,b) + min(c,d) << endl;
}


Measured memory_bytes: 256
// 見せてやるぜ、奇跡ってやつをよぉ……
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}
#define DEBUG_VLL(vec) REP(i, vec.size()) cerr<<vec[i]<<(i==vec.size()-1?'\n':' ');

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b; cin >> a >> b;
    if (a<10 && b<10) cout << a*b << '\n';
    else cout << "-1\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,s,n)for(int i=s;i<n;i++)
int main()
{
	int N; cin >> N;
	int a[100];

	int A = 0, B = 0;
	rep(i, 0, N) {
		int x;
		cin >> x;
		a[i] = -x;
	}
	sort(a, a + N);

	rep(i, 0, N)
	{
		//cout << a[i] << " ";
		if (i % 2 == 0)
		{
			A += a[i];
		}
		else {
			B += a[i];
		}
	}

	cout << B - A << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
	"bufio"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readLine() string{
	if sc.Scan() {
		return sc.Text()
	}
	return ""
}

func main() {
	var n int
	fmt.Scanln(&n)
	hs := make([]int, n)
	sc.Split(bufio.ScanWords)
	for i:=range hs {
		if sc.Scan() {
			h, _ := strconv.Atoi(sc.Text())
			hs[i] = h
		}
	}
	ans := cal(n, hs)
	fmt.Println(ans)
}

func cal(n int, hs []int) int {
	ans := 0
	max := 0
	// fmt.Println(hs)
	for i:=0;i<n-1;i++ {
		if hs[i] >= hs[i+1] {
			max++
		} else {
			max = 0
		}
		if ans < max {
			ans = max
		}
	}
	return ans
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t T=0; T<v.size(); ++T){cout << " " << #v << "[" << T << "]=" << v[T];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    lint x;
    cin >> x;
    lint max_reach = 0;
    repeat_from_to(t, 1, 1000000) {
        max_reach += t;
        if (x <= max_reach) {
            cout << t << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll N, R; cin >> N >> R;
    int count = 0;
    while(N > 0){
        N /= R;
        ++count;
    }
    cout << count << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 256
from itertools import combinations


def main():
    N = int(input())
    S = [input() for _ in range(N)]

    f(S)


def f(S):
    march = list("MARCH")
    n = {k: 0 for k in march}
    for s in S:
        if s[0] in march:
            n[s[0]] += 1

    ans = 0
    for a, b, c in combinations(march, 3):
        ans += n[a] * n[b] * n[c]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9776
#include <iostream>

#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include <cstdlib>
#include <typeinfo>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(long long a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//ll INF = 10000000;
//ll mod = 1000000007;//10^9+7

//using Graph = vector<vector<pair<int, int>>>;
//Graph G(100100);


//番号ズレ注意！！
int main() {
    int K, X;
    cin >> K >> X;
    for (int i = X - K + 1; i < X + K; i++) {
        cout << i << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;





int main(void) {
  ll k, a, b;
  cin >> k >> a >> b;
  
  ll t=a-1;
  ll ans=max(1+k, a+(b-a)*((k-t)/2)+(k-t)%2);
  pt(ans);
  
}








Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n =scn.nextInt();
		int W = scn.nextInt();
		int[]v = new int[n];
		int[]w = new int[n];
		int maxval=0;
		for(int i=0;i<n;i++)
		{
			w[i]=scn.nextInt();
			v[i]=scn.nextInt();
			maxval+=v[i];
		}
		
		long []dp = new long[maxval+1];
		Arrays.fill(dp, Integer.MAX_VALUE);
		dp[0]=0;
			for(int j=0;j<n;j++)
			{
				for(int i=maxval;i>=v[j];i--)
				{
			     if(dp[i-v[j]]!=Integer.MAX_VALUE)
					dp[i]=Math.min(dp[i], w[j]+dp[i-v[j]]);
			}
		}
			int max=0;
		for(int i=1;i<maxval+1;i++)
		{
			if(i>max&&dp[i]<=W)
			{
				max=i;
			}
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 37832
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    int A, B, C, K, ans, res;
	cin >> A >> B >> C >> K;
    ans = max({A, B, C});
    res = ans*(pow(2,K)) + A + B + C - ans;
    cout << res << endl;   
	return 0;
}

Measured memory_bytes: 256
INF = 10 ** 10

n,m = map(int,input().split(' '))
a = [0] * n
b = [0] * n
for i in range(n):
    a[i],b[i] = map(int,input().split(' '))
c = [0] * m
d = [0] * m
for i in range(m):
    c[i],d[i] = map(int,input().split(' '))

for i in range(n):
    mn = INF
    mi = -1
    for j in range(m):
        x = abs(a[i]-c[j]) + abs(b[i]-d[j])
        if x < mn:
            mn = x
            mi = j
    print(mi+1)

Measured memory_bytes: 3064
/**
 *    author:  ykaka
 *    created: 01.08.2020 20:54:48       
**/
 
#include <iostream>
using namespace std;
 
int main(){
  int x;
  cin >> x ;
  if(x >= 30) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}




Measured memory_bytes: 3508
#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>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int n, m; cin>>n>>m;
    vector<ll> a(n);
    map<ll, int, greater<ll>> cnt;
    for(int i=0; i<n; i++){
        cin>>a[i];
        cnt[a[i]]++;
    }

    ll sum = n;
    for(int i=0; i<m; i++){
        ll b, c; cin>>b>>c;
        cnt[c] += b;
    }

    ll ans = 0;
    for(auto i : cnt){
        if(sum - i.sc >= 0){
            ans += (ll)i.fs * i.sc;
            sum -= i.sc;
        }
        else{
            ans += (ll)max(sum, 0LL) * i.fs;
            sum -= i.sc;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 13568
ABCD = input().strip()
answer = ''
for i in range(1 << 4-1):
    output = []
    for j in range(4-1):
        if (i>>j)&1 == 1:
            output.append(ABCD[j])
            output.append('+')
        else:
            output.append(ABCD[j])
            output.append('-')
    output.append(ABCD[3])
    formula = ''.join(output)
    if eval(formula) == 7:
        answer = answer.join(formula+'=7')
        break
    else:
        output.clear()
        
print(answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int mod=1e9+7;
int32_t main(){
  BOOST;
  int ans=3,n;
  string s1,s2;
  cin>>n>>s1>>s2;
  for (int i=0;i<n;i++){
  	if (s1[i]==s2[i]) {if (i&&s1[i-1]==s2[i-1])ans*=2,ans%=mod;}
  	else if (s1[i-1]==s2[i-1])ans*=2,ans%=mod,i++;
  	else ans*=3,ans%=mod,i++;
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int n, t;
	cin>>n>>t;
	int anst = 9999999;
	int ansn = 9999999;
	for(int i = 1; i <= n; i++){
		int nn, tn;
		cin>>nn>>tn;
		if(tn <= t){
			if(nn < ansn){
				anst = tn;
				ansn = nn;
			}
		}
	}
	if(ansn == 9999999)cout<<"TLE";
	else cout<<ansn;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans = ans - scan.nextInt() + scan.nextInt() + 1;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 25172
s=int(input())
a=s//100
b=s%100
if 1<=a<=12 and 1<=b<=12:
  print("AMBIGUOUS")
elif 1<=a<=12 and (b>12 or b==0):
  print("MMYY")
elif (a==0 or a>12) and 1<=b<=12:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 9168
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int counter = scanner.nextInt();
		int[] sam = new int[counter];
		int sams = 0;
		
		for(int i = 0;i<counter;i++) {
			sam[i]= scanner.nextInt();
			sams += sam[i];
		}
		double ave = (double) (((double)sams)/((double)counter));
		
		double sa = 100;
		int result = -1;
		
		for(int i = 0;i<counter;i++) {
			if(sa > shortAbs((double) ((double)sam[i]-ave))) {
				sa = shortAbs((double) ((double)sam[i]-ave));
				result = i;
			}
		}
		System.out.println(result);
	}
	
	public static double shortAbs(double a) {
		if(a < 0) {
			return (double) -a;
		}
		else {
			return a;
		}
	}
}

Measured memory_bytes: 22996
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    pair<int, int> G[M];
    map<int, pair<int, int> > m; 

    for(int i=0; i<M; i++){
        cin >> G[i].first >> G[i].second; // pi, yi
        m.insert({i, G[i]});
    }
    map<int, int> odr;
    sort(G, G + M);
    int pre = -1;
    int cnt = 0;

    for(int i=0; i<M; i++){
        if(pre != G[i].first){
            cnt = 0;
            pre = G[i].first;
        }
        cnt ++;
        odr.insert({G[i].second, cnt});
    }


    for(int i=0; i<M; i++){
        cout << setfill('0') << right << setw(6) << m.at(i).first;
        cout << setfill('0') << right << setw(6) << odr.at(m.at(i).second)<< endl;
    }
    return 0;
}

Measured memory_bytes: 13184
#include<bits/stdc++.h>
using namespace std;
const int N=262145;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
int main()
{
	cin>>n;
	if(n<=999) puts("ABC");
	else puts("ABD");
	return 0;
}


Measured memory_bytes: 256