akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<algorithm>
#define maxn 100005
int vis[maxn];
#define ll long long
const ll mod=1e9+7;
using namespace std;
int n;
int a[maxn];
ll quickpow(ll a,ll b)
{ll ans=1;
    while(b)
    {
        if(b&1)
            ans=ans*a%mod;
            b>>=1;
            a=a*a%mod;
    }
    return ans%mod;
}
int main()
{memset(vis,0,sizeof(vis));
    scanf("%d",&n);
    int flag=0;
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
        for(int i=1;i<=n;i++)
    vis[a[i]]++;
    if(n%2==0)
    {


        for(int i=1;i<=n;i++)
        if(a[i]==0)
        {
            flag=1;
            break;
        }
    for(int i=1;i<=n;i++)
        if(vis[a[i]]!=2)
        {flag=1;
            break;
    }
    }
    else
    {
        for(int i=1;i<=n;i++)
            if(a[i]==0&&vis[a[i]]!=1)
        {
            flag=1;
            break;
        }
        for(int i=1;i<=n;i++)
            if(a[i]!=0&&vis[a[i]]!=2)
        {
            flag=1;
            break;
        }
    }
    if(flag)
        printf("0\n");
    else
        printf("%lld\n",quickpow(2,n/2));
        return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
// #define multicase
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 1e2 + 5;

int n, l;
string s[N];

void solve() {
    int T = 1;
  #ifdef multicase
    cin >> T;
  #endif
    for(int tc = 1; tc <= T; tc++) {
        cin >> n >> l;
        for(int i = 1; i <= n; i++) {
            cin >> s[i];
        }
        sort(s + 1, s + n + 1);
        for(int i = 1; i <= n; i++) cout << s[i];
        cout << "\n";
    }
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    solve();
    
}

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

using namespace std;
int input(){
    int res = 0; char c = ' ';
    while (c < '0') c = getchar();
    while (c >= '0') res = res * 10 + (c - '0'), c = getchar();
    return res;
}
const int N = 301;

int a[N][N], c[N];
char d[N];
int main(){
    int n = input(), m = input(), ans = 1e9;
    for (int i = 0; i < n; ++ i)
        for (int j = 0; j < m; ++ j)
            a[i][j] = input() - 1;
    for (int i = 0; i < m; ++ i){
        for (int j = 0; j < n; ++ j)
            for (int k = 0; k < m; ++ k)
                if (!d[a[j][k]]){
                    ++ c[a[j][k]];
                    break;
                }
        int idx, mx = -1;
        for (int j = 0; j < m; c[j] = 0, ++ j)
            if (c[j] > mx)
                mx = c[idx = j];
        d[idx] = 1;
        ans = min(ans, mx);
    }
    cout << ans;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0; i < N; i++){
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  if(N%2 != 0) a.push_back(0);
  
  int count = 0;
  for(int i=0; i < N; i = i+2){
    count += a.at(i)-a.at(i+1);
  }
  cout << count << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scan = new Scanner(System.in);
        int cat = scan.nextInt();
        int catordog = scan.nextInt();
        int catcaunt = scan.nextInt();
        
        String ans;
        
        if(cat > catcaunt){
            ans = "NO";
        }else if(cat + catordog < catcaunt){
            ans = "NO";
        }else{
            ans = "YES";
        }
 
        System.out.println(ans);
        
    }
}

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

struct node{
  int key;
  node *right, *left, *parent;
};

node *root, *nil;

node *treeMinimum(node *x){
  while(x->left != nil) x = x->left;

  return x;
  
}

node *find(node *u, int k){
  while(u != nil && k != u->key){
    if(k < u->key) u = u->left;

    else u = u->right;
    
  }

  return u;
  
}

node *treeSuccessor(node *x){
  if(x -> right != nil) return treeMinimum(x->right);

  node *y = x->parent;

  while(y != nil && x == y->right){
    x = y;
    y = y->parent;
    
  }

  return y;
  
}

void treeDelete(node *z){
  node *y;
  node *x;

  if(z->left == nil || z->right == nil) y = z;

  else y = treeSuccessor(z);

  if(y->left != nil){
    x = y->left;
  }

  else{
    x = y->right;
  }

  if(x != nil){
    x->parent = y->parent;
  }

  if(y->parent == nil){
    root = x;
  }

  else{
    if(y == y->parent->left){
      y->parent->left = x;
    }

    else{
      y->parent->right = x;
    }
  }

  if(y != z){
    z->key = y->key;
  }

  free(y);
  
}

void insert(int k){
  node *y = nil;
  node *x = root;
  node *z;

  z = (node *)malloc(sizeof(node));
  z->key = k;
  z->left = nil;
  z->right = nil;

  while(x != nil){
    y = x;

    if(z->key < x->key) x = x->left;
    else x = x->right;

  }

    z->parent = y;

    if(y == nil) root = z;

    else{
      if(z->key < y->key) y->left = z;

      else y->right = z;

  }  
}

void inorder(node *a){
  if(a == nil) return;

  inorder(a->left);

  cout << " " << a->key;

  inorder(a->right);
}

void preorder(node *a){
  if(a == nil) return;

  cout << " " << a->key;
  
  preorder(a->left);
  preorder(a->right);
  
}

int main()
{
  int n, x;
  string s;

  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> s;

    if(s == "find"){
      cin >> x;
      node *t = find(root, x);

      if(t != nil) cout << "yes" << endl;
      else cout << "no" << endl;
      
    }

    else if(s == "insert"){
      cin >> x;
      insert(x);
     
    }

    else if(s == "print"){
      inorder(root);
      cout << endl;

      preorder(root);
      cout << endl;
    }

    else if(s == "delete"){
      cin >> x;
      treeDelete(find(root, x));
    }
  }

  return 0;
  
}



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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,cnt=0;
  long long ans=1;
  long long a[100009];
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a,a+n);
  reverse(a,a+n);
  for(int i=0;i<n;i++){
    if(a[i]==a[i+1]){
      ans*=a[i];
      i++;
      cnt++;
    }
    if(cnt==2)break;
  }
  if(cnt==2)cout<<ans<<endl;
  else cout<<0<<endl;
  return(0);
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    vector<int> ans(n);
    int l, cl, cr, r, p = 0;
    while (p < n) {
        l = p;
        while (s.at(p) == 'R') ++p;
        cl = p - 1, cr = p;
        while (s.at(p) == 'L') {
            ++p;
            if (p == n) break;
        }
        r = p - 1;
        ans.at(cl) += (cl - l) / 2 + 1 + (r - cr + 1) / 2;
        ans.at(cr) += (cl - l + 1) / 2 + (r - cr) / 2 + 1;
    }
    for (int i = 0; i < n; ++i) cout << ans.at(i) << (i == n - 1 ? '\n' : ' ');
    return 0;
}


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


int main() {
	
	string s;
	cin >> s;
	for(int i=0; i<s.size(); i++){
		if(i%2==1){
			if(s.at(i)=='R') {
				cout << "No" << endl;
				break;
			}
		}
		else {
			if(s.at(i)=='L') {
				cout << "No" << endl;
				break;
			}
		}
		if(i==s.size()-1) cout << "Yes" << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	// your code goes here
	int h;
	cin>>h;
	if(h==1)
	cout<<"1\n";
	else
	{
	    int c=0,x=1;
	    while(1)
	    {
	        if(x>h)
	        break;
	        else{
	            c+=x;
	        x=x<<1;
	        
	        }
	    }
	    cout<<c<<"\n";
	}
	return 0;
}


Measured memory_bytes: 256
s = input().split()
x = s[0]
y = s[1]

dic = {"A": 10, "B": 11, "C": 12, "D": 13, "E": 14, "F": 15}

if dic[x] < dic[y]:
    print("<")
elif dic[x] == dic[y]:
    print("=")
else:
    print(">")


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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    float n,m;
    cin>>n>>m;
    cout<<ceil(float(n/m))<<"\n";
}
// Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


Measured memory_bytes: 3776
# include <bits/stdc++.h>
using namespace std;
 
int main () {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (int i = 0; i < H; i++) {
  cin >> S.at(i);
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S.at(i).at(j) == '#') {
        cout << '#';
      }
      else {
        int ans;
        ans = 0;
        if (j-1 >= 0) {
          if (i-1 >=0) {
            if (S.at(i-1).at(j-1) =='#') {
              ans += 1;
            }
          }
          if (S.at(i).at(j-1) =='#') {
            ans +=1;
          }
          if (i+1 < H) {
            if (S.at(i+1).at(j-1) =='#') {
              ans +=1;
            }
          }
        }
        if (i-1 >=0) {
          if (S.at(i-1).at(j) =='#') {
            ans += 1;
          }
        }
        if (i+1 < H) {
          if (S.at(i+1).at(j) =='#') {
            ans +=1;
          }
        }
        if (j+1 < W) {
          if (i-1 >=0) {
            if (S.at(i-1).at(j+1) =='#') {
              ans += 1;
            }
          }
          if (S.at(i).at(j+1) =='#') {
            ans +=1;
          }
          if (i+1 < H) {
            if (S.at(i+1).at(j+1) =='#') {
              ans +=1;
            }
          }
        }
        cout << ans;
      }
    }
    cout <<endl;
  }
}

Measured memory_bytes: 256
str = STDIN.gets.chomp()
order_num = STDIN.gets.chomp().to_i

for i in 0..order_num - 1 do
    line = STDIN.gets.chomp()
    order = line.split(" ")
    case order[0]
    when "print"
        puts str[order[1].to_i..order[2].to_i]
    when "reverse"
        str[order[1].to_i..order[2].to_i] = str[order[1].to_i..order[2].to_i].reverse
    when "replace"
        str[order[1].to_i..order[2].to_i] = order[3]
    end
end

Measured memory_bytes: 6132
s =list(input())
t=list(input())
ans=[]
for i in range(len(s)-len(t)+1):
    check=0
    s_check=s[i:i+len(t)]
    for k in range(len(s_check)):
        if s_check[k]==t[k]:
            check+=1
    ans.append(check)
print(len(t)-max(ans))

Measured memory_bytes: 67980
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli; 
lli spf[10000004];
void precalc()
{
	spf[1]=1;
	
	for(int i =2;i<=10000000;i++)
	{
		if(spf[i]!=0)continue;
		
		int temp=i;
		while(temp<=10000000)
		{
			spf[temp]=i;
			temp=temp+i;
		}
	}
	
}
lli ans[10000004];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli temp1,temp2,m,t,x,y,b,temp,a,q,d,p,mx,n,k;
    precalc();

    ans[1]=1;
    
    for(int i =2;i<=10000000;i++)
    {
    	ans[i]+=ans[i-1];
    	
    	lli prev=spf[temp],count=0;
    	temp1=1;
    	temp=i;
    	while(temp>1)
    	{
    		if(spf[temp]!=prev)
    		{
    			prev=spf[temp];
    			temp1=temp1*(count+1);
    			count=0;
    		}
    		temp=temp/spf[temp];
    		count++;
    	
    	}
    	if(spf[temp]!=prev&&count!=0)
		{
			prev=spf[temp];
			temp1=temp1*(count+1);
			count=1;
		}
    	
    	ans[i]+=(temp1*i);
    }
    
    cin>>n;
    cout<<ans[n]<<endl;
   	
}

	

Measured memory_bytes: 159804
#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 n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> ans(n);
  rep(i, n) {
    if (i % 2 == 0)
      ans[0] += a[i];
    else
      ans[0] -= a[i];
  }
  for (int j = 1; j < n; j++) {
    ans[j] = a[j - 1] * 2 - ans[j - 1];
  }

  rep(i, n) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 2048
// Copyright (C) 2017 Sayutin Dmitry.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.

#include <iostream>
#include <vector>
#include <stdint.h>
#include <algorithm>
#include <set>
#include <map>
#include <array>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <string>
#include <assert.h>
#include <iterator>
#include <cstdint>
#include <cinttypes>
#include <string.h>
#include <random>
#include <numeric>
#include <tuple>


using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::min;
using std::abs;
using std::max;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

#define pb push_back
#define eb emplace_back


int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    // code here.
    int n = input<int>();

    vector<int> perm(n);
    for (int& el: perm)
        el = input<int>() - 1;

    int ans = 0;

    for (int i = 0; i != n;)
        if (perm[i] != i)
            ++i;
        else {
            int j;
            for (j = i; j != n and perm[j] == j; ++j) {}

            int len = j - i;
            ans += (len + 1) / 2;

            i = j;
        }
    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  set<pair<int, int> > s;
  vector<int> v;
  int n,m;
  cin>>n>>m;int x,y;
  for(int i=0;i<m;i++)
  {
    cin>>x>>y;
    if(x>y)swap(x,y);
    s.insert({x,y});
  }
  for(int i=2;i<=n;i++)
  {v.push_back(i);}
  int ans=0;
  do
  {
    bool valid=true;
     if(s.count({1,v[0]}))valid=valid & 1;
      else valid=false;
    for(int i=0;i<n-2;i++)
    {
      int u=v[i];int t=v[i+1];
      if(u>t)swap(u,t);
      if(s.count({u,t}))valid=valid & 1;
      else valid=false;
    }
    if(valid){ans++;}
    
  }while(next_permutation(v.begin(),v.end()));
  cout<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>
double max(double a,double b){return a>b?a:b;}
int main(){
	int n,m;
	int i,j,k;
	double dp[2][100];
	double ch[100][100];
	while(1){
	scanf("%d %d",&n,&m);
	if(n==0)return 0;
	for(i=0;i<n;i++)for(j=0;j<n;j++)scanf("%lf",&ch[i][j]);
	for(i=0;i<n;i++)dp[0][i]=1.0f;
	for(i=1;i<m;i++){
		for(j=0;j<n;j++){
			dp[i%2][j]=0.0f;
			for(k=0;k<n;k++)dp[i%2][j]=max(dp[i%2][j],dp[(i+1)%2][k]*ch[k][j]);
		}
	}
	double ans=0.0f;
	for(i=0;i<n;i++)ans=max(ans,dp[(m+1)%2][i]);
	printf("%.2lf\n",ans);
	}
}

Measured memory_bytes: 1172
from collections import defaultdict
H, W, M = map(int, input().split())
hs = defaultdict(int)
ws = defaultdict(int)
expl = set()

for i in range(M):
    h, w = map(int, input().split())
    hs[h] += 1
    ws[w] += 1
    expl.add((h, w))

hscan = []
wscan = []
hmax = max(hs.values())
wmax = max(ws.values())

for i, m in hs.items():
    if m == hmax:
        hscan.append(i)

for i, m in ws.items():
    if m == wmax:
        wscan.append(i)

for h in hscan:
    for w in wscan:
        if not (h, w) in expl:
            print(hmax + wmax)
            exit()

print(hmax + wmax - 1)

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    string s;cin>>s;
    map<char,int> mp;
    rep(i,s.size())mp[s[i]]++;
    for(auto m:mp){
        if(m.second & 1){
            out("No");
            return 0;
        }
    }
    out("Yes");
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		
		double minMax = ((double)a * (double)b / 2.0);
		int res = 0;
		if ((x * 2) == a && (y * 2) == b) {
			res = 1;
		}
		System.out.println(minMax + " " + res);
	}
	
	static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 24788
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n, m;
	cin >> n >> m;
	int mat[n][n];
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			mat[i][j]=0;
		}
	}
	for(int i=0; i<m; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		mat[a][b]=1;
		mat[b][a]=1;
	}

	vector<int> v;
	for(int i=0; i<n; i++) v.push_back(i);
	int ans=0;
	while(v[0]==0){
		bool b=true;
		for(int i=1; i<n; i++){
			if(mat[v[i-1]][v[i]]==0) b=false;
		}
		if(b) ans++;
		next_permutation(v.begin(), v.end());
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            out.print(Math.min(in.nextInt(), in.nextInt()) +
                    Math.min(in.nextInt(), in.nextInt()));

        }

    }
}



Measured memory_bytes: 23764
N = int(input())
A = list(map(int, input().split(' ')))
B1 = [0 for i in range(60)]
B0 = [0 for i in range(60)]
for x in A:
    bA = format(x,"b").zfill(60)
    for i in range(60):
        if bA[i] == "1":
            B1[i] += 1
        elif bA[i] == "0":
            B0[i] += 1
ans = 0
for i in range(60):
    ans = (ans + 2**(59-i)*B1[i]*B0[i]) % (10**9+7)
print(ans)

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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define dep(i, a, n) for(int i = a; i >= (n); i--)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll
#define INF 100000000

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll h, hh, k, kk;
  ll a, b, c, d, hiro, ken;
  string result;
  cin >> h >> hh >> k >> kk >> a >> b >> c >> d;
  hiro = h * a + hh * b + (h / 10) * c + (hh / 20) * d;
  ken = k * a + kk * b + (k / 10) * c + (kk / 20) * d;
  if(ken == hiro) result = "even";
  else if(ken < hiro) result = "hiroshi";
  else result = "kenjiro";
  cout << result << endl;
	return 0;
}


Measured memory_bytes: 3256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef long long typ;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,lint> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define N 114514
vector<pint> gr[252521];
int r[N],c[N];lint a[N],mi[252521];
struct wunionf{
	vector<int> data;
	vector<typ> we;
	wunionf(int size):data(size,-1),we(size,0){}
	
	//x+z=yになるようにする
	//矛盾するかの判定はしてない(diffを使って判定しよう)
	bool unions(int x,int y,typ z){
		z+=weight(x);z-=weight(y);
		x=root(x);y=root(y);
		if(x!=y){
			if(data[y]<data[x]){int d=x;x=y;y=d;z=-z;}
			data[x]+=data[y];data[y]=x;
			we[y]=z;
		}
		return x!=y;
	}
	
	int weight(int x){
		root(x);
		return we[x];
	}
	
	bool finds(int x,int y){
		return root(x)==root(y);
	}
	int root(int x){
		if(data[x]<0) return x;
		int par=root(data[x]);
		we[x]+=we[data[x]];
		return data[x]=par;
	}
	
	int find(int x){
		return -data[x];
	}
	
	//y-x(xから見たyの重み)を求める。やる前にfinds(x,y)でつながってるかを確認する。
	typ diff(int x,int y){
		return we[y]-we[x];
	}
};
string cal(void)
{
	wunionf uni(252521);
	int R,C,n;
	scanf("%d %d",&R,&C);
	scanf("%d",&n);
	rep(i,n) scanf("%d %d %lld",&r[i],&c[i],&a[i]);
	rep(i,n){
		r[i]--;c[i]--;
		gr[r[i]].pb(mp(c[i],a[i]));
		gr[c[i]+N].pb(mp(r[i]+N,a[i]));
	}
	rep(i,2*N){
		if(gr[i].size()<2) continue;
		int m=gr[i].size();
		sort(All(gr[i]));
		rep(j,m-1){
			int x=gr[i][j].fi,y=gr[i][j+1].fi;lint z=gr[i][j+1].se-gr[i][j].se;
			if(uni.finds(x,y) && uni.diff(x,y)!=z) return "No";
			uni.unions(x,y,z);
		}
	}
	rep(i,114514) mi[i]=1145141919819364364LL;
	rep(i,2*N){
		int r=uni.root(i);
		mi[r]=min(mi[r],uni.diff(r,i));
	}
	rep(i,n){
		int r1=uni.root(c[i]),r2=uni.root(r[i]+N);
		if(a[i]+uni.diff(c[i],r1)+mi[r1]+uni.diff(r[i]+N,r2)+mi[r2]<0LL) return "No";
	}
	return "Yes";
}
int main()
{
	cout<<cal()<<endl;
}


Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl 

void Suhaib_Sawalha (){

    int n;
    long double a , s = 0;
    cin >> n;
    for (int i = 0 ; i < n ; ++i){
        cin >> a;
        s += 1.0 / a;
    }

    cout << fixed << setprecision(20) << 1.0 / s;

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}

Measured memory_bytes: 3756
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;



namespace ConsoleApplication2
{

    class Program
    {
        static void Main(string[] args)
        {

            
            int  postition=0,range=0;

            string[] mass = Console.ReadLine().Split(' ');


            int[] result = new int[3];

            //int[] listinput = new int[mass.Length];

            //for (int i = 0; i < mass.Length; i++)
            //{
            //    listinput[i] = int.Parse(mass[i]);
            //}
            range = int.Parse(mass[0]);


            result[0] = range * range * range;

            Console.Write(result[0]);



            //postition = int.Parse(mass[1]);

            //int nowposition = postition - (range - 1);

            //for(int i= 0; i<=(range-1)*2;i++)
            //{

            //    Console.Write(nowposition);
            //    Console.Write(" ");
            //    nowposition++;
            //}

            range = 0;

        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)

const ll MOD = 1e9 + 7;

int n;
double memo[301][301][301];

double DFS(int a, int b, int c) {
  double ret = 0;
  if (memo[a][b][c] > 0) {
    return memo[a][b][c];
  }
  if (a) {
    ret += DFS(a - 1, b, c) * a / (a + b + c);
  }
  if (b) {
    ret += DFS(a + 1, b - 1, c) * b / (a + b + c);
  }
  if (c) {
    ret += DFS(a, b + 1, c - 1) * c / (a + b + c);
  }
  if (a + b + c > 0) {
    ret += (double) n / (a + b + c);
  } else {
    ret = 0;
  }
  memo[a][b][c] = ret;
  return ret;
}

void solve(istream& cin, ostream& cout) {
  cin >> n;
  int a;
  vector<int> cnt(4, 0);
  REP(i, 301) {
    REP(j, 301) {
      REP(k, 301) {
        memo[i][j][k] = 0;
      }
    }
  }
  REP(i, n) {
    cin >> a;
    cnt[a]++;
  }
  cout << setprecision(10) << DFS(cnt[1], cnt[2], cnt[3]) << endl;
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


Measured memory_bytes: 213376
#include <bits/stdc++.h>
#define REP(i, n) for (int i=0, i##_limit=(n); i<i##_limit; ++i)
#define FOR(i, a, b) for (int i=(a), i##_limit=(b); i<i##_limit; ++i)
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long;
using pi = pair<int, int>;

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

    bool ret = false;
    REP(i, 10) REP(j, 10)
    {
        if (i*j == N) ret = true;
    }

    cout << (ret ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
import collections

N = int(input())
A = [int(i) for i in input().split()]
ans = 0
di = collections.Counter(A)
if N % 2 != 0:
    num_list = [int(i) for i in range(2, N, 2)]
    for num in num_list:
        if di[num] != 2:
            break
    else:
        if A.count(0) == 1:
            ans = (2 ** (N // 2)) % (10 ** 9 + 7)

else:
    num_list = [int(i) for i in range(1, N, 2)]
    for i in num_list:
        if di[i] != 2:
            break
    else:
        ans = (2 ** (N // 2)) % (10 ** 9 + 7)
print(ans)

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


int main(void)
{
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
	}
	if (N == K) {
		cout << 1 << endl;
		return 0;
	}

	N = N - K;
	long long ans = 1;
	do {
		N -= (K-1);
		ans++;

	} while (N > 0);

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef complex<double> P;
typedef pair<P,P> L;
typedef pair<L,bool> P2;
 
const double EPS=1e-8;
 
double dot(P a,P b){ return real(conj(a)*b); }
 
double cross(P a,P b){ return imag(conj(a)*b); }
 
P proj(P p,L l){
  return l.first+dot(p-l.first,l.second-l.first)/norm(l.second-l.first)*(l.second-l.first);
}
 
P reflect(P p,L l){
  return p+(proj(p,l)-p)*2.0;
}
 
P crossPoint(L l,L m){
  double A=cross(l.second-l.first,m.second-m.first);
  double B=cross(l.second-l.first,l.second-m.first);
  if(fabs(A)<EPS&&fabs(B)<EPS) return m.first;
  else if(fabs(A)>=EPS) return m.first+B/A*(m.second-m.first);
}
 
string s;
int p;
 
P2 bnf();
 
P get_num(){
 
  P res;
  int f=0;
 
  if(s[p]=='-') f=1, p++;
 
  double num1=0;
   
  while('0'<=s[p]&&s[p]<='9') num1=num1*10+s[p]-'0', p++;
 
  if(f) num1*=-1;
 
  f=0;
   
  p++;
 
  double num2=0;
 
  if(s[p]=='-') f=1, p++;
   
  while('0'<=s[p]&&s[p]<='9') num2=num2*10+s[p]-'0', p++;
   
  if(f) num2*=-1;
   
  f=0;
   
  return P(num1,num2);
}
 
P2 get_P2(){
 
  if(s[p]=='('){
 
    p++;
     
    P2 res=bnf();
 
    p++;
 
    return res;
  }
   
  return P2(L(get_num(),0),0); // 0: Point,  1: Line
}
 
P2 bnf(){
 
  P2 res=get_P2();
   
  while(p<s.size()&&s[p]=='@'){
 
    p++;
     
    P2 r=get_P2();
     
    bool A=res.second,B=r.second;
     
    if(!A&&!B){
      res.first=L(res.first.first,r.first.first);
      res.second=1;
    }
     
    if(A&&B){
      res.first.first=crossPoint(res.first,r.first);
      res.second=0;
    }
     
    if(!A&&B){
      res.first.first=reflect(res.first.first,r.first);
      res.second=0;
    }
     
    if(A&&!B){
      res.first.first=reflect(r.first.first,res.first);
      res.second=0;
    }
     
  }
   
  return res;
}
 
string Cut(string s){
 
  string res;
 
  for(int i=0;i<s.size();i++){
    if(s[i]=='('&&(s[i+1]=='-'||('0'<=s[i+1]&&s[i+1]<='9'))) continue;
    if(s[i]==')'&&('0'<=s[i-1]&&s[i-1]<='9')) continue;
    res+=s[i];
  }
   
  return res;
}
 
int main(){
 
  while(1){
 
    cin>>s;
    if(s=="#") break;
 
    s=Cut(s);
     
    p=0;
     
    P2 ans=bnf();
 
    printf("%.8f %.8f\n",ans.first.first.real(),ans.first.first.imag());
     
  }
   
  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<long> v;
    for (int i = 0; i < n; ++i) {
        long x;
        cin >> x;
        v.push_back(x);
    }
    cout << *min_element(v.begin(), v.end()) << " ";
    cout << *max_element(v.begin(), v.end()) << " ";
    cout << accumulate(v.begin(), v.end(), 0L) << "\n";
}

Measured memory_bytes: 1340
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static int N;
    static int[] H;

    public static void Main(string[] args)
    {
        N = Input.NextInt();
        H = Input.LineInt();
        int ans = 0;
        int min = int.MinValue;
        for (int i = 0; i < N; i++)
        {
            if (min <= H[i])
            {
                ans++;
                min = H[i];
            }
        }

        Console.WriteLine(ans);
    }
}

public static class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

Measured memory_bytes: 13396
#include <cstdio>
#include <cmath>
#include <algorithm>

const int inf = 1e9;

using namespace std;

int main()
{
    int e;
    
    while (scanf("%d", &e), e) {
        int mi = inf;

        for (int z = 0; z * z * z <= e; ++z) {
            int y = sqrt(e - z * z * z);
            int x = e - y * y - z * z * z;
            mi = min(mi, x + y + z);
        }

        printf("%d\n", mi);
    }
}

Measured memory_bytes: 1028
n = int(input())

a = list(map(int,input().split()))

b = list(map(int,input().split()))

c = list(map(int,input().split()))

ans = sum(b)
if n == 1:
    print(ans)
else:
    for i in range(n-1):
        if a[i] + 1 == a[i+1]:
            ans += c[a[i]-1]
    print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int Q;
int l,r;
static const int MAX=100000;
bool f[MAX+1];
int c[MAX+2];
void prime(){
    for(int i=2;i<=MAX;i++){
        if(f[i])continue;
        for(int j=i*2;j<=MAX;j+=i){
            f[j]=true;
        }
    }
    for(int i=3;i<=MAX;i+=2){
        if(!f[i]&&!f[(i+1)/2])
            c[i]++;
    }
    for(int i=3;i<=MAX;i++) c[i]+=c[i-1];

}
int main(){
    cin>>Q;
    prime();
    while(Q--){
        cin>>l>>r;
        cout<<c[r]-c[l-1]<<"\n";
    }
    return 0;
}


Measured memory_bytes: 1152
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力
static long long slVal;											// 値

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i, j, k;
	char lc1Buf[1024];

	// データ - 初期化
	slVal = 0;

	// 序数 - 取得
	int liNo;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &liNo);

	// 加算
	for (i = 0; i < liNo; i++) {
		for (j = 0; ; j++) {

			// チェック
			sprintf(lc1Buf, "%lld", slVal + 1);
			int liLen = strlen(lc1Buf);
			for (k = 1; k < liLen; k++) {
				int liDF = abs(lc1Buf[k] - lc1Buf[k - 1]);
				if (liDF > 1) {
					break;
				}
			}
			if (k == liLen) {
				slVal++;
				break;
			}

			slVal /= 10;
		}
		for ( ; j > 0; j--) {
			long long llVal = slVal % 10 - 1;
			if (llVal < 0) {
				llVal = 0;
			}
			slVal = slVal * 10 + llVal;
		}
	}

	// 出力
	sprintf(lc1Buf, "%lld\n", slVal);
	fOutLine(lc1Buf);

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



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

using namespace std;

int h,w;

void solve(){
    int i,j;
    string str;
    cin >> h >> w;
    vector<string> s(h);
    for(i = 0;i < h;i++) cin >> s[i];
    vector<long long> c(h*w+1,0),d(h*w+1,0);
    int f[400][400];
    memset(f,-1,sizeof(f));
    vector<pair<int,int> > st;
    int k = 0;
    for(i = 0;i < h;i++){
        for(j = 0;j < w;j++){
            if(f[i][j] == -1){
                f[i][j] = k;
                st.push_back(make_pair(i,j));
                for(c[k] = d[k] = 0;st.size()>0;){
                    int y = st.back().first;
                    int x = st.back().second;
                    if(s[y][x] == '#') c[k]++;
                    else d[k]++;
                    f[y][x] = k;
                    st.pop_back();
                    if(y > 0 && f[y-1][x] == -1 && s[y-1][x] != s[y][x]){
                        f[y-1][x] = k;
                        st.push_back(make_pair(y-1,x));
                    }
                    if(x > 0 && f[y][x-1] == -1 && s[y][x-1] != s[y][x]){
                        f[y][x-1] = k;
                        st.push_back(make_pair(y,x-1));
                    }
                    if(y+1 < h && f[y+1][x] == -1 && s[y+1][x] != s[y][x]){
                        f[y+1][x] = k;
                        st.push_back(make_pair(y+1,x));
                    }
                    if(x+1 < w && f[y][x+1] == -1 && s[y][x+1] != s[y][x]){
                        f[y][x+1] = k;
                        st.push_back(make_pair(y,x+1));
                    }
                }
                k++;
            }
        }
    }
    long long ans = 0;
    for(i = 0;i < h*w+1;i++){
        ans += c[i]*d[i];
    }
    cout << ans << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 4728
using System;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
using IEInt32 = System.Collections.Generic.IEnumerable<int>;

static class PokerHand
{
    static void Main()
    {
        Func<IEnumerable<IEInt32>, int[], string> combinationOf =
            (g, h) =>
                g.Any( x => x.Skip( 3 ).Any() )
                    ? "four card"
                : g.All( x => x.Skip( 1 ).Any() )
                    ? "full house"
                : new[] { 10, 11, 12, 13, 1 }.Except( h ).All( _ => false )
                    ? "straight"
                : E.Range( h.Min(), 5 ).Except( h ).All( _ => false )
                    ? "straight"
                : g.Any( x => x.Skip( 2 ).Any() )
                    ? "three card"
                : g.Where( x => x.Skip( 1 ).Any() ).Skip( 1 ).Any()
                    ? "two pair"
                : g.Any( x => x.Skip( 1 ).Any() )
                    ? "one pair"
                : "null";

        var indata = Console.In.ReadToEnd()
            .Split( 
                new[] { '\r', '\n' },
                StringSplitOptions.RemoveEmptyEntries );
        var q =
            from hand in indata
            let h = Array.ConvertAll( hand.Split( ',' ), int.Parse )
            let g = h.GroupBy( x => x ).Cast<IEInt32>()
            select combinationOf( g, h );
        foreach( var c in q )
            Console.WriteLine( c );
    }
}

Measured memory_bytes: 6592
package main

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

	"github.com/emirpasic/gods/trees/redblacktree"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	h := getNextInt(scanner)
	w := getNextInt(scanner)

	rbt := redblacktree.NewWithIntComparator()
	rbt2 := redblacktree.NewWithIntComparator()
	for i := 0; i < w; i++ {
		rbt.Put(i, i)
	}
	rbt2.Put(0, w)

	for i := 0; i < h; i++ {
		a := getNextInt(scanner) - 1
		b := getNextInt(scanner)
		x := -1
		for node, ok := rbt.Ceiling(a); ok && node.Key.(int) <= b; node, ok = rbt.Ceiling(a) {
			k := node.Key.(int)
			v := node.Value.(int)
			rbt.Remove(k)
			if x < v {
				x = v
			}
			decrement(rbt2, k-v)
		}
		if b < w && x != -1 {
			old, found := rbt.Get(b)
			if found {
				x = max(old.(int), x)
			}
			rbt.Put(b, x)
			increment(rbt2, b-x)
		}
		if rbt2.Empty() {
			fmt.Fprintln(writer, -1)
			continue
		}
		fmt.Fprintln(writer, rbt2.Left().Key.(int)+i+1)
	}
}
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func update(tree *redblacktree.Tree, key interface{}, x int) {
	old, found := tree.Get(key)
	if found {
		y := old.(int) + x
		if y <= 0 {
			tree.Remove(key)
			return
		}
		tree.Put(key, y)
		return
	}
	tree.Put(key, x)
}
func increment(tree *redblacktree.Tree, key interface{}) {
	update(tree, key, 1)
}
func decrement(tree *redblacktree.Tree, key interface{}) {
	update(tree, key, -1)
}


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

int AgreementCountAnswer(int n)
{
	int AgreementCount = 0;
	for(int a = 0; a < 10; a++){
		for(int b = 0; b < 10; b++){
			for(int c = 0; c < 10; c++){
				for(int d = 0; d < 10; d++){
					if(a + b + c + d == n) AgreementCount++;
				}
			}
		}
	}
	return AgreementCount;
}

int main()
{
	while(true){
		int n;
		cin >> n;
		if(cin.eof() == true) break;
		cout << AgreementCountAnswer(n) << endl;
	}
	return 0;
}

Measured memory_bytes: 3008
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s, s1, s2, s3;
  cin >> s;
  s1 = s/100;
  s2 = (s - (s1 * 100)) / 10;
  s3 = s - (s1 * 100) - (s2 * 10);
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int distr[7];

int main()
{
    int n;
    scanf( "%d\n", &n );
    for( int i = 0; i < n; i++ )
    {
        float a;
        scanf( "%f\n", &a );
        if( a < 165.0 )
        {
            distr[1]++;
        }
        else if( a < 170.0 )
        {
            distr[2]++;
        }
        else if( a < 175.0 )
        {
            distr[3]++;
        }
        else if( a < 180.0 )
        {
            distr[4]++;
        }
        else if( a < 185.0 )
        {
            distr[5]++;
        }
        else
        {
            distr[6]++;
        }
    }
    for( int i = 1; i <= 6; i++ )
    {
        printf( "%d:", i );
        while( 0 < distr[i] )
        {
            printf( "%c", '*');
            distr[i]--;
        }
        printf( "\n" );
    }
    return 0;
}


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

using namespace std;

int main(){
	int n,a,b,c,d; cin >> n >> a >> b >> c >> d;
	a--;b--;c--;d--;
	string s; cin >> s;
	for(int i=a+1;i<c;i++){
		if(s[i]=='#' && s[i+1]=='#'){
			cout << "No" << endl;
			return 0;
		}
	}
	for(int i=b+1;i<d;i++){
		if(s[i]=='#' && s[i+1]=='#'){
			cout << "No" << endl;
			return 0;
		}
	}
	if(c<d)
		cout << "Yes" << endl;
	else{
		for(int i=b;i<=d;i++){
			if(s[i]=='.' && s[i-1]=='.' && s[i+1]=='.'){
				cout << "Yes" << endl;
				return 0;
			}
		}
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void){

int i,j,x;
int n=0;
int card[4][13];
char mark;

  for(i=0;i<4;i++){
    for(j=1;j<14;j++){
      card[i][j]=0;
    }
  }

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c %d",&mark,&x);
    switch(mark){
    case 'S': card[0][x]=1;
      break;
    case 'H': card[1][x]=1;
      break;
    case 'C': card[2][x]=1;
      break;
    case 'D': card[3][x]=1;
      break;
		}
		
	}
    for(i=0;i<4;i++){
      for(j=1;j<14;j++){
        if(card[i][j]==0){
          if(i==0)
            printf("S %d\n",j);
	      else if(i==1)
            printf("H %d\n",j);
          else if(i==2)
            printf("C %d\n",j);
          else if(i==3)
            printf("D %d\n",j);
        }
      }
    }
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll 				long long
#define ld 				long double
#define fastio 			ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) 		cerr<<#x<<" "<<x<<endl
#define cina(a,n) 		for(ll i = 0;i<n;i++)	cin>>a[i];
#define couta(a,n) 		for(ll i = 0;i<n;i++) cout<<a[i]<<" ";
#define fauto(ar)		for(auto x : ar)	cout<<x<<" ";
#define mod 			1000000007
#define siz 			105
#define f 				first
#define s 				second
#define pb 				push_back
#define endl 			"\n"
#define ci 				cin.ignore()
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	int x,y;
	cin>>x>>y;
	cin>>b;
	if(a == b)
	x--;
	else
	y--;
	cout<<x<<" "<<y;
	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    String s=gs();

	    int g=0;
	    int p=0;
	    int point=0;
	    for (int i=0; i<s.length();i++) {
	    	char c=s.charAt(i);
	    	if(c=='g') {
	    		if(p+1<=g) {
	    			point++;
	    			p++;
	    		} else {
	    			g++;
	    		}
	    	} else {
	    		if(p+1<=g) {
	    			p++;
	    		} else {
	    			g++;
	    			point--;
	    		}
	    	}
	    }

	    System.out.println(point);
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 39404