akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int mod = 1e9+7;
const int maxn = 200005;
int T,n,m;
ll num[maxn];
ll step[maxn];
int main() {
	cin>>n>>m;
	int flag = 0;
	for(int i=0;i<m;i++){
		int t;
		cin>>t;
		num[t]=1;
		if(i>0&&num[t]&&num[t-1])
			flag = 1;
	}
	if(num[1]==1){
		step[2]=1;
	}
	else if(num[2]==1){
		step[1]=1;
	}
	else {
		step[1]=1;
		step[2]=2;
	}
//	cout<<step[1]<<endl<<step[2]<<endl;
	if(flag){
		cout<<0<<endl;
		//cout<<11111<<endl;
		return 0;
	}
	else {
		for(int i=3;i<=n;i++){
			if(num[i]){
				//cout<<11111<<endl;
				step[i]=0;
				step[i+1]=step[i-1];
				i++;
			}
			else {
				step[i]=step[i-1]+step[i-2];
				step[i]%=mod;
			}
		}
	}
	cout<<step[n]<<endl;
}



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

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

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

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main(){
    int N; cin >> N;
    
    vector<int> a( N );
    REP( i, N ) cin >> a[i];
    sort( ALL( a ) );


    int ans = -INF;
    REP( i, N - 1 ){
        if( abs( a[N - 1] / 2 - ans ) > abs( a[N - 1] / 2 - a[i] ) ){
            ans = a[i];
        }

        if( a[N - 1] % 2 == 1 ){
            if( abs( ( a[N - 1] + 1 ) / 2 - ans ) > abs( ( a[N - 1] + 1 ) / 2 - a[i] ) ){
                ans = a[i];
            }
        }
    }

    cout << a[N - 1] << " " << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();
	
	string s; cin >> s;
	map<char, int>mp;
	rep(i, 0, s.size()) {
		mp[s[i]]++;
	}
	bool is = true;
	for (auto p : mp) {
		if (p.second > 1)is = false;
	}
	cout << (is ? "yes" : "no") << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
int MOD=1000000007;
int main(){
    int N,d=100,a=0; cin >> N;
    int A;
    for(int i=0; i<N; i++){
        cin >> A;
        a=0;
        while(A%2==0){
            A/=2;
            a++;
        }d=min(d,a);
    }
    cout << d << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int H;
    while (1)
    {
        cin >> H;
        if (H == 0)
            break;
        int field[10][6] = {};
        for (int i = 0; i < H; i++)
            for (int j = 0; j < 5; j++)
                cin >> field[i][j];
        int ans = 0;
        while (1)
        {
            int score = 0;
            for (int i = 0; i < H; i++)
            {
                int cnt = 1;
                for (int j = 0; j < 4; j++)
                {
                    if (field[i][j] == field[i][j + 1] && field[i][j] != -1)
                        cnt++;
                    else
                    {
                        if (cnt >= 3)
                        {
                            score += cnt * field[i][j];
                            for (int k = j; k > j - cnt; k--)
                                field[i][k] = -1;
                        }
                        cnt = 1;
                    }
                }
                if (cnt >= 3)
                {
                    score += cnt * field[i][4];
                    for (int j = 4; j > 4 - cnt; j--)
                        field[i][j] = -1;
                }
            }
            if (score == 0)
                break;
            ans += score;
            for (int i = 0; i < 5; i++)
            {
                vector<int> v;
                for (int j = 0; j < H; j++)
                    if (field[j][i] != -1)
                        v.push_back(field[j][i]);
                reverse(all(v));
                for (int j = 0; j < v.size(); j++)
                    field[H - j - 1][i] = v[j];
                for (int j = v.size(); j < H; j++)
                    field[H - j - 1][i] = -1;
            }
            // for (int i = 0; i < H; i++)
            // {
            //     for (int j = 0; j < 5; j++)
            //         cout << field[i][j] << " ";
            //     cout << endl;
            // }
            // cout << endl;
        }
        cout << ans << endl;
    }
}


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

int main() {
  int n,d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  for (int i = 0;i < n;i++){
    for (int j = 0;j < d;j++){
      cin >> x[i][j];
    }
  }
  int ans = 0;
  
  for (int i = 0;i < n-1;i++){
    for (int j = i+1;j < n;j++){
      int t = 0;
      for (int k = 0;k < d;k++){
        t += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
      }
      for (int k = 1;k*k <= t;k++){
        if (k*k == t){
          ans++;
        }
      }
    }
  }
      
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <utility>
using namespace std;

int main()
{
    int k, cnt = 0;
    string s;
    
    cin >> s;
    k = s.size();

    for(int i = 0;i < k;i++){
        if(s[i] == 'o'){
            cnt++;
        }
    }

    if(15 - k >= 8 - cnt){
        cout << "YES";
    }
    else{
        cout << "NO";
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int n,A[20];

int solve(int i,int m){
	if(m == 0)return 1;
	if(i >= n)return 0;
	int res = solve(i+1,m) || solve(i+1,m-A[i]);
	return res;
}

int main(void){
	int q,m,i;

	scanf("%d",&n);
	for(i = 0;i < n;i++){
	scanf("%d",&A[i]);
	}
	
	scanf("%d",&q);
	for(i = 0;i < q;i++){
	scanf("%d",&m);
	
	if(solve(0,m) == 1 )printf("yes\n");
	else if(solve(0,m) == 0)printf("no\n");
	}
	return 0;

}


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

int main() {
	int		a,b,c,i,j,k,n,m,x,y,h,w,ans = 0;
	string	str;
	
	cin >> h >> w >> n;
	
	
	if (h > w) {
		ans = n / h;
		if (n%h) ans++;
	} else {
		ans = n / w;
		if (n%w) ans++;
	}

	cout << ans << endl;


}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  char c;
  cin >> c;
  if(c == 'A') cout << "T" << endl;
  if(c == 'T') cout << "A" << endl;
  if(c == 'G') cout << "C" << endl;
  if(c == 'C') cout << "G" << endl;
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define loop(i,a,b)for(ll i=a;i<=b;i++)
#define loopr(i,a,b)for(ll i=b;i>=a;i--)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define vll vector<ll> 
#define vvl vector<vll>
#define vpll vector<pll>
#define pll pair<ll,ll>
#define F first
#define S second
#define MOD 1000000007
ll max(ll a,ll b){if (a>b) return a; else return b;}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll T=1;
	//cin >> T;
	ll t=0;
	while(t++<T){
		ll n,k;
		cin>>n>>k;
		vll a(n);
		fo(i,n)cin>>a[i];
		ll lo=1,hi=*max_element(all(a)),ans;
		ll m;
		while(lo<=hi){
			m=(lo+hi)/2;
			ll req=0;
			fo(i,n){
				req+=(a[i]+m-1)/m-1;
			}
			if(req<=k){ans=m;hi=m-1;}
			else lo=m+1;
		}
		cout<<ans<<endl;
	}
return 0;
}


Measured memory_bytes: 4716
S = gets.chomp
Q = gets.to_i
s1 = []
s2 = []
flag = 1

Q.times do
    Query = gets.split(" ")
    if Query[0] == "1"
        flag *= -1
    elsif Query[0] == "2"
        if Query[1] == "1"
            if flag == 1
                s1 << Query[2]
            else
                s2 << Query[2]
            end
        elsif Query[1] == "2"
            if flag == 1
                s2 << Query[2]
            else
                s1 << Query[2]
            end
        end
    end
end

if flag == 1
    puts s1.reverse.join + S + s2.join
else
    puts s2.reverse.join + S.reverse + s1.join
end

Measured memory_bytes: 23804
#include <iostream>

using namespace std;

int main() {

	/* ----- 変数宣言 ----- */
	int x, a, b, c;
	int i, j, k;
	int ans = 0;

	/* ----- 入力 ----- */
	cin >> a >> b >> c >> x;

	/* ----- 計算 ----- */
	for (i = 0; i <= a; i++) {
		for (j = 0; j <= b; j++) {
			for (k = 0; k <= c; k++) {
				if ((500 * i + 100 * j + 50 * k) == x)	ans++;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int N, K;
	int k;
	cin >> N >> K;
	
	double ans = 0;
	int score;
	for (int i = 1; i < N+1; i++){
		score = i;
		double ansT = 1 / (double)N;
		for ( k = 1; K > score; k++){
			score = score * 2;
			ansT = ansT*(1.0 / 2.0);
		}
		ans += ansT;
	}
	printf("%.9f\n", ans);
	return 0;
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    vector<ll> dic(26);
    string S;
    cin >> S;
    for(auto &c: S) dic[c - 'a']++;
    for(ll i = 0;i < dic.size();i++) {
        if(dic[i] == 0) {
            cout << (char)(i + 'a') << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define ll long long
    #define int long long
    #define pb push_back
    #define For(i,n) for(ll  i=0;i<n;i++)
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;clock_t clk = clock();
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define mod 998244353
    #define ld long double
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define fi first
    #define se second
    #define pii pair<ll,ll>
    #define what_is(x) cerr << #x << " is " << x << endl;
    #define time cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';
    const double pi=3.14159265358979323846264;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

/**********************************************************************************************************************/

signed main()/*Check flow ---question galat mat padhna yr*/
{
    fast;
    string s;
    cin>>s;
    if(s=="ABC")
    {
        cout<<"ARC"<<endl;
    }
    else 
    {
        cout<<"ABC"<<endl;
    }
}   

Measured memory_bytes: 3628
def find(target):
    if parent[target] < 0:
        return target
    else:
        parent[target] = find(parent[target])
        return parent[target]

def is_same(x, y):
    return find(x) == find(y)

def union(x, y):
    root_x = find(x)
    root_y = find(y)
    if root_x == root_y:
        return
    if parent[root_x] > parent[root_y]:
        root_x, root_y = root_y, root_x
    parent[root_x] += parent[root_y]
    parent[root_y] = root_x
def members(n, x):
    root = find(x)
    return [i for i in range(n) if find(i) == root]

def get_size(x):
    return -parent[find(x)]

def get_root():
    return [i for i, root in enumerate(parent) if root < 0]
n, m = map(int, input().split())
parent = [-1 for _ in range(n)]
for _ in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    union(a, b)
    # print(parent)
ans = 0
for i in range(n):
    ans = max(ans, get_size(i))
print(ans)

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

int H,W,i,j;

	while(1){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0)break;
		
		for(i=1;i<=H;i++){
			for(j=1;j<=W;j++){
				printf("%c",'#');
			}
			printf("\n");
		}
		printf("\n");
	}
return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    for (double i = 1; i < 10; i++)
    {
        int x = n / i;
        if (x == n / i and x <= 9 and x >= 1)
        {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long double db;
int n,x;db d,ans,S;
int main()
{
	cin>>n>>d>>x;
	S=2*n*d+1.0*n*(2*n-1)*x;
	for (int i=n;i;i--) ans+=S/(i*2),S-=S/i/i;
	printf("%.10Lf\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int n;
  std::cin >> n;
  bool can = false;
  for (int i = 1; i < 10; ++i) {
    for (int j = 1; j < 10; ++j) {
      if (i * j == n) {
        can = true;
        break;
      }
    }
  }
  if (can) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>

#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;

int main() {
    string S, T;
    cin >> S >> T;
    int ret = 0;
    rep(i, S.size()) {
        if(S[i] != T[i])
            ++ret;
    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 3324
numbers = int(input())
digits = [int(i) for i in str(numbers)]
hon = [2, 4, 5, 7, 9]
pon = [0, 1, 6, 8]
bon = [3]
if digits[-1] in hon:
    print("hon")
elif digits[-1] in pon:
    print("pon")
else:
    print("bon")


Measured memory_bytes: 9200
# きりみんちゃんの配信からきました
# 登場回数が同一ならいけそうなのでそうする
from string import ascii_lowercase
s, t = input(), input()
alphabets = ascii_lowercase
sd, td = {}, {}
for sv in s:
    if sv in sd:
        sd[sv] += 1
    else:
        sd[sv] = 1
for tv in t:
    if tv in td:
        td[tv] += 1
    else:
        td[tv] = 1
sort_sk = sorted(sd.values())
sort_tk = sorted(td.values())
print("Yes" if sort_sk == sort_tk else "No")

Measured memory_bytes: 4164
<?php

fscanf(STDIN, "%d %d", $n, $m);
$L = [];
$R = [];
for ($i = 0; $i < $m; ++$i) {
    fscanf(STDIN, "%d %d", $l, $r);
    $L[] = $l;
    $R[] = $r;
}

$l_max = 1;
$r_min = $n;
for ($i = 0; $i < $m; ++$i) {
    $l_max = max($l_max, $L[$i]);
    $r_min = min($r_min, $R[$i]);
}

/* echo "l_max: $l_max, r_min: $r_min", PHP_EOL; */

echo $l_max > $r_min ? 0 : $r_min - $l_max + 1;


Measured memory_bytes: 14840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

/*
Name: str2dec
Inputs:
    string s : string representing a number such as 123.4, 0.123, 123.
    logn long shift_size : shift size, formally, this function return s * 10 ^ shift_size.
Output:
    Return s * 10 ^ shift_size as long long.
*/
long long str2dec(string s, long long shift_size) {
    auto pos = s.find('.');
    if(pos == string::npos) return atoi(s.c_str()) * pow(10LL, shift_size); // If s is an integer
    long long res = atoi(s.substr(0, pos).c_str()) * pow(10LL, shift_size); 
    res += atoi(s.substr(pos+1, s.size()-pos-1).c_str()) * pow(10LL, shift_size - (s.size()-pos-1));
    return res;
}

ll factorize(ll n, ll d){
    ll res = 0;
    while(n % d == 0) {
        res++;
        n /= d;
    }
    return res;
}

int main(){

    // input
    ll n;
    cin >> n;
    VS a(n);
    rep(i, 0, n) cin >> a[i];
    
    // string2decimal
    VL p(n);
    rep(i, 0, n) p[i] = str2dec(a[i], 9);

    // factorize
    VL x(n), y(n);
    rep(i, 0, n) {
        x[i] = factorize(p[i], 5);
        y[i] = factorize(p[i], 2);
    }    

    // ans search
    VVL t(100, VL(100, 0));
    ll ans = 0;
    rep(i, 0, n) {
        // update ans
        rep(j, max(0LL, 18-x[i]), 100) {
            rep(k, max(0LL, 18-y[i]), 100) {
                ans += t[j][k];
            }
        }
        // update t
        t[x[i]][y[i]]++;
    }

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

Measured memory_bytes: 14816
#include <bits/stdc++.h>
using namespace std;
int main (){
int a,b,c,f=0;
cin >> a >> b;
if(a%3==0||b%3==0)
{
cout <<"Possible"<<endl;
}
else{
c=a+b;
if(c%3==0)
f=1;
else
f=0;
if(f==1)
cout <<"Possible" << endl;
else
cout <<"Impossible" <<endl;
}
return 0;
}


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

int main() {
  int n, s;
  cin >> n >> s;
  constexpr int kMod = 998244353;
  vector<int> dp(s + 1);
  dp[0] = 1;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    vector<int> nxt(s + 1);
    for (int j = 0; j <= s; ++j) {
      nxt[j] = (dp[j] + dp[j]) % kMod;
      if (j >= x) {
        (nxt[j] += dp[j - x]) %= kMod;
      }
    }
    dp = nxt;
  }
  cout << dp[s] << "\n";
}


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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const LL INF = 1e18;

struct Edge{
  LL to, cap, cost, rev;
  Edge(LL to_=0, LL cap_ = 0, LL cost_ = 0, LL rev_ = 0)
	:to(to_), cap(cap_), cost(cost_), rev(rev_){}
};

const int MAX_V = 3010;
int V = MAX_V;
vector<Edge> G[MAX_V];
LL dist[MAX_V];
int prevv[MAX_V], preve[MAX_V]; //??´??????????????¨???

void add_edge(LL from, LL to, LL cap, LL cost){
  G[from].push_back(Edge(to, cap, cost, G[to].size()));
  G[to].push_back(Edge(from, 0, -cost, G[from].size()-1));
}

LL min_cost_flow(int s, int t, LL f){
  LL res = 0;
  while(f > 0){
	fill(dist, dist+V, INF);
	dist[s] = 0;
	bool update = true;
	while(update){
	  update = false;
	  for(int v=0;v<V;++v){
		if(dist[v] == INF) continue;
		for(int i=0;i<G[v].size();++i){
		  Edge& e = G[v][i];
		  if(e.cap > 0 && dist[v] + e.cost < dist[e.to]){
			dist[e.to] = dist[v] + e.cost;
			prevv[e.to] = v;
			preve[e.to] = i;
			update = true;
		  }
		}
	  }
	}

	if(dist[t] == INF) return -1;

	LL d = f;
	for(int v=t;v!=s;v=prevv[v])
	  d = min(d, G[prevv[v]][preve[v]].cap);

	f -= d;
	res += d * dist[t];
	for(int v=t;v!=s;v=prevv[v]){
	  Edge& e = G[prevv[v]][preve[v]];
	  e.cap -= d;
	  G[v][e.rev].cap += d;
	}
  }
  
  return res;
}

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

  int N; cin >> N;
  vector<PLL> xs(N);
  REP(i,N)
  	cin >> xs[i];

  int S = MAX_V-2, T = MAX_V-1;
  LL B = 1000010;
  map<int,int> ws;
  REP(i,N){
	if(!ws.count(xs[i].FF)){
	  ws[xs[i].FF] = SZ(ws)-1;
	}
	if(!ws.count(xs[i].SS)){
	  ws[xs[i].SS] = SZ(ws)-1;
	}
	add_edge(S,i,1,0);
	add_edge(i,N+ws[xs[i].FF],1,B-xs[i].SS);
	add_edge(i,N+ws[xs[i].SS],1,B-xs[i].FF);
	add_edge(i,T,1,B);
  }
  for(auto& w: ws){
  	add_edge(N+w.SS,T,1,0);
  }
  LL ans = N*B - min_cost_flow(S,T,N);

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

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

using namespace std;

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

    int N, W, v, w, m;

    cin >> N >> W;
    vector<vector<int>> dp(N, vector<int>(W + 1));
    cin >> v >> w >> m;
    for (int j = 1; j <= m && j * w <= W; ++j)
        dp[0][j * w] = j * v;

    for (int i = 1; i < N; ++i) {
        cin >> v >> w >> m;

        for (int j = 0; j < w; ++j) {
            deque<int> deq;

            for (int k = 0; k * w + j <= W; ++k) {
                int cur = k * w + j;

                while (!deq.empty() &&
                       dp[i -1][deq.back()] + v * (cur - deq.back()) / w < dp[i - 1][cur])
                    deq.pop_back();
                deq.push_back(cur);

                int prev = deq.front();
                if (prev <= cur - m * w) deq.pop_front();
                if (prev != 0 && dp[i - 1][prev] <= 0) continue;

                dp[i][cur] = dp[i - 1][prev] + v * (cur - prev) / w;
            }
        }
    }

    cout << *max_element(dp[N - 1].begin(), dp[N - 1].end()) << endl;

    return 0;
}



Measured memory_bytes: 6804
#include<stdio.h>
int main(void)
{
  int a,b,c;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);

  if(a >= b && b >= c){
    printf("%d %d %d\n",c,b,a);
}else if(a <= b && b <= c){
    printf("%d %d %d\n",a,b,c);
}else if(a >= c && c >= b){
   printf("%d %d %d\n",b,c,a);
}else if(b >= a && a >= c){
    printf("%d %d %d\n",c,a,b);
}else if(b >= c && c >= a){
     printf("%d %d %d\n",a,c,b);
}else if(c >= a && a >= b){
     printf("%d %d %d\n",b,a,c);
}
return 0;
}

Measured memory_bytes: 1780
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
void solve(){
	ll n;
	cin>>n;
	ll res=1e18, ans=1;
	rep(i,0,n){
		ll x;
		cin>>x;
		if(x==0){
			res=1;
			ans=0;
			break;
		}
		res/=x;
		ans*=x;
	}
	if(res==0)ans=-1;
	cout<<ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


Measured memory_bytes: 3644
E = input()
N = len(E)

for n in range(2**(N-1)):
    s = 0
    ans = []
    B = bin(n)[2:]
    while len(B) < N - 1:
        B = "0" + B
    ans += "{:s}".format(E[0])
    s += int(E[0])
    for i, e in enumerate(E[1:]):
        if B[i] == "0":
            ans += "{:s}".format("-")
            s -= int(e)
        else:
            ans += "{:s}".format("+")
            s += int(e)
        ans += "{:s}".format(e)
    if s == 7:
        ans += "=7"
        print(*ans, sep="")
        break
            

Measured memory_bytes: 3064
import java.util.Scanner;

/**
 * ソーシャルゲーム (Social Game)
 */
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A, B, C;
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();

		int ans = 0;
		int bonus = 0;

		while (C > 0) {
			C -= A;
			ans++;
			bonus++;
			if (bonus == 7) {
				C -= B;
				bonus = 0;
			}
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 26372
#include<iostream>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<numeric>
#include<vector>
#include<string>

#define MAX_V 100001
#define INF (1e9 + 1)


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

struct edge{
  int to,dist;
};

int V,E,r,a,b,c;

vector<edge> G[MAX_V];

int d[MAX_V];

void dijkstra(){
  int i;
  REP(i,MAX_V) d[i] = INF;
  d[r]=0;
  priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>Q;
  Q.push(make_pair(0,r));
  while(!Q.empty()){
    pair<int,int> p = Q.top();

    Q.pop();
    int pos = p.second,cost = p.first;
    REP(i,G[pos].size()){
      edge e = G[pos][i];
      int to = e.to;
      int newcost = cost + e.dist;
      if(newcost < d[to]){
        d[to] = newcost;
        Q.push(make_pair(d[to],to));
      }
    }
  }

    REP(i,V){
      if(d[i]==INF)printf("INF\n");
      else printf("%d\n",d[i]);
    }
}

int main(){
    int i;
    scanf("%d %d %d",&V,&E,&r);
    REP(i,E){
      scanf("%d %d %d",&a,&b,&c);
      G[a].push_back((edge){b,c});
    }
    dijkstra();
    return 0;

}



Measured memory_bytes: 13048
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <stack>
#include <queue>
#include <bitset>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring> 
#include <iostream>
#include <algorithm>
using namespace std;

int X;

int main()
{
	cin >> X;
	if(X >= 30)
		printf("Yes\n");
	else
		printf("No\n");
}

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

public class Main {
	private	static			BufferedReader	br      = null;
	private	static	final	int				MAP_ID  = 0;
	private	static	final	int				MAP_NUM = 1;
	private	static	final	int				MAP_MAX = 2;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int[]	head = parseData();

		if (head != null) {
			if (head[0] > 0) {
				int		tl  = 1;
				int[][]	map = null;

				while (tl < head[0]) {
					tl*=2;
				}

				map = new int[MAP_MAX][tl*2+1];
				Arrays.fill(map[MAP_NUM], Integer.MIN_VALUE);

				for(int l = 0; l < head[0]; l++) {
					map[MAP_ID][tl+l]  = l+1;
					map[MAP_NUM][tl+l] = 0;
				}

				for (int q = 0; q < head[1]; q++) {
					int[]	node = parseData();

					map[MAP_NUM][tl+node[0]-1] += node[1];
					updateTree((tl+node[0]-1)>>1, map);
					System.out.println(map[MAP_ID][1] + " " + map[MAP_NUM][1]);
				}
			}
		}
	}

	private static void updateTree(int i, int[][] map) {
		for (; i > 0; i = i>>1) {
			int	L = 2*i;
			int	R = 2*i+1;
			if(map[MAP_NUM][L]==map[MAP_NUM][R]){
				map[MAP_NUM][i] = map[MAP_NUM][L];
				map[MAP_ID][i]  = Math.min(map[MAP_ID][L], map[MAP_ID][R]);
			}
			else if(map[MAP_NUM][L] < map[MAP_NUM][R]){
				map[MAP_NUM][i] = map[MAP_NUM][R];
				map[MAP_ID][i]  = map[MAP_ID][R];
			}
			else{
				map[MAP_NUM][i] = map[MAP_NUM][L];
				map[MAP_ID][i]  = map[MAP_ID][L];
			}
		}
	}

	private static int[] parseData() {
		int[]	data = null;
		String	str  = null;

		if ((str = parseStdin()) != null) {
			String[]	lines = str.split(" ");

			if (lines.length > 0) {
				data = new int[lines.length];
				data[0] = Integer.parseInt(lines[0]);
				data[1] = Integer.parseInt(lines[1]);
			}
		}

		return data;
	}

	private static String parseStdin() {
        String  stdin = null;
        
        try {
        	String  tmp = br.readLine();
        	if (tmp != null) {
            	if (!tmp.isEmpty()) {
            		stdin = tmp;
            	}
        	}
        }
        catch (IOException e) {}
 
        return stdin;
	}
}

Measured memory_bytes: 112840
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long int
signed main(){
    int a,b,c,d;cin>>a>>b>>c>>d;
    cout<<max(max(a*c,b*d),max(a*d,b*c))<<"\n";
    return 0;
}


Measured memory_bytes: 3672
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


import numpy as np
from numba import njit, b1, i4, i8, f8
from heapq import heappop as hpp, heappush as hp

@njit((b1[:, :],i8,i8,i8,i8))
def main(ss,ch,cw,dh,dw):
    inf = 1<<30
    h,w = ss.shape
    start = ch*w+cw
    goal = dh*w+dw
    n = h*w
    seen = np.full(n, inf, np.int64)
    seen[start] = 0
    q = [(0, start)] # ワープ回数, 現在位置, 最後の道の位置
    while q:
        pnum,pu = hpp(q)
        ux,uy = divmod(pu,w)
        if pu==goal:
            break
        for xx in range(-2, 3):
            for yy in range(-2, 3):
                if xx==yy==0:
                    continue
                if abs(xx)+abs(yy)<=1:
                    vv = 0
                else:
                    vv = 1
                x,y = ux+xx, uy+yy
                u = x*w + y
                num = pnum+vv
                if x<0 or y<0 or x>=h or y>=w or ss[x][y]:
                    continue
        #         print(x,y)
                if seen[u]>num:
                    seen[u] = num
                    hp(q,(num, u))
                
    val = seen[goal]
    if val==inf:
        return -1
    else:
        return val
h,w = map(int, input().split())
ch,cw = map(int, input().split())
dh,dw = map(int, input().split())
ch -= 1
cw -= 1
dh -= 1
dw -= 1
rows,cols = h,w

OK = "."
NG = "#"

ss = np.array([[c=="#" for c in input()] for _ in range(h)])

print(main(ss,ch,cw,dh,dw))

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int solve(int A, int B, int C) {
  if (A % 2 == B % 2 && 
      A % 2 == C % 2) {
    int ma = max({A, B, C});
    return ((ma - A) + (ma - B) + (ma - C)) / 2;
  } else {
    return 1001001001;
  }
}

int main2() {
  int A = nextInt();
  int B = nextInt();
  int C = nextInt();

  int ans = min({
    solve(A, B, C),
    1 + solve(A, B+1, C+1),
    1 + solve(A+1, B, C+1),
    1 + solve(A+1, B+1, C)
  });
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#include<string>
#include<cstring>
#include<queue>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define output(x) cout<<x<<endl;

int par[100001];

void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
	}
}
//木の根を求める
int root(int x) {
	if (par[x] == x)
		return x;
	else {
		return par[x] = root(par[x]);
	}
}
//find
bool same(int x, int y) {
	return root(x) == root(y);

}
//union
void unite(int x, int y) {
	x = root(x);
	y = root(y);
	if (x == y) return;
	par[x] = y;
}

int main()
{
	long long int i, j, k, l, m, n, sum,flag,ans1,N,M,K;
	sum = 0;
	flag = 0;
	ans1 = 0;
	int A[3];
	cin >> A[0]>>A[ 1] >> A[2];
	sort(A, A + 3);
	output(A[2]*10+A[1]+A[0]);



	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int a,b;
	int t[4];
	
	scanf("%d %d %d %d\n",t,t+1,t+2,t+3);
	a=t[0]+t[1]+t[2]+t[3];
	scanf("%d %d %d %d\n",t,t+1,t+2,t+3);
	b=t[0]+t[1]+t[2]+t[3];

	printf("%d\n",a<b?b:a);



	return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  ll ans = 0;
  for (int i = 2; i < n; i++) {
    if (p[i - 1] < p[i] && p[i - 1] > p[i - 2]) ans++;
    if (p[i - 1] > p[i] && p[i - 1] < p[i - 2]) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
N = input()
input_num = int(N)
N_list = list(N)

first_num = N_list[0]

number = first_num * 3

if input_num <= int(number):
  print(number)
else:
  first_num = int(first_num) + 1
  number = str(first_num) * 3
  print(number)

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
    int input_num;
    int num[100];
    int i, j;
    int ans =1;

    scanf("%d", &input_num);

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

    for(i=1; i<input_num; i++){
        for(j=0; j<i; j++){
            if(num[j] > num[i]){
                break;
            }
        }
        if(i == j){
            ans += 1;
        }
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split()))
m = 1000
kabu = 0
for i in range(n-1):
    if a[i] < a[i+1]:
        kabu += m//a[i]
        m -= (m//a[i])*a[i]
    else:
        m += a[i]*kabu
        kabu = 0
print(m+kabu*a[-1])

Measured memory_bytes: 9184
#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<unordered_map>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long 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
#define dme cout<<-1<<endl;return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
//20:00~
const int mod=1e9+7;
const llint big=1e16+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	int n,z,w;cin>>n>>z>>w;
	vector<int>a(n);
	for(auto &it:a){cin>>it;}
	if(n>=2){cout<<max(abs(a.back()-w),abs(a[n-2]-a.back()))<<endl;}
	else{cout<<max(abs(a.back()-w),0)<<endl;}
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main()
{
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);
	
	if(A==B&&A==C&&B==C)
{
	printf("No");
}
	else if(A==B||A==C||B==C)
{
	printf("Yes");
}
	else if(A!=B&&A!=C&&B!=C)
{
	printf("No");
}
	return 0;
}

Measured memory_bytes: 3208
N, L = map(int, input().split())
a = [int(i) for i in input().split()]

max_k = 0
max_p = 0

for i in range(N-1):
    if a[i]+a[i+1] > max_k:
        max_k = a[i]+a[i+1]
        max_p = i+1

if max_k < L:
    print('Impossible')
    exit()
else:
    print('Possible')

for i in range(1, N):
    if i == max_p:
        break
    else:
        print(i)

for i in range(N-1, 0, -1):
    if i == max_p:
        print(i)
        exit()
    else:
        print(i)


Measured memory_bytes: 63984
N = int(input())
A = list(map(int, input().split()))
S = sum(A)

cost = int(1e18)
p = 0
for i in range(N):
    cost = min(cost, abs(S - p - p))
    p += A[i]
p = 0
for i in range(N):
    cost = min(cost, abs(S - p - p))
    p += A[N - i - 1]
print(cost)


Measured memory_bytes: 26220
#include<stdio.h>
#include<string.h>

int main() {
  char s[1001], t[1001];
  scanf("%s", s);
  scanf("%s", t);
  char *p;
  int i,j;
  int count,ans;
  ans = 100000;
  for (i=0;i<strlen(s)-strlen(t)+1;i++) {
    p = &s[i];
    count =0;
    for (j=0;j<strlen(t);j++) {
      if (t[j]!=p[j]) {
        count++;
      }
    }
    //printf("%d ",count);
    if (count<ans) {
      ans = count;
    }
  }
  printf("%d", ans);  
}


Measured memory_bytes: 1736
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  string s;
  cin >> s;
  vector<int> a(1, 1);
  for (int i = 1; i < sz(s); i++) {
    if (s[i] == s[i - 1]) a.back()++;
    else a.push_back(1);
  }
  int ans = 0;
  int rem = 0;
  for (int i = 0; i < sz(a); i++) {
    if (rem) a[i]--;
    rem = 0;
    if (a[i] == 0) continue;
    ans += 2 * (a[i] / 3);
    if (a[i] % 3 == 1) {
      ans++;
    } else if (a[i] % 3 == 2) {
      ans++;
      if (i != sz(a) - 1) {
        ans++;
        rem = 1;
      }
    }
  }
  cout << ans << "\n";
}



Measured memory_bytes: 2700
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String b = br.readLine()
            .replaceAll("A", "t")
            .replaceAll("T", "a")
            .replaceAll("C", "g")
            .replaceAll("G", "c")
            .toUpperCase();
    
    System.out.println(b);
  }
}


Measured memory_bytes: 22612
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    string s;
    cin >> s;
    cout << s[0];
    cout << s.length()-2;
    cout << s[s.length()-1]<<endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main (){
    int n,res=0;cin>>n;
    map<int,int>M,cnt;
    vector<int>V(n);
    for(int i=0;i<n;i++){cin >> V[i]; cnt[V[i]]++;}
    sort(V.begin(),V.end());
    for(int i=0;i<n;i++){
        int x = V[i];
        int sq = sqrt(x);
        int dv=0;
        for(int j=1;j<=sq;j++){
            if(x%j==0){
                int k = x/j;
                if( M[j] == 1 || M[k] == 1){
                    dv = 1;
                    break;
                }
            }
        }
        if(dv==0 && cnt[x]==1 )res++;

        M[x]=1;
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 42144
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N,T;
  cin>>N;
  cin>>T;
  vector<pair<int,int>>eaa(N);
  for(int i=0;i<N;i++)
  {
  int a,b;
    cin>>a>>b;
    pair<int,int>t(a,b);
    eaa.at(i)=t;
  }
  pair<int,int>d(10000,10000);
  int j=10000;
  for(int i=0;i<N;i++)
  {
  if(eaa.at(i).second<=T) 
  {
  if(d>eaa.at(i)) 
  {d=eaa.at(i);
   j=eaa.at(i).first;
  }
  }
  }
  
  if(j==10000) cout<<"TLE";
  else cout<<j;
}








Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        int nMinus1C2 = 1;
        for (int i = n - 1; i >= n - 2; i--) {
            nMinus1C2 *= i;
        }
        nMinus1C2 /= 2;
        if (k > nMinus1C2) {
            System.out.println(-1);
            return;
        }
        
        int m = (n - 1) + (nMinus1C2 - k);
        System.out.println(m);
        for (int i = 1; i < n; i++) {
            System.out.println("1 " + (i + 1));
        }
        int l = nMinus1C2 - k;
        int p = 2;
        int q = 3;
        while (l-- > 0) {
            System.out.println(p + " " + q);
            q++;
            if (q > n) {
                p++;
                q = p + 1;
            }
        }
    }
}

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

int main(int argc, char *argv[]){
  int w, h;
  while(cin >> w >> h, w){
    vector<int> x(w), y(h);
    for (int i = 0; i < w; i++) {
      cin >> x[i];
    }
    
    for (int i = 0; i < h; i++) {
      cin >> y[i];
    }
    int ans = 0;
    for (int i = 0; i < w; i++) {
      for (int j = 0; j < h; j++) {
        if(x[i] == y[j]){
          ans += x[i];
          x[i] = y[j] = 0;
        }
      }
    }
    for (int i = 0; i < w; i++) {
      ans += x[i];
    }
    for (int i = 0; i < h; i++) {
      ans += y[i];
    }
    std::cout << ans << std::endl;    
  }
  return 0;
}

Measured memory_bytes: 1192
function main(input) {
  input = input.split(/\r\n|\r|\n/);
  const n = parseInt(input[0]);
  const s = input.slice(1,n+1);
  const m = parseInt(input[n+1]);
  const t = input.slice(n+2);
  const o = {};
  s.forEach(si => {
    if(!o[si]) o[si] = 0;
    o[si]++;
  });
  t.forEach(ti => {
    if(!o[ti]) o[ti] = 0;
    o[ti]--;
  });
  var max = 0;
  Object.keys(o).forEach(k => {
    max = Math.max(max, o[k]);
  });
  console.log(max);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
def test():
    n = int(input())
    a = list(map(int,input().split()))
    a.sort()
    b = []
    i = 0
    while i + 1 < n:
        if a[i] == a[i+1]:
            b.append(a[i])
            i += 2
        else:
            i += 1
    print(b[-1]*b[-2] if len(b)>=2 else 0)


if __name__ == "__main__":
    test()


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

const long long MOD = 1000000007;

long long pow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}

long long comb(long long a, long long b) {
    long long x = 1, y = 1;
    for (long long i = 0; i < b; i++) {
        x *= a - i;
        y *= i + 1;
        x %= MOD;
        y %= MOD;
    }
    return (x * pow(y, MOD-2)) % MOD;
}

int main() {
    long long n, a, b;
    cin >> n >> a >> b;
    long long ans = (pow(2ll, n) - 1) % MOD;
    ans -= comb(n, a);
    ans = (ans + MOD) % MOD;
    ans -= comb(n, b);
    ans = (ans + MOD) % MOD;
    cout << ans << endl;
    return 0;
}

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


int main(){
    int A,B,K, L1,L2;

    scanf("%d %d %d",&A,&B,&K);

    L1=A+K-1;
    if(B<=L1) L1=B;
    for(int i=A;i<=L1;i++){
        printf("%d\n", i);   
    }

    L2=B-K+1;
    if(L1>=L2) L2=L1+1;
    for(int i=L2;i<=B;i++){
        printf("%d\n", i);   
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>

int main()
{
	double a, b, c, d, e, f;
	while (std::cin >> a >> b >> c >> d >> e >> f) {
		double const denominator = a * e - b * d;
		double const numerator1 = c * e - b * f;
		double const numerator2 = a * f - c * d;
		std::cout.setf(std::ios::fixed);
		std::cout.precision(3);
		std::cout << std::showpoint
				  << (numerator1 ? numerator1 / denominator : 0.0) << ' '
				  << (numerator2 ? numerator2 / denominator : 0.0) << std::endl;
	}
	return 0;
}

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

int main() {
  int N, M,A,S=0;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> A;
    S += A; 
  }
  if(N - S < 0){
    cout << -1 << endl;
  }else{
    cout << N - S << endl;
  }

}


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

int main()
{
    int a,b;
    cin >> a >> b;
    int x = 0;
    if((a+b)%2 == 1){
        x = (a+b+1)/2;
    }
    else{
        x = (a+b)/2;
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#include<vector>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++) 
#define ltype int
#define rep(i,j,k) for(ltype (i)=(j);(i)<=(k);(i)++)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
const int inf=0x3f3f3f3f,
mod=1000000007;
const double pi=3.1415926535897932,
eps=1e-6;
ll n,m,ans,cur;
struct cake{
    ll a,b,c;
}a[1005],c[1005];
bool cmp(cake a,cake b){
    return a.a+a.b+a.c>b.a+b.b+b.c;
}
int main()
{
    scanf("%lld%lld",&n,&m);
    rep(i,1,n) scanf("%lld%lld%lld",&a[i].a,&a[i].b,&a[i].c);
    rep(i,0,7){
        cur=0;
        rep(j,1,n) c[j]=a[j];
        if(i&1) rep(j,1,n) c[j].a=-c[j].a;
        if(i&2) rep(j,1,n) c[j].b=-c[j].b;
        if(i&4) rep(j,1,n) c[j].c=-c[j].c;
        sort(c+1,c+n+1,cmp);
        rep(j,1,m) cur+=c[j].a+c[j].b+c[j].c;
        ans=max(cur,ans);
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;


int main(void){
	int n;
	cin>>n;
	ll pre;
	cin>>pre;
	bool ans=true;
	rep(i,n-1){
		ll cur;
		cin>>cur;
		if(pre<cur)pre=cur-1;
		else if(pre == cur)pre=cur;
		else{
			ans=false;
			break;
		}
	}

	if(ans)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#define P 100003
#define N 100000
using namespace std;

int main(){
    long long n,k;
    vector<int> a;
    string yes = "YES", no = "NO";

    cin >> n;
    for(int i=0;i<n;i++){
        cin >> k;
        a.push_back(k);
    }

    sort(a.begin(),a.end());
    for(int i=0;i<n-1;i++){
        if(a[i] == a[i+1]){
            cout << no;
            return 0;
        }
    }

    cout << yes;


    return 0;
}


Measured memory_bytes: 1400