akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using WeightedGraph = vector<vector<pair<int, int>>>;
const int INF = 1 << 29;

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

int h, w;
int gx, gy;
vector<string> s;
vector<char> s_;
vector< vector<int> > steps;

vector<int> dijkstra(int s, WeightedGraph & G){
  using P = pair<ll, int>;
  int n=G.size();
  vector<int> ds(n,INF);
  vector<int> bs(n,-1);
  priority_queue<P, vector<P>, greater<P> > pq;
  ds[s]=0;
  pq.emplace(ds[s],s);
  while(!pq.empty()){
    P p=pq.top();pq.pop();
    int v=p.second;
    if(ds[v]<p.first) continue;
    for(auto& e:G[v]){
      int u=e.first;
      ll c=e.second;
      if(s_[v] != '#' && s_[u] == '#'){
          ++c;
      }
      if(ds[u]>ds[v]+c){
        ds[u]=ds[v]+c;
        bs[u]=v;
        pq.emplace(ds[u],u);
      }
    }
  }
  return ds;
}

int main() {
    cin >> h >> w;
    gx = w-1; gy = h-1;

    s.resize(h);
    for(int i = 0;i < h; i++){
        cin>>s[i];
    }
    WeightedGraph G(w*h);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if(i<h-1)G[i*w+j].push_back({(i+1)*w+j,0});
            if(j<w-1)G[i*w+j].push_back({i*w+j+1,0});
            s_.push_back(s[i][j]);
        }
    }
    auto ds = dijkstra(0, G);
    int cur = 0;
    if(s[0][0]=='#') ++cur;
    cout << ds[h*w-1] +cur << endl;
    return 0;
}


Measured memory_bytes: 896
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

#include <numeric>

#include <map>

#include <deque>

#include <cassert>

#include <memory>

using namespace std;

typedef unsigned long long LL;

int main() {

    int n, m;
    cin >> n >> m;
    cout << n*(n-1)/2 + m*(m-1)/2 << endl;


    

}

Measured memory_bytes: 256
#include<stdio.h>
int solve(int,int);
int S[20],n;
int main()
{
  int i,q,T[200];
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&S[i]);
    }
  scanf("%d",&q);
  for(i=0;i<q;i++)
    {
      scanf("%d",&T[i]);
    }
    for(i=0;i<q;i++)
      {
        if(solve(0,T[i]))
          printf("yes\n");
else printf("no\n");
      }
  return 0;
}

    int solve(int i,int j)
    {
      int result;
      if(j==0)
        return 1;
      if(i>=n)
        return 0;
      result=solve(i+1,j) || solve(i+1,j-S[i]);
        return result;
    }


Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, m = 0;
    cin >> n;
    string s = to_string(n);
    for (char i : s) m += i - '0';
    if (n % m == 0) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 384
A,B,C,D=map(int, input().split())

while A>=0 and C>=0:
  C-=B
  #print(A,B,C,D)
  if C<=0:
    print('Yes')
    break
  A-=D
  #print(A,B,C,D)
  if A<=0:
    print('No')
    break

Measured memory_bytes: 9104
n = gets.strip.to_i
xys = n.times.map { gets.strip.split.map(&:to_i) }

if n == 1
    puts 1
else
    dxdy = []
    xys.combination(2).to_a.map do |c|
        p1, p2 = c
        dx = p1[0] - p2[0]
        dy = p1[1] - p2[1]

        dxdy.push [dx, dy]
        dxdy.push [-dx, -dy]
    end

    count = dxdy.group_by(&:itself).map { |k, v| [v.size, k] }.max_by(&:first)[0]
    puts n - count
end


Measured memory_bytes: 2300
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  string s;
  cin >> s;
  if(s == "ABC"){
    cout << "ARC" << endl;
  }else{
    cout << "ABC" << endl;
  }
}

Measured memory_bytes: 3592
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
  
using namespace std;
//using namespace boost;
//using namespace multiprecision;  

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

constexpr int dx[] = {1,0,-1,0,1,1,-1,-1};
constexpr int dy[] = {0,-1,0,1,1,-1,-1,1};
//}}}
//UnionFind{{{
struct UnionFind {
    vector< int > data;
 
    UnionFind(int sz) {
        data.assign(sz, -1);
    }
 
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }
 
    int find(int k) {
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }
 
    int size(int k) {
        return (-data[find(k)]);
    }

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

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

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

    UnionFind uf(n+1);
    map<pii,bool> mp;
    vector<int> cnt(n+1);

    rep(i,m){
        int a,b;
        cin >> a >> b;
        uf.unite(a,b);
        if(a > b) swap(a,b);
        mp[pii(a,b)] = true;
        ++cnt[a];
        ++cnt[b];
    }

    rep(i,k){
        int a,b;
        cin >> a >> b;
        if(a > b) swap(a,b);
        if(!mp[pii(a,b)] && uf.same(a,b)){
            ++cnt[a];
            ++cnt[b];
        }
    }

    reps(i,n){
        cout << (i == 1 ? "" : " ") << uf.size(i) - cnt[i] - 1;
    }
    cout << '\n';

    return 0;
}


Measured memory_bytes: 14976
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
vector<ll> kinds(100000,-1);
vector<ll> vec[100000];
void dfs(ll k,ll num){
  if(kinds[k] != -1){
    return;
  }
  kinds[k] = num;
  for(auto itr:vec[k]){
    dfs(itr,num);
  }
}
int main(){
  ll n,m;
  cin >> n >> m;
  rep(i,m){
    cin >> t1 >> t2;
    vec[t1].push_back(t2);
    vec[t2].push_back(t1);
  }
  rep(i,n){
    dfs(i,i);
  }
  ll q;
  cin >> q;
  rep(i,q){
    cin >> t1 >> t2;
    if(kinds[t1] == kinds[t2]){
      cout << "yes" << endl;
    }else{
      cout << "no" << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 12048
#include <vector>
#include <iostream>
#include <cmath>

using namespace std;

vector<pair<long long, long long> > prime_fac(long long N){
    vector<pair<long long, long long> > res;
    for(long long i=2; i*i<=N; ++i){
        if(N%i != 0)continue;

        long long ex = 0;
        while(N%i ==0){
            ex++;
            N /= i;
        }

        res.push_back({i, ex});
    }

    if(N != 1){
        res.push_back({N, 1});
    }

    return res;
} 

int main(){

    long long N, P;
    cin >> N >> P;

    const auto& res = prime_fac(P);
    long long ans = 1;

    for(int i=0; i<res.size(); ++i){
        if(res[i].second >= N){
            long long tmp1 = (res[i].first);
            long long tmp2 = (res[i].second)/N;
            ans *= pow(tmp1, tmp2); 
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}

//座圧(破壊的)
int cocomp(ll*a,int n){
	//0～cnt-1に圧縮
	ll*b=(ll*)malloc(sizeof(ll)*n);
	memcpy(b,a,sizeof(ll)*n);
	sortup(b,n);
	int cnt=1;
	rep(r,1,n)if(b[r]!=b[cnt-1])b[cnt++]=b[r];
	rep(i,0,n){
		int l=0,r=cnt;
		while(r-l>1){int m=(l+r)/2;if(b[m]>a[i])r=m;else l=m;}
		a[i]=l;
	}
	free(b);
	return cnt;
}

ll a[1010],b[1010];
ll sum[1010],mm[1010],len[1010],cnt;

int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",a+i);
		b[i]=a[i];
	}
	cocomp(b,n);
	
	for(int i=0;i<n;i++)if(b[i]!=-1){
		int tsum=0;
		int tlen=0;
		int tmm=1e9;
		int crr=i;
		do{
			tsum+=a[crr];
			tmm=min(tmm,a[crr]);
			tlen++;
			int temp=b[crr];
			b[crr]=-1;
			crr=temp;
		}while(crr!=i);
		sum[cnt]=tsum;
		mm[cnt]=tmm;
		len[cnt]=tlen;
		cnt++;
	}
	
	int ans=1e9;
	rep(i,0,cnt){
		//mm[i]を使う
		int tans=0;
		rep(j,0,cnt)tans+=min((sum[j]-mm[j])+(len[j]-1)*mm[j],(sum[j]-mm[j])+(len[j]-1)*mm[i]+(mm[i]+mm[j])*2);
		ans=min(ans,tans);
	}	
	
	printf("%d\n",ans);
}


Measured memory_bytes: 2108
#include<stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r){

  int x, i, j, t;
  x = A[r];
  i = p-1;

  for(j=p; j<r; j++){
    if(A[j] <= x){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }

  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;

  return i+1;
}

int main(){

  int i, q;

  scanf("%d",&n);

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

  q = partition(0,n-1);

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

  return 0;
}

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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

int main(){
    string s;
    cin >> s;
    if(s[2]==s[3]&&s[4]==s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
    vector<int>x(5);
    for (int i = 0; i < 5; i++) {
        cin >> x.at(i);
        if (x.at(i) == 0) {
            cout << i+1;
            break;
        }
    }
} 

Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b ||a==c ||b==c){
		if(a==b && a==c){
			cout<<"No"<<endl;
			return 0;
		}
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

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

int main() {
	int x;
	cin >> x;
	ll ans = 0;
	ans += x / 500 * 1000;
	ans += x%500 / 5 * 5;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define mod 1000000007
int main() {
  fio;
  int l, r, d, ans = 0;
  cin >> l >> r >> d;
  for (int i = l; i <= r; i++) {
    if (i % d == 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using ll = long long;
using PII = std::pair<int, int>;
using PLL = std::pair<ll, ll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define allpt(v) (v).begin(), (v).end()


const int mod = 1e9 + 7;
const string wsp = " ";
const string tb = "\t";
const string rt = "\n";

void showvec(vector<int> v)
{
    rep(i, v.size() - 1)
    {
        cout << v[i] << wsp;
    }
    cout << v[v.size() - 1] << rt;
}

class Unionfind
{
    vector<int> p;
    vector<int> q;

public:
    int find(int x);
    void unite(int x, int y);
    Unionfind(int n);
    vector<int> outputfriends();
};

Unionfind::Unionfind(int n)
{
    for (int i = 0; i < n; i++)
    {
        p.push_back(i);
    }
    q.resize(n);
    fill(q.begin(), q.end(), 1);
}
int Unionfind::find(int x)
{
    while (p[x] != x)
    {
        p[x] = p[p[x]];
        x = p[x];
    }
    return x;
}

void Unionfind::unite(int x, int y)
{
    x = Unionfind::find(x);
    y = Unionfind::find(y);
    if (x != y)
    {
        p[x] = y;
        q[x] += q[y];
        q[y] = q[x];
    }
}

vector<int> Unionfind::outputfriends()
{
    rep(i, q.size())
    {
        int j = Unionfind::find(i);
        q[i] = q[j];
    }
    rep(i, q.size()) q[i]--;
    return q;
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int n, m, k, a, b, c, d;
	cin >> n;
  	cout << (n + 1) / 2 << rt;

    return 0;
}


Measured memory_bytes: 256
/*
 * atcoder/abc089/b.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  string s, t;
  cin >> s >> t;
  s += s;
  int n = t.size();
  loop(i,0,n) {
    if (s.substr(i, n) == t) {
      cout << "Yes" << endl;
      return;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3620
char buf[2020000];
sz;
N;
long A[1<<17];
long X;
main()
{
	read(0,buf,2020000);
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		N=N*10+k-'0';
	}
	for(int i=0;i<N;i++)
	{
		for(;;)
		{
			char k=buf[sz++];
			if(k<'0')break;
			A[i]=A[i]*10+k-'0';
		}
		X^=A[i];
	}
	X=~X;
	for(int i=0;i<N;i++)A[i]&=X;
	int id=0;
	for(int i=60;i--;)
	{
		int t=id;
		while(t<N&&!(A[t]>>i&1))t++;
		if(t==N)continue;
		if(t>id)A[id]^=A[t];
		for(int j=0;j<N;j++)if(j!=id&&A[j]>>i&1)A[j]^=A[id];
		id++;
	}
	long ans=0;
	for(int i=0;i<N;i++)ans^=A[i];
	printf("%ld\n",ans*2+~X);
}

Measured memory_bytes: 2816
N, M = map(int, input().split())
item_list = list(map(int, input().split()))

hyousu = sum(item_list)
threshold = hyousu * (1 / (4 * M))

item_list.sort(reverse=True)
if item_list[M-1] < threshold:
  print('No')
else:
  print('Yes')



Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define emp emplace

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

const int N = 110, V = 100010;
int w[N], v[N];
int pd[V];

int main()
{	
	int n, mw;
	scanf("%d %d", &n, &mw);
	for (int i = 0; i < n; i++)
		scanf("%d %d", w+i, v+i);
	memset(pd, 0x3f, sizeof(pd));
	pd[0] = 0;
	for (int i = 0; i < n; i++)
	{	
		for (int val = V-1-v[i]; val >= 0; val--)
			pd[val + v[i]] = min(pd[val + v[i]], pd[val] + w[i]);
	}
	for (int i = V-1; i >= 0; i--)
	{
		if (pd[i] <= mw)
		{
			printf("%d\n", i);
			return 0;
		}
	}
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int A,B;
int main()
{
	int n,ans = 0;
	cin>>n;
	while(n % 10 == 0)
	{
		n/=10;
	}
	
	if(n == 1)
	{
		cout<<10;
		return 0;
	}
	
	while(n > 0)
	{
		ans += n % 10;
		n /= 10;
	}
	cout<<ans<<'\n';
}

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

using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	bool flag=false;
	for(int i=0;i<n;i++){
		int a;
		scanf("%d",&a);
		if((a&1)==0){
			if(a%5!=0&&a%3!=0){
				flag=true;
			}
		}
	}
	if(flag){
		puts("DENIED");
	}else{
		puts("APPROVED");
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rw freopen("input.txt","r",stdin),freopen("output.txt","w",stdout);
#define pb push_back
#define F first
#define S second
#define pf push_front
#define lp(i,a,b) for (int i=a;i<=(int)b;++i)
#define lp2(i,a,b) for (int i=a;i>=b;--i)
#define f(x) return cout<<x<<"\n",0
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000007
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define p(x) cout<<#x<<" = { "<<x<<" } \n"
#define FAST ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N=(int)1e5+5;

int main()
{
#ifdef ONLINE_JUDGE
    FAST;
#endif
    int n,t;
    cin>>n>>t;
    if (t*2-1<=n)
        cout<<"YES\n";
    else
        cout<<"NO\n";
    return 0;
}


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

const int N=505;
int A[N][N], D[31][31];
int dp[3][31];
int main() {
	int n,c;
	cin >> n >> c;
	for (int i=0; i<c; i++) {
		for (int j=0; j<c; j++) {
			cin >> D[i][j];
		}
	}
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			cin >> A[i][j];
			A[i][j]--;
		}
	}

	for (int i=0; i<c; i++) {
		for (int x=0; x<n; x++) {
			for (int y=0; y<n; y++) {
				int t=(x+y)%3;
				dp[t][i]+=D[A[x][y]][i];
			}
		}
	}
	int ans=1e9;
	for (int i=0; i<c; i++) {
		for (int j=0; j<c; j++) {
			if ( i==j ) continue;
			for (int k=0; k<c; k++) {
				if ( i==k || j==k ) continue;
				int res=dp[0][i]+dp[1][j]+dp[2][k];
				ans=min(res,ans);
			}
		}
	}
	cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 1e5+5;
int a[N];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n);
	long long ans=1;
	int cnt=0;
	for(int i=n;i>=1;)
	{
		if(a[i]==a[i-1])
		{
			ans*=a[i];
			i-=2;
			cnt++;
		}
		else i--;
		if(cnt>=2) break;
	}
	if(cnt>=2)
	cout<<ans<<endl;
	else cout<<'0'<<endl;
} 

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define foreach(c,itr) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define INF 1e9;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
int main(){
	int a,b,n;
	cin>>a>>b>>n;
	cout<<min(a*b,n);
	return 0;
}

Measured memory_bytes: 256
def getN():
    return int(input())


def getNM():
    return map(int, input().split())


def getList():
    return list(map(int, input().split()))

n,k = getNM()
nums = []
for i in range(n):
    a,b = getNM()
    nums.append((a,b))

nums.sort(key=lambda x:x[0])

for n in nums:
    a,b = n
    k-=b
    if k <= 0:
        print(a)
        break


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> c(n + 1, false), d(n + 1, false);

  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    if (x == 1) c[y] = true;
    if (y == n) d[x] = true;
  }
    for (int i = 0; i <= n; i++) {
      if (c[i] && d[i]) {
        cout << "POSSIBLE" << endl;
        return 0;
      }
    }
    cout << "IMPOSSIBLE" << endl;
  }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>

#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;

using namespace std;

void solve(){
    string s;
    ll k;
    cin >> s >> k;
    for(int i = 0; i < min((ll)s.size(), k); i++){
        if(s[i] >= '2'){
            cout << s[i];
            return;
        }
    }
    cout << 1;
}

int main(){
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
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, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int pass = 0;
    int foreign = 0;
    rep(i, s.length()) {
        if ( s[i] == 'a' ) {
            if ( pass < a + b ) {
                cout << "Yes" << endl;
                ++pass;
            }
            else {
                cout << "No" << endl;
            }

        }
        else if ( s[i] == 'b' ) {
            if ( pass < a + b && foreign < b ) {
                cout << "Yes" << endl;
                ++pass;
            }
            else {
                cout << "No" << endl;
            }
            ++foreign;
        }
        else {
            cout << "No" << endl;
        }
    }
    return 0;
}


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

#define ll long long
#define ull unsigned long long
#define f(a, b) for (ll i = a; i < b; i++)
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pl pair<ll, ll>
#define vll vector<ll>
#define pll vector<pair<ll, ll>>
#define ld long double
#define fr(a, b) for (ll j = a; j >= b; j--)
#define fi(a, b) for (ll j = a; j < b; j++)
#define fii(a, b) for (ll k = a; k < b; k++)
#define print(x) cerr << #x << " is " << x << endl;
//      typedef tree<ll ,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main()
{
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "rt", stdin);
//     freopen("output.txt", "wt", stdout);
// #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin >> n;
    ll a[n + 1];
    ll ans[n + 1];
    memset(ans, 0, sizeof(ans));
    f(1, n + 1) cin >> a[i];
    ll m = 0;
    fr(n, 1)
    {
        ll x = 0;
        for (int i = j; i <= n; i += j)
            if (ans[i] == 1)
                x ^= 1;
        if (a[j] == x)
            continue;
        ans[j] = 1;
        m++;
    }
    cout << m << "\n";
    f(1, n + 1) if (ans[i] == 1) cout << i << " ";

    return 0;
}

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

using ll = long long int;

const ll MAX = (ll)(1e9 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

/////////////////////////////////////////////////////////////
class BinaryIndexedTree {
public:
  static const int MAX_N_LIB = (int)(2e5 + 100);

  ll bit_bit[MAX_N_LIB];
  int bit_n;

  BinaryIndexedTree(int n) {
    bit_n = n;
    init();
  }

  void init() {
    for (int i = 0; i < bit_n; ++i) bit_bit[i] = 0LL;
  }

  ll sum(int i) {
    ll s = 0LL;
    while (i > 0) {
      s += bit_bit[i];
      i -= i & -i;
    }
    return s;
  }

  void add(int i, ll x) {
    while (i <= bit_n) {
      bit_bit[i] += x;
      i += i & -i;
    }
  }
};
/////////////////////////////////////////////////////////////

int n;
ll a[MAX_N];
ll b[MAX_N];

int s[MAX_N];

BinaryIndexedTree bit(MAX_N * 2);

bool check(ll x) {
  ll num = 0;

  for (int i = 1; i <= n; ++i) s[i] = (a[i] >= x) ? 1 : -1;
  // for (int i = 1; i <= n; ++i) num += (s[i] == 1) ? 1 : 0; // for singleton
  for (int i = 1; i <= n; ++i) s[i] += s[i - 1];

  bit.init();

  for (int i = 0; i <= n; ++i) {
    num += bit.sum(s[i] + MAX_N);
    bit.add(s[i] + MAX_N, 1);
  }

  // printf("s: ");
  // for (int i = 1; i <= n; ++i) {
  //   printf("%d ", s[i]);
  // }
  // printf("\n");

  ll whole = (1LL * (n + 1) * n) / 2;
  ll target =  (whole - 1) / 2 + 1;

  // printf("%lld: %lld\n", x, num);

  return (num >= target);
}

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &(a[i]));
    b[i] = a[i];
  }

  sort(b + 1, b + n + 1);

  b[n + 1] = b[n] + 1; // guard

  int ok = 1;
  int ng = n + 1;

  // ll ok = 1;
  // ll ng = MAX;

  while (abs(ok - ng) > 1) {
    int next = (ok + ng) / 2;
    // ll next = (ok + ng) / 2;

    if (check(b[next])) {
    // if (check(next)) {

      ok = next;
    }
    else {
      ng = next;
    }
  }

  printf("%lld\n", b[ok]);
  // printf("%lld\n", ok);

  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)(x).size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
typedef long long ll;

int MOD;

int n;
vector<int> g[100005];
ll f[100005],r[100005],z[100005];

void dfs1(int x, int p){
	for(int y:g[x])if(y!=p)dfs1(y,x);
	f[x]=1;
	for(int y:g[x])if(y!=p)f[x]=f[x]*f[y]%MOD;
	f[x]++;
}

ll p[100005];

void dfs2(int x, int pp){
	r[x]=(f[x]+MOD-1)*z[x]%MOD;
	int k=0;
	p[0]=1;
	for(int y:g[x])if(y!=pp){
		p[k+1]=p[k]*f[y]%MOD;
		k++;
	}
	ll w=1;
	for(int i=SZ(g[x])-1;i>=0;--i)if(g[x][i]!=pp){
		int y=g[x][i];
		z[y]=(w*p[--k]%MOD*z[x]+1)%MOD;
		w=w*f[y]%MOD;
	}
	for(int y:g[x])if(y!=pp)dfs2(y,x);
}

int main(){
	scanf("%d%d",&n,&MOD);
	fore(_,1,n){
		int x,y;
		scanf("%d%d",&x,&y);x--;y--;
		g[x].pb(y);g[y].pb(x);
	}
	dfs1(0,-1);z[0]=1;dfs2(0,-1);
	fore(i,0,n)printf("%lld\n",r[i]);
	return 0;
}

Measured memory_bytes: 14592
#include<stdio.h>
#define n_max 1000000
typedef struct{
  char name[10];
  int e_time;
}pro;
void enqueue(pro);
pro dequeue();
void exe();
int dif(pro);
int b_time;
int sum=0;
int head=0;
int tail=0;
pro pro1[n_max];
int main(){
  int i;
  int n;
  scanf("%d%d",&n,&b_time);
  tail=n;
  for(i=0;i<n;i++){
    scanf("%s%d",pro1[i].name,&pro1[i].e_time);
  }
  exe(pro1);
  return 0;
}
void enqueue(pro p){
pro1[tail]=p;
if(tail==n_max-1)tail=0;
else tail++;
}
pro dequeue(){
pro p;
p=pro1[head];
  if(head==n_max-1)head=0;
  else head++;
  return p;
}
void exe(){
  int d_f;
  pro p2;
  while(head!=tail){
    p2=dequeue();
    d_f=dif(p2);
    sum+=d_f;
    p2.e_time-=d_f;
    if(p2.e_time>0)enqueue(p2);
    else printf("%s %d\n",p2.name,sum);
  }
}
int dif(pro p){
  return p.e_time>b_time?b_time:p.e_time;
}



Measured memory_bytes: 4636
#!/usr/bin/env ruby
 
s = gets.chomp
k = gets.chomp.to_i
 
a = s.split(//).map(&:to_i)

count = 0
while ((n = a.shift) == 1)
  count += 1
end

if count >= k
  result = 1
else
  result = n
end
puts result


Measured memory_bytes: 1788
#include <stdio.h>
#define MAX 1000
int main()
{
        char input[MAX];
        int output = 0;
        int count = 0;

        while ( 1 )
        {
                scanf("%s", input);
                if ( input[0] == '0' )
                {
                        return 0;
                }

                while  ( input[count] != '\0' )
                {
                        output = output + input[count] - 48;
                        count = count + 1;
                }

                printf("%d\n", output);
                output = 0;
                count = 0;
        }
        return 0;
}

Measured memory_bytes: 536
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
int a,b,x;
double sp;
int main() {
	scanf("%d %d %d",&a,&b,&x);
	sp=a*a*b/2.0;
	if(x<=sp) {
		double h=2.0*x/a/b;
		printf("%.10lf\n",90-atan(h/b)/acos(-1)*180);
	}
	else {
		double v=a*a*b-x;
		double h=2*v/a/a;
		printf("%.10lf\n",atan(h/a)/acos(-1)*180);
	}
	return 0;
}

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

int main() {
    int n, m; cin >> n >> m;
    string s; cin >> s;
    vector<int> sh(n, -1);
    for (int i = 0; i < m; ++i) {
        int l, r; cin >> l >> r;
        l--, r--;
        sh[l] = max(sh[l], r);
    }
    for (int i = 0; i < n; ++i) {
        if (sh[i] == -1) continue;
        for (int j = i + 1; j < n; ++j) {
            if (sh[j] <= sh[i]) sh[j] = -1;
        }
    }
    for (int i = 0; i < n; ++i) {
        if (sh[i] == -1) continue;
        for (int j = i + 1; j <= sh[i]; ++j) {
            if (sh[j] != -1) break;
            sh[j] = sh[i];
        }
    }
    vector<int> pref(n);
    for (int i = 0; i < n; ++i) {
        pref[i] = (s[i] == '0');
        if (i > 0) pref[i] += pref[i - 1];
    }
    constexpr int kMod = 1'000'000'000 + 7;
    vector<int> dp(n + 1, 0);
    dp[0] = 1;
    for (int i = 0; i < n; ++i) {
        if (sh[i] == -1) {
            if (s[i] == '0') {
                for (int j = n; j > 0; --j) dp[j] = dp[j - 1];
                dp[0] = 0;
            }
        } else {
            vector<int> nxt(n + 1, 0);
            for (int j = 0; j <= n; ++j) {
                if (dp[j] == 0) continue;
                int cnt = pref[sh[i]] - j;
                assert(cnt >= 0);
                if (cnt > 0) (nxt[j + 1] += dp[j]) %= kMod;
                if (sh[i] - i + 1 - cnt > 0) (nxt[j] += dp[j]) %= kMod;
            }
            dp = nxt;
        }
    }
    cout << dp[pref[n - 1]] << "\n";
}


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

using namespace std;

int gcd(int i, int j) {

	//ユークリッドの互除法で最大公約数を求める
	//2変数の場合

	if (i < j) { swap(i, j); }

	while (i%j != 0) {
		int r;
		r = i % j;
		if (r == 0) { return j; }
		else { i = j; j = r; }
	}
	return j;
}

int main() {

	int a,b;
	cin >> a >> b;
	cout << gcd(a, b) << endl;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

int main(){
    int n, k;
    cin >> n >> k;

    vector<int> p;

    rep(i,n){
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
    }

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

    int ans = 0;

    rep(i,k) ans += p[i];

    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 3600
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let x: u32 = s.trim().parse().ok().unwrap();

    let y: u32 = x / 100;
    let z: u32 = ((x % 100) + 4) / 5;
    println!("{}", if y >= z { 1 } else { 0 });
}

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

using namespace std;

int main(){
  //load datas
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  
  //parse to vector
  vector<int> addresses{a, b, c, d, e};
  
  //view contents
  size_t s = addresses.size();
  for(int i = 0; i < s; i++){
    for(int j = i + 1; j < s; j++){
      if(addresses.at(j) - addresses.at(i) > k){
        cout << ":(";
        return 0;
      }
    }
  }
  
  cout << "Yay!";
  
  return 0;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define fi first
#define se second

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 2e+5+5;
const int mo = 1e+9+7;

int cnt[N];
LL inv[N],js[N],miv[N];
int n;
int a[N];
int fa[N];
struct edge{
	int x,nxt;
}e[N*2];
int h[N],tot,key[N],k;
bool bz[N];
int pt[N],u;
int siz[N];
int pre[N],suf[N];

bool dfs(int x){
	bz[x]=1;
	siz[x]=1;
	int s=0;
	for(int p=h[x];p;p=e[p].nxt)
	if (!bz[e[p].x]){
		s++;
		if (dfs(e[p].x))return 1;
		siz[x]+=siz[e[p].x];
	}
	return s>1;
}

LL quickmi(LL x,LL tim){LL ans=1;for(;tim;tim/=2,x=x*x%mo)if (tim&1)ans=ans*x%mo;return ans;}

int getfather(int x){return fa[x]==x?x:fa[x]=getfather(fa[x]);}

void inse(int x,int y){
	e[++tot].x=y;
	e[tot].nxt=h[x];
	h[x]=tot;
}

int main(){
	n=get();
	inv[0]=js[0]=inv[1]=js[1]=miv[0]=1;
	miv[1]=(mo+1)/2;
	fo(i,2,n){
		inv[i]=1ll*(mo-mo/i)*inv[mo%i]%mo;
		js[i]=js[i-1]*i%mo;
		miv[i]=miv[i-1]*miv[1]%mo;
	}
	fo(i,2,n)inv[i]=inv[i]*inv[i-1]%mo;
	fo(i,1,n)fa[i]=i;
	fo(i,1,n){
		int x=a[i]=get();
		inse(x,i);
		int tx=getfather(x),ti=getfather(i);
		if (tx!=ti)fa[ti]=tx;
		else key[++k]=i;
	}
	int ans=1;
	fo(i,1,k){
		int x=key[i];
		bz[pt[u=1]=x]=1;
		for(x=a[x];x!=key[i];x=a[x])bz[pt[++u]=x]=1;
		fo(j,1,u)if (dfs(pt[j])){ans=0;break;}if (!ans)break;
		int ps=0;
		fd(j,u,1){ps=max(0,ps-1);if (siz[pt[j]]>1){if (ps){ans=0;break;}ps=siz[pt[j]]-1;}}if (!ans)break;
		fd(j,u,1){ps=max(0,ps-1);if (siz[pt[j]]>1){if (ps){ans=0;break;}ps=siz[pt[j]]-1;}}if (!ans)break;
		int mx=0;
		fo(j,1,u)mx=max(mx,siz[pt[j]]);
		if (mx==1)cnt[u]++;
		fo(j,1,u)pre[j]=pre[j-1]+siz[pt[j]]-1;
		fo(j,1,u)pre[j+u]=pre[j+u-1]+siz[pt[j]]-1;
		fo(j,1,u)
		if (siz[pt[j]]>1){
			if (pre[j+u-1]==pre[j+u-siz[pt[j]]])ans=ans*2%mo;
		}
	}
	if (!ans)return printf("0\n"),0;
	fo(i,1,n)
	if (cnt[i]){
		LL now=1,tmp=0;
		fo(j,0,cnt[i]/2){
			if (i%2==1&&i>1)tmp=(tmp+js[cnt[i]]*inv[j]%mo*inv[cnt[i]-j*2]%mo*miv[j]%mo*now%mo*quickmi(2,cnt[i]-j*2)%mo)%mo;
			else tmp=(tmp+js[cnt[i]]*inv[j]%mo*inv[cnt[i]-j*2]%mo*miv[j]%mo*now%mo)%mo;
			now=now*i%mo;
		}
		ans=tmp*ans%mo;
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

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

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int n, h[125252];
	cin>>n;
	REP(i, n){
		cin>>h[i];
	}
	bool ok=true;
	int cnt=0;
	FORR(i, 0, n-1){
		if(h[i]-1>h[i+1]){
			ok=false;
			break;
		}
		else if(h[i]>h[i+1]){
			--h[i];
		}
	}
	cout<<(ok ? "Yes" : "No")<<'\n';
	return 0;
}


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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

ll pow2(ll a, ll b) {
    ll res = a;
    for (ll i = 1; i < b; i++) {
        res *= a;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    vector<int> numbers(n);
    rep(i, n) cin >> numbers[i];
    rep(i, n) numbers[i] -= (i + 1);
    sort(numbers.begin(), numbers.end());
    int k = numbers[n / 2];
    ll ans = 0;
    for (int i : numbers) ans += abs(i - k);
    cout << ans << endl;
}


Measured memory_bytes: 1152
#include<stdio.h>
int main()
{
   char a, b;
   
   scanf("%c %c", &a, &b);
   
   if (a == 'H' || a == 'D' && b == 'H' || b == 'D'  )
   {
   	
   	if (a == 'H' && b == 'H' || a == 'D' && b == 'D' )
   	{
   		printf("H");
   	}
   	else if (a == 'D' && b == 'H' || a == 'H' && b == 'D') 
   	{
   		printf("D");
   	}
   	
   }
   else
   return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdlib.h>
using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if (a - (b + c) <= 0){
    cout << abs(a - (b + c)) << endl;
  }else{
    cout << 0 << endl;
  }
}

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

int main(){
	int n, b, f, r, v;
	int oh[4][3][10] = { 0 };
	
	
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> b >> f >> r >> v;
		b--; f--; r--;
		oh[b][f][r] += v;
	}
	
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++){
				cout << ' ' << oh[i][j][k];
			}
			cout << endl;
		}
		if(i != 3) cout << "####################" << endl;
	}
	
	return 0;
}
	

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

int main(){
  int N;
  cin >> N;
  map<long long,int> M;
  for(int i = 0; i < N; ++i){
    long long l;
    cin >> l;
    ++M[-l];
  }
  long long ans = 0, l = 0;
  for(auto itr = M.begin(); itr != M.end(); ++itr){
    if(itr->second >= 2 && l == 0){
      l = itr->first;
      itr->second -= 2;
    }
    if(itr->second >= 2){
      l *= itr->first;
      itr->second -= 2;
      ans = l;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6528
import time
s = time.time()
import numpy as np

D = int(input())
c = np.array(list(map(int, input().split())))
S = np.array([list(map(int, input().split())) for i in range(D)])

last_day = np.zeros(26, dtype=int)

ans = []
for d in range(1, D+1):
    decrease = c * (d - last_day)
    sd = decrease.sum()
    diff = [S[d-1, i] - sd + decrease[i] for i in range(26)]
    choice = np.argmax(diff)
    ans.append(choice+1)
    last_day[choice] = d

def calc_pre(ans, pre_t, t, d):
    flag1 = flag2 = True
    res = [-1, -1]
    for day in range(d-1, -1, -1):
        td = ans[day]
        if td == pre_t and flag1:
            res[0] = day
            flag1 = False
        if td == t and flag2:
            res[1] = day
            flag2 = False
        if not (flag1 or flag2):
            return res
    return res

def calc_next(ans, pre_t, t, d):
    flag1 = flag2 = True
    res = [D, D]
    for day in range(d+1, D):
        td = ans[day]
        if td == pre_t and flag1:
            res[0] = day
            flag1 = False
        if td == t and flag2:
            res[1] = day
            flag2 = False
        if not (flag1 or flag2):
            return res
    return res

while time.time() - s < 1.9:
    d = np.random.randint(0, D, 1)[0]
    t = np.random.randint(0, 26, 1)[0]
    pre_t = ans[d] - 1
    if pre_t == t:
        continue
    dm1, dm2 = calc_pre(ans, pre_t, t, d)
    dp1, dp2 = calc_next(ans, pre_t, t, d)
    diff = S[d, t] - S[d, pre_t] + c[pre_t]*(dm1-d)*(dp1-d) - c[t]*(dm2-d)*(dp2-d)
    if diff > 0:
        ans[d] = t + 1

print(*ans, sep='\n')

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

int main() {
	int n;
	while (cin >> n, n) {
		int te[10] = {};
		int ba = 0;

		string y;
		cin >> y;

		for (int i = 0;i < 100;i++) {
			if (y[i] == 'M') {
				te[i%n]++;
			}
			else if (y[i] == 'S') {
				te[i%n]++;
				ba += te[i%n];
				te[i%n] = 0;
			}
			else {
				te[i%n]++;
				te[i%n] += ba;
				ba = 0;
			}
		}
		sort(te, te + n);
		for (int i = 0;i < n;i++)cout << te[i] << ' ';
		cout << ba << endl;
	}
	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
typedef vector<string> vs;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#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)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
ll dp[200200],p[2][200200],mod[2],sum[2];
int main(){
    ll n;
    string s;cin>>n>>s;
    dp[0]=0;
    for(int i=1;i<200200;i++){
        dp[i]=dp[i%__builtin_popcount(i)]+1;
    }
    int cnt=0;
    rep(i,n)cnt+=(s[i]=='1');
    mod[0]=cnt+1;
    mod[1]=cnt-1;
    rep(i,2){
        if(mod[i]==0){
            continue;
        }
        p[i][0]=1;
        for(int j=1;j<200100;j++){
            p[i][j]=2ll*p[i][j-1]%mod[i];
        }
        for(int j=0;j<n;j++){
            if(s[j]=='1'){
                sum[i]+=p[i][n-1-j];
                sum[i]%=mod[i];
            }
        }
    }
    rep(i,n){
        int ans=0;
        if(s[i]=='0'){
            ans=1+dp[(sum[0]+p[0][n-1-i])%mod[0]];
        }else if(mod[1]){
            ans=1+dp[(sum[1]+mod[1]-p[1][n-1-i])%mod[1]];
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
#define ll long long  int
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)


using namespace std;
int main() 
{
    int n,m;
    cin>>n>>m;
    string arr[n+1];
    int i;
    for(i=0;i<n;i++)
    	cin>>arr[i];
    int dp[n+2][m+2];
    int j;
    for(i=0;i<=n;i++)
    {
    	for(j=0;j<=m;j++)
    		dp[i][j]=0;
    }

    for(i=0;i<m;i++)
    {
    	if(arr[0][i]=='.')
    		dp[0][i]=1;
    	else
    		break;

    }

     for(i=0;i<n;i++)
    {
    	if(arr[i][0]=='.')
    		dp[i][0]=1;
    	else
    	break;
    }
 
    for(i=1;i<n;i++)
    {
    	for(j=1;j<m;j++)
    	{
    		if(arr[i][j]=='.')
    			dp[i][j]=(dp[i][j-1]%mod+dp[i-1][j]%mod)%mod;
    		else
    			dp[i][j]=0;
    	}
    }
   
    cout<<dp[n-1][m-1];
    return 0;
}

Measured memory_bytes: 9384
from itertools import combinations as cmbs
import sys
c = {"M":0,"A":0,"R":0,"C":0,"H":0}
sys.stdin.readline()
for si in sys.stdin:
    if si[0] in c:
        c[si[0]] += 1
ans = sum(i*j*k for i,j,k in cmbs(c.values(),r=3))
print(ans)


Measured memory_bytes: 8988
import sys

a = []
for l in sys.stdin:
    a.append(l)

sent = a[1]
num = int(a[0].split()[1]) - 1
new_sent = [each_char for each_char in sent]
new_sent[num] = new_sent[num].lower()
new_sent = ''.join(new_sent)
print(new_sent)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("QWERTYASDFZXCV");
            //5
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("ZABCZ");
            //4
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("HASFJGHOGAKZZFEGA");
            //12
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string s = InputList[0];

        var Matches = Regex.Matches(s, "A.*Z");
        Console.WriteLine(Matches.Cast<Match>().Max(X => X.Length));
    }
}


Measured memory_bytes: 6152
#include<stdio.h>
int main()
{
    long long int N,K;
    scanf("%lld%lld",&N,&K);

    long long int a,b,sum=0;

    for(long long int i=K; i<=N+1; i++)
    {
        sum=sum+i*(N-i+1)+1;
    }
    b=sum%(1000000007);
    printf("%lld",b);
}

Measured memory_bytes: 1732
/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o A.exe A.cpp 
Execute: ./A
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int gcd_euclid(int a, int b) {
  if(b == 0) {
    return a;
  }
  return gcd_euclid(b, a % b);
}

int main() { 	
	int x;
	cin >> x;
	
	cout << 360 / gcd_euclid(x, 360) << endl; 
	
	return 0; 
} 


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define m 1000000007
using namespace std;

long long dp[1001][1001];

long long f(char**a, int i, int j, int h, int w)
{
    if(i==(h-1)&&j==(w-1))
    {
        return 1;
    }
    if(i>=h||j>=w)
    {
        return -1;
    }
    if(a[i][j]=='#')
    {
        return -1;
    }
    if(dp[i][j]!=-1)
    {
        return dp[i][j];
    }
    long long k1=f(a, i+1, j, h, w)%m;
    if(k1<0)k1=0;
    long long k2=f(a, i, j+1, h, w)%m;
    if(k2<0)k2=0;
    dp[i][j]=((k1%m)+(k2%m))%m;
    return dp[i][j];
}
int main()
{
    int h, w;
    cin>>h>>w;
    memset(dp, -1, sizeof(dp));
    char**a=new char*[h];
    for(int i=0;i<h;i++)
    {
        a[i]=new char[w];
        for(int j=0;j<w;j++)
        {
            cin>>a[i][j];
        }
    }
    cout<<f(a, 0, 0, h, w)<<endl;
return 0;
}



Measured memory_bytes: 9216