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

using namespace std;

int n, ap[20];

int take(vector<int> v)
{
    int ans = 24;

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

    for(int i=0; i<v.size(); ++i)
        for(int j=i+1; j<v.size(); ++j)
        {
            int a = v[i], b = v[j];

            ans = min(ans, b-a);
            ans = min(ans, 24-b+a);
        }
    return ans;
}

int main()
{
   // freopen("input", "r", stdin);
    cin.sync_with_stdio(false); cin.tie(0);

    cin >> n;

    int i, j;
    for(i=1; i<=n; ++i)
    {
        int x;
        cin >> x;
        ++ap[x];
    }

    ap[0] ++;

    vector<int> v, w;

    for(i=0; i<=12; ++i)
        if(ap[i] >= 3)
        {
            cout << 0 << '\n';
            exit(0);
        }
        else if(ap[i] == 2)
        {
            v.push_back(i);
            v.push_back(-i);
        }
        else if(ap[i] == 1)
            w.push_back(i);

    int ans = 0;

    for(i=0; i<(1<<(int)w.size()); ++i)
    {
        vector<int> vv = v;

        for(j=0; j<w.size(); ++j)
            if(i & (1<<j)) vv.push_back(w[j]);
                else vv.push_back(-w[j]);

        ans = max(ans, take(vv));
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll dx[]={0,0,1,1,1,-1,-1,-1};
ll dy[]={1,-1,-1,0,1,-1,0,1};

int main()
{
    ll n,m;
    cin>>n>>m;
    vector<bool> vis(n,false);
    ll ac=0,wa=0;
    vector<ll> v(n,0);
    for(int i=0;i<m;i++)
    {
        ll p;string s;
        cin>>p>>s;p--;
        if(s=="AC")
        {
            if(vis[p]==false)
            {
                vis[p]=true;
                ac++;
            }
        }
        else if(s=="WA")
        {
            if(vis[p]==false)
                v[p]++;
        }
    }
    for(int i=0;i<n;i++)
        if(vis[i]==true)
        wa+=v[i];
    cout<<ac<<" "<<wa<<"\n";
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int Z = sc.nextInt();
        int K = sc.nextInt();
        
        long[] A = new long[X];
        long[] B = new long[Y];
        long[] C = new long[Z];
        
        for(int i = 0; i < X; i++){
            A[i] = sc.nextLong();
        }
        
        for(int i = 0; i < Y; i++){
            B[i] = sc.nextLong();
        }
        
        for(int i = 0; i < Z; i++){
            C[i] = sc.nextLong();
        }        
        
        reverseSort(A);
        reverseSort(B);
        reverseSort(C);

        PriorityQueue<int[]> queue = new PriorityQueue<int[]>( new Comparator<int[]>(){
            @Override
            public int compare(int[] o1, int[] o2){
                long V = (A[o2[0]] + B[o2[1]] + C[o2[2]]) - (A[o1[0]] + B[o1[1]] + C[o1[2]]);
                return Long.signum(V);
            }
        } );
        
        Set<Long> isDone = new HashSet<>();
        queue.add( new int[]{ 0, 0, 0 });
        isDone.add(makeFlag(0, 0, 0));

        long[] ans = new long[K];
        for(int i = 0; i < K; i++){
            int[] cp = queue.poll();
            int Ai = cp[0];
            int Bi = cp[1];
            int Ci = cp[2];
            
            ans[i] = A[Ai] + B[Bi] + C[Ci];

            if( Ai+1 < X && !isDone.contains(makeFlag(Ai+1, Bi, Ci)) ){                
                queue.add( new int[]{ Ai+1, Bi, Ci } );
                isDone.add( makeFlag(Ai+1, Bi, Ci) );
            }
            
            if( Bi+1 < X && !isDone.contains(makeFlag(Ai, Bi+1, Ci)) ){                             
                queue.add( new int[]{ Ai, Bi+1, Ci } );
                isDone.add( makeFlag(Ai, Bi+1, Ci) );                
            }
            
            if( Ci+1 < X && !isDone.contains(makeFlag(Ai, Bi, Ci+1)) ){                             
                queue.add( new int[]{ Ai, Bi, Ci+1 } );
                isDone.add( makeFlag(Ai, Bi, Ci+1) );                
            }            
        }
        
        StringBuilder sb = new StringBuilder();
        for(long i : ans){
            sb.append(i).append("\r\n");
        }
        System.out.println(sb.toString());
        
    }
    
    static long makeFlag(int a, int b, int c){
        return (long)1e6 * a + (long)1e3 * b + c;
    }
    
    static void reverseSort(long[] L){
        Arrays.sort(L);
        int len = L.length;
        for(int i = 0; i < len/2; i++){
            long tmp = L[i];
            L[i] = L[len-1-i];
            L[len-1-i] = tmp;
        }
    }
}


Measured memory_bytes: 28712
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

//lli gcd(lli a,lli b){
//    lli x,y;
//    x=max(a,b);
//    y=min(a,b);
//    if(x%y==0){
//        return y;
//    }
//    else{
//        return gcd(y,x%y);
//    }
//}
//
//lli lcm(lli a,lli b){
//    lli x,y;
//    x=max(a,b);
//    y=min(a,b);
//    return x*y/gcd(x,y);
//}

int main(){
    lli h,w,ans;
    lli i,j;
    cin>>h>>w;
    if((h==1)||(w==1)){
        ans=1;
    }
    else{
        i=h/2;
        ans=i*w;
        if(h%2==1){
            ans+=ceil((double)w/2);
        }
    }
    cout<<ans<<endl;
}


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

const int N = 100005;

int n, a[N];
long long l[N], r[N];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	for (int i = 1; i <= n; ++i) {
		l[i] = l[i - 1] + abs(a[i] - a[i - 1]);
	}
	for (int i = n; i >= 1; --i) {
		r[i] = r[i + 1] + abs(a[i] - a[i + 1]);
	}
	for (int i = 1; i <= n; ++i) {
		printf("%lld\n", l[i - 1] + r[i + 1] + abs(a[i - 1] - a[i + 1]));
	}
}

Measured memory_bytes: 3712
n,k = map(int,input().split())
list1 = []

for i in range(k):
  d = int(input())
  p = list(map(int,input().split()))
  for j in p:
    list1.append(j)
    
count = 0
for m in range(1,n+1):
  if m not in list1:
    count += 1
    
print(count)
    

Measured memory_bytes: 9144
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
int gcd(int a, int b) { return b?gcd(b,a%b):a;}
int lcm(int a, int b) { return a/gcd(a,b)*b;}


int const INF = 1001001001;


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

int N,X;
cin >> N >> X;
vi x(N),y(N);
rep(i,N){
    cin >> x[i];
    y[i] = abs(X - x[i]);
}
int ans = y[0];
rep(i,N) {
    ans = gcd(ans,y[i]);
}

cout << ans << endl;

return 0;
}

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

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"); }
template <typename T> string to_string(T 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 T, typename U> string to_string(pair<T, U> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
void print_debug() { cerr << endl; }
template <typename T, typename... U> void print_debug(T t, U... u) { cerr << " " << to_string(t); print_debug(u...); }
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", print_debug(__VA_ARGS__)
#else
#define debug(...)
#endif

typedef long long ll;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  int a, b;
  cin >> a >> b;
  cout << a*b;
}


Measured memory_bytes: 3640
public class Hello{
    public static void Main(){
        // Your code here!
        string[] r = ((string)System.Console.ReadLine()).Split(' ');
        int a = int.Parse(r[0]);
        int b = int.Parse(r[1]);
        int c = int.Parse(r[2]);
        string ans ="";
        if (a<b && b<c)
            ans = "Yes";
        else
            ans = "No";
            
        System.Console.WriteLine(ans);
    }
}



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

int main(){
    string s;
    int pos=0,flag=0;
    cin>>s;
    pos=s.find("C");
    if(pos!=-1&&pos!=s.size()){
        pos=s.find("F",pos);
        if(pos!=-1){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

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

int main(){
  int N; cin >> N;
  long long B, A; cin >> B >> A;
  long long X = 0;
  rep(i, N - 2) {
    long long n; cin >> n;
    X ^= n;
  }
  bitset<50> bs(A + B), x(X);
  vector<int> ans(50);

  bool rev = false, check = true;
  repr(i, 50) {
    if (!rev) {
      if (bs[i] == 0 and x[i] == 0) {
        ans[i] = 0;
      } else if (bs[i] == 0 and x[i] == 1) {
        check = false;
      } else if (bs[i] == 1 and x[i] == 0) {
        rev = true;
        ans[i] = 0;
      } else {
        ans[i] = 2;
      }
    } else {
      if (bs[i] == 0 and x[i] == 0) {
        ans[i] = 1;
        rev = false;
      } else if (bs[i] == 0 and x[i] == 1) {
        ans[i] = 2;
      } else if (bs[i] == 1 and x[i] == 0) {
        ans[i] = 1;
      } else {
        check = false;
      }
    }
    if (!check) {
      cout << -1 << endl;
      return 0;
    }
  }
  if (rev) {
    cout << -1 << endl;
    return 0;
  }

  vector<long long> mx(51, 0);
  long long tmp = 0, dig = 1;
  rep(i, 50) {
    if (ans[i] != 0) tmp += dig;
    mx[i + 1] = tmp;
    dig *= 2;
  }
  long long res = 0;
  repr(i, 50) {
    dig /= 2;
    if (ans[i] == 1) res += dig;
    if (ans[i] == 2) {
      if (res + mx[i] < A) res += dig;
    }
  }
  if (res < A or res == A + B) {
    cout << -1 << endl;
    return 0;
  }
  cout << res - A << endl;
}


Measured memory_bytes: 3548
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

const int INF{1001001001};
const lint LINF{1001001001001001001ll};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == (lint)v.size() - 1 ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

signed main() {
  int a, b;
  cin >> a >> b;
  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
    print("Possible");
  } else {
    print("Impossible");
  }
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

const ll mod=1000000007;

ll mod_pow(ll x,ll y){
    ll res=1;
    while(y>0){
        if(y&1) res=res*x%mod;
        x=x*x%mod;
        y>>=1;
    }
    return res;
}

class union_find{
	private:
	vector<int> parent,rank;
	int size;
	public:
    int cnt;

    union_find()=default;
    union_find(int n){ init(n); }

    void init(int n){
		size=n;
		cnt=n;
		parent.resize(size);
		rank.resize(size);
		for(int i=0; i<size; ++i){
			parent[i]=i;
			rank[i]=0;
		}
	}

	int find(int x){
		if(parent[x]==x) return x;
		else return parent[x]=find(parent[x]);
	}

	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y]){
			parent[x]=y;
		} else {
			parent[y]=x;
			if(rank[x]==rank[y]) ++rank[x];
		}
        --cnt;
	}

	bool is_same(int x,int y){
		return find(x)==find(y);
	}
};

void solve(){
    while(true){
        ll n,m;
        cin >> n >> m;
        if(n==0 and m==0) break;

        union_find uf(n);
        rep(i,0,m){
            int a,b;
            cin >> a >> b;
            uf.unite(a-1,b-1);
        }
        ll ans=mod_pow(2,uf.cnt);
        if(uf.cnt!=n) ans=(ans+1)%mod;
        cout << ans << endl;
    }
}

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

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

#define first  fs
#define second se
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, char s = '\n') { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int main() {
	int W = in(), a = in(), b = in();
	int c = a + W, d = b + W;

	int l = b - c, r = a - d;
	cout << (l < 0 && r < 0 ? 0 : min(abs(l), abs(r))) << endl;
}



Measured memory_bytes: 256
/*
 Educational Dp Contest Atcoder
 
 */

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define all(x) x.begin(),x.end()

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}

const ll MOD =998244353;
const ll hell=1000000007;
const int INF=1e16;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

const int N=1e5+5;
int dp[N][101];int a[101],vl[101];
void solve()
{
    int n,w;
    cin>>n>>w;
    int s=0;
    for(int i=1;i<=n;i++)
    {  cin>>a[i]>>vl[i];
        s+=vl[i];
    }
    for(int i=0;i<=s;i++)
        for(int j=0;j<=n;j++)
            dp[i][j]= INF;
    for(int j=0;j<=n;j++)
        dp[0][j]=0;
    for(int i=1;i<=s;i++)
        for(int j=1;j<=n;j++)
        {
            dp[i][j]=dp[i][j-1];
            if(vl[j]<=i)
                dp[i][j]=min(dp[i][j],dp[i-vl[j]][j-1]+a[j]);
        }
    for(int i=s;i>=0;i--)
     if(dp[i][n]<=w)
     {
         cout<<i<<endl;
         return;
     }
}

int32_t main()
{
    
    IOS;
    //FILE *fin = freopen("in","r",stdin);
    //FILE *fout = freopen("out","w",stdout);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 79232
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>
#include <iomanip>
 
const int MOD = 1000000007;
 
 
ll POWER(ll x,ll y)
{
	ll ret=1;
	ll p=x;
	for (ll i=y;i>0;i/=2)
	{
		if (i%2) ret=(ret*p)%MOD;
		p=(p*p)%MOD;
	}
	return ret;
}
ll gcm(ll a, ll b)
{
	if (b>a) {ll c=a; a=b; b=c;}
	while (b>0)
	{
		ll r=a%b;
		a=b;
		b=r;
	}
	return a;
}
 
 
 
 
int main(int argc, char *argv[])
{
	int n,m,x;
	cin>>n>>m>>x;
	int a[12][12];
	int c[12];

	for (int i=0;i<n;i++) 
	{
		cin>>c[i];
		for (int j=0;j<m;j++) cin>>a[i][j];
	}

	int ret=MOD;
	for (int b=0;b<(1<<n);b++)
	{
		int cost=0;
		int t[12];
		for (int j=0;j<m;j++) t[j]=0;
		for (int i=0;i<n;i++)
		{
			if (b&(1<<i))
			{
				//cerr<<b<<" "<<i<<endl;
				for (int j=0;j<m;j++) t[j]+=a[i][j];
				cost+=c[i];
			}

		}
		bool f=true;
		for (int j=0;j<m;j++)
		{
			cerr<<t[j]<<" ";
			if (t[j]<x) f=false;
		}
		cerr<<endl;
		if (f && ret>cost) ret=cost;
	}
	if (ret==MOD) ret=-1;

	cout<<ret<<endl;
 
	return 0;
}
 

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 998244353;

llong mpow(llong n, llong m) {
	if (m == 0) return 0;
	if (m == 1) return n;

	llong ret = mpow(n, m/2);
	ret = ret * ret % mod;
	if (m&1)
		ret = ret * n % mod;

	return ret;
}

int main() {
	llong N;
	vector<llong> D;
	map<llong, llong> m;

	cin >> N;
	D.resize(N);
	llong maxi = -inf;
	for (auto &in: D) {
		cin >> in;
		++m[in];
		maxi = max(maxi, in);
	}

	llong ans = 1;
	if (!(m[0] == 1 && D[0] == 0)) {
		ans = 0;
	}
	for (int i = 1; i <= maxi; ++i) {
		ans = ans * mpow(m[i-1], m[i]) % mod;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 7296
import java.util.*;
import java.io.*;
public class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int x = Integer.parseInt(in.readLine());
    int ans = 0;
    while(x >= 5){
      if(x >= 500){
        ans += 1000 * (x / 500);
        x %= 500;
      } else {
        ans += 5 * (x/5);
        x %= 5;
      }
    }
    System.out.println(ans);
  }
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i < b; i++)
#define REPE(i,a,b) for (int i = a; i <= b; i++)

int main() {
	int n = 0;
	scanf("%d", &n);
	vector<vector<int>>  arr(n + 1, vector<int>(3, 0)), dp(n + 1, vector<int>(3, 0));
	int i = 0, j = 0, ans = 0;
	for (i = 0; i < n; i++) {
		for (j = 0; j < 3; j++) {
			cin >> arr[i][j];
		}
	}
	for (i = 0; i < 3; i++)
		dp[0][i] = arr[0][i];
	for (i = 1; i < n ; i++) {
		for (j = 0; j < 3; j++) {
			if (j == 0)
				dp[i][j] = arr[i][j] + max(dp[i - 1][j + 1], dp[i - 1][j + 2]);
			else if (j == 1)
				dp[i][j] = arr[i][j] + max(dp[i - 1][j - 1], dp[i - 1][j + 1]);
			else if (j == 2)
				dp[i][j] = arr[i][j] + max(dp[i - 1][j - 2], dp[i - 1][j - 1]);
		}
	}
	ans = max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11136
n = int(input())
co = 10**9
ma = -(10**9)
rr = int(input())
if rr < co:
	co = rr
for i in range(n-1):
	r = int(input())
	k = co
	if r < co:
		co = r
	if r - k > ma:
		ma = r - k
print(ma)


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

int main() {
    double a, b, t;
    cin >> a >> b >> t;

    double i = 1.0;
    int ans = 0;
    while(a * i <= t + 0.5) {
        ans += b;
        i += 1.0;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
 
int main() {
  
  int K;
  cin >> K;

  vector<vector<long long>> C(100,vector<long long>(0));
  set<long long> S;
  for(int i = 1;i <= 9;i++) {
    C[1].push_back(i);
    S.insert(i);
  }
  int d = 1;

  while(1) {
    int n = C[d].size();
    for(int i = 0;i < n;i++) {
      int num = C[d][i]%10;
      if(num != 9) C[d+1].push_back(C[d][i]*10+num+1);
      C[d+1].push_back(C[d][i]*10+num);
      if(num != 0) C[d+1].push_back(C[d][i]*10+num-1);
    }

    for(int i = 0;i < C[d+1].size();i++) {
      S.insert(C[d+1][i]);
    }
    if(S.size() > 100000) break; 
    d++;
  }

  vector<long long> ans(0);
  for(auto s :S) {
    ans.push_back(s);
  }
  sort(ans.begin(),ans.end());
  cout << ans[K-1] << endl;

  
}


Measured memory_bytes: 13300
#include <bits/stdc++.h>
    
using namespace std;
int N;
int a,b,c;
int main( ) {
    	scanf("%d", &N);
    	a=N/100;
    	b=N/10%10;
    	c=N%100%10;
    // 	printf("%d\n", a);
    // 	printf("%d\n", b);
    // 	printf("%d\n", c);
    	if (a==7 or b==7 or c==7){
    	    printf("Yes");
    	}
    	else{
    	    printf("No");
    	}
    
    return 0;
}

Measured memory_bytes: 3828
#include<stdio.h>

int main(void) {
	int N;
  scanf("%d", &N);
  int A[N];
  int ans[N];

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

  for(int i = 1; i <= N; ++i) {
		ans[A[i]] = i;
	}

  for(int i = 1; i <= N; ++i) {
		printf("%d ", ans[i]);
	}
  return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;

int main(){
    
    int n,x;
    int m[110];

    cin >> n >> x;
    rep (i,n) cin >> m[i];

     int rest = x;

     rep(i,n){
         rest = rest -m[i];
     };

    int min = m[0];
    rep(i,n){
        if(min>m[i]) min = m[i];
    };

    int cnt =0;
    cnt = n + rest/min;

    cout << cnt << endl;


    return 0;
}

Measured memory_bytes: 256
#pragma warning(disable: 4996)
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <sstream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 1; i <= (n); i++)


int main() {
    int n, k;
    cin >> n >> k;
    double ans = 0,tmp = 1;
   
    double b = 0;
    rep(i, n) {
        double a = 1,cnt = i,c = 1;
        while (cnt < k) {
            cnt *= 2;
            c *= 2;
        }
        c *= n;
        a *= (double)1 / c;
        
        b += a;
    }
    b *= tmp;

    ans += b;
    printf("%.16f", ans);

    return 0;
}

Measured memory_bytes: 3136
#include <stdio.h>
struct card{
    char suit;
    int value;
};
struct card c[2][36];

void Swap(int b, int x, int y){
    int v;
    char s;
    v=c[b][x].value;
    s=c[b][x].suit;
    c[b][x].value=c[b][y].value;
    c[b][x].suit=c[b][y].suit;
    c[b][y].value=v;
    c[b][y].suit=s;
}

void Print(int b, int n){
    for(int i=0;i<n;i++){
        printf("%c%d",c[b][i].suit,c[b][i].value);
        if(i!=n-1) printf(" ");
        else printf("\n");
    }
}

void isStable(int x,int n){
    int flag=0;
    int y;
    if(x==0) y=1;
    else y=0;
    
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int a=0;a<n;a++){
                for(int b=a+1;b<n;b++){
                    if(c[x][i].value==c[x][j].value && c[x][i].value==c[y][b].value && c[x][i].suit==c[y][b].suit && c[x][j].value == c[y][a].value && c[x][j].suit == c[y][a].suit){
                        printf("Not stable\n");
                        flag=1;
                        break;
                    }
                }
                if(flag==1) break;
            }
            if(flag==1) break;
        }
        if(flag==1) break;
    }
    if(flag==0) printf("Stable\n");
}

void BubbleSort(int n){
    for(int i=0;i<n;i++){
        for(int j=n-1;j>i;j--){
            if(c[0][j].value<c[0][j-1].value){
                Swap(0,j,j-1);
            }
        }
    }
    Print(0,n);
    isStable(0,n);
}

void SelectionSort(int n){
    int i,j,minj;
    for(i=0;i<n;i++){
        minj=i;
        for(j=i;j<n;j++){
            if(c[1][j].value<c[1][minj].value){
                minj=j;
            }
       }
       Swap(1,i,minj);
    }
    Print(1,n);
    isStable(1,n);
}

int main(void){
    int n;
    scanf("%d", &n);
    for(int i=0;i<n;i++){
        scanf("%c",&c[0][i].suit);
        if(c[0][i].suit<65||89<c[0][i].suit) scanf("%c",&c[0][i].suit);
        scanf("%d",&c[0][i].value);
        c[1][i]=c[0][i];
    }
    BubbleSort(n);
    SelectionSort(n);
    
    return 0;
}



Measured memory_bytes: 2148
r,c = map(int, input().split())
l = []
for i in range(0, r):
  e = list(map(int, input().split()))
  l.append(e)

for i in range(0, r):
  s = sum(l[i])
  l[i].append(s)
  print(' '.join(map(str,l[i])))

ele = []
for i in range(0, c + 1):
  e = 0
  for j in range(0, r):
    e += l[j][i]
  ele.append(e)

print(' '.join(map(str,ele)))


  





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



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

Measured memory_bytes: 3576
"use strict";

const upperBound = (arr, n) => {
    let first = 0, last = arr.length - 1, middle;
    while (first <= last) {
        middle = 0 | (first + last) / 2;
        if (arr[middle] <= n) first = middle + 1;
        else last = middle - 1;
    }
    return first;
}

const lowerBound = (arr, n) => {
    let first = 0, last = arr.length - 1, middle;
    while (first <= last) {
        middle = 0 | (first + last) / 2;
        if (arr[middle] < n) first = middle + 1;
        else last = middle - 1;
    }
    return first;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const L = arg[1].split(" ").map(n=>parseInt(n)).sort((a,b)=>a-b);
    
    // console.log(L);
    let answer = 0;
    
    for(let i=0; i<N; i++) {
        for(let j=i+1; j<N; j++) {
            const b = L[i];
            const c = L[j];
            
            //const min = lowerBound(L.slice(j+1), Math.abs(b-c));
            const max = lowerBound(L, b + c);
            
            // console.log(b);
            // console.log(c);
            
            //console.log("min:" + min);
            //console.log(N - max);
            // console.log("max:" + max);
            answer += max - (j + 1);
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7748
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int n;
int k;
int b;
int c;
int d;
int e;//ワイルドカードの値
while(cin >>n){
cin >>k;
if(n==0){break;}
int a[k];
b=0;
while(b<k){
cin >>a[b];
b=b+1;}
sort(a,a+b);
c=1;
d=0;
if(a[0]!=0){
b=1;
while(b<k){
if(a[b]==a[b-1]+1){c=c+1;}
else{if(d<c){d=c;} c=1;}
b=b+1;}}
if(a[0]==0){
e=0;
b=2;
if(a[1]!=1){c=2; e=a[1]-1;}
while(b<k){
if(a[b]==a[b-1]+1){c=c+1;}
else if(a[b]==a[b-1]+2){c=a[b]-e; e=a[b]-1;}
else{c=2; e=a[b]-1;}
if(d<c){d=c;}
b=b+1;}
if(a[k-1]!=n){c=a[b]+1-e; if(d<c){d=c;}}}
cout <<d<<endl;}}

Measured memory_bytes: 1488
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <numeric>
#define ll long long
#define INF INT_MAX 
using namespace std;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<int> > dist(H,vector<int> (W,-1));
    vector<vector<char> > A(H,vector<char> (W));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> A[i][j];
        }
    }
    queue<int> que;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(A[i][j]=='#'){
                dist[i][j] = 0; 
                que.push(i);
                que.push(j);
            }
        }
    }

    while(!que.empty()){
        int curx = que.front(); que.pop();
        int cury = que.front(); que.pop();
        for(int i=0;i<4;i++){
            int nx = curx + dx[i];
            int ny = cury + dy[i];
            if(0 <= nx && nx < H && 0 <= ny && ny < W){
                if(dist[nx][ny]==-1){
                    dist[nx][ny] = dist[curx][cury] + 1;
                    que.push(nx);
                    que.push(ny);
                }
            }
        }
    }
    int ans = 0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            ans = max(dist[i][j],ans);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 13456
N, K = gets.split(' ').map(&:to_i)

a = Array.new(N)

N.times do |i|
  k = 0
  while (i+1)*(2**k) <K
    k += 1
  end
  a[i] = Rational(1, N*(2**k))
end

p a.inject(:+).to_f

Measured memory_bytes: 9340
#include "bits/stdc++.h"
using namespace std;


/* macro */
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define sec second
#define fir first
#define pb push_back



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
//const int inf = pow(2, 62);
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};



/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
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; }




/* main */
struct cumsum1d{
    int n;
    vector<int> arr;

    cumsum1d(int len){
        n = len;
        rep(i,0,n) arr.push_back(0);
    }

    void init(vector<int> vec){
        arr = vec;
        n = arr.size();
    }

    void add(int a, int b, int val = 1){
        arr[a] += val;
        if(b + 1 < n) arr[b + 1] -= val;
    }

    void build(){
        rep(i,1,n) arr[i] += arr[i-1];
    }

    int query(int from, int to){
        int ret = arr[to];
        if(from) ret -= arr[from - 1];
        return ret;
    }

};




signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k; cin >> n >> k;

    vi arr; rep(i,0,n) arr.push_back(input());

    cumsum1d cs = cumsum1d(n);

    cs.init(arr);

    cs.build();

    vi sums;

    rep(i,0,n){
        rep(j,i, n){
            sums.push_back(cs.query(i,j));
        }
    }



    sort(all(sums));


    int t = 0;
    revrep(i,60,-1){
        vi sub;
        rep(j,0,sums.size()){
            if(sums[j] & (1LL << i)){
                sub.push_back(sums[j]);
            }
        }

        if(sub.size() >= k){
            sums = sub;
            t |= (1LL << i);
        }
    }

    print(t);





    

    
    




    
    



    
    

    







   




    

    

    




    



    



    

 
    
    


    

    
   
    













}






    










    




    










Measured memory_bytes: 6512
import java.util.Scanner;

public class Main{
	public static void time(int[] h, int[] m, int[] s){
		int hour = h[1]-h[0];
		int minute = m[1]-m[0];
		int second = s[1]-s[0];
		if( second < 0 ){
			second += 60;
			minute--;
		}
		if( minute < 0 ){
			minute += 60;
			hour--;
		}
		
		System.out.println(hour + " " + minute + " " + second);
	}
	
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int[][] h = new int[3][2];
		int[][] m = new int[3][2];
		int[][] s = new int[3][2];
		
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 2; j++){
				h[i][j] = stdIn.nextInt();
				m[i][j] = stdIn.nextInt();
				s[i][j] = stdIn.nextInt();
			}
		}
		
		for(int i = 0; i < 3; i++){
			time(h[i], m[i], s[i]);
		}
	}
}

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

public class Main {
    static IO io = new IO();
    public static void main(String[] args) {
        int n = io.nextInt();
        int l[] = new int[3];
        for (int i = 0; i < n; i++) {
            l[0] = io.nextInt();
            l[1] = io.nextInt();
            l[2] = io.nextInt();
            Arrays.sort(l);
            if (l[0]*l[0]+l[1]*l[1]==l[2]*l[2]) System.out.println("YES");
            else System.out.println("NO");
        }
    }

    static class IO extends PrintWriter {
        private final InputStream in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        IO() {
            this(System.in);
        }

        IO(InputStream source) {
            super(System.out);
            this.in = source;
        }

        boolean hasNextByte() {
            if (ptr < buflen) return true;
            else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) return false;
            }
            return true;
        }

        int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        }

        boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }

        int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public void close() {
            super.close();
            try {
                in.close();
            } catch (IOException ignored) {
            }
        }
    }
}

Measured memory_bytes: 25604
#include<stdio.h>
int main(){
	int S,h,m,s;
	h=0;
	m=0;
	s=0;
	scanf("%d",&S);
	h=S/60/60;
	m=S/60%60;
	s=S%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    int ans = 0;
    rep(i, n) {
        if ( sa[i] == sb[i] && sb[i] == sc[i] ) continue;
        if ( sa[i] != sb[i] && sb[i] != sc[i] && sc[i] != sa[i] ) {
            ans += 2;
            continue;
        }
        if ( sa[i] != sb[i] && sa[i] != sc[i] && sb[i] == sc[i] ||
             sb[i] != sc[i] && sb[i] != sa[i] && sc[i] == sa[i] ||
             sc[i] != sa[i] && sc[i] != sb[i] && sa[i] == sb[i] ) {
            ans += 1;
            continue;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 998244353;const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//g++ yarudake.cpp -std=c++17 -I .
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; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    vector<vector<ll>> dp(c+1,vector<ll>(d+1,0));
    dp[a][b]=1;
    for(ll i=a+1;i<=c;i++){
        dp[i][b]=dp[i-1][b]*b;
        dp[i][b]%=MOD;
    }
    for(ll i=b+1;i<=d;i++){
        dp[a][i]=dp[a][i-1]*a;
        dp[a][i]%=MOD;
    }
    for(ll i=a+1;i<=c;i++){
        for(ll j=b+1;j<=d;j++){
            dp[i][j]=dp[i-1][j]*j;
            dp[i][j]%=MOD;
            dp[i][j]+=dp[i][j-1]*i;
            dp[i][j] %= MOD;
            dp[i][j]-=((dp[i-1][j-1]*(i-1))%MOD*(j-1))%MOD;
            dp[i][j]=(dp[i][j]+MOD)%MOD;
        }
    }
    cout<<dp[c][d]<<"\n";
}

Measured memory_bytes: 73672
using System;

class Program {
  static void Main() {
    int a = int.Parse(Console.ReadLine());
    int b = int.Parse(Console.ReadLine());
    int c = int.Parse(Console.ReadLine());
    int x = int.Parse(Console.ReadLine());
    int ans = 0;
    for (int i = 0; i <= a; i++) {
      for (int j = 0; j <= b; j++) {
        for (int k = 0; k <= c; k++) {
          if (x == 500 * i + 100 * j + 50 * k) ans++;
        }
      }
    }
    Console.WriteLine(ans);
  }
}

Measured memory_bytes: 11092
#include <iostream>
#include <stdio.h>

using namespace std;

static const int N = 100;
void output(int list[],int n,int swap_number);

void bubble_sort(int list[],int n){
	bool flag = true;
	int swap_number = 0;
	while(flag){
		flag = false;
		for(int i = n - 1; i > 0; i-- ){
			if( list[i] < list[i - 1] ){
				int tmp = list[i - 1];
				list[i - 1] = list[i];
				list[i] = tmp;
				swap_number++;
				flag = true; 
			}
		}
	}

	output(list,n,swap_number);
}

void output(int list[],int n,int swap_number){

	for(int i = 0; i < n; i++){
		if(i == n - 1){
			printf("%d\n", list[n - 1]);
		}else{
			printf("%d ", list[i]);
		}
	}
	cout << swap_number << endl;
}


int main(void){
	int list[N],n;

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

	bubble_sort(list,n);

	return 0;
}

Measured memory_bytes: 1192
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main() {
    vi a,b;
    rep(i,3){
        int x;
        cin>>x;
        a.pb(x);
    }
    rep(i,2){
        int x;
        cin>>x;
        b.pb(x);
    }
    
    sort(all(a));
    sort(all(b));
    
    cout<<a[0]+b[0]-50<<endl;
    
    return 0;
}

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

int main()
{
  int N, A;
  int dp[10005];
  
  fill_n(dp, 10005, 1 << 28);
  dp[0] = 0;
  
  cin >> N;
  for(int i = 1; i < N; i++) {
    cin >> A;
    for(int j = 0; j <= i / 2; j++) {
      dp[j] = min(dp[j], dp[i - j] + A);
      dp[i - j] = min(dp[i - j], dp[j] + A);
    }
  }

  cout << dp[N / 2] << endl;
  return 0;
}

Measured memory_bytes: 3132
#include<stdio.h>

int dp[50];

int fib(int n)
{
  if( n == 0 || n == 1 )
    return dp[n] = 1;
  if( dp[n] != -1 )
    return dp[n];
  return dp[n]=  fib(n-1) + fib(n-2);
}

int main()
{
  int n,i;
  for( i = 0; i < 50; i++ )
    dp[i]=-1;
  scanf("%d",&n);
  printf("%d\n",fib(n));
  
  return 0;
}



Measured memory_bytes: 2112
#include<string>
#include<iostream>
#include<cctype>
using namespace std;
int main(){
    string a;
    string b;
    string f;
    string g;
    int c=0,d,e;
    cin>>a;
    d=a.size();
    while(true){
        b="";
        cin>>f;
        e=f.size();
        if(f=="END_OF_TEXT"){
            cout<<c<<endl;
            break;
        }
        for(int i=0;i<e;i++){
            b += tolower(f[i]);
        }
        if(b==a){
            c++;
        }
    }
    return 0;
}


Measured memory_bytes: 3196
import itertools

input()
rods = list(map(int, input().split(" ")))
sorted_rods = sorted(rods)

count = 0
for combination in itertools.combinations(sorted_rods, 3):
  a, b, c = combination
  if a != b and b != c:
    if a + b > c:
      count += 1
      
print(count)

Measured memory_bytes: 9184
using System;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    public static void Main(string[] args)
    {
        while (true)
        {
            var Size = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            if (Size[0] == 0) break;

            var Count = new Dictionary<int, int>();

            for (int i = 0; i < Size[0]; i++)
            {
                var Line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                for (int j = 0; j < Size[1]; j++)
                {
                    Count[j + 1] = (Count.ContainsKey(j + 1) ? Count[j + 1] : 0) + Line[j];
                }
            }

            StringBuilder Result = new StringBuilder();
            Count.OrderByDescending(p => p.Value).Select(p => p.Key).ToList().ForEach(p => Result.Append(p).Append(" "));
            Console.WriteLine(Result.ToString().Trim());
        }
    }
}

Measured memory_bytes: 10428
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include <unordered_map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n; ++i)
#define ALL(a) (a).begin(),(a).end()
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)

 
int  main(){
    ll n;
    cin >> n;
 
    unordered_map<string, int> m;
    rep(i, n){
        string s;
        cin >> s;
        sort(ALL(s));
        auto iter = m.find(s);
        if(iter  == m.end())m.emplace(s, 1);
        else m[s]++;
    }

    ll ans = 0;
    all_map(itr, m)rep(i, itr->second)ans+=i;

    printf("%lld",ans);
}

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

int root(vector<int> &r, int a)
{
    if (r[a] == a) return a;
    else return r[a] = root(r, r[a]);
}

int main()
{
    long long N, K, L;
    scanf("%lld%lld%lld", &N, &K, &L);
    vector<int> road, rail;
    for (int i = 0; i <= N; i++) {
        road.push_back(i);
        rail.push_back(i);
    }
    for (int i = 1; i <= K; i++) {
        int p, q;
        scanf("%d%d", &p, &q);
        road[root(road, p)] = root(road, q);
    }
    for (int i = 1; i <= L; i++) {
        int r, s;
        scanf("%d%d", &r, &s);
        rail[root(rail, r)] = root(rail, s);
    }
    map<pair<int, int>, int> mp;
    for (int i = 1; i <= N; i++) {
        mp[make_pair(root(road, i), root(rail, i))]++;
    }
    for (int i = 1; i <= N; i++) {
        printf("%d ", mp[make_pair(root(road, i), root(rail, i))]);
    }
    printf("\n");
}


Measured memory_bytes: 13548
#include <stdio.h>

main(){

  int i,j,tmp;
  int n;
  int A[100];
  int count=0;
 
  
scanf("%d",&n);
if(n<1||n>100)return 0;
 
 for(i=0;i<n;i++){
   scanf("%d",&A[i]);
 }
 
 for(i=0;i<n;i++){
   for(j=1;j<n;j++){
     if(A[j]<A[j-1]){
       tmp=A[j];
       A[j]=A[j-1];
       A[j-1]=tmp;
       count++;
     }
   }
 }


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

Measured memory_bytes: 604