akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int l[4][13] = {};
    int n,s, ms;
    string m;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> m >> s;
        
        if(m == "S"){
            ms = 0;
        } else if(m == "H") {
            ms = 1;
        } else if(m == "C") {
            ms = 2;
        } else {
            ms = 3;
        }
        l[ms][s-1] = 1;
        
    }
    for(int i = 0; i <= 3; i++){
        for(int j = 0; j <= 12; j++){
            if(l[i][j] == 0){
                if(i == 0){
                    cout << "S" << " " << j + 1 << endl;
                } else if (i == 1){
                    cout << "H" << " " << j + 1 << endl;
                } else if (i == 2){
                    cout << "C" << " " << j + 1 << endl;
                } else if (i == 3){
                    cout << "D" << " " << j + 1 << endl;
                }
            }
        }
    }
    return 0;
}


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

using namespace std;

int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    vector<long long> a(3);

    for(long long i = 0 ; i < 3 ; i++) {

        cin >> a[i];

    }

    if(accumulate(a.begin(),a.end(),0LL)>=22) {

        cout << "bust" << '\n';

    } else {

        cout << "win" << '\n';

    }

    return 0;

}



Measured memory_bytes: 3600
n, k = map(int, input().split())
A = [*map(int, input().split())]
P, M = [], [] # plus, minus
for a in A:
    if a < 0: M.append(a)
    else: P.append(a)

def mix():
    len_p = len(P); len_m = len(M)
    P.sort(reverse=True); M.sort()
    P.append(-1); M.append(1) # add endpoint
    pa, ma = [], []
    while len(pa) + len(ma) < k:
        if P[len(pa)] < -M[len(ma)]: ma.append(M[len(ma)])
        else: pa.append(P[len(pa)])
    if len(ma)%2 == 0: return pa + ma
    exist_pa = len(pa) > 0; exist_ma = len(ma) > 0
    remain_p = len_p - len(pa) > 0; remain_m = len_m - len(ma) > 0
    if exist_pa & exist_ma & remain_p & remain_m:
        if abs(pa[-1] * P[len(pa)]) < abs(ma[-1] * M[len(ma)]):
            pa.pop(); ma.append(M[len(ma)])
        else:
            ma.pop(); pa.append(P[len(pa)])
    elif exist_ma & remain_p:
        ma.pop(); pa.append(P[len(pa)])
    elif exist_pa & remain_m:
        pa.pop(); ma.append(M[len(ma)])
    else:
        P.pop(); M.pop()
        P.sort(); M.sort(reverse=True)
        P.append(-1); M.append(1) # add endpoint
        pa, ma = [], []
        while len(pa) + len(ma) < k:
            if P[len(pa)] >= -M[len(ma)]: ma.append(M[len(ma)])
            else: pa.append(P[len(pa)])
        if len(ma)%2 == 1: return pa + ma
        exist_pa = len(pa) > 0; exist_ma = len(ma) > 0
        remain_p = len_p - len(pa) > 0; remain_m = len_m - len(ma) > 0
        if exist_pa & exist_ma & remain_p & remain_m:
            if abs(pa[-1] * P[len(pa)]) >= abs(ma[-1] * M[len(ma)]):
                pa.pop(); ma.append(M[len(ma)])
            else:
                ma.pop(); pa.append(P[len(pa)])
        elif exist_ma & remain_p:
            ma.pop(); pa.append(P[len(pa)])
        elif exist_pa & remain_m:
            pa.pop(); ma.append(M[len(ma)])
    return pa + ma

ans_list = []
if k==n: ans_list = A
elif len(P) == n: ans_list = sorted(P, reverse=True)[:k]
elif len(M) == n: ans_list = sorted(M, reverse=k%2)[:k]
else: ans_list = mix()
MOD = 10**9 + 7
ans = 1
for a in ans_list: ans *= a; ans %= MOD
ans += MOD; ans %= MOD
print(ans)


Measured memory_bytes: 31824
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
int N;
int Array[105];
map <int, int> M;
int DP[105][105][105];
const int MOD = 1000000007;
void Read()
{
    cin >> N;
    for(int i = 1; i <= N * 2 - 1; i++)
        cin >> Array[i];
    sort(Array + 1, Array + N * 2 - 1 + 1);
}
void Add(int& x, int y)
{
    x += y;
    if(x >= MOD)
        x -= MOD;
}
void Solve()
{
    DP[1][1][1] = 1;
    M[Array[N]] = 1;
    int ans = 0;
    int l = N, r = N;
    for(int i = 1; i <= N; i++)
    {
        l--;
        r++;
        int st = 0, cand = 0;
        if(M[Array[l]] == 0)
            st++, cand++;
        if(M[Array[r]] == 0)
            cand++;
        M[Array[l]] = 1;
        M[Array[r]] = 1;
        for(int j = 1; j <= N * 2 - 1; j++)
            for(int k = 1; k <= j; k++)
            {
                if(DP[i][j][k] == 0)
                    continue;
                if(i == N)
                    Add(ans, DP[i][j][k]);
                for(int p = 1; p <= j + cand; p++)
                {
                    if(p < k + st)
                    {
                        Add(DP[i + 1][j + cand - (k + st - p - 1)][p], DP[i][j][k]);
                    }
                    if(p > k + st)
                        Add(DP[i + 1][j + cand - (p - k - st - 1)][k + st + 1], DP[i][j][k]);
                }
                Add(DP[i + 1][j + cand][k + st], DP[i][j][k]);
            }
    }
    cout << ans << "\n";
}
int main()
{
    Read();
    Solve();
    return 0;
}


Measured memory_bytes: 3328
import java.util.*;
import java.text.*;

class Main {
    public static void main(String[]args)throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();
        int [][] a = new int[n][m];
        int [][] b = new int[m][l];
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        for(int j = 0; j < m; j++) {
            for(int k = 0; k < l; k++) {
                b[j][k] = sc.nextInt();
            }
        }
        long [][] x = new long[n][l];
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                for(int k = 0; k < l; k++) {
                    x[i][k] += a[i][j]*b[j][k];
                }
            }
        }
        for(int i = 0; i < n; i++) {
            for(int k = 0; k < l; k++) {
                System.out.print((k == 0 ? "" : " ") + x[i][k]);
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 45068
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	for (int i = 1; i <=  b; i++) {
		if (i*a % b == c) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
long long a[100001], b[100001][3], c[100001];
int main() {
	long long n, m;
	cin >> n >> m;
	for (int i = 0; i <= n; i++) a[i] = 0;
	for (int i = 0; i < m; i++) cin >> c[i];
	for (int i = 1; i < n; i++) 
		cin >> b[i][0] >> b[i][1] >> b[i][2];
	for (int i = 0; i < m-1; i++) {
		if (c[i] < c[i + 1]) {
			for (int j = c[i]; j < c[i + 1]; j++) {
				a[j]++;
			}
		}
		else {
			for (int j = c[i]-1; j >= c[i+1]; j--)
				a[j]++;
		}
	}
	long long sum = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] * b[i][0] > a[i] * b[i][1] + b[i][2])
			sum += (a[i] * b[i][1] + b[i][2]);
		else sum += (a[i] * b[i][0]);
	}
	cout << sum << endl;
}

Measured memory_bytes: 7016
#include <iostream>

using namespace std;

int main() {
    long long H, W;
    cin >> H >> W;
    if (H == 1 || W == 1) {
        cout << 1 << endl;
    } else {
        long long ans = H * W % 2 ? (H * W + 1) / 2 : H * W / 2;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <utility>
#include <vector>
#include <iostream>
#include <cstdlib>
#include<bits/stdc++.h>
#include <limits>
#include <set>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef long long ll;
ul gcd(ul a, ul b){return b? gcd(b, a%b):a;}
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    int locate = -1;

    for(int i = S.length()-1; i >= 0; i--){
        if(S.length()-i < T.length()){
            continue;
        }
        bool flag = true;
        for(int j = 0; j < T.length(); j++){
            if(S.at(i+j)=='?'||S.at(i+j)==T.at(j)){
                continue;
            }else{
                flag = false;
                break;
            }
        }
        if(flag){
            locate = i;
            break;
        }
    }
    if(locate < 0) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	for(int i = 0; i < T.length(); i++) {
		S[i + locate] = T[i];
	}
	for(int i = 0; i < S.length(); i++) {
		if(S[i] == '?') S[i] = 'a';
	}
    cout << S << endl;
    return 0;
}

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

int INF = 1e9 + 7;

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

int main() {
	int n, a;
	cin >> n;
	vector<int> b(10, 0);
	for (int i = 1; i <= n; i++) {
		cin >> a;
		if (a <= 399) b[1] = 1;
		else if (a <= 799) b[2] = 1;
		else if (a <= 1199) b[3] = 1;
		else if (a <= 1599) b[4] = 1;
		else if (a <= 1999) b[5] = 1;
		else if (a <= 2399) b[6] = 1;
		else if (a <= 2799) b[7] = 1;
		else if (a <= 3199) b[8] = 1;
		else b[9]++;
	}
	int ans = 0;
	for (int i = 1; i <= 8; i++) ans += b[i];
	if(!ans) cout << 1 << " " << b[9] << endl;
	else cout << ans << " " << ans + b[9] << endl;
}

Measured memory_bytes: 256
#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; } //最小公倍数

int vector_finder(vector<int> vec, int number) {
  auto itr = find(vec.begin(), vec.end(), number);
  size_t index = distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

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

int main(){
  ll a,b;
  cin >> a >> b;
  cout << (a+b*2)/(b*2+1) << endl;
}

Measured memory_bytes: 256
///who is the king ??? *** << t.mohammad >> *** ///
/*
                  00                                                                                                            00
                 00                               00                                                                           00
            0000000000                           00                                                                           00
           0000000000   000       000           00                        000       000  000       000                       00
              00       0000     0000           00         000000         0000     0000  0000     0000   000000              00
             00       00 00   00 00    000    00        00000000        00 00   00 00  00 00   00 00  00000000       00000000
            00       00  00 00  00   00000   000000    00    000       00  00 00  00  00  00 00  00  00    000     0000000000
           00       00   000   00  00   00  00000000  00    0000      00   000   00  00   000   00  00    0000    00     0000
          00       00         00  00   00  00    00  00    00 00     00         00  00         00  00    00 00   00     00 00
         00  00   00         00   00000   00    00  00000000  00    00         00  00         00  00000000  00  000000000  00
        00  00   00         00    000    00    00   000000    00   00         00  00         00   000000    00  0000000    00
*/
#include <bits/stdc++.h>
using namespace std ;
typedef long long int ll;
typedef long double dou ;
typedef pair<ll , ll> pii;
typedef map<ll, bool> mib;
typedef pair<ll, bool> pib;
typedef map<ll , ll> mii;
#define wh while
#define str string
#define vec vector
#define fori(a1 , a2 , a3) for(ll i = a1 ; i < a2 ; i = i + a3)
#define for_i(b1 , b2 , b3) for(ll i = b1 ; i >= b2 ; i = i - b3)
#define forj(c1 , c2 , c3) for(ll j = c1 ; j < c2 ; j = j + c3)
#define for_j(d1 , d2 , d3) for(ll j = d1 ; j >= d2 ; j = j - d3)
#define fore(e1 , e2 , e3) for(ll e = e1 ; e < e2 ; e = e + e3)
#define for_e(f1 , f2 , f3) for(ll e = f1 ; e >= f2 ; e = e - f3)
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ff first
#define ss second
#define fast ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
#define setp(t) cout << setprecision(t) << fixed ;
str s[3] ;
set <ll> q ;
int main(){
	fast ;
	ll n ;
	cin >> n ;
	fori(0 , 3 , 1)
	{
		cin >> s[i] ;
	}
	ll fin = 0 ;
	fori(0 , n , 1)
	{
		q.clear() ;
		q.insert(s[0][i]) ;
		q.insert(s[1][i]) ;
		q.insert(s[2][i]) ;
		fin = fin + (q.size() - 1) ;
	}
	cout << fin ;
}




Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
int a, b, d, r;
double f;
scanf("%d %d",&a, &b);
d = a / b;
r = a % b;
f = 1.000000 * a / b ;
printf("%d %d %.6lf\n",d, r, f); 
return 0 ;
}



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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cerr << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

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

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

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

const int maxn = 210;
const ll MOD = 998244353;
const ll i2 = (MOD + 1) / 2;

ll p2[maxn];
bool f[maxn][maxn];

int main() {
	p2[0] = 1;
	for (int i = 1; i < maxn; ++i) {
		p2[i] = p2[i-1] * 2 % MOD;
	}

	int N; cin >> N;
	V<pii> pt;
	rep(i, N) {
		int x, y;
		cin >> x >> y;
		pt.eb(x, y);
	}

	ll all = p2[N];
	ll ng = 1 + N;

	rep(i, N) {
		rep(j, N) if (j != i) {
			if (f[i][j]) continue;
			V<int> vec{i, j};

			rep(k, N) {
				if (k != i && k != j) {
					int a = pt[k].fi - pt[i].fi, b = pt[k].se - pt[i].se;
					int p = pt[j].fi - pt[i].fi, q = pt[j].se - pt[i].se;
					if (a * q - b * p == 0) {
						vec.pb(k);
					}
				}
			}

			int sz = vec.size();
			rep(a, sz) {
				rep(b, a) {
					f[vec[b]][vec[a]] = f[vec[a]][vec[b]] = 1;
				}
			}
			dump(sz);

			ll u = (p2[sz] - sz - 1) % MOD;
			if (u < 0) u += MOD;
			ng += u;
			ng %= MOD;
		}
	}

	all -= ng;
	if (all < 0) all += MOD;
	cout << all << endl;

	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
h = gets.split.map(&:to_i)+[0]
a = [10**18]*(n+2)
a[0] = 0

(n-1).times{|i|
  a[i+2] = a[i]+(h[i]-h[i+2]).abs if a[i+2] > a[i]+(h[i]-h[i+2]).abs
  a[i+1] = a[i]+(h[i]-h[i+1]).abs if a[i+1] > a[i]+(h[i]-h[i+1]).abs
}

p a[n-1]

Measured memory_bytes: 9612
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    string S;cin>>S;
    S[3]='8';
    cout<<S<<endl;
}

Measured memory_bytes: 3520
def examA():
    M1, D1 = LI()
    M2, D2 = LI()
    if D1+1==D2:
        ans = 0
    else:
        ans = 1
    print(ans)
    return


def examB():
    return

def examC():
    return

def examD():
    return
def examE():
    return

def examF():
    return

import sys,copy,bisect,itertools,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

int32_t main()
{
    IOS;
string s;
cin>>s;
int n=s.size();
char cur[]={'W','B'};
int state=1;
int ans1=0,ans2=0;
if(s[0]!=cur[state])state^=1;

    for (int i = 0; i < n; ++i) {
        if(s[i]!=cur[state])state^=1,ans1++;
    }
    if(s[n-1]!=cur[state])state^=1;
    for (int i = n-1; i >=0 ; --i) {
        if(s[i]!=cur[state])state^=1,ans2++;
    }
    cout<<min(ans2,ans2);
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j,f[6];
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	for(i=1; i<=5; i++) cin>>f[i];
	for(i=1; i<=5; i++){
		if(f[i]==0){
			cout<<i;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3616
#include<iostream>
using namespace std;
typedef long long ll;
ll num[100005]={0};
int main(){
  ll n,x;
  cin>>n>>x;
  for(int i=1;i<=n;i++) cin>>num[i];
  ll ok_l=0;
  for(int i=1;i<n;i++){
    if(num[i]+num[i+1]>=x) ok_l=i;
  }
  if(ok_l==0){
    cout<<"Impossible"<<endl;
    return 0;
  }
  cout<<"Possible"<<endl;
  for(int i=1;i<ok_l;i++) cout<<i<<endl;
  for(int i=n-1;i>ok_l;i--) cout<<i<<endl;
  cout<<ok_l<<endl;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    lint N;
    cin >> N;
    vec<lint> a_list(N);
    range(i, 0, N) cin >> a_list.at(i);
    unordered_map<lint, lint> count;
    for (const auto a : a_list) {
        count[a - 1] += 1;
        count[a] += 1;
        count[a + 1] += 1;
    }
    // cout << count << "\n";
    lint max_count = 0;
    for (const auto item_with_count : count) {
        lint c = item_with_count.second;
        max_count = max(max_count, c);
    }
    cout << max_count << "\n";
}

Measured memory_bytes: 5028
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <math.h> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int main(){
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    ll t,a,b;
    cin >> t >> a >> b;
    ll res = 0;

    res = min(a*t,b);
 
    cout << res << endl;


    return 0;    

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int k,a,b;
    cin >>k;
    cin >>a >> b;
    if(a%k==0 || b%k==0 || a%k > b%k || (b-a+1)>=k)cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>
 
int a,b,c,i;
int d=0;
int main(void){
  scanf("%d %d %d",&a,&b,&c);
  //printf("%d %d %d",a,b,c);
  for(i=a;i<=b;i++){
    if(c%i==0){
    d++;}
    else;
}
      printf("%d\n",d);
return 0;
}


Measured memory_bytes: 2108
#include <stdio.h>
typedef long long ll;

//引数：n=対象の数値[in]、x=最上位桁数[out]、dig=桁数[out]	
//返値：0=成功、-1=最上位桁以外の数値がすべて9
int get_dig(ll n, int *x, int *dig){
  	int flag=1;
	while(n!=0){
		*x = (int)n;
      	if(n/10 && n%10!=9){ flag=0; }
		n /= 10;
		*dig+=1;
	}
  	if( flag ){ return -1; }
  	else	  { return  0; }
}
int main(){
  	ll	n;
	int	ans,top,dig=0;
  	scanf("%lld", &n);
	if( get_dig(n, &top, &dig) == -1 ){ ans =  top   +(9*(dig-1)); }
  	else							  { ans = (top-1)+(9*(dig-1)); }
  	printf("%d\n", ans);
  	return 0;
}

Measured memory_bytes: 1688
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int p,q,r;
    cin>>p>>q>>r;
    cout<<min(p+r,min(p+q,r+q))<<endl;
    return 0;
}


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

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MN = 1e5 + 5, LN = 17, INF = 0x3f3f3f3f, MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    int a[3]; cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    int cnt = 3;
    if (a[0] == a[1]) cnt--;
    if (a[1] == a[2]) cnt--;
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 256
//
// Created by yamunaku on 2020/01/26.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    int n, k;
    cin >> n >> k;
    vi h(n);
    rep(i, n){
        cin >> h[i];
    }
    sort(all(h));
    ll ans = 0;
    rep(i, n - k){
        ans += h[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main() {
    int n;
    cin >> n;
    map<int, int> m;
    rep(i, n) {
        int a;
        cin >> a;
        m[a]++;
    }

    int ans = 0;
    for(auto p : m) {
        int x = p.first;
        int cnt = p.second;
        if(cnt < x) ans += cnt;
        else ans += (cnt - x);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4736
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void) {
	int i,j,h,n,K;cin>>n>>K;
	llint dp[101][256]={0};
	dp[0][0]=1;
	for(i=0;i<n;i++){
		int x;cin>>x;
		for(j=i;j>=0;j--){
			for(h=0;h<256;h++){
				dp[j+1][h^x]+=dp[j][h];
				dp[j+1][h^x]%=mod;
			}
		}
	}
	llint ans=0,kai=1;
	for(i=0;i<=n;i++){
		ans+=dp[i][K]*kai;
		ans%=mod;
		kai*=(i+1);
		kai%=mod;
	}
	cout<<ans<<endl;
	
	return 0;
}


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(10);

}

signed main() {
	string mon[12] = { "01", "02", "03", "04", "05", "06",  "07", "08", "09", "10", "11", "12" };
	string s;
	bool ans1 = false;
	bool ans2 = false;

	cin >> s;

	string s1 = s.substr(0, 2);
	string s2 = s.substr(2);

	REP(i, 12) {
		if (s2 == mon[i]) {
			ans1 = true;
		}

		if (s1 == mon[i]) {
			ans2 = true;
		}
	}

	if (ans1 && ans2) {
		cout << "AMBIGUOUS" << endl;
	}
	else if (ans1) {
		cout << "YYMM" << endl;
	}
	else if (ans2) {
		cout << "MMYY" << endl;
	}
	else {
		cout << "NA" << endl;
	}
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    transform(s.begin()+k-1,s.begin()+k, s.begin()+k-1,::tolower);

    cout << s << endl;
    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	string S;
	cin >> S;
	if (S[S.size()-1]=='s') {
		ce((S+"es"))
	}
	else {
		ce((S + "s"))
	}
    return 0;
}



Measured memory_bytes: 3628
#include<cstdio>
#include<algorithm>
#define MAXN 1000+10

using namespace std;
int main(){
    long long n,m;
    scanf("%lld %lld",&n,&m);
    long long ans=0;
    if(m<2*n){//s无法用完
        ans+=m/2;
        n-=m/2;
        m%=2;
    }
    else if(m>=2*n){//全部s用完
        ans+=n;
        m-=2*n;//1个s消耗两个c
        n=0;
    }
    if(m>=4){//scc友4个c组成
        ans+=m/4;
        m%=4;
    }
    printf("%lld\n",ans);
    return 0;
}


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

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc int t; cin >> t; while(t--)
#define sz(x) (int)(x).size()
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep = ""; for(const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << "\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

const int N = 1e5+5;
LL dp[N];
LL cost[105], val[105];

void solve(){
    int n, w;
    cin >> n >> w;
    for(int i = 0; i < n; ++i) cin >> cost[i] >> val[i];

    memset(dp, 0, sizeof dp);
    for(int i = 1; i <= n; ++i){
        for(int j = w; j >= cost[i-1]; --j)
            dp[j] = max(dp[j], dp[j-cost[i-1]] + val[i-1]);
    }

    cout << dp[w] << "\n";
}

int main()
{
    Fast;
    //louisfghbvc{
        solve();
    //}
    return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	vector<string>s(3);
	for(auto&i:s)cin>>i;
	vector<int>abc(3,0);
	for(int i=0,tmp;;){
		if(s.at(i).size()==abc.at(i)){
			cout<<static_cast<char>('A'+i)<<"\n"s;
			break;
		}
		tmp=i;
		i=s.at(i).at(abc.at(i))-'a';
		++abc.at(tmp);
	}
}

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef pair<ll, ll> PLL;

const ll M=1e9+7;

ll mpow(ll x, ll y, ll m) {
    if (y==0)
        return 1;
    else if (y%2==1)
        return x * mpow(x, y-1, m)%m;
    else
        return mpow(x*x%m, y/2, m)%m;
}

// mod inverse 法mにおけるxの逆数
ll minverse(ll x, ll m) {
    return mpow(x, m-2, m);
}

ll  fact[100010];
ll rfact[100010];
void c3_init(ll m) {
    fact[1]  = rfact[1] = 1;
    for (ll i = 2; i < 100010; i++) {
        fact[i] = (fact[i-1]*i)%m;
        rfact[i] = minverse(fact[i], m);
    }
}

ll c3(ll n, ll k, ll m) {
    if (n<k)
        return 0;
    else if (n == k || k == 0)
        return 1;
    else
        return (((fact[n] * rfact[k])%m) * rfact[n-k])%m;
}


signed main() {
    c3_init(M);
    ll N;
    cin>>N;
    vector<ll> a(N+1);

    ll p,q;
    map<ll, ll> m; // val -> index

    rep(i,0,N+1) {
        cin>>a[i];
        auto it = m.find(a[i]);
        if (it == m.end()){
            m[a[i]] = i;
        } else {
            p = i;
            q = m[a[i]];
        }
    }

    // printf("%d is found at index %d and index %d\n", a[p], p, q);
    // (29) 19 (31) (9) が重複する数列
    rep(k, 1, N+2){
        ll ans = c3(N+1, k, M);
        ans -= c3(N-p+q, k-1, M);
        if (ans < 0)
            ans+=M;
        cout<<ans%M<<endl;
    }
    return 0;
}


Measured memory_bytes: 9856
#include <stdio.h>
#include <stdlib.h>

void mergeSort(int*,int,int);
void merge(int*,int,int,int);

int count=0;

int main(){
  int i,n,*S;

  scanf("%d",&n);
  S=(int*)malloc(sizeof(int)*n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);

  mergeSort(S,0,n);

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

void mergeSort(int *A, int left, int right){
  int mid,i;
  if (left+1<right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

void merge(int *A,int left,int mid,int right){
  int n1,n2,*L,*R,i,k,j;
  n1=mid-left;
  n2=right-mid;
  L=(int*)malloc(sizeof(int)*(n1+1));
  R=(int*)malloc(sizeof(int)*(n2+1));
  for(i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=A[mid +i];
  }
  L[n1]=1073741823;
  R[n2]=1073741823;
  i=0;
  j=0;
  for (k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i=i+1;
    }
    else{ 
      A[k]=R[j];
      j=j+1;
    }
    count++;
  }
}

Measured memory_bytes: 63348
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

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

  int a, b, c; cin >> a >> b >> c;
  cout << b + min(c,a+b+1) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
typedef long long ll;
const int N=400+10;
int h, w, g[N][N], vis[N][N], d[5][5];
ll cb, cw, ans=0;
inline void dfs( int x, int y )
{
	vis[x][y]=1; 
	if ( g[x][y] ) ++cb;
	else ++cw;
	for ( int i=1; i<=4; i++ )
	{
		int dx=x+d[i][1], dy=y+d[i][2];
		if ( !vis[dx][dy]&&g[dx][dy]!=g[x][y]&&dx>=1&&dx<=h&&dy>=1&&dy<=w ) dfs( dx, dy );
	}
}
int main()
{
	scanf( "%d%d\n", &h, &w );
	for ( int i=1; i<=h; i++ )
	{
		char s[N];
		scanf( "%s", &s );
		for ( int j=1; j<=w; j++ ) 
		  if ( s[j-1]=='#' ) g[i][j]=1;
		  else g[i][j]=0;
	}
	d[1][1]=1, d[2][1]=-1, d[3][2]=1, d[4][2]=-1;
	for ( int i=1; i<=h; i++ )
	  for ( int j=1; j<=w; j++ )
	  {
	  	  if ( vis[i][j] ) continue;
		  cb=cw=0;
		  dfs( i, j );
		  ans+=cb*cw;
	  }
	printf( "%lld", ans );
	return 0;
}

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

using namespace std;

int main() {
	string t;
	cin >> t;
	bool flag = false;
	for (auto& i : t)
	{
		if (i == '?') {
			i = 'D';
		}
	}
	cout << t << endl;
}

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

using namespace std;

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

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N, M;
	map<string, int> m;
	cin >> N;
	string tmp;
	REP(i, 0, N){
		cin >> tmp;
		m[tmp] += 1;
	}
	cin >> M;
	REP(i, 0, M){
		cin >> tmp;
		m[tmp] -= 1;
	}
	int ans = 0;
	
	for(auto x=m.begin(); x != m.end(); ++x){
		ans = max(ans, x->S);
	}
	cout << ans;
	

}


Measured memory_bytes: 256
from numpy import *

n, m = map(int, input().split())
l = []
for _ in range(m):
   *a, = map(int, input().split())
   l.append(a[1:])
*p, = map(int, input().split())

ans = 0
for t in range(2**n):
   tmp = array([t >> s & 1 for s in range(n)])
   if p == [sum(tmp[array(i)-1]) % 2 for i in l]:
      ans += 1

print(ans)


Measured memory_bytes: 12448
using System;
public class Hello{
    public static void Main(){
        var array = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
        int A = array[0];
        int B = array[1];
        
        int X = B - A;
        
        int ans = X * (X + 1) / 2 - B;
        Console.WriteLine(ans);
        
    }
}

Measured memory_bytes: 11092
def solve():
    N = int(input())
    S = [input() for _ in range(N)]
    print('AC x {}'.format(S.count('AC')))
    print('WA x {}'.format(S.count('WA')))
    print('TLE x {}'.format(S.count('TLE')))
    print('RE x {}'.format(S.count('RE')))

if __name__ == "__main__":
    solve()

Measured memory_bytes: 16084
import java.util.Scanner;
import java.util.TreeSet;

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

    // 思考停止整数取得
    int a =  scanner.nextInt();
    int b =  scanner.nextInt();
    int c =  scanner.nextInt();

    // list（普通のコレクション）, map（マッピングありコレクション）, set（重複なしコレクション）
    TreeSet<Integer> colorSet = new TreeSet<>();
    // ArrayList<Integer> colorList = new ArrayList<>();

    // 重複なしコレクションに色a, b, cを追加していく（重複は無視される）
    colorSet.add(a);
    colorSet.add(b);
    colorSet.add(c);
    System.out.println(colorSet.size());
  }
}

Measured memory_bytes: 35704
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>

using namespace std;
typedef long long ll;

int H,W;
char S[20][20];
char T[20][20];
int a[20][20];

struct Corr {
    int y;
    int x;
};

int bfs(int s_y, int s_x){
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      a[i][j]=-1;
    }
  }
  int y_vec[4];
  y_vec[0]=0;
  y_vec[1]=0;
  y_vec[2]=-1;
  y_vec[3]=1;
  int x_vec[4]; 
  x_vec[0]=-1;
  x_vec[1]=1;
  x_vec[2]=0;
  x_vec[3]=0;
  queue<Corr> q;
  Corr start = {s_y, s_x};
  a[s_y][s_x]=0;
  q.push(start);
  while(!q.empty()){
    Corr now = q.front();
    q.pop();
    int y = now.y;
    int x = now.x;
    for(int i=0;i<4;i++){
      Corr next = {y + y_vec[i], x + x_vec[i]};
      if(0 <= next.y && next.y < H && 0 <= next.x && next.x < W && S[next.y][next.x]=='.' && a[next.y][next.x]==-1){
	a[next.y][next.x] = a[now.y][now.x]+1;
	q.push(next);
      }
    }
  }
  int m = 0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      m = max(m,a[i][j]);
    }
  }
  return m;
}

int main(){
  cin >> H >> W;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> S[i][j];
      //a[i][j]=0;
    }
  }
  int ans = 0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(S[i][j]=='.') ans = max(ans , bfs(i,j));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3176
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}
int a[200010];
signed main() {
	int n, m;
	cin >> n >> m;
	rep(i, n) {
		cin >> a[i];
	}
	sort(a, a + n);
	reverse(a, a + n);
	int sum = m, ans = 0;
	rep(i, n) {
		if (sum > 0) {
			sum--;
		}
		else {
			ans += a[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
int N;
struct P {
	LL x,y;
	P() {};
	P(LL x,LL y):x(x),y(y) {}
	P operator +(P p) {
		return P(x+p.x,y+p.y);
	}
	P operator -(P p) {
		return P(x-p.x,y-p.y);
	}
	LL dot(P p) {
		return x*p.x+y*p.y;
	}
	LL det(P p) {
		return x*p.y-y*p.x;
	}
	bool operator ==(P p) {
		return x==p.x&&y==p.y;
	}
	double len() {
		return sqrt(x*x+y*y);
	}
};
P ps[105];
P po[105];
double pro[105];

bool cmp_x(const P &p,const P &q) {
	if(p.x!=q.x) return p.x<q.x;
	return p.y<q.y;
}
vector<P> convex_hull(P *ps,int n) {
	sort(ps,ps+n,cmp_x);
	int k=0;
	vector<P> qs(n*2);
	for(int i=0; i<n; i++) {
		while(k>1&&(qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0) k--;
		qs[k++]=ps[i];
	}
	for(int i=n-2,t=k; i>=0; i--) {
		while(k>t && (qs[k-1]-qs[k-2]).det(ps[i]-qs[k-1])<=0) k--;
		qs[k++]=ps[i];
	}
	qs.resize(k-1);
	return qs;
}
void calcPro(int i,P a,P b) {
//	printf("#%d\n",a.dot(b));
//	printf("#a=(%d,%d) b=(%d,%d)\n",a.x,a.y,b.x,b.y);
//	printf("#%f\n",a.len()*b.len());
//	printf("#%f\n",a.dot(b)/a.len()/b.len());
//	printf("#%f\n",acos(a.dot(b)/a.len()/b.len()));
	double x=a.dot(b)/a.len()/b.len();
	if(x<=-1+1e-10) pro[i]=0.5;
	else if(x>=1-1e-10) pro[i]=0.0;
	else pro[i]=acos(x)/(2*3.14159265358979);
//	printf("#pro=%f\n",pro[i]);
}
int main() {
	scanf("%d",&N);
	int x,y;
	for(int i=0; i<N; i++) {
		scanf("%d%d",&x,&y);
		po[i].x=ps[i].x=x;
		po[i].y=ps[i].y=y;
	}
	if(N==1) {
		printf("1\n");
		return 0;
	}
	if(N==2) {
		printf("0.50000000000000000000\n0.5000000000000000000\n");
		return 0;
	}
	vector<P> qs=convex_hull(ps,N);
	int n=qs.size();
	calcPro(0,qs[0]-qs[n-1],qs[1]-qs[0]);
	for(int i=1; i<n-1; i++) {
		calcPro(i,qs[i]-qs[i-1],qs[i+1]-qs[i]);
	}
	calcPro(n-1,qs[n-1]-qs[n-2],qs[0]-qs[n-1]);
	//print
	bool isok=false;
	for(int i=0; i<N; i++) {
		isok=false;
		for(int j=0; j<n; j++) {
			if(po[i]==qs[j]) {
				printf("%.20f\n",pro[j]);
				isok=true;
			}
		}
		if(!isok) printf("0.00000000000000000000000000\n");
	}
	return 0;
}





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

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

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

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N;
    cin >> N;

    vector<int> cnt(int(1e5) + 5);
    vector<int> a(N);
    set<int> st;
    for (auto &ai: a) {
        cin >> ai;
        cnt[ai]++;
        st.insert(ai);
    }

    int norm = 0;
    for (auto &si: st) {
        if (!(cnt[si] % 2)) {
            norm++;
        }
    }

    cout << (norm % 2 ? st.size() - 1 : st.size()) << "\n";

    return 0;
}


Measured memory_bytes: 5760
/*
___ is a raging sadist.
*/
//Destroy all WA at test 2
// Stay cool
// Pass the 4th wall..

#include "bits/stdc++.h"
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double
#define pow power
#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define siz(a) int((a).size())
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
#define endl "\n"
#define pi 3.14159265
const ll mod = 1000 * 1000 * 1000 + 7;
const ll mod1 = 998244353;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7; 
using namespace std;

ll power(ll x, ll y) 
{ 
   ll res = 1;      
  
   
    while (y > 0) 
    { 
       
        if (y & 1) 
            res = (long long)(res*x); 
  

        y = y>>1; 

        if (x<=100000000)
        x = (long long)(x*x);

        //cout<<x<<'\n'; 
    } 
    return res; 
} 






int main()
{

#ifndef ONLINE_JUDGE    
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif

fastio();

    ll n;
    cin>>n;

    ll maxn=0;

    ll a[n];

    For(i,0,n)
    cin>>a[i];

    ll sum=0;

    for(int i=0;i<n;i++)
    {
        maxn=max(a[i],maxn);
        sum+=maxn-a[i];
    }

    cout<<sum;

return 0;
}

// check all product based operations for integer overflow

Measured memory_bytes: 5200