akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N=1*1e5+10,Mod=1e9+7;
typedef long long ll;
#define pb push_back
int a[N],one=1,mark[N];
int n,k,u,v,sig;
ll ans=1ll;
vector<int> G[N];
void dfs(int u,int p)
{
  int temp=1;
  for(auto v:G[u])
  {
    if(v==p) continue;
    if(!mark[v])
    {
      temp++;
      if((k-temp)<0) sig=1;
      ans=(ans*(k-temp))%Mod;
    }
    dfs(v,u);
  }
  // return;
}
int main()
{
  cin>>n>>k;
  for(int i=1;i<n;i++)
  {
    cin>>u>>v;
    if(u>v) swap(u,v);
    if(u==1) one++,mark[v]=1;
    G[u].pb(v);
    G[v].pb(u);
  }
  mark[1]=1;
  dfs(1,0);
  if(sig) cout<<"0"<<endl;
  else
  {
    for(int i=0;i<one;i++)
    {
      if((k-i)<=0)
      {
        cout<<"0"<<endl;
        return 0;
      }
      ans=(ans*(k-i))%Mod;
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0; i<n; ++i)
#define rep1(i,n) for(ll i=1; i<=n; ++i)
#define revrep(i,n) for(ll i=n-1; n>=0; --i)
inline constexpr ll Inf = (1ULL << 62) -1;
#define fastio cin.tie(nullptr); ios_base::sync_with_stdio(false);
#define endl '\n'
template <class T> bool updmax(T& a, T b) { if (b > a) { a = b; return true;} return false;}
template <class T> bool updmin(T& a, T b) { if (b < a) { a = b; return true;} return false;}

int main() {
    fastio;
    string s, front, back;
    ll q;
    cin >> s >> q;
    bool rev = false;
    rep(i,q) {
        int t;
        cin >> t;
        if (t == 1)
            rev = !rev;
        else {
            int f;
            char c;
            cin >> f >> c;
            if ((f == 1)^(rev))
                front.push_back(c);
            else
                back.push_back(c);
        }
    }
    if (rev) {
        reverse(begin(s), end(s));
        swap(front, back);
    }
    reverse(begin(front), end(front));
    cout << front + s + back << endl;
}


Measured memory_bytes: 4216
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  string s;
  cin>>s;
  bool ans = true;
  for(int i=0;i<s.length();i++){
  	if(((i+1)%2==0&&s[i]!='L'&&s[i]!='U'&&s[i]!='D')||((i+1)%2!=0&&s[i]!='R'&&s[i]!='U'&&s[i]!='D')){
		ans=false;
  	}
  }
  if(ans){
  	cout<<"Yes"<<endl;
  }else{
  	cout<<"No"<<endl;
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <vector>
#define llint long long

using namespace std;

struct edge{
	llint to, cost;
	edge(){}
	edge(llint a, llint b){
		to = a, cost = b;
	}
};

llint n, m, p;
vector<edge> G[2505];
vector<llint> revG[2505];
llint dist[2505];
bool used[2505], used2[2505];

bool BellmanFord()
{
	for(int i = 1; i <= n; i++) dist[i] = 1e12;
	dist[1] = 0;
	
	llint cnt = 0;
	bool update = true;
	while(update){
		update = false;
		for(int i = 1; i <= n; i++){
			if(!used[i] || !used2[i]) continue;
			for(int j = 0; j < G[i].size(); j++){
				if(!used[G[i][j].to]) continue;
				if(dist[G[i][j].to] > dist[i] + G[i][j].cost){
					dist[G[i][j].to] = dist[i] + G[i][j].cost;
					update = true;
				}
			}
		}
		cnt++;
		if(cnt >= n+m+1) return false;
	}
	return true;
}

void dfs(llint v)
{
	used[v] = true;
	for(int i = 0; i < revG[v].size(); i++){
		if(used[revG[v][i]]) continue;
		dfs(revG[v][i]);
	}
}

void dfs2(llint v)
{
	used2[v] = true;
	for(int i = 0; i < G[v].size(); i++){
		if(used2[G[v][i].to]) continue;
		dfs2(G[v][i].to);
	}
}


int main(void)
{
	cin >> n >> m >> p;
	llint a, b, c;
	for(int i = 1; i <= m; i++){
		cin >> a >> b >> c;
		G[a].push_back(edge(b, p-c));
		revG[b].push_back(a);
	}
	
	dfs(n);
	dfs2(1);
	
	if(!BellmanFord()) cout << -1 << endl;
	else cout << max(0LL, -dist[n]) << endl;
	
	return 0;
}


Measured memory_bytes: 640
/*
 * main.c
 *
 *  Created on: 2019/03/06
 *      Author: family
 */


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c,d;
    char yes[4] = "Yes\0";
    char no[4] = "No\0\0";
    char *ans;
    scanf("%d %d %d %d",&a,&b,&c, &d);
    if (abs(a - c) <= d) {
      ans = yes;
    } else if((abs(a-b) <= d) && (abs(b-c) <= d)) {
      ans = yes;
    } else {
      ans = no;
    }
    printf("%s\n",ans);
    return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import numpy as np

h, w, k = map(int, input().split())
c = np.array([list(input()) for _ in range(h)])

rst = 0
for i in range(pow(2, h)):
    h_mask = np.array(list(map(lambda x: x == "0", ("000000" + bin(i)[2:])[-h:])))
    _c = c[h_mask].T
    for j in range(pow(2, w)):
        w_mask = np.array(list(map(lambda x: x == "0", ("000000" + bin(j)[2:])[-w:])))
        if len(_c) == 0:
            count = 0
        else:
            __c = _c[w_mask]
            count = np.count_nonzero(__c == '#')
        if k == count:
            rst += 1

print(rst)


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


int main()
{
	ll a,b;
	cin>>a>>b;
	if(b>0&&a>0) cout<<"Positive"<<endl;
	else if(b<0)
	{
		if((b-a+1)%2==0) cout<<"Positive"<<endl;
		else cout<<"Negative"<<endl;
	}
	else
	{
		cout<<"Zero"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import math
from itertools import product
from collections import deque

h, w = map(int, input().split())
ch, cw = map(lambda x: int(x) - 1, input().split())
dh, dw = map(lambda x: int(x) - 1, input().split())
S = [input() for _ in range(h)]


distance = [[math.inf for _ in range(w)] for _ in range(h)]
distance[ch][cw] = 0
queue = deque([(ch, cw)])
pathes = {(0, -1), (-1, 0), (0, 1), (1, 0)}
warps = set(product(range(-2, 3), range(-2, 3))) - {(0, 0)} - pathes

while queue:
    i, j = queue.popleft()
    for pi, pj in pathes:
        u, v = i+pi, j+pj
        if 0 <= u < h and 0 <= v < w and S[u][v] == '.' and distance[u][v] > distance[i][j]:
            distance[u][v] = distance[i][j]
            queue.appendleft((u, v))

    for wi, wj in warps:
        x, y = i + wi, j + wj
        if 0 <= x < h and 0 <= y < w and S[x][y] == '.' and distance[x][y] > distance[i][j] + 1:
            distance[x][y] = distance[i][j] + 1
            queue.append((x, y))

print(distance[dh][dw] if distance[dh][dw] != math.inf else -1)


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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) (in).begin(),(in).end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最小公倍数

char input(){
  char a;
  cin >> a;
  return a;
}

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

Measured memory_bytes: 256
S=input()
if (S[0]==S[1] and S[2]==S[3] and S[0]!=S[3]) or (S[0]==S[2] and S[1]==S[3] and S[0]!=S[3]) or (S[0]==S[3] and S[2]==S[1] and S[0]!=S[1]):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 105;
const ll LINF = 1e18 + 5;
int k;
string s;
ll dp[N][2][4];
ll dfs(int pos, int limit, int state) 
{
	if(pos==-1) return !state;
	if(~dp[pos][limit][state]) return dp[pos][limit][state];
	int up = limit ? s[pos]-'0' : 9;
	ll ans = 0;
	for(int i=0;i<=up;i++)
	{
		if(i&&state) ans += dfs(pos-1, limit&&i==s[pos]-'0', state-1);
		else if(i==0) ans += dfs(pos-1, limit&&i==s[pos]-'0', state);
	}
	return dp[pos][limit][state] = ans;	
}
ll solve() 
{
	memset(dp, -1, sizeof(dp)); 
	reverse(all(s));
	int pos = sz(s);
	return dfs(pos-1, 1, k);
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> s >> k;
 	cout << solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
          int n, i , c = 0 ;
          scanf("%d", &n) ;
          int a[n] ,b[n];
          for(i = 0 ; i < n ; i++)
          {
                    scanf("%d", &a[i]) ;
                    b[i] = a[i] ;
          }
          sort(b, b+n) ;
          for(i = 0 ; i < n ; i++)
          {
                    if(a[i] != b[i]) c++ ;
                    if(c >2) break ;
          }
          if(c == 2 || c == 0) printf("YES\n") ;
          else printf("NO\n") ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1001001;
const LL INF=1e15;
void gg(){
	puts("-1");
	exit(0);
}
int n;
int a[N];
LL suf[N];
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=0;i<=n;i++){
		cin>>a[i];
	}
	/**
	 * t=1;
	 * {
	 * ans+=t;
	 * t-=a[i];
	 * t=t...t*2;
	 * }
	 * assert(t==0);
	 */
	for(int i=n;i>=0;i--){
		suf[i]=suf[i+1]+a[i];
	}
	LL t=1;
	LL ans=0;
	for(int i=0;i<=n;i++){
		ans+=t;
		t-=a[i];
		if(t<0)gg();
		LL s=suf[i+1];
		assert(s>=t);
		t*=2;
		t=min(t,suf[i+1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4820
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
using namespace std;
typedef long long ll;

int main(){
  int n;
  cin >> n;
  int ans = 0;
  for(int i=0;i<n;i++) {
    int value;
    cin >> value;
    ans += value -1;
  }

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


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, k;
	cin >> n >> k;
	vl v(n);
	REP(i, n)cin >> v[i];
	ll x = 0;
	RREP(i, 50) {
		int cnt0 = 0, cnt1 = 0;
		REP(j, n) {
			if ((1ll << i)&v[j])cnt1++;
			else cnt0++;
		}
		if (cnt0 > cnt1) {
			if ((x | (1ll << i)) <= k)x |= (1ll << i);
		}
	}
	ll ans = 0;
	REP(i, n) {
		ans += x ^ v[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
/*
    Author - Param Kothari
    Ah shit, here we go again
*/
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair 
 
typedef long long ll;
typedef long double ld;

void solve(){
    ll n = 0, h = 0, suma = 0;
    cin >> n >> h;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < max(n - h, 0LL); i++){
        suma += a[i];
    }
    cout << suma << "\n";
    return;
}
 
int main(){
    IOS;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1792
import math
import sys

comb=[0,0,0,1,3,6,10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528, 561, 595, 630, 666, 703, 741, 780, 820, 861, 903, 946, 990, 1035, 1081, 1128, 1176, 1225, 1275, 1326, 1378, 1431, 1485, 1540, 1596, 1653, 1711, 1770, 1830, 1891, 1953, 2016, 2080, 2145, 2211, 2278, 2346, 2415, 2485, 2556, 2628, 2701, 2775, 2850, 2926, 3003, 3081, 3160, 3240, 3321, 3403, 3486, 3570, 3655, 3741, 3828, 3916, 4005, 4095, 4186, 4278, 4371, 4465, 4560, 4656, 4753, 4851, 4950]
n=int(input())
k=int(input())
s=str(n)
L=len(s)

ans=0
if n<k:
    ans=0

elif k==1:
    for i in range(L):
        for a in range(1,10):
            if a*(10**i)<=n:
                ans+=1

elif k==2:
    for i in range(1,L):
        for j in range(i):
            for a in range(1,10):
                for b in range(1,10):
                    if a*(10**i)+b*(10**j)<=n: ans+=1


elif k==3 and L<4:
    for a in range(1,10):
        for b in range(1,10):
            for c in range(1,10):
                if a*100+b*10+c<=n: ans+=1

elif k==3 and L>=4:
    ans=sum(comb[:L])*9**3
    ans+=comb[L]* 81 * (int(s[0])-1)

    m=int(s[1:])
    for i in range(1,L-1):
        for j in range(i):
            for a in range(1,10):
                for b in range(1,10):
                    if a*(10**i)+b*(10**j)<=m: ans+=1

print(ans)

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int a,b,h; cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

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


int main()
{
  int N, T; cin >> N >> T;
  vector<int> A(N); REP(i, N) cin >> A[i];

  int ma = -1, mia = INF;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    mia = min(mia, A[i]);
    int cost = A[i] - mia;
    if (cost == ma) ans++;
    else if (cost > ma) {
      ans = 1;
      ma = cost;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line[] = br.readLine().split(" ");
		int a = Integer.parseInt(line[0]);
		int b = Integer.parseInt(line[1]);
		String ans = "";
		if (a <= 8 && b <= 8) {
			ans = "Yay!";
		} else {
			ans = ":(";
		}

		System.out.println(ans);
	}

}

Measured memory_bytes: 22996
#include <iostream>
#include <cstdlib>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
    int H=0;
    int N=0;
    int temp=0;
    
    vector<int> A;
    
    cin >> H >> N;
    for(int i = 0; i < N; i++){
        cin >> temp;
        A.push_back(temp);
    }
    
    if(accumulate(A.begin(), A.end(), 0) >= H) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 892
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define FORD(x,y,z) for(int x=y;x>=z;x--)
#define MSET(x,y) memset(x,y,sizeof(x))
#define FOR(x,y) for(__typeof(y.begin()) x=y.begin();x!=y.end();x++)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define INF 2000000000
void RI(){}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}
using namespace std;
typedef long long LL;
typedef pair<int,int> Pi;
int n,fa[21][M],sum[M],dep[M];
vector<Pi> e[M];
namespace Init
{
	int m,t[M],dis[M],day[M],fr[M];
	vector<Pi> E[M];
	struct P
	{
		int d,day,fr,to;
		P(){}
		P(int a,int b,int c,int dd)
		{
			d = a;
			day = b;
			fr = c;
			to = dd;
		}
	};
	bool operator < (P a,P b)
	{
		if(a.d != b.d) return a.d > b.d;
		if(a.day != b.day) return a.day > b.day;
		return t[a.fr] > t[b.fr];
	}
	priority_queue<P> q;
	
	void init()
	{
		int cur;
		int x,y,z;
		P st;
		RI(n,m);
		REP(i,1,n) RI(t[i]);
		REP(i,1,m)
		{
			RI(x,y,z);
			E[x].PB( MP(y,z) );
			E[y].PB( MP(x,z) );
		}

		REP(i,1,n) dis[i] = INF;
		q.push( P(0,0,0,1) );
		while(!q.empty())
		{
			cur = q.top().to;
			st = q.top();
			q.pop();
			if(dis[cur] <= st.d) continue;
			
			dis[cur] = st.d;
			day[cur] = st.day;
			fr[cur] = st.fr;
			FOR(i,E[cur]) if(dis[i->F]==INF)
				q.push( P(dis[cur]+i->S, day[cur]+1, cur, i->F) );
		}
		///
		
		REP(i,1,n) if(fr[i])
		{
			z = dis[i] - dis[fr[i]];
			x = i;
			y = fr[i];
			e[x].PB( MP(y,z) );
			e[y].PB( MP(x,z) );
		}
	}
}
void dfs(int cur,int f,int s,int d)
{
	sum[cur] = s;
	fa[0][cur] = f;
	dep[cur] = d;

	FOR(i,e[cur]) if(i->F!=f)
		dfs(i->F, cur, s+i->S, d+1 );
}
int up(int x,int d)
{
	if(d<=0) return x;
	FORD(i,20,0) if(d & (1<<i)) x=fa[i][x];
	return x;
}
int main()
{
	Init::init();
	dfs(1,-1,0,0);
	REP(i,1,20) REP(j,1,n)
	{
		if(fa[i-1][j]==1) fa[i][j]=1;
		else fa[i][j] = fa[i-1][fa[i-1][j]];
	}

	int q;
	int st,d,p;
	int free;
	int Up, Down;
	RI(q);
	while(q--)
	{
		RI(st,d,p);
		free = up(st, dep[st]-d);

		Down = sum[st] - sum[free];
		Up = sum[free];
		Up = max(0, Up-p);
		printf("%d\n", Up+Down);
	}
	
	return 0;
}

Measured memory_bytes: 39624
// AOJ 1160
#include<iostream>
#define rep(i,a) for( int i = 0; i != (a); ++i )

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

int w, h;
bool c[50][50];

void dfs( int y, int x )
{
	c[y][x] = false;

	rep( i, 8 )
	{
		int nx = x+dx[i], ny = y+dy[i];

		if( nx >= 0 && nx < w && ny >= 0 && ny < h && c[ny][nx] )
			dfs( ny, nx );
	}

	return;
}

int main()
{
	while( std::cin >> w >> h, w|h )
	{
		rep( i, h )
			rep( j, w )
				std::cin >> c[i][j];

		int ans = 0;
		rep( i, h )
			rep( j, w )
				if( c[i][j] )
					dfs( i, j ), ++ans;

		std::cout << ans << std::endl;
	}

	return 0;
}

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

int main(){
    ll n,m;cin>>n>>m;
vl a(m);rep(i,n)cin>>a[i];
ll ans =n;

rep(i,m){ans-=a[i];}

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

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,in;
	while(cin>>n,n){
		rep(i,9)cin>>in,n-=in;
		cout<<n<<endl;
	}
}


Measured memory_bytes: 3076
#include<stdio.h>
#include<algorithm>
using namespace std;
unsigned long long t[100];
int main() {
	int n;
	scanf("%d",&n);
	for(int i=0; i<n; ++i)
		scanf("%llu",t+i);
	for(int i=1; i<n; ++i)
		t[i]=t[i]/__gcd(t[i],t[i-1])*t[i-1];
	printf("%llu\n",t[n-1]);
	return 0;
}

Measured memory_bytes: 128
#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;
typedef long long ll;
 
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
 
    int n;
    cin >> n;

    vector<int> d(n);
    rep(i, n) cin >> d[i];
 
    sort(d.begin(), d.end());

    cout << d[n/2] - d[n/2-1] << endl;
 
 
    return 0;
}

Measured memory_bytes: 640
#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;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};
int main(void){
  int a, b;
  cin >> a >> b;

  int cnt = b - a;  //bが1からどこまで足した値か
  int height_b = (1 + cnt) * cnt / 2;  //bの真の高さ
  int ans = height_b - b;
  cout << ans << endl;
}


Measured memory_bytes: 3512
#include <iostream>
#define mod 998244353

using namespace std;

long long fact[300009], inv[300009];

long long modpow(long long a, long long b, long long m)
{
	long long p=1, q=a;
	for (int i=0; i<30; i++)
    {
		if ((b/(1LL<<i))%2==1) { p*=q; p%=m; }
		q*=q; q%=m;
	}
	return p;
}

long long Div(long long a, long long b, long long p)
{
	return (a*modpow(b, p-2, p))%p;
}

void init(long long p)
{
	fact[0]=1;
	for (int i=1; i<=300000; i++) fact[i]=(1LL*fact[i-1]*i)%p;
	for (int i=0; i<=300000; i++) inv[i]=Div(1, fact[i], p);
}

long long nCrModp (long long n, long long r, long long p)
{
    if (r<0 || r>n) return 0;
    return ((fact[n]*inv[r])%p)*inv[n-r]%p;
}

long long calc (long long n, long long a, long long b)
{
    long long r=nCrModp(n, a, mod)*nCrModp(n, b, mod)%mod;
    return r;
}

int main()
{
    init(mod);
    long long n, a, b, k, B, ans=0;
    cin>>n>>a>>b>>k;
    for (int i=0; i<=n; i++)
    {
        if ((k-i*a)%b==0)
        {
            B=(k-i*a)/b;
            if (B<=n) { ans=(ans+calc(n, i, B))%mod; }
        }
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 4992
# -*- coding: utf-8 -*-
from sys import stdin

n = int(stdin.readline().rstrip())
A = list(map(int,stdin.readline().split()))
q = stdin.readline().rstrip()
M = list(map(int, stdin.readline().split()))

sum_results = set()

for i in range(2 ** n):
  sum_tmp = 0
  for j in range(n):
    # print("pattern i:{} j:{} i>>j{}".format(i,j,i>>j))

    if ((i >> j) & 1):  #順に右にシフトさせ最下位bitのチェックを行う
      sum_tmp += A[j]
  else:
    sum_results.add(sum_tmp)

for m in M:
  if m in sum_results:
    print("yes")
  else:
    print("no")



Measured memory_bytes: 5664
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy


def main():
    k = int(input())

    if k%2 == 0 or k%5 == 0:
        print(-1) 
        sys.exit()

    mod = 7
    for i in range(1,10**6+1):   
        
        if mod%k == 0:
            print(i)
            sys.exit()
        mod = (mod*10 + 7)%k

if __name__ == '__main__':
	main()


Measured memory_bytes: 69500
#include <stdio.h>
#include <unistd.h>

int main(void) {
    usleep(1.999 * 1000000);
	
  	int n, x, t; scanf("%d %d %d", &n, &x, &t);
  	int sum = 0, ans = 0;
    for(int i = 0; 1 ;i++) {
    	sum += x;
      	ans += t;
      	if (sum >= n) {
          break;
        }
    }
  	printf("%d\n", ans);
}

Measured memory_bytes: 1736
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stack>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <bitset>
#include<unordered_map>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
#define endl '\n'
#define exit(s) return cout<<s,0;
#define sz(s) (int)(s.size())
#define all(s) s.begin(),s.end()
#define allr(s) s.rbegin(), s.rend()
#define watch(x) cout << (#x) << " = " << x << endl
#define DNT ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

	

int main() {
	DNT;

	string x, y;
	cin >> x >> y;
	y.pop_back();
	if (x == y)
		cout << "Yes" << endl;
	else
		cout << "No"<< endl;
	return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
#define pll pair<ll,ll>
#define pii pair<int,int>
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
 
ll gcd(ll a,ll b){ if(b==0) return a; return gcd(b,a%b) ;} 

template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}
 
void solve(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans = max(b*d,max(b*c,max(a*c,a*d)));
	cout<<ans<<endl;
}
 
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	ll t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}    
    return 0;
}

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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

int main(){
    int n;
    string ans = "Yes";
    vector<string> w;
    cin >> n;
    REP(i,n){
        string tmp;
        cin >> tmp;
        w.push_back(tmp);
    }
    char back = w[0].back();
    FOR(i,1,n){
        if(back != w[i].front()){
            ans = "No";
            break;
        }
        back = w[i].back();
    }
    sort(w.begin(),w.end());
    FOR(i,1,n){
        if(w[i-1] == w[i]){
            ans = "No";
            break;
        }
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 char c;
 cin>>c;
 if(c=='G')
 {
     cout<<'C';
 }
 else if(c=='C')
 {
     cout<<'G';
 }
 else if(c=='A')
    cout<<'T';
    else if(c=='T')
        cout<<'A';


     return 0;
}


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

int32_t main() {
	
	int n;	cin >> n;
	map<int,bool> f;
	
	for(int x=0;x<n;x++){
		int t;	cin >> t;
		if(f[t]){
			f[t] = false;
		}else{
			f[t] = true;
		}
	}
	
	int ans = 0;
	
	
	for(auto it : f)
		ans += (it.second == true);
		
		cout << ans;
	
	return 0;
}

Measured memory_bytes: 6528
x,y = map(int,input().split())
if y == x:
    print(0)
elif abs(y) == abs(x):
    print(1)
elif x*y > 0:
    if x < y:
        print(y-x)
    else:
        print(x-y+2)
elif x*y == 0:
    if x < y:
        print(y-x)
    else:
        print(x-y+1)
else:
    if x < y:
        print(min(y-x,abs(abs(x)-abs(y))+1))
    else:
        print(min(x-y,abs(abs(x)-abs(y))+1))


Measured memory_bytes: 9068
/*A - Transfer*/

#include <bits/stdc++.h>
using namespace std;

int main(){

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

	int a, b, c;

	cin >> a >> b >>c;

	if(c - a + b < 0)
		cout << "0";
	else
		cout << c - a + b;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	int k;
	string s;
	cin>>k;
	cin>>s;
	if(k>=s.length()){
		cout<<s<<endl;
	}else{
		for(int i=0;i<=k-1;i++){
			if(i==k-1){
				cout<<s[i]<<"..."<<endl;
			}else{
				cout<<s[i];
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<cmath>
#include<cstring>
#include<queue>
using namespace std;
int SolutionB()
{
    int n,k,m;
    cin>>n>>k>>m;
    int sum=0;
    for(int i=0;i<n-1;i++){
        int tmp;
        cin>>tmp;
        sum+=tmp;
    }
    int left=n*m-sum;
    if(left>k) return -1;
    else return max(0,left);
}
void SolutionC()
{
    int n,m;
    cin>>n>>m;
    vector<bool> vis(n+1,false);
    vector<int> W(n+1,0);
    int ac=0,wa=0;
    for(int i=0;i<m;i++){
        int p;
        string res;
        cin>>p>>res;
        if(vis[p]==false){
            if(res=="AC"){
                vis[p]=true;
                ac++;
                wa+=W[p];
            }
            else W[p]++;
        }
    }
    cout<<ac<<" "<<wa<<endl;
}
const int maxn=30;
bool a[maxn][maxn];
int v[maxn][maxn];
int d[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
int n,m;
int res;
typedef pair<int,int> ii;
void BFS(int i,int j)
{
    memset(v,0,sizeof(v));
    queue<ii> q;
    q.push(ii{i,j});
    v[i][j]=1;
    while(!q.empty()){
        int x=q.front().first;
        int y=q.front().second;
        q.pop();
        res=max(res,v[x][y]-1);
        for(int i=0;i<4;i++){
            int nx=x+d[i][0];
            int ny=y+d[i][1];
            if(nx>=0&&nx<n&&ny>=0&&ny<m&&a[nx][ny]&&!v[nx][ny]){
                v[nx][ny]=v[x][y]+1;
                q.push(ii{nx,ny});
            }
        }
    }

}
void SolutionD()
{
    cin>>n>>m;
    res=0;
    for(int i=0;i<n;i++){
        for(int  j=0;j<m;j++){
            char c;
            cin>>c;
            a[i][j]=(c=='.');
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(a[i][j]) BFS(i,j);
        }
    }
    cout<<res<<endl;
}
int main()
{
	SolutionD();
}


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

int main(){
    int n; cin >> n;
    vector<int> X(n), Y(n);
    for (int i=0; i<n; i++){
        cin >> X[i];
        Y[i] = X[i];
    }
    sort(X.begin(), X.end());
    int m = n/2;
    for (int i=0; i<n; i++){
        if(Y[i]<X[m]) cout << X[m] << endl;
        else cout << X[m-1] << endl;
    }
}

Measured memory_bytes: 4736
#include <iostream>

using namespace std;

int main()
{
	long n,min,max,l;
	
	cin>>n;
	
	for (int i=0;i<n;i++)
	{
		cin>>l;
		if (i==0) {min=l; max=l;}
		if (l<min) min=l;
		if (l>max) max=l;
	}
	
	cout<<(max-min)<<endl;
	
	return 0;
}



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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  
  rep(i, N) {
    int A, B;
    cin >> A >> B;
    sum += (B - A + 1);
  }
  
  cout << sum << endl;
}

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

int main() {
	int N; cin >> N;
	if (N >= 1000) {
		cout << "ABD" << endl;
		return 0;
	}
	cout << "ABC" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
inline char tc(void){
	static char fl[10000],*A=fl,*B=fl;
	return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;
}
inline int read(void){
	int a=0;static char c;
	while((c=tc())<'0'||c>'9');
	while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();
	return a;
}
inline int cmp(int a,int b){
	return a>b;
}
int n,k,a[5001],dp[5001],b[5001],ans;
int main(void){
	register int i,j;
	n=read(),k=read();
	for(i=1;i<=n;++i)
		a[i]=read();
	sort(a+1,a+n+1,cmp);
	dp[0]=1;
	for(j=1;j<=n;++j)
		for(i=k-1;i>=0;--i){
			if(dp[i]&&i+a[j]>=k)b[j]=1;
			if(dp[i]&&i+a[j]<k)dp[i+a[j]]=1;
		}
	for(i=n;i>=1;--i)
		if(b[i]){
			ans=i;
			break;
		}
	printf("%d\n",n-ans);
	return 0;	
}

Measured memory_bytes: 256
N, K = map(int,input().split())
D = list(map(int,input().split()))
a = 10 
b = 10
c = 10
d = 10
e = 10
ans = 100000
for i in range(N,100000):
    if i >= 10000:
        a = i//10000
    if i >= 1000:
        b = (i//1000)%10
    if i >= 100:
        c = (i//100)%10
    if i >= 10:
        d = (i//10)%10
    e = i%10
    S = D.count(a) + D.count(b) + D.count(c) + D.count(d) + D.count(e)
    if S == 0:
        if ans > i:
            ans = i
print(ans)


Measured memory_bytes: 3064
// Problem : C - : (Colon)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		long double a,b,h,m;
		cin>>a>>b>>h>>m;
		long double ang = (60*h-11*m)/2.0;
		ang*=(acos(-1));
		ang/=180;
		//cout<<cos(ang)<<"\n";
		long double xxx  = a*a + b*b - 2*a*b*(cos(ang))  ;
		xxx = sqrtl(xxx);
		cout<<fixed<<setprecision(20)<<xxx;  	
    }
    return 0;
}


Measured memory_bytes: 4164
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
// #pragma GCC optimize("O2")
typedef long long int ll;
typedef long double ld;
typedef map <ll,ll> mm;
typedef vector <ll> mv;
typedef pair <ll,ll> mp;
typedef set <ll> ms;
typedef multiset <ll> mms;
typedef queue <ll> mq;
typedef deque <ll> mdq;
typedef stack <ll> mst;
typedef priority_queue <ll> mpq;
typedef priority_queue <ll, vector<ll>, greater<ll> > mmh;
typedef complex<double> cd;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define flush cout.flush();
#define all(v) v.begin(),v.end()
#define deb(x) cout << #x << " " << x << endl;
#define ff first
#define ss second
#define pb(v) push_back(v)
#define lb(v) lower_bound(v)
#define ub(v) upper_bound(v)
#define cn continue
#define forl(i,n) for(ll i=0;i<n;i++)
#define forlr(i,n) for(ll i=n-1;i>=0;i--)
#define rev(s) reverse(s.begin(),s.end())
void swap(ll &a,ll &b) {
	ll tmp=a;
	a=b;
	b=tmp;
}
ll atoistring(string s) {
	stringstream lol(s);
	ll x;
	lol>>x;
	return x;
}
void pv(mv v) {
	forl(i,v.size()) cout<<v[i]<<" ";
	cout<<"\n";
}
void pa(ll *v, ll size) {
	forl(i,size) cout<<v[i]<<" ";
	cout<<"\n";
}
void removeDups(mv &v) {
	sort(all(v));
	mv::iterator it = unique(v.begin(), v.end());
	v.resize(distance(v.begin(), it));
}
inline ld kthRoot(ld n, ll k) {
	return pow(k, (1.0 / k) * (log(n) / log(k)));
}
ll power(ll x, ll y, ll p) {
	ll res=1;
	x=x%p;
	while(y>0) {
		if(y&1) res = (res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
void checkmod(ll &x, ll mod) {
	if(x>=mod) x%=mod;
}

ll mod = 1e9 + 7;

void thisIsMain() {
	ll x;
	cin>>x;
	cout<<(!x)<<"\n";
}

int main(void)
{
	fastio
	ll t = 1;
	// cin>>t;
	while(t--) thisIsMain();
	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b,c,y,x,z;
    cin>>a>>b>>c;
    if((a[0]>='a'&&a[0]<='z')&&(b[0]>='a'&&b[0]<='z')&&(c[0]>='a'&&c[0]<='z'))
    {
        y=a[0]-32;
        cout<<y;
        x=b[0]-32;
        cout<<x;
        z=c[0]-32;
        cout<<z;
    }



    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(str(input()))
cntr = t.count("r")
cnts = t.count("s")
cntp = t.count("p")
cntr0 = 0
cnts0 = 0
cntp0 = 0
ans = 0
# print(t)
for i in range(n-k):
    if t[i] == "r"and t[i] == t[i+k]:
        cntr0 += 1
        t[i+k] = "q"
    elif t[i] == "s"and t[i] == t[i+k]:
        cnts0 += 1
        t[i+k] = "q"
    elif t[i] == "p"and t[i] == t[i+k]:
        cntp0 += 1
        t[i+k] = "q"

ans = p*(cntr - cntr0) + r*(cnts - cnts0) + s*(cntp - cntp0)
print(ans)
    



Measured memory_bytes: 4084
using System;
class count{
    public static void Main(){
        String str = Console.ReadLine();
        str = str+"*";
        String bigs = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        String smalls = "abcdefghijklmnopqrstuvwxyz";
        int[] count = new int[26];
        int o = 0;
        for(int i=0; i<26; i++){
            count[i] = 0;
        }
        while(!str.Equals("*")){
            foreach(char c in str){
                for(int i=0; i<26; i++){
                    if(c.Equals(bigs[i]) || c.Equals(smalls[i])){
                        count[i]++;
                    }
                }
            }
            str = Console.ReadLine();
            str = str+"*";
        }
        foreach(char c in smalls){
            Console.WriteLine("{0} : {1}",c,count[o]);
            o++;
        }
    }
}


Measured memory_bytes: 17900
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,k,e=0,o=0,a,c=1,b,d=0;
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a%2==0) e++;
    else o++;
  }
  for(int i=0;i<e;i++) c*=2;
  for(int i=k;i<=o;i+=2){
    b=1;
    for(int j=0;j<i;j++){
      b*=o-j;
      b/=j+1;
    }
    d+=b*c;
  }
  cout<<d;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int k,n,flag1=0,flag2=0;
   cin>>k>>n;
   int a[n];
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
       if(i>=1)
       {
         if(a[i]-a[i-1]>=flag2)
         {
            flag1=i;
            flag2=a[i]-a[i-1];
         }

       }
   }
   if(k-a[n-1]+a[0]>flag2)
   {
       cout<<k-(k-a[n-1]+a[0]);
   }
   else
   {
       cout<<k-a[flag1]+a[flag1-1];
   }
    return 0;
}


Measured memory_bytes: 1024
def insertion_sort(l, g):
    cnt = 0
    for i in range(g, len(l)):
        tmp = l[i]
        j = i - g
        while j >= 0 and l[j] > tmp:
            l[j+g] = l[j]
            cnt += 1
            j -= g
        l[j+g] = tmp

    return l, cnt


def shell_sort(l, lg):
    tot = 0
    for g in lg:
        sl, cnt = insertion_sort(l, g)
        tot += cnt
    return sl, tot


if __name__ == '__main__':
    N = int(input())
    l = []
    for _ in range(N):
        l.append(int(input()))

    lg = [1]
    while True:
        gc = 3 * lg[-1] + 1
        if gc > N:
            break
        lg.append(gc)

    lg = lg[::-1]

    print(len(lg))
    print(' '.join(map(str, lg)))
    sl, tot = shell_sort(l, lg)
    print(tot)
    for e in sl:
        print(e)



Measured memory_bytes: 45504
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;

    int a, b, c;
    io.read(a, b, c);
    set<int> st;
    st.insert(a);
    st.insert(b);
    st.insert(c);
    cout << st.size();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    double a,b,h,m;cin >> a >> b >> h >> m;
    double ans ;
    double theta = abs(30*h+30*m/60 - 360*m/60);
    // cout << theta/360 << endl;
    ans = a*a + b*b - 2*a*b*cos(2*3.14159265358979*theta/360);
    ans = sqrt(ans);
    cout << fixed << setprecision(11) << ans << endl;
}


Measured memory_bytes: 4200
#include<bits/stdc++.h>
#define dump(a) cout << #a << "=" << a << endl
using namespace std;

#define TREE_LEN 1001
#define STR_LEN 5000 //50+1000

char tree_str[TREE_LEN][STR_LEN];
int N;
string line;

void replace_before() {
	for(int y=0; y<N; y++) { //1~1000
		if (tree_str[y][0] != '.') { continue; } //??±??????????????°

		for(int x=0; x<STR_LEN; x++)
		{
			if (tree_str[y][x] != '.') { //?????????????????°
				if ((x-1) >= 0) {
					tree_str[y][x-1] = '+';
					break;
				}
			}
		}
	}
}

void replace_tate()
{
	for(int x=0; x<STR_LEN; x++) {
		bool is_start = false;
		//????§????,?????????????????????
		vector<pair<int,int> > ys;
		vector<int> tmp_pair;

		for(int y=0; y<N; y++) { //1~1000
			if ('a' <= tree_str[y][x] && tree_str[y][x] <= 'z') {
				tmp_pair.clear();
			}
			else if (tree_str[y][x] == '+') {
				if (tmp_pair.size() == 0) {
					tmp_pair.push_back(y+1);
				}
				else if (tmp_pair.size() == 1) {
					tmp_pair.push_back(y-1);
					ys.push_back(make_pair(tmp_pair[0],tmp_pair[1]));
					tmp_pair.clear(); //?????£??????
					tmp_pair.push_back(y+1);
				}
			}
		}

		for(int i=0; i<ys.size(); i++) {
			for (int y=ys[i].first; y<=ys[i].second; y++) {
				if (tree_str[y][x] == '.') { tree_str[y][x]='|'; }
			}
		}
	}
}

void replace_other() {
	for(int y=0; y<N; y++) { //1~1000
		for(int x=0; x<STR_LEN; x++) {
			if (tree_str[y][x]=='.') {
				tree_str[y][x] = ' ';
			}
		}
	}
}


void show() {
	for(int y=0; y<N; y++) { //1~1000
		for(int x=0; x<STR_LEN; x++)
		{
			if (tree_str[y][x] == '0') {
				break;
			}
			else {
				cout << tree_str[y][x];
			}
		}
		cout << endl;
	}
}

int main() {
	while(cin >> N) {
		if (N == 0) { break; }

		for(int y=0; y<N; y++) { //1~1000
			for(int x=0; x<STR_LEN; x++) {
				tree_str[y][x] = '0';
			}
		}

		for(int y=0; y<N; y++) { //1~1000
			cin >> line;

			for(int x=0; x<line.size(); x++) {
				tree_str[y][x] = line[x];
			}
		}
		replace_before();
		replace_tate();
		replace_other();
		show();
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 6116
#include<bits/stdc++.h>
using namespace std;
long long int n,m,zrq;
int main() {
	cin>>n>>m;
	zrq=2*n;
	if(zrq>m)cout<<m/2<<endl;
	else if(zrq==m)cout<<n<<endl;
	else {
		m-=zrq;
		m/=4;
		cout<<n+m<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll read()
{
	char c;
	ll w=1;
	while((c=getchar())>'9'||c<'0')if(c=='-')w=-1;
	ll ans=c-'0';
	while((c=getchar())>='0'&&c<='9')ans=(ans<<1)+(ans<<3)+c-'0';
	return ans*w;
}
int n,m;
struct node
{
	int next,to;
}e[1000005];
int cnt;
int h[1000005];
void add(int x,int y)
{
	cnt++;
	e[cnt].next=h[x];
	h[x]=cnt;
	e[cnt].to=y;
}
int vis[1000005];
void dfs(int x)
{
	if(vis[x])return;
	vis[x]=1;
	for(int i=h[x];i;i=e[i].next)
	{
		dfs(e[i].to);
	}
}
int main(){
	n=read();
	m=read();
	for(int i=1;i<=m;i++)
	{
		int a,b;
		a=read();
		b=read();
		add(a,b);
		add(b,a);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			dfs(i);
			ans++;
		}
	}
	cout<<ans-1<<endl;
	return 0;
}

Measured memory_bytes: 6796
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

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

    int ans = -1;
    
    for (int i = 0; i <= 1001; i++) {
        int temp = i * 0.08;
        int temp2 = i * 0.1;
        if (temp == a && temp2 == b) {
            ans = i;
            cout << ans << endl;
            exit(0);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <algorithm>
#define ll long long
#define INF 100000000000000
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);
  ll V, E, r;
  cin >> V >> E >> r;
  
  vector< vector< pair<ll,ll> > > edges(V);
  
  for(ll i = 0; i < E; i++){
    ll s,t,d;
    cin >> s >> t >> d;
    edges[s].push_back(make_pair(t,d));
  }
  vector<ll> dist(V, INF);
  dist[r] = 0;
  priority_queue< pair<ll,ll>, vector< pair<ll,ll> >, greater< pair<ll,ll> > > pq;
  pq.push(make_pair(0,r));
  while(!pq.empty()){
    ll source = pq.top().second;
    pq.pop();
    for(pair<ll,ll> edge: edges[source]){
      if(dist[edge.first] > dist[source] + edge.second){
	dist[edge.first] = dist[source] + edge.second;
	pq.push(make_pair(dist[edge.first],edge.first));
      }
    }
  }

  
  for(ll i = 0; i < V; i++){
    if(dist[i] == INF){
      cout << "INF" <<endl;
    }else{
      cout << dist[i] << endl;
  }
  }
  

}

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

int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	for(auto &i:a)cin >> i;
	sort(a.begin(),a.end());
	
	if(N%3!=0){
		if(a[N-1]==0)cout << "Yes" << endl;
		else cout << "No" << endl;
		return 0;
	}
	
	bool flag=true;
	for(int i=0;i+1<N/3;i++)if(a[i]!=a[i+1])flag=false;
	for(int i=N/3;i+1<N/3*2;i++)if(a[i]!=a[i+1])flag=false;
	for(int i=N/3*2;i+1<N;i++)if(a[i]!=a[i+1])flag=false;
	
	if(flag){
		int X=a[0];
		X^=a[N/3];
		X^=a[N/3*2];
		if(X!=0)flag=false;
	}
	
	if(flag)cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 640