akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

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

using namespace std;

int main() {
  int n, k;
  std::cin >> n >> k;
  std::vector<int> x(n);
  rep(i, n) { std::cin >> x[i]; }

  int ans = 0;
  rep(i, n) { ans += min(x[i] * 2, abs(k - x[i]) * 2); }
  std::cout << ans << std::endl;
  return 0;
}


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

int a, b;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> a >> b;
    if(a > 9 || b > 9) cout << "-1\n";
    else cout << a * b << "\n";
    return 0;
}

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


using namespace std;
const int maxn=1e5+5;
int gcd(int a , int b)
{
        return a%b==0? b:gcd(b,a%b);
}
inline LL quickread()
{
	LL X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}
int main()
{
    LL x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    LL ans;
    if(d>=x)
    {
        if(k%2==1)
            cout<<abs(d-x);
        else
            cout<<x;
    }
    else
    {
        if(x/d>=k)
        {
            cout<<abs(x-d*k);
        }
        else
        {
            LL ans;
            LL cha1=x-x/d*d;

            LL cha2=d-cha1;

            if(cha1<cha2)
            {
                if((k-x/d)%2==0)
                {
                    ans=cha1;
                }
                else
                    ans=cha2;
            }
            else
            {
                if((k-x/d)%2==1)
                    ans=cha2;
                else
                    ans=cha1;
            }
            cout<<ans<<endl;
        }
    }

}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define fastio 	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define unmap  	unordered_map<int,int>
#define	unset	unordered_set<int>
#define maxpq  	priority_queue<int>
#define minpq  	priority_queue<int, vector<int>, greater<int>>
#define pb 		push_back		
#define ll 		long long
#define ull     unsigned ll
#define ff 		first
#define ss 		second//typedef second ss;
#define foton(i,n) for(int i=0;i<n;i++)
#define	faton(i,a,n)	for(int i=a;i<=n;i++)
#define mod 	1000000007
int const inf = 10000007;
#define endl "\n"
using namespace std;

int main(){
	fastio;
	string s;cin>>s;
    int n = s.size();
    if(s[n-1] == 's') s += "es";
    else{
        s += 's';
    }
    cout<<s<<endl;
	return 0;
}

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

typedef long long ll;

int main(){
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  for (int i = 0; i < M; i++) {
    cin >> B.at(i);
  }
  int cnt=0;
  for (int i = 0; i < N; i++) {
    vector<int> A(M);
    for (int j = 0; j < M; j++) {
      cin >> A.at(j);
    }
    int sum=0;
    for (int k = 0; k < M; k++) {
      sum += B.at(k)*A.at(k);
    }
    sum += C;
    if(sum>0) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

int main(){

    int n, m, q,result = 0;
    cin >> n>> m>> q;

    vector<vector<int>> v=vector<vector<int>>(n, vector<int>(n, 0));
    vector<vector<int>> r=vector<vector<int>>(n, vector<int>(n, -1));
    int tmp1, tmp2;

    REP(i,m){
        cin >> tmp1 >> tmp2;
        v[tmp1-1][tmp2-1]++;
    }

    REP(i,q){

        cin >> tmp1 >> tmp2;
        if(r[tmp1-1][tmp2-1]!=-1){
            cout << r[tmp1 - 1][tmp2 - 1] << endl;
        }else{
            FOR(j,tmp1-1,tmp2){
                result += accumulate(&(v[j][tmp1 - 1]), &(v[j][tmp2]), 0);
            }
            cout << result << endl;
            r[tmp1 - 1][tmp2 - 1] = result;
        }


        
        result = 0;
    }

    return 0;
}

Measured memory_bytes: 2944
#include<stdio.h>

int main(void){
  int n;
  scanf("%d",&n);
  char c1[n],c2[n];
  scanf("%s %s",&c1,&c2);
  for(int i=0;i<n;++i){
    printf("%c",c1[i]);
    printf("%c",c2[i]);
  }  
  return 0;
}
  
  

Measured memory_bytes: 128
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <vector>
#include <string>
#include <cctype>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, double> pid;
typedef pair<LL, int> pLi;
typedef pair<int, LL> piL;
typedef stringstream strstm;
#define PI acos(-1.0)
#define CLR(a) MST(a,0);
#define E 2.718281829459
#define pb(x) push_back(x)
#define CLR(a) MST(a,0);
#define lowbit(x) (x & (-x))
#define DBG(x) cout << (x) << " ";
#define MST(a,b) memset(a,b,sizeof(a));
#define _for(i,a,b) for(int i = (a); i < (b); ++i)
#define _rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define _ech(x,z) for(auto x = z.begin(); x != z.end(); ++x)
 
const int MAXN = 100000 + 11;
int arr[MAXN][3];
 
 
int main(int argc, char const *argv[])
{
	int n; cin >> n;
	_for(i,0,n) cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
	int step1 = arr[0][1] + arr[0][2];
	if(arr[0][0] < step1){
		puts("No");
		return 0;
	}
	_for(i,1,n){
		int step = abs(arr[i][1] - arr[i-1][1]) + abs(arr[i][2] - arr[i-1][2]);
		if(step > arr[i][0]){
			puts("No");
			return 0;
		}else if(step == 0){
			int de = arr[i][0] - arr[i-1][0];
			if(de & 1){
				puts("No");
				return 0;
			}
		}else{
			int de = arr[i][0] - arr[i-1][0];
			if(de & 1 && !(step & 1)){
				puts("No");
				return 0;
			}
			if(!de & 1 && step & 1){
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
 
	return 0;
}

Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) printf("Case #%d: ",i);
using namespace std;
typedef long long int ll;
typedef complex<double> com;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main(){
	int a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f;
	a *= 100; b *= 100;
	vector<P> ans;
	int sum = a, maxx = 0;
	rep(i, 0, 100)rep(j, 0,100)rep(k,0,100)rep(l,0,100) {
		int water = i * a + j * b;
		int sugar = k * c + l * d;
		if (water + sugar <= f && sugar * 100 <= water * e && maxx * (water + sugar) <= sum * sugar) {
			maxx = sugar;
			sum = water + sugar;
		}
	}
	printf("%d %d", sum, maxx);
	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

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

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

template <class T>
struct BIT {
    int n;
    vector<T> bit;

    BIT(int _n = 0) : n(_n), bit(n + 1) {}

    // sum of [0, i), 0 <= i <= n
    T sum(int i) {
        T s = 0;
        while (i > 0) {
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }

    // 0 <= i < n
    void add(int i, T x) {
        ++i;
        while (i <= n) {
            bit[i] += x;
            i += i & -i;
        }
    }

    //[l, r) 0 <= l < r < n
    T sum(int l, int r) { return sum(r) - sum(l); }
};

int main() {
    int N, K;
    cin >> N >> K;
    V<ll> a(N);
    ll s = 0;
    rep(i, N) {
        ll x;
        cin >> x;
        s += x;
        a[i] = s - (ll)(i + 1) * K;
    }
    V<ll> xs = a;
    xs.pb(0);
    sort(ALL(xs));
    xs.erase(unique(ALL(xs)), xs.end());
    debug(a);

    auto get = [&](ll x) { return lower_bound(ALL(xs), x) - xs.begin(); };

    BIT<ll> T(N + 1);
    T.add(get(0ll), 1);

    ll ans = 0;
    rep(i, N) {
        int p = get(a[i]);
        ans += T.sum(0, p + 1);
        T.add(p, 1);
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	unsigned long long int a;
	long double b;
	cin >> a >> b;
	long double ans = a * b;
	cout << (unsigned long long int) trunc(ans) << '\n';
	
	return 0;
}


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

int main(){
    int a,b;
    char c;
    
    while(true){
        cin >> a >> c >> b;
        if(c=='?') break;
        
        switch(c){
                case '+':
                cout << a+b << endl;
                break;
                case '-':
                cout << a-b << endl;
                break;
                case '*':
                cout << a*b << endl;
                break;
                case '/':
                cout << a/b << endl;
                break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  cout << ((10*b+c)%4==0?"YES":"NO") << endl;
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n)for (int i=0;i<(n);i++)
#define PB push_back
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ll long long
using namespace std;
int n;
int d[1010];
bool rec(int num){
    vector<int>V;
    while(num>0){
        V.PB(num%10);
        num/=10;
    }
    reverse(ALL(V));
    REP(i,n-V.size()+1){
        bool f=true;
        REP(j,V.size()){
            if(V[j]!=d[i+j])f=false;
        }
        if(f)return true;
    }
    return false;
}
int main(){
    cin>>n;
    REP(i,n)cin>>d[i];
    int now=0;
    bool f=false;
    REP(i,n)if(d[i]==0)f=true;
    if(!f){
        cout<<0<<endl;return 0;
    }
    while(1){
        if(!rec(now)){
            cout<<now<<endl;
            return 0;
        }
        now++;
    }
}

Measured memory_bytes: 3152
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

vector<int> g[100111];
deque<int> ans;
int n,m;
bool use[100111];
int main()
{
	get2(n,m);
	for(int i=1,u,v;i<=m;i++)
	{
		get2(u,v);
		g[u].pb(v);
		g[v].pb(u);
	}
	ans.pb(1);use[1]=1;
	while(true)
	{
		int x=ans.back();
		bool ok=0;
		for(int i=0;i<(int)g[x].size();i++)
			if(!use[g[x][i]])
			{
				ans.pb(g[x][i]);
				use[g[x][i]]=1;
				ok=1;
				break;
			}
		if(!ok)break;
	}
	while(true)
	{
		int x=ans.front();
		bool ok=0;
		for(int i=0;i<(int)g[x].size();i++)
			if(!use[g[x][i]])
			{
				ans.push_front(g[x][i]);
				use[g[x][i]]=1;
				ok=1;
				break;
			}
		if(!ok)break;
	}
	printf("%d\n",(int)ans.size());
	for(int i=0;i<(int)ans.size();i++)printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 6784
#include<stdio.h>
int main(void){
    int A[100];
    int i, j, t, minj, sw = 0, N;

    scanf("%d", &N);
    for(i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }

    for(i = 0; i < N; i++){
        minj = i;
        for(j = i; j < N; j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        if(i != minj){
        t = A[i];
        A[i] = A[minj];
        A[minj] = t;
        sw++;
        }
    }

    printf("%d", A[0]);
    for(i = 1; i < N; i++){
        printf(" %d", A[i]);
    }
    printf("\n");
    printf("%d\n", sw);
    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK


        */

fast();
//ll t;cin>>t;while(t--)
{
   double n;
   cin>>n;


   double a=n/3;
   cerr<<a<<endl;
   double ans=a*a*a;
   cout<<fixed<<setprecision(12)<<ans<<endl;

  

   

}
return 0;
}

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

int dist[55][55];
int A[2005], B[2005];
bool flag[55];
int N, M;

bool dfs(int v, int g, int c)
{
    bool ret = false;
    if(v == g) return (true);
    if(flag[v]) return (false);
    flag[v] = true;
    for(int i = 0; i < N; i++) {
        if(dist[v][i] != c && dist[v][i] != -1) ret |= dfs(i, g, c);
    }
    return (ret);
}

int main()
{
    int cnt = 0;
    memset(dist, -1, sizeof(dist)); 
    cin >> N >> M;
    
    for(int i = 0; i < M; i++) {
        cin >> A[i] >> B[i]; --A[i], --B[i];
        dist[A[i]][B[i]] = dist[B[i]][A[i]] = i;
    }

    for(int i = 0; i < M; i++) {
        fill_n(flag, 55, false);
        cnt += dfs(A[i], B[i], i);
    }

    cout << M - cnt << endl;

    return (0);
}



Measured memory_bytes: 256
b[5<<17],S[2<<17],q;char*p=S;main(t){for(scanf("%*d%s%*d ",S);*p;)b[++q]=1<<*p++-97;for(;q=~getchar();)if(scanf(q&1?t=0,"%d%d ":"%d%s ",&q,S),!t){for(int i=q;i<=*S;)t|=b[i++];printf("%d ",__builtin_popcount(t));}else b[q]=1<<*S-97;}

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

using namespace std;

int n, k, d[9];
bool ok;

int main(){
	cin >> n >> k;
	for(int i = 0; i < k; ++i) cin >> d[i];
	
	for(int i = n;; ++i){
		string s = to_string(i);
		ok = true;
		for(int p = 0; p < s.size(); ++p){
			for(int q = 0; q < k; ++q){
				if(s[p] == (char)(d[q]+'0')) ok = false;
			}
		}
		if(ok){
			cout << i << endl;
			return 0;
		}
	}
}

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

typedef long long ll;

struct UnionFind{
    vector<int> par;
    vector<int> sizes;
    UnionFind(int n):par(n),sizes(n,1){ rep(i,n)par[i]=i; }
    //find root of x
    int find(int x){
        if(x!=par[x]) par[x] = find(par[x]);
        return par[x];
    }
    void unite(int x,int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(sizes[x] < sizes[y]) swap(x, y);
        par[y] = x;
        sizes[x] += sizes[y];
    }
    bool same(int x,int y){ return find(x) == find(y); }
    int size(int x){ return sizes[find(x)]; }
};

int main() {
	ll N,M;
	cin>>N>>M;
	vector<ll> A(M),B(M);
	rep(i,M){
		cin>>A[i]>>B[i];
		A[i]--;B[i]--;
	}
	vector<ll> ans(M);
	ans[M-1] = N*(N-1)/2;
	UnionFind uni(N);
	for (int i = M-1; i >=1; --i){
		if(uni.same(A[i],B[i])){
			ans[i-1] = ans[i]; 
		}
		else{
			ans[i-1] = ans[i]-uni.size(A[i])*uni.size(B[i]);
			uni.unite(A[i],B[i]);
		}
	}
	rep(i,M){
		cout<<ans[i]<<endl;
	}
}


Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,M,X;
    cin >>N>>M>>X;

    vector<ll> C(N);

    vector<vector<ll>> A(N,vector<ll>(M));

    rep(i,N){
        cin>>C[i];

        rep(j,M){
            cin>>A[i][j];
        }
    }
    ll ans = INF;
    rep(i,(1<<N)){
        vector<ll> S;
        rep(j,N){
            if(i&(1<<j)){
                S.pb(j);
            }
        }
        vector<ll> sum(M);
        ll mo=0;
        rep(j,S.size()){
            mo += C[S[j]];
            rep(k,M){
                sum[k]+=A[S[j]][k]; 
            }
        }
        ll flag =0;
        rep(k,M){
            if(sum[k]<X){
                flag = 1;
                break;
            }
        }
        if(flag == 0){
            chmin(ans,mo);
        }

        
    }
    if(ans==INF){
        cout<<-1<<endl;
    }else{
        cout << ans << endl;
    }
    


    return 0;
    

}

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

public class Main {

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tok;

        public InputReader(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream));
            tok = null;
        }

        public InputReader(String inputFile) throws FileNotFoundException {
            reader = new BufferedReader(new FileReader(inputFile));
            tok = null;
        }

        public String nextLine() {
            String c = "";
            try {
                c = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

            return c;
        }

        public String next() {
            while (tok == null || !tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(nextLine());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }

            return tok.nextToken();
        }

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

        public long nextLong() {
            return Long.parseLong(next());
        }
    }

    public static void main(String args[]) {
        InputStream inputstream = System.in;
        OutputStream outputstream = System.out;
        InputReader in = new InputReader(inputstream);
        PrintWriter out = new PrintWriter(outputstream);
        Task solver = new Task();
        solver.solve(in, out);
        out.flush();
    }

    static class Task {
        public void solve(InputReader in, PrintWriter out) {
            int n = in.nextInt();
            String colors = in.next();
            int whites = 0;
            for (char c : colors.toCharArray()) {
                if (c == 'W')
                    whites++;
            }
            if(whites==0 || n-whites==0){
                out.println(0);
                return;

            }
            int red=n-whites;
            int x=0,y=0;
            for(int i=0;i<red;i++){
                if(colors.charAt(i)=='W')
                x++;
            }
            for(int i=red;i<n;i++){
                if(colors.charAt(i)=='R')
                y++;
            }
            int ans=x+y-Math.min(x, y);
            out.println(ans);
        }
    }
}


Measured memory_bytes: 36744
### main

as = gets.strip.split(' ').map{|s| s.to_i}
bs = gets.strip.split(' ').map{|s| s.to_i}

asum = as.inject(0){|s, n| s + n}
bsum = bs.inject(0){|s, n| s + n}

puts (asum >= bsum ? asum : bsum)

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

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

    int n;
    cin >> n;
    vector<int> S(n);
    for (int i = 0; i < n; i++) cin >> S[i];
    int q;
    cin >> q;
    vector<int> T(q);
    for (int i = 0; i < q; i++) cin >> T[i];
    int cnt = 0;
    for (auto t : T) {
        auto it = lower_bound(S.begin(), S.end(), t);
        if (it != S.end() && *it == t) cnt++;
    }
    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 3312
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<vector>
#include<string.h>
using namespace std;
#define NIL -2000000001
#define INFTY 2000000001
#define MAX 100001
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n = 0;
int color[MAX], d[MAX];
vector<pair<int, int> > G[MAX];


void sp() {
  for ( int i = 0; i < n; i++ ) {
    color[i] = WHITE;
    d[i] = INFTY;
  }
  priority_queue<pair<int, int> > PQ;
  PQ.push(make_pair(0, 0));
  d[0] = 0;
  color[0] = GRAY;

  while (true) {
    int mincost;
    int u; //訪問する頂点

    // for (int i = 0; i < n; i++) {
    //   if (color[i] != BLACK && d[i] < mincost) {
    //     mincost = d[i];
    //     u = i;
    //   }
    // }

    pair<int, int> f = PQ.top();
    PQ.pop();
    u = f.second;
    mincost = (-1)*f.first;

    color[u] = BLACK;

    // u周りの頂点vの情報を入れる
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i].first;
      if (color[v] != BLACK && d[u]+G[u][i].second < d[v]) {
        d[v] = d[u]+G[u][i].second;
        color[v] = GRAY;
        PQ.push(make_pair(-d[v], v));
      }
    }
    if (PQ.empty()) break;
  }

  for (int v = 0; v < n; v++) {
    printf("%d %d\n", v, d[v]);
  }
}

int main() {
  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) {
    int stash, k;
    scanf("%d %d", &stash, &k);
    for ( int j = 0; j < k; j++) {
      int v;
      scanf("%d", &v);
      int g;
      scanf("%d", &g);
      G[i].push_back(make_pair(v, g));
    }
  }

  sp();

  return 0;
}



Measured memory_bytes: 9716
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define per(i,j,n) for(int i=(int)(j);(int)(n)<=i;i--)
#define int long long
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define endl "\n"
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<vi>
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=(1ll<<62)-1;
signed main(){
  ll N,M; cin>>N>>M;
  ll X=N*M/__gcd(N,M);
  string S,T; cin>>S>>T;
  map<int,char> A;
  rep(i,0,N){
    ll Y=i*X/N;
    A[Y]=S[i];
  }
  ll ans=X;
  rep(i,0,M){
    ll Y=i*X/M;
    if(A.count(Y)&&A[Y]!=T[i]) ans=-1;
  }
  cout<<ans<<endl;
}

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

int main(){
  string a,b;
  cin >> a;
  cin >> b;
  if((a[0]==b[2])&&(a[1]==b[1])&&(a[2]==b[0])){
  	cout << "YES" << endl;
  }else{
  	cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;



void oneCase () {
   int a, b;
   cin >> a >> b;
   cout << 6 - a - b << "\n";
}




int main() {
    int k = 1;
//    cin >> k;
    for (int i = 0; i < k; ++i) {
        oneCase();
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <vector>
#include <string>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

int main() { _
  string s, t; cin >> s >> t;
  int n = 0; 
  for (int i = 0; i < 3; i++) {
    if (s[i] == t[i]) n++;
  }
  cout << n << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#include <cstring>
#include <set>
#include <map>
#define rep(i, m, n) for (int i = m; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout << #x << ": " << x << endl
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int a,b,c;

int main()
{
    cin >> a >> b >> c;
    if(a<=c && c<=b){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 101
#define INF 2001
#define W -10
#define B -9

void prim(void);

int omomi[MAX][MAX];
int n;
int d[MAX];
int pi[MAX];
int color[MAX];

int main()
{
  int i,j,SUM=0;

  scanf("%d",&n);
  
  for(i=1;i<=n;i++)
    {
      for(j=1;j<=n;j++)
	{
	  scanf("%d",&omomi[i][j]);
	}
    }
  
  prim();

  for(i=1;i<=n;i++)
    {
      SUM+=d[i];
    }

  printf("%d\n",SUM);

  return 0;
}

void prim(void)
{
  int i,j,k,min;
  
  for(i=1;i<=n;i++)
    {
      d[i]=INF;
      pi[i]=EOF;
      color[i]=W;
    }

  d[1]=0;

  while(1)
    {
      min=INF;
      for(i=1;i<=n;i++)
	{
	  if(color[i]!=B && d[i]<min)
	    {
	      min=d[i];
	      j=i;
	    }
	}
      
      if(min==INF)
	{
	  break;
	}

      color[j]=B;

      for(k=1;k<=n;k++)
	{
	  if(color[k]!=B && omomi[j][k]<d[k]&&omomi[j][k]!=-1)
	    {
	      pi[k]=j;
	      d[k]=omomi[j][k];
	    }
	}
    }
}



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

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.test();
    }
    
    int n;
    private void test() {
        Scanner input = new Scanner(System.in);
        n = input.nextInt();
        int[][] us = new int[n+1][n+1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                int v = input.nextInt();
                us[i][j] = v == -1 ? Integer.MAX_VALUE : v;
            }
            us[i][i] = 0;
        }
        
        int[] f = new int[n+1];
        f[1] = 1;
        int t = calc(us, f);
        System.out.println(t);
    }
    int calc(int[][] us, int[] f) {
        int a = 0;
        int v = Integer.MAX_VALUE;
        for (int i = 1; i <= n; i++) {
            if (f[i] == 1) {
                for (int j = 1; j <= n; j++) {
                    if (i != j && f[j] != 1 && us[i][j] < v) {
                        a = j;
                        v = us[i][j];
                    }
                }
            }
        }
        f[a] = 1;
        if (f[0] == 1) return 0;
        return v + calc(us, f);
    }
}

class Scanner {
    BufferedReader r;
    StreamTokenizer st;
    
    public Scanner(InputStream in) {
        r = new BufferedReader(new InputStreamReader(in));
        st = new StreamTokenizer(r);
    }
    
    public String next() {
        nextToken();
        return st.sval;
    }
    
    public Integer nextInt() {
        nextToken();
        return (int)st.nval;
    }
    
    private int nextToken() {
        int token = st.TT_EOF;
        try {
            token = st.nextToken();
        } catch (IOException e) {
        }
        return token;
    }
}



Measured memory_bytes: 27200
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int a, b; cin >> a >> b;
  cout << max(a - 2 * b, 0) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n;
    k=n;
    int s=0;
    while(n)
    {
        s+=(n%10);
        n/=10;
    }
    if(k%s==0)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3588
L = int(input())

xs = []

for m in range(21):
    if (2 << m) > L:
        break
    xs.append((m+1, m+2, 0))
    xs.append((m+1, m+2, 1 << m))

b = 1 << m

for i in range(m - 1, -1, -1):
    c = 1 << i
    if L - b >= c:
        xs.append((i + 1, m + 1, b))
        b += c

print(m + 1, len(xs))

for x in xs:
    print(*x)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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; }



int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  string s, t;
  cin >> s >> t;

  int ans = inf;
  rep(i, s.size() - t.size() + 1) {
    int res = 0;
    rep(j, t.size()) res += (s[i + j] != t[j]);
    chmin(ans, res);
  }
  cout << ans << '\n';

  
  return 0;
}

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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  bool ok = false;
  string s,t;
  cin >> s >> t;
  ll size1 = s.size();
  ll size2 = t.size();
  for(ll i=size1-size2;i>=0;i--){
    rep(j,size2){
      if(s[i+j]!=t[j] && s[i+j]!='?') break;
      else if(j==size2-1){
        ok = true;
        rep(k,size2) s[i+k] = t[k];
      }
    }
    if(ok) break;
  }
  rep(i,size1){
    if(s[i]=='?') s[i] = 'a';
  }
  if(ok) cout << s << endl;
  else cout << "UNRESTORABLE" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define BIT(n) (1LL << (n))
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
#define MAXN 2001
#define MAXP 2001
lli C[MAXN][MAXP];
void init() {
  REP(i, MAXN) { C[i][0] = 1; }
  REPS(i, MAXN - 1) {
    REPS(j, MAXP - 1) { C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD; }
  }
}
//     0 1 2
// i=0. 1 0 0 0000
// i=1. 1 1 0 0000
// i=2. 1 2 1 0000
// K,i. not 0.  ( (K-1)  i-1)
// N-K-(i-1) divide i+2 (max) allow 0. ( N-K+1 i  )
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  init();
  // cout << C[2][0] << " " << C[2][0] << "\n";
  cin >> N >> K;
  // 5 3, 3--1*3 6--2*3 1
  REPS(i, K) { cout << (C[K - 1][i - 1] * C[N - K + 1][i]) % MOD << "\n"; }
}

Measured memory_bytes: 31488
C = input()
d = {"a": "b", "b": "c", "c": "d", "d": "e", "e": "f", "f": "g", "g": "h", "h": "i", "i": "j", "j": "k", "k": "l", "l": "m", "m": "n", "n": "o", "o": "p", "p": "q", "q": "r", "r": "s", "s": "t", "t": "u", "u": "v", "v": "w", "w": "x", "x": "y", "y": "z"}

print(d[C])

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <cfloat>
#include <cmath>
#include <functional>

using namespace std;

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

#define EPSILON 1e-8
#define INF (INFINITY/3)
#define MOD 1000000007L

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> iiPair;
typedef pair<double, int> diPair;


class Main {
public:

	ll getAns(ll k) {
		return ll(floor((-1 + sqrt(1 + 8 * k)) / 2 - EPSILON)) + 1;
	}
};


int main()
{
	Main main;
	ll k;
	
	cin >> k;

	cout << main.getAns(k) << endl;

	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
//const int mod=998244353;
//int Pow(int x,int y){
//	int ans=1;
//	for (;y;y>>=1,x=(LL)x*x%mod)
//		if (y&1)
//			ans=(LL)ans*x%mod;
//	return ans;
//}
//void Add(int &x,int y){
//	if ((x+=y)>=mod)
//		x-=mod;
//}
//void Del(int &x,int y){
//	if ((x-=y)<0)
//		x+=mod;
//}
//int Add(int x){
//	return x>=mod?x-mod:x;
//}
//int Del(int x){
//	return x<0?x+mod:x;
//}
const int N=13,S=6e5;
int n,m;
char t[S];
int T[S],P[S];
vi a[N][S];
int res[N][S];
int rev[3]={0,2,1};
int main(){
	n=read();
	scanf("%s",t+1);
	m=strlen(t+1);
	For(i,1,m){
		T[i]=t[i]=='S',P[i]=P[i-1]^T[i];
		if (!T[i])
			a[0][0].pb(i);
	}
	For(i,0,n-1){
		int s=pow(3,i);
		For(v,0,s*3-1){
			int d=v/s,t=v%s;
			if (i>0)
				res[i][v]+=res[i-1][t];
			int las=0;
			for (auto k : a[i][t]){
				if (P[k]^P[las])
					d=rev[d];
				d=(d+1)%3;
				if (!d)
					a[i+1][v].pb(k);
				las=k;
			}
			if (P[las]^P[m])
				d=rev[d];
			res[i][v]+=d*s;
		}
	}
	int n3=pow(3,n);
	For(i,0,n3-1)
		printf("%d ",res[n-1][i]);
	puts("");
	return 0;
}
/*
46
1 2 0 1
2 1 0 2
*/

Measured memory_bytes: 216072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,X;
    cin >> N >> X;
    int m[N];
    int sum=0;
    int q=INF;
    rep(i,N) {
        cin >> m[i];
        sum+=m[i];
        q=min(q,m[i]);
    }
    cout << N+(X-sum)/q << endl;




}

Measured memory_bytes: 256
def main(N, A):
    ans = 0
    culm = sum(A)
    for i in range(N-1):
        culm -= A[i]
        ans += A[i]*culm
        ans %= 10**9 + 7
    return ans

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    ans = main(N, A)
    print(ans)



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

int main(){
int n,m;
cin>>n>>m;
map<int, pair<int,int> > sub;
map<int, pair<int,int> >::iterator it ; 
  for(int i=0;i<m;i++){
    int p;
    string s;
  cin>>p>>s;
   it = sub.find(p); 
       if(it==sub.end()){
  			if(s=="WA"){
              pair<int, int>pair1 = make_pair(0, 1); 
   
    	     	sub[p]=pair1;
         }	else{
               pair<int, int>pair1 = make_pair(1, 0); 
   
    			sub[p]=pair1;
      } } 
    else
          if(it->second.first==0 && s=="WA")
          {
         int	q = it->second.second;
            it->second.second=q+1;
          }else{
         int q = it->second.first;
          it->second.first = 1;
          }
  }
  
  int a=0,b=0;
  
for (it = sub.begin(); it != sub.end(); ++it) { 
 if(it->second.first==1){
 a+=it->second.first;
  b+=it->second.second;
 }
} 
  cout<<a<<" "<<b;
}


Measured memory_bytes: 6528
import java.util.Scanner;

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

		int target = 0;
		for (int i = n; 1 <= i; i--) {
			target = (int) Math.sqrt(i);
			if (i == Math.pow(target, 2)) {
				target = i;
				break;
			}
		}

		System.out.println(target);

	}

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,i,j,s,n;
int main()
{
scanf("%d%d%d%d",&a,&b,&c,&n);
    for (i=0;i<=a;i++)
     for (j=0;j<=b;j++)
      if ((n-i*500-j*100>=0)&&(n-i*500-j*100<=c*50)) ++s;
    printf("%d\n",s);
    return 0;
	
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
	ll n;
	deque<ll> a, b;
	scanf("%lld", &n);
	for (ll i = 0; i < n; i++) {
		ll temp;
		cin >> temp;
		a.push_back(temp);
	}
	int t = 0;
	for (auto x: a) {
		//cout << x << endl;;
		if (t%2 != 0) {
			b.push_back(x);
		} else {
			b.push_front(x);
		}
		/*
		for (auto y: b) {
			cout << y;
		}
		cout << endl;*/
		t++;
	}
	if (n % 2 == 0) { //反転
		for (int i = b.size()-1; i >= 0; i--) {
			if (i != b.size()-1) cout << " ";
			cout << b.at(i);
		}
		cout << endl;
	} else {
		for (int i = 0; i != b.size(); i++) {
			if (i != 0) cout << " ";
			cout << b.at(i);
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

pair<i64, i64> input() {
  string s;
  cin >> s;
  i64 N = s.size();
  if(N - 2 >= 0 && s[s.size() - 2] == '.') {
    return { (i64)std::stoi(s.substr(0, s.size() - 2).c_str()) * 10 + (i64)(s[s.size() - 1] - '0'), 10 };
  }
  else if(N - 3 >= 0 && s[N - 3] == '.') {
    return { (i64)std::stoi(s.substr(0, s.size() - 3).c_str()) * 100 + (i64)(s[s.size() - 2] - '0') * 10 + (i64)(s[s.size() - 1] - '0'), 100 };
  }
  else {
    return { (i64)(std::stoi(s.c_str())), 1 };
  }
}

int main() {
  i64 a;
  cin >> a;
  auto p = input();
  i64 c = a * p.first;
  c /= p.second;
  cout << c << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <cassert>
using namespace std;

//common
//using i32=int;using i64=long long;
typedef long long ll;
// using uint=unsigned int;using ull=unsigned long long;
// template<typename T> using matrix=vector<vector<T> >;

#define BR "\n"
#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

//config
#define MODE_DEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef MODE_DEBUG
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#else
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}

template<class T> inline string toString(const vector<vector<T>>& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

//ind -> V から V->ind (注:単射)
template<typename T>
map<T,int> rev(const vector<T>& xs){
	map<T,int> rev;
	REP(i,(int)xs.size())rev.insert(make_pair(xs[i],i));
	return rev;
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

int main(){
	int n;cin >>n;
	vector<int> as(n);
	REP(i,n)cin >> as[i];
	vector<ll> dp(20+1);
	vector<ll> tmp(20+1);

	dp[as[0]]=1;
	for(int i=1;i<n-1;i++){
		for(int pv=0;pv<=20;pv++){
			int p=pv+as[i];
			if(IN(0,p,20+1))tmp[p]+=dp[pv];
			int m=pv-as[i];
			if(IN(0,m,20+1))tmp[m]+=dp[pv];
		}
		dp=tmp;
		fill(ALL(tmp),0);
		// DUMP(toString(dp));
		// DUMP(toString(tmp));
	}
	cout<<dp[as[n-1]]<<endl;

	return 0;
}

Measured memory_bytes: 1204
#include <stdio.h>

int main(void)
{
	int x,a,b;
	
	scanf("%d",&x);
	scanf("%d",&a);
	scanf("%d",&b);
	
	if(b <= a){
		printf("delicious\n");
	}
	else if(a<b && b<=(a+x)){
		printf("safe\n");
	}
	else{
		printf("dangerous\n");
	}
	
	return 0;
}


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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int IINF = 2002002002;
constexpr ll LINF = 9009009009009009009LL;

//===



int mht(Pii pos1, Pii pos2)
{
	return abs(pos1.first - pos2.first) + abs(pos1.second - pos2.second);
}


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

	vector<pair<Pii, int>> info(N);

	for (int i = 0; i < N; ++i) {
		int x, y, h;
		cin >> x >> y >> h;
		info[i].first = make_pair(x, y);
		info[i].second = h;
	}

	pair<Pii, int> base_info;
	for (int i = 0; i < N; ++i) {
		if (info[i].second > 0) {
			base_info = info[i];
			break;
		}
	}

	Pii ans_top;
	int ans_h;
	bool ok;
	for (int cx = 0; cx <= 100; ++cx) {
		for (int cy = 0; cy <= 100; ++cy) {
			ok = true;
			Pii p = { cx, cy };
			int h_top = base_info.second + mht(base_info.first, p);
			for (int i = 0; i < N; ++i) {
				int hi = h_top - mht(info[i].first, p);
				hi = max(hi, 0);
				if (info[i].second != hi) {
					ok = false;
					break;
				}
			}
			if (ok) {
				ans_top = { cx, cy };
				ans_h = h_top;
				break;
			}
		}
		if (ok) break;
	}

	cout << ans_top.first << " " << ans_top.second << " " << ans_h << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

int main(){
	ios_base::sync_with_stdio(false);
	int n, x;
	cin >> n >> x;
	vector<ll> w(n), v(n);
	for(int i = 0; i < n; ++i){ cin >> w[i] >> v[i]; }
	const ll w0 = w[0];
	vector<vector<ll>> vv(4);
	for(int i = 0; i < n; ++i){
		vv[w[i] - w0].push_back(v[i]);
	}
	vector<vector<ll>> vvi;
	for(auto& a : vv){
		sort(a.begin(), a.end(), greater<ll>());
		vector<ll> integral(1, 0);
		for(auto t : a){
			integral.push_back(integral.back() + t);
		}
		vvi.emplace_back(std::move(integral));
	}
	ll answer = 0;
	for(int i0 = 0; i0 <= vv[0].size(); ++i0){
		for(int i1 = 0; i1 <= vv[1].size(); ++i1){
			for(int i2 = 0; i2 <= vv[2].size(); ++i2){
				const ll wsum = i0 * (w0 + 0) + i1 * (w0 + 1) + i2 * (w0 + 2);
				if(wsum > x){ break; }
				const ll r = min<int>(vv[3].size(), (x - wsum) / (w0 + 3));
				const ll vsum = vvi[0][i0] + vvi[1][i1] + vvi[2][i2] + vvi[3][r];
				answer = max(answer, vsum);
			}
		}
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 256