akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define eps 1e-9
#define maxp 99940000
#define mod 1000000007
#define pi 3.141592653589793238
#define sin(s) scanf("%lld",&s);
#define sout(s) printf("%lld\n",s);
#define in(s) cin>>s
#define in2(a,b) cin>>a>>b
#define in3(a,b,c) cin>>a>>b>>c
#define vll vector<ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl '\n'
#define sp ' '
#define gear_change ios_base::sync_with_stdio(false),cin.tie(0)
#define nfl(i,n) for(i=0;i<n;i++)
#define sfl(i,s,e) for(i=s;i<e;i++)
#define ufl(i,n) for(i=n-1;i>=0;i--)
ll power(ll x,ll y){
    ll ret=1;
    while(y>0){
        if(y&1)
            ret=(ret*x);
        y/=2;
        x=(x*x);
    }
    return ret;
}
string rot(string s){
	string ret="";
	ll i;
	for(i=1;s[i];i++){
		ret+=s[i];
	}
	ret+=s[0];
	return ret;
}
void solve(){
	ll n,m,i,s=0;
	cin>>n>>m;
	vll vec(m);
	nfl(i,m){
		cin>>vec[i];
		s+=vec[i];
	}
	if(s>n){
		cout<<-1<<endl;
		return;
	}
	cout<<n-s<<endl;
}	
int main(){
	gear_change;
	ll test=1;
	// in(test);/
	while(test--){
		solve();
	}
}	


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

#define double      long double
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
#define endl        "\n"
#define repp(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a,b) 	for(int i=a;i<=b;i++)
#define IOS         ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int N=1e5 + 5;
const int MOD=998244353;

int pow(int a, int b, int m)
{
	int ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

int modinv(int k)
{
	return pow(k, MOD-2, MOD);
}

int32_t main()
{
	IOS;
	//memset(dp,-1,sizeof(dp));	
	int T;
	T = 1;
	while(T--)
	{
		int n,s;
		cin >> n;
		cin >> s;
		int dp[n+1][s+1];
		memset(dp,0,sizeof(dp));
		int inv2 = modinv(2);
		dp[0][0] = pow(2,n,MOD);
		int a[n];
		rep(i,0,n-1)
		{
			cin >> a[i];
		}
		repp(i,0,n)
		{
			repp(j,0,s+1)
			{
				dp[i+1][j] = (dp[i+1][j] +  dp[i][j])%MOD;
				if(j+a[i]<=s)
					dp[i+1][j+a[i]]  = (dp[i+1][j+a[i]] + dp[i][j]*inv2)%MOD;
			}
		}
		cout << dp[n][s] << endl;
	}
}


Measured memory_bytes: 73960
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertionSort(int A[], int n, int g)
{
    for(int i=g; i<n; i++)
    {
        int v = A[i];
        int j = i-g;
        while(j>=0 && A[j]>v)
        {
            A[j+g] = A[j];
            j -= g;
            cnt++;
        }
        A[j+g] = v;
    }
}
void shellSort(int A[], int n)
{
    for(int h = 1; ; )
    {
        if(h > n)   break;
        G.push_back(h);
        h = 3*h + 1;
    }
    for(int i=G.size()-1; i>=0; i--)
    {
        insertionSort(A, n, G[i]);
    }
}

int main()
{
    cin >> n;
    for(int i=0; i<n; i++)
        scanf("%d", &A[i]);
    cnt = 0;
    shellSort(A,n);
    cout << G.size() << endl;
    for(int i=G.size()-1; i>=0; i--)
    {
        printf("%d", G[i]);
        if(i)  printf(" ");
    }
    cout << endl;
    cout << cnt << endl;
    for(int i=0; i<n; i++)
        cout << A[i] << endl;
    return 0;
}

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

using namespace std;

#define ll long long
int m = 1000000007;

ll bin_pow(int a, int pow) {
    if (pow == 1) return a % m;
    if (pow % 2 == 0) {
        ll tmp = bin_pow(a, pow / 2) % m;
        return tmp * tmp % m;
    }
    return (a % m) * (bin_pow(a, pow - 1) % m) % m;
}

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

    unordered_set<int> correct;

    int n;
    string s;
    cin >> n >> s;

    int ans = 0;

    for (int i = 2; i < n; i++) {
        if (s[i - 2] == 'A' && s[i - 1] == 'B' && s[i] == 'C') ans++;
    }
    
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
lists = [list(map(str, input())) for i in range(H)]

remove_W = []
remove_dict = {i:0 for i in range(W)}

for i in range(H):
    count_W = 0
    for j in range(W):
        if lists[i][j] == ".":
            remove_dict[j] += 1
            count_W += 1
            if count_W == W:
                remove_W.append(i)
            else:
                continue
remove_H = []
for key, value in remove_dict.items():
    if value == H:
        remove_H.append(key)

remove_H = reversed(remove_H)

for k in remove_H:
    for i in range(H):
        for j in range(W):
            if j == k:
                lists[i].pop(j)
            else:
                continue
remove_W = reversed(remove_W)
# lists_pop = [lists.remove(lists[i]) for i in remove_W]
lists_pop = [lists.pop(i) for i in remove_W]

for i in lists:
    print("".join(i))

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

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

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

int t[110];

int main(){
    int a, b, c, d; cin >> a >> b >> c >> d;
    t[a]++;
    t[b]--;
    t[c]++;
    t[d]--;

    REP( i, 109 ){
        if( i == 0 ) continue;
        t[i] += t[i - 1];
    }

    int ans = 0;
    REP( i, 109 ){
        if( t[i] >= 2 ) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N; cin >> N;
    if (N % 2 == 1) {
        cout << 0 << "\n";
        return 0;
    }
    lint ans = 0;
    lint cur_p = 5;
    while (N >= cur_p) {
        ans += N / cur_p;
        cur_p *= 5;
    }

    cur_p = 10;
    while (N + cur_p / 2 >= cur_p) {
        ans -= (N + cur_p / 2) / cur_p;
        cur_p *= 5;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
S = input()
k = False
for i, s in enumerate(S):
    if (i+1) % 2 == 0:
        if s == "L" or s == "U" or s == "D":
            k = True
        else:
            k = False
            break
    else:
        if s == "R" or s == "U" or s == "D":
            k = True
        else:
            k = False
            break

if k:
    print("Yes")
else:
    print("No")


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

using namespace std;

string s;

int main()
{
    cin>>s;
    int len=s.size();
    int p=0;
    int res=0,ans=0;
    for(int i=0;i<len;i++)
    {
        res+=(s[i]-'0'==p);
        p^=1;
    }
    p=1;
    for(int i=0;i<len;i++)
    {
        ans+=(s[i]-'0'==p);
        p^=1;
    }
    cout<<min(res,ans)<<'\n';
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define MOD 1000000007
#define fi first
#define se second
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define repe(i,n) for(int i = 0 ; i <= n ; i++)
#define repb(i,a,b) for(int i = a ; i < b ; i++)
#define repeb(i,a,b) for(int i = a ; i <= b ; i++)
#define rfor(i,n,a) for(int i = n ; i >= a ; i--)
#define pb push_back
#define popb pop_back()
#define endl "\n"
#define pii pair<int,int> 
#define pll pair < long long, long long >
typedef priority_queue<ll, vector<ll>, greater<ll>> minheap;
typedef priority_queue<ll> maxheap;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a,b) cout << a << " " << b << endl
#define p3(a,b,c) cout << a << " " << b << " " << c << endl
#define p4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl
#define sortv(v) sort(v.begin(),v.end())
#define rsortv(v) sort(v.begin(),v.end(), greater<>());
#define sortby(v,prop) sort( v.begin( ), v.end( ), [ ]( const auto& lhs, const auto& rhs ){ return lhs.prop < rhs.prop; });
#define rsortby(v,prop) sort( v.begin( ), v.end( ), [ ]( const auto& lhs, const auto& rhs ){ return lhs.prop > rhs.prop; });

ll modPower(ll num,ll r){
	if(r==0) return 1;
	if(r==1) return num%MOD;
	ll ans=modPower(num,r/2)%MOD;
	if(r%2==0) {
		return (ans*ans)%MOD;
	} return (((ans*ans)%MOD)*num)%MOD;
}

ll nCr(ll n, ll r) { 
    ll res = 1; 
    if (r > n - r) {
        r = n - r; 
    }
    rep(i,r) { 
        res *= (n - i); 
        res /= (i + 1); 
    } 
    return res; 
}

bool isPrime(long long n)
{
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
 
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
 
    return true;
}


/*-------------------------------------------------*/

void solve() {

	ll n, num, q, sum= 0, a, b;
	cin >> n;

	unordered_map<ll,ll> m;

	rep(i,n) {
		cin >> num;
		m[num]++;
		sum += num;
	}

	cin >> q;

	rep(i,q) {
		cin >> a >> b;
		ll afreq = m[a], bfreq = m[b];
		sum -= afreq*a;
		sum += afreq*b;
		m[a] = 0;
		m[b] += afreq;
		p1(sum);
	}
}


int main()
{
	fastio;
	solve();
	return 0;
}

Measured memory_bytes: 7128
#include <bits/stdc++.h>
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> 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) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif


typedef long long ll; 
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
 
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

const int INF = (int)1e9;
const int maxN = 51;

void solve() {
  string s;
  cin >> s;
  if (s[1] == 'B') cout << "ARC"; else cout << "ABC";
}
 
int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
 
  return 0;
}

Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
vector<int>Col(100005);
struct Edge {
	int to, id;
	Edge(int to, int id) :to(to), id(id) {}
};
vector<Edge>g[100005];

void dfs(int v, int d = 0, int p = -1) {
	int num = 1;
	for (Edge e : g[v]) {
		if (p == e.to) {
			continue;
		}
		if (num == d) {
			num++;
		}
		Col[e.id] = num;
		dfs(e.to, num, v);
		num++;
	}
}

int main() {
	int N;
	cin >> N;
	for (int n = 0; n < N - 1; ++n) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].emplace_back(b, n);
		g[b].emplace_back(a, n);
	}
	int color = 0;
	int sta;
	for (int n = 0;n < N; ++n) {
		color = max(color, (int)g[n].size());
		if (color == (int)g[n].size()) {
			sta = n;
		}
	}
	cout << color <<endl;
	dfs(sta);
	for (int n = 0; n < N - 1; ++n) {
		cout << Col[n] << endl;
	}
	return 0;
}

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

void Main()
{
	int r, c;
	cin >> r >> c;
	vector<vector<int>> table(r+1, vector<int>(c+1));
	int sum = 0;
	rep(i, r){
		rep(j, c){
			cin >> table[i][j];
			sum += table[i][j];
		}
	}
	table[r][c] = sum;
	rep(i, r){
		int sum1 = 0;
		rep(j, c){
			sum1 += table[i][j];
		}
		table[i][c] = sum1;
	}
	rep(j, c){
		int sum2 = 0;
		rep(i, r){
			sum2 += table[i][j];
		}
		table[r][j] = sum2;
	}
	rep(i, r+1){
		rep(j, c+1){
			cout << table[i][j];
			if(j != c){
				cout << ' ';
			}
		}
		cout << endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 3220
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int K = in.nextInt();
            int a = K / 2;
            int b = (int) Math.ceil(K / 2.0);
            out.println(a * b);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
import numpy as np
n = int(input())
w = np.array(list(map(int, input().split())))
w_amount = w.cumsum()
w_reverse_amount = w[::-1].cumsum()[::-1]
res = abs(w_amount[0] - w_reverse_amount[1])
min_index = 0
for i in range(n-1):
  if(res >= abs(w_amount[i] - w_reverse_amount[i+1])):
    res = abs(w_amount[i] - w_reverse_amount[i+1])
print(res)

Measured memory_bytes: 14476
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

#define MAX_N 200000
#define MAX_A 200000
#define MAX 60

ll dp[MAX + 1][MAX_N + 1];

signed main(){
    ll n,k;
    cin >> n >> k;
    int a[n];
    rep(i,n){
        cin >> a[i];
    }
    int nxt[MAX_A + 1];
    for(int i = 2 * n - 1; i >= 0; i--){
        dp[0][i % n] = nxt[a[i % n]] - i + 1;
        nxt[a[i % n]] = i;
    }
    for(int i = 0; i < MAX; i++){
        for(int j = 0; j < n; j++){
            dp[i + 1][j] = dp[i][j] + dp[i][(dp[i][j] + j) % n];
            dp[i + 1][j] = min(dp[i + 1][j], n * k);
        }
    }
    int now = 0;
    ll sum = n * k;
    while(sum > n){
        for(int i = MAX; i >= 0; i--){
            if(dp[i][now] < sum){
                sum -= dp[i][now];
                now = (now + dp[i][now]) % n;
                goto ok;
            }
        }
        break;
        ok:;
    }
    bool exist[MAX_A + 1] = {};
    vector<int> ans;
    for(int i = now; i < n; i++){
        if(exist[a[i]]){
            while(exist[a[i]]){
                exist[ans.back()] = false;
                ans.pop_back();
            }
        }else{
            ans.emplace_back(a[i]);
            exist[a[i]] = true;
        }
    }
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 99444
#include <stdio.h>
int main(){
    int n,i,j,k;
    int str[100];
    int max;
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&str[i]);
    for(k=0;k<n-1;k++)
        printf("%d ",str[k]);
    printf("%d\n",str[k]);
    for(i=1;i<n;i++){
        max=str[i];
        
        for(j=i-1;j>=0 && str[j]>max;j--)
            str[j+1]=str[j];
        str[j+1]=max;
        for(k=0;k<n-1;k++) printf("%d ",str[k]);
        printf("%d\n",str[k]);
    }
    //system("pause");
    return 0;
}

Measured memory_bytes: 596
s = list(input())
temp_s = s[2:-1]
#print(temp_s)

if (s[0]=="A")and("C" in temp_s):
  s.remove("A")
  s.remove("C")
  temp = s.copy()
  if len(set(s) - set(list("".join(temp).lower())))==0:
    print("AC")
  else:
    print("WA")
else:
    print("WA")

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(void)
{
  int a,b; cin>>a>>b;
  int sum=a+b;
  
  if(sum==5){puts("1");}
  else if(sum==4){puts("2");}
  else if(sum==3){puts("3");}
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
 
#define max(x, y)	(((x) > (y))? (x) : (y))
#define abs(x)		(((x) < 0)? (-1*(x)) : (x))
 
using namespace std;
 
int main() {
	string s;
 
	cin >> s;
 
  	s[3] = '8';
  
	cout << s << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
main(){
	int i,n,k,q,tmp;
	int score[100000];
	scanf("%d %d %d",&n,&k,&q);
	for(i=0;i<n;i++){
		score[i]=0;
		if(i+1==n){
			score[i+1]=-1;
		}
	}
	for(i=1;i<q;i++){
		scanf("%d",&tmp);
		score[tmp-1]++;
	}
	scanf("%d",&tmp);
	score[tmp-1]++;
	//printf("%d %d",n,score[i]);
	for(i=0;i<n;i++){
//		printf("%d %d",n,score[i]);
		if(score[i]+k>q){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}
	return 0;
}

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

int main() {
  int N,K,price=0;
  cin>>N>>K;
  vector<int> vec(N);
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
}
  std::sort(vec.begin(),vec.end());
  
  for(int i=0;i<K;i++){
    price+=vec.at(i);
  }
  cout<<price<<endl;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

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

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];

    set<string> st;
    rep(i, n) st.insert(s[i]);

    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 25040
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		if(n>=3200) {
			System.out.println(s);
		}else {
			System.out.println("red");
		}
	}
 
}

Measured memory_bytes: 21844
import java.util.Scanner;

class Point {
	static double EPS = 0.0000000001;
	double x; double y;
	public Point(double ax, double ay){x=ax;y=ay;}
	public Vector sum(Point p) { return new Vector(x+p.x,y+p.y); }
	public Vector diff(Point p) { return new Vector(x-p.x,y-p.y); }
	public Vector mult(double k) { return new Vector(x*k,y*k); }
	public Vector div(double k) { return new Vector(x*(1.0/k),y*(1.0/k)); }
	public boolean equals(Point p){return Math.abs(x-p.x)<EPS && Math.abs(y-p.y)<EPS;}
	public String toString(){return "("+x+","+y+")";}
}
class Vector extends Point {
	public Vector(double ax, double ay) {super(ax,ay);}
	public Vector(Point p1, Point p2) {super(p1.x-p2.x,p2.x-p2.y);}
	public double norm() {return x*x+y*y;}
	public double abs() {return Math.sqrt(norm());}
	// TODO:
	public boolean isSmallerThan(Vector v) {return x!=v.x?x<v.x:y<v.y;}
	public double dotProduct(Vector v) {return x*v.x+y*v.y;}
	public double crossProduct(Vector v) {return x*v.y - y*v.x;}
}

public class Main {
	static double EPS = 0.0000000001;
	public static void main(String[] a){
		Scanner scan = new Scanner(System.in);
		
		Point p0 = new Point(scan.nextInt(), scan.nextInt());
		Point p1 = new Point(scan.nextInt(), scan.nextInt());
		int p = scan.nextInt();
		for (int i=0;i<p;i++) {
			Point p2 = new Point(scan.nextInt(), scan.nextInt());
			int res=ccw(p0,p1,p2);
			if (res==1) System.out.println("COUNTER_CLOCKWISE");
			if (res==2) System.out.println("CLOCKWISE");
			if (res==3) System.out.println("ONLINE_BACK");
			if (res==5) System.out.println("ON_SEGMENT");
			if (res==4) System.out.println("ONLINE_FRONT");
		}
	}
	static int ccw(Point lp0, Point lp1, Point p) {
		Vector lv = lp1.diff(lp0);
		Vector pv = p.diff(lp0);
		double cp=0.0;
		if ((cp=lv.crossProduct(pv))>EPS) {return 1;} // counter-clockwise
		if (cp<-EPS) {return 2;} // clockwise
		if (lv.dotProduct(pv)<-EPS) return 3; // online-back
		if (lv.norm() < pv.norm()) return 4; // online-front
		return 5; // on-segment
	}

}

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

int main(){
  
  long long N, M, i, p, NumWA = 0, NumAC = 0;
  cin >> N >> M;
  string S;
  vector<bool> AC(N, false);
  vector<long long> WA(N, 0);
  
  for (i = 0; i < M; i++){
    
    cin >> p >> S;
    p--;
    
    if (S == "AC" && AC.at(p) == false){
      
      AC.at(p) = true;
      NumAC++;
      
    } else if (S == "WA" && AC.at(p) == false) {
      
      WA.at(p)++;
    }
  }
  
  for (i = 0; i < N; i++){
    if (AC.at(i) == 1) NumWA += WA.at(i);
  }
  
  cout << NumAC << " " << NumWA << endl;
  return 0;
}

Measured memory_bytes: 1024
#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 = 4;

ll dp[1010][2][1010];

void solve() {
    memset(dp,0,sizeof(dp));
    string A;
    int K;
    cin >> A >> K;

    const int n = A.size();

    dp[0][0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k <= K; k++) {
                int x = j ? 9 : A[i] - '0';
                for (int d = 0; d <= x; d++) {
                    if(d == 0){
                        dp[i + 1][j || d < x][k] += dp[i][j][k];
                    }
                    else{
                        dp[i + 1][j || d < x][k + 1] += dp[i][j][k];
                    }
                }
            }
        }
    }
    ll ans = 0;
    for (int j = 0; j < 2; j++) {
        ans += dp[n][j][K];
    }
    cout << ans << 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: 16128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
//#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    string s;cin>>s;
    cout<<s[0]<<s[1]<<s[2]<<endl;
    
    return 0;
}





Measured memory_bytes: 3652
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007

ll N,K;
vector<ll> x(100010,0);
vector<ll> y(100010,0);
vector<char> c(100010);
vector<vector<ll>> sum(2010,vector<ll>(2010,0));

ll getsum(ll x1,ll x2, ll y1, ll y2){
    if (x1 < 0) x1 = 0;
    if (y1 < 0) y1 = 0;
    if (x2 >= 2*K) x2 = 2*K-1;
    if (y2 >= 2*K) y2 = 2*K-1;
    if (x1 >= 2*K ||y1 >= 2*K) return 0;
    if (x2 < 0 || y2 < 0) return 0;
    if (x1 > 0 && y1 > 0)
        return sum[x2][y2] - sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1];
    if (x1 > 0)
        return sum[x2][y2] - sum[x1-1][y2];
    if (y1 > 0)
        return sum[x2][y2] - sum[x2][y1-1];
    else
        return sum[x2][y2];
}

int main() {
    cin >> N >> K;
    rep(i,N){
        cin >> x[i] >> y[i] >> c[i];
    }
    rep(i,N){
        if (c[i] == 'W') {
            y[i] += K;
        }
        x[i] = x[i]%(K*2);
        y[i] = y[i]%(K*2);
        sum[x[i]][y[i]] ++;
    }
        
    rep(i,2010){
        rep(j,2010){
            if (i > 0 && j > 0) sum[i][j] += sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
            else if(i > 0) sum[i][j] += sum[i-1][j];
            else if(j > 0) sum[i][j] += sum[i][j-1];
        }
    }
    
    ll ans = 0;
    rep(i,2*K){
        rep(j,2*K){
            ll temp = 0;
            temp += getsum(i-3*K+1,i-2*K,j-K+1,j)+getsum(i-K+1,i,j-K+1,j)+getsum(i+K+1,i+2*K,j-K+1,j);
            temp += getsum(i-3*K+1,i-2*K,j+K+1,j+2*K)+getsum(i-K+1,i,j+K+1,j+2*K)+getsum(i+K+1,i+2*K,j+K+1,j+2*K);
            temp += getsum(i-3*K+1,i-2*K,j-3*K+1,j-2*K)+getsum(i-K+1,i,j-3*K+1,j-2*K)+getsum(i+K+1,i+2*K,j-3*K+1,j-2*K);
            temp += getsum(i-2*K+1,i-K,j-2*K+1,j-K)+getsum(i+1,i+K,j-2*K+1,j-K)+getsum(i+2*K+1,i+3*K,j-2*K+1,j-K);
            temp += getsum(i-2*K+1,i-K,j+1,j+K)+getsum(i+1,i+K,j+1,j+K)+getsum(i+2*K+1,i+3*K,j+1,j+K);
            temp += getsum(i-2*K+1,i-K,j+2*K+1,j+3*K)+getsum(i+1,i+K,j+2*K+1,j+3*K)+getsum(i+2*K+1,i+3*K,j+2*K+1,j+3*K);
            ans = max(ans,temp);
            
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 33536
#include<stdio.h>
double dp[310][310][310];
double solve(int i, int j, int k, int n)
{
        if((i == 0 && j == 0 && k == 0)||(i < 0 || j < 0 || k < 0))
                return 0;
        if(dp[i][j][k] != -1)
                return dp[i][j][k];
        dp[i][j][k] = 1+ (n - i-j-k + i*solve(i-1, j, k, n) + j*solve(i+1, j-1, k, n) + k*solve(i, j+1, k-1, n))/(i+j+k);
        return dp[i][j][k];
}
int main()
{       
        int i, j, k, one, two, three, n;
        scanf("%d", &n);
        double a[n];
        one = two = three = 0;
        for(i = 0; i < 310; i++)
        {
                for(j = 0; j < 310; j++)
                {
                        for(k = 0; k < 310; k++)
                        {
                                dp[i][j][k] = -1;
                        }
                }
        }
        for(i = 0; i < n; i++)
        {
                scanf("%lf", a+i);
                if(a[i] == 1)
                        one++;
                else if (a[i] == 2)
                        two++;
                else
                        three++;
        }
        double ans = solve(one, two, three, n);
        printf("%.9lf", ans);
        return 0;
} 

Measured memory_bytes: 232960
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    XYH = [list(map(int, input().split()))for _ in range(N)]

    XYH.sort(key=lambda i: i[2], reverse=True)

    for cx in range(101):
        for cy in range(101):
            x, y, h = XYH[0]
            ch = h + abs(cy - y) + abs(cx - x)

            if all([h == max(ch - abs(cy - y) - abs(cx - x), 0) for x, y, h in XYH[1:]]):
                print(cx, cy, ch)
                exit()

    print(XYH)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
import Prelude hiding (elem)
import Control.Applicative
import Control.Monad.State
data LazySegTree a =  Leaf a | Elem { eSize :: Int, elem :: a} | Tree { size :: Int
                                                                      , left :: LazySegTree a
                                                                      , right :: LazySegTree a
                                                                      , lazy :: Bool
                                                                      } deriving (Show)

main = do
    [n, q] <- map read.words<$>getLine
    let init = fromList $ replicate n (2^31 - 1)
    evalStateT (query q) init

query :: Int -> StateT (LazySegTree Int) IO ()
query 0 = return ()
query n  = do
    getQuery
    query (n-1)

getQuery :: StateT (LazySegTree Int) IO ()
getQuery = do
    (x:xs) <- lift $ map read.words<$>getLine
    case x of
      0 -> let [s,t,x] = xs in modify (\tr -> updateT tr s t x)
      1 -> let [i] = xs in get >>= \tr -> (lift $ print $ findT tr i)

isElem :: LazySegTree a -> Bool
isElem (Elem _ _) = True
isElem _          = False

fromList :: [a] -> LazySegTree a
fromList xs = fl n xs
    where n = length xs

fl :: Int -> [a] -> LazySegTree a
fl n [x] = Leaf x
fl n xs = Tree n leftT rightT True
    where n' = n `div` 2
          (xsL, xsR) = splitAt n' xs
          leftT = fl n' xsL
          rightT = fl (n-n') xsR

updateT :: LazySegTree a -> Int -> Int -> a -> LazySegTree a
updateT (Leaf a) _ _ x = Leaf x
updateT tr s t x
  | isElem tr = elemUpdateT tr s t x
  | n <= s = tr { lazy = False, right = updateT (right tr) (s-n) (t-n) x }
  | n > t  = tr { lazy = False, left = updateT (left tr) s t x }
  | t-s+1 == size tr = Elem (size tr) x
  | otherwise = tr { lazy = False
                   , left = updateT (left tr) s (n-1) x
                   , right = updateT (right tr) 0 (t-n) x
                   }
    where n = size tr `div` 2

elemUpdateT tr s t x
  | eSize tr == 1 = Leaf x
  | n <= s = Tree { size = eSize tr, lazy = False, left = lt, right = elemUpdateT rt (s-n) (t-n) x}
  | n > t = Tree { size = eSize tr, lazy = False, left = elemUpdateT lt s t x, right = rt }
  | t - s + 1 == eSize tr = tr { elem = x }
  | otherwise = Tree { lazy = False
                     , left = elemUpdateT lt s (n-1) x
                     , right = elemUpdateT rt 0 (t-n) x
                     , size = eSize tr
                     }
    where n = eSize tr `div` 2
          lt = Elem n (elem tr)
          rt = Elem (eSize tr - n) (elem tr)

findT (Leaf x) 0 = x
findT tr i
  | isElem tr = elem tr
  | n <= i = findT (right tr) (i-n)
  | n > i = findT (left tr) i
    where n = size tr `div` 2



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

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int T = scan.nextInt();
    int MinCost = 0;
    boolean flag = false;

    int[][] d = new int[N][2];
    for(int i = 0; i < N; i++){
      d[i][0] = scan.nextInt();
      d[i][1] = scan.nextInt();
      if(d[i][1] <= T){
        flag = true;
        MinCost = d[i][0];
      }
    }


    if(flag == false){
      System.out.println("TLE");
    }else{
      for(int i = 0; i < N ; i++){
        if((T >= d[i][1])&&(MinCost > d[i][0]))
          MinCost = d[i][0];
      }
      System.out.println(MinCost);
    }
  }
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n,m,a,b,c,d,e;
	long double z,w;
	string str;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b>>c;
	cout<<a*b/2;



	cout<<endl;
} 


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


int main (){
    int i;
    int n;
    int s[1000] = {0};
    int temp = 0;
    int ans = 0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&s[i]);
        temp += s[i];
    }
    i=0;
    sort(s,s+n);
    if(temp % 10 != 0 ){
        printf("%d\n",temp);
    }else{
        while(1){
            ans = temp;
            ans -= s[i];
            if(ans % 10 != 0){
                printf("%d\n",ans);
                break;
            }
            if(i >= n){
                printf("0\n");
                break;
            }
            i++;
        }
    }
    

    
    return 0;
}


Measured memory_bytes: 888
h,w,d = map(int,input().split())
hw = [[] for _ in range(h*w+1)]
for i in range(h):
    row = list(map(int,input().split()))
    for j in range(w):
        hw[row[j]] = [i,j]
 
a = [0 for _ in range(h*w+1)]
for i in range(d+1,h*w+1):
    a[i] = a[i-d] + abs(hw[i][0] - hw[i-d][0]) + abs(hw[i][1] - hw[i-d][1])
 
q = int(input())
for i in range(q):
    L,R = map(int,input().split())
    print(a[R] - a[L])

Measured memory_bytes: 17188
/**
 *   author: malviyanshiv
 *   created: 27 July 2019  17:37:22
**/

#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for(int i = a; i < b; i++)
#define RREP(i, a, b) for(int i = a-1; i >= b; i--)
#define FORE(a) for(auto ele : a )
#define ALL(a) begin(a), end(a)
#define RPB(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define PB push_back
#define MP make_pair
#define MOD 1000000007
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define F first
#define S second
#define TC int t; cin >> t; while(t--)
#define SET(a,b) memset(a,b,sizeof(a))

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

typedef long long ll;
typedef pair< int, int > PII;


void optimizeIO(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
}

int main(){
	optimizeIO();

	int n;
	cin >> n;
	vector<ll> ai(n+1), bi(n);
	REP(i, 0, n+1)
		cin >> ai[i];
	REP(i, 0, n)
		cin >> bi[i];
	ll tot = 0;
	ll pow, prev = ai[n];
	for(int i = n-1; i >= 0; i--){
		pow = bi[i];
		if( prev >= pow ){
			tot += pow;
			prev = ai[i];
		}else{
			tot += prev;
			pow -= prev;
			prev = ai[i];
			if( prev >= pow ){
				tot += pow;
				prev -= pow;
			}else{
				tot += prev;
				prev = 0;
			}
		}
	}
	cout << tot << endl;
	return 0;
}

Measured memory_bytes: 1792
n = [int(x) for x in input()]
op = len(n) - 1
for i in range(2**op):
    op_list = ["-"]*op
    for j in range(op):
        if (i>>j)&1:
            op_list[op-1-j] = "+"
    formula = ""
    for p_n,p_o in zip(n,op_list+[""]):
        formula += str(p_n) + p_o
    if eval(formula) == 7:
        print(formula+"=7")
        break

Measured memory_bytes: 3060
n = gets.to_i
value = gets.split(" ").map(&:to_i)
cost = gets.split(" ").map(&:to_i)

v_c = []
for i in 0..n-1
  array = value[i] - cost[i]
  v_c << array
end

if v_c.all?{|item| item < 0}
  puts 0
  exit
end
puts v_c.select{|item| item >= 0}.inject(:+)

Measured memory_bytes: 1788
a, b = [int(x) for x in input().split()]

minans = int(a / 0.08)

if minans > int(b / 0.1):
    minans = int(b / 0.1)

for i in range(minans, 2000):
    if int(i * 0.08) == a and int(i * 0.1) == b:
        print(i)
        break
else:
    print(-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;


int main() {
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	long double maxe = 0;
	vector<long double>A(N), B(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> A.at(i);
	}
	for (size_t i = 0; i < N; i++)
	{
		cin >> B.at(i);
		A.at(i) =abs(A.at(i)- B.at(i));
		maxe = max(maxe, A.at(i));
	}
	long double ans=0;
	for (size_t i = 1; i <= 3; i++)
	{
		ans = 0;
		for (size_t j = 0; j < N; j++)
		{
			ans += pow(A.at(j), i);
		}
		cout << pow(ans, 1.0 / i)<<endl;
	}
	cout << maxe << endl;
}



Measured memory_bytes: 3544
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#include <list>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;
//dp[i][j][k] i番目までのカードを見て選んだカードがj枚で合計がkとなる場合の数
int x[51];
ll dp[51][51][2550];
int main(void){
    int n,a;
    cin>>n>>a;
    for(int i=0;i<n;i++){
        cin>>x[i];
        
    }
    memset(dp,0,sizeof(dp));
    dp[0][0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<=2500;k++){
                if(dp[i][j][k]){
                    //選択しない場合
                    dp[i+1][j][k]+=dp[i][j][k];
                    //選択する場合
                    dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
                }
            }
        }
    }
    ll ans=0;
    //平均aで選んだカードがi枚の時合計はa*iである
    for(int i=1;i<=n;i++){
        ans+=dp[n][i][a*i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 52096
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    for(int i=1; i<=a*b; i++){
        if(a*i%b==c){
            cout << "YES" << endl; 
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

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

int parent(int i){
    return i/2;
}   

int left(int i){
    return 2*i;
}

int right(int i){
    return 2*i+1;
}    

int main(){
    int H;
    cin >> H;
    int A[H+1];
    for(int i = 1; i <= H; i++) cin >> A[i];
    
    for(int i = 1; i <= H; i++){
        cout << "node " << i << ": key = " << A[i] << ", ";
        if(parent(i) >= 1)  cout << "parent key = " << A[parent(i)] << ", ";
        if(left(i) <= H)    cout << "left key = " << A[left(i)] << ", ";
        if(right(i) <= H)    cout << "right key = " << A[right(i)] << ", ";
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string s;
    cin >> s;
    int q;
    cin >> q;
    int count = 0;
    for(int i = 0; i < q; i++){
        int first;
        cin >> first;
        if(first == 1){
            count += 1;
        }
        else if(first == 2){
            int second;
            string x;
            cin >> second >> x;
            if(second == 1){
                if(count % 2 == 0){
                    //s = x + s;
                    s.insert(0,x);
                }else{
                    //s = s + x;
                    s.append(x);
                }
            }else{
                if(count % 2 == 0){
                    //s = s + x;
                    s.append(x);
                }else{
                    //s = x + s;
                    s.insert(0,x);
                }
        }
    }
    }
    if(count % 2 == 0){    
        cout << s << endl;
    }else{
        for(int i = s.size()-1; i > -1; i--){
            cout << s.at(i);
        }
    }
    return 0;
}



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

public class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] s = br.readLine().split(" ");
    int n = Integer.parseInt(s[0]);
    int W = Integer.parseInt(s[1]);
    long[] val = new long[n];
    long[] wt = new long[n];
    long maxVal = 0;
    for(long i=0;i<n;i++){
      String[] str = br.readLine().split(" ");
      wt[(int)i] = Long.parseLong(str[0]);
      val[(int)i] = Long.parseLong(str[1]);
      maxVal += val[(int)i];
    }
    long[][] dp = new long[(int)n+1][(int)maxVal+1];
    long max = 0;
    for(long i=0;i<=n;i++){
      for(long j=0;j<=maxVal;j++){
        if(i==0 || j==0) {
 
                    if(j==0)
                        dp[(int)i][(int)j]=0;
                    else
                    dp[(int)i][(int)j] = Long.MAX_VALUE;
 
                    continue;
                }
        else if(j>=val[(int)(i)-1] && dp[(int)(i)-1][(int)j-(int)val[(int)(i)-1]]!=Long.MAX_VALUE)
          dp[(int)i][(int)j] = Math.min(dp[(int)(i)-1][(int)j], wt[(int)(i)-1] + dp[(int)(i)-1][(int)j-(int)val[(int)(i)-1]]);
        else
          dp[(int)i][(int)j] = dp[(int)(i)-1][(int)j];
        
        if(dp[(int)i][(int)j]<=W)
          max = Math.max(max,j);
      }
    }
    
    
    System.out.println(max);
  }
}


Measured memory_bytes: 137472
n, k = map(int, input().split())
a = list(map(int, input().split()))

a = sorted(a)[::-1]
ans = n
sm = 0

for i in range(n):
    if sm + a[i] < k:
        sm += a[i]
    else:
        ans = min(ans, n - i - 1)

print(ans)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
struct Graph{
  using seen_t=size_t; using ver_t=size_t; using edge_t=pair<ver_t,seen_t>;
  const seen_t NO=1e9;
  vector<seen_t> seen;
  vector<vector<edge_t>> edge;
  Graph(size_t n): seen(n,NO), edge(n) {}

  void search(ver_t v0){
    seen[v0]=0;
    priority_queue<pair<seen_t,ver_t>,vector<pair<seen_t,ver_t>>,greater<pair<seen_t,ver_t>>> que; que.push(make_pair(0,v0)); // dijkstra
    ver_t curv; seen_t alt;
    while(!que.empty()){
      curv=que.top().second; que.pop(); // dijkstra
      for(const auto& nextv:edge[curv]){
        alt=seen[curv]+nextv.second;
        if(seen[nextv.first]>alt && alt<NO){
          seen[nextv.first]=alt;
          que.push(make_pair(alt,nextv.first)); // dijkstra
        }
      }
    }
  }
};
ostream& operator<<(ostream& os, const Graph& x){
  for(size_t i=0; i<x.edge.size(); ++i){
    cout<<(i)<<' '<<x.seen[i]<<'\n';
  }
  return os;
}
int32_t main(){
  ios::sync_with_stdio(false); cin.tie(0);
  size_t n; cin>>n;
  Graph graph(n);
  size_t u,k,v,c;
  for(size_t i=0; i<n; ++i){
    cin>>u>>k;
    graph.edge[u].resize(k);
    for(size_t j=0; j<k; ++j){
      cin>>v>>c; graph.edge[u][j]=make_pair(v,c);
    }
  }
  graph.search(0);
  cout<<graph;
}


Measured memory_bytes: 10948
from queue import Queue
import sys

sys.setrecursionlimit(10 ** 6)

def main():
  n, m = map(int, input().split())

  edges = [[] for _ in range(n)]

  for _ in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    edges[a].append(b)
    edges[b].append(a)

  visited = {0: -1}

  q = Queue()
  q.put(0)

  while not q.empty():
    current = q.get()
    for nxt in edges[current]:
      if nxt not in visited:
        visited[nxt] = current
        q.put(nxt)

  if len(visited) == n:
    print("Yes")
    for i in range(1, n):
      print(visited[i] + 1)
  else:
    print("No")


main()


Measured memory_bytes: 41088
#include <iostream>

int main()
{
    int a;
    std::cin>>a;
    for(int i=0;i<a;i++){
        int b,c;
        std::cin>>b>>c;
        if(b%c==0)std::cout<<c<<std::endl;
        else std::cout<<b%c<<std::endl;
    }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long 
#define clr(c) memset(c,0,sizeof(c))
#define inf 0x7fffffff
const int mod=1e9+7;
const int M=4e5+5;
const int N=2e5+10;
using namespace std;
inline ll read()
{
	ll sum=0,b=1;char c=getchar();
	while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
	while(isdigit(c)){sum=sum*10+c-'0';c=getchar();}
	return b*sum;
}
ll t,n,m,k;
ll a,b,c;
ll ans;
int main()
{
	ll N;
	N=read();
	int count=0;
	int temp=0;
	for(int i=8;i<N+1;i++){
		if(i%2==1)
		{
			temp=0;
			for(int j=1;j<i+1;j++)
			{
				if(i%j==0)
				{
					temp++;
				}
			}
			if(temp==8)
			{
			count++;
			}
			
		}
		
	}
		cout<<count;
		
  	
  
	
	return 0;
}  

Measured memory_bytes: 256