akhauriyash/Code-Regression huggingface dataset:
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, 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 each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
template<typename T> ll min(ll a, const T&& b) { return a < b ? a : b; }
template<typename T> ll min(const T&& a, ll b) { return a < b ? a : b; }
template<typename T> ll max(ll a, const T&& b) { return a > b ? a : b; }
template<typename T> ll max(const T&& a, ll b) { return a > b ? a : b; }
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; 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; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) { return os << "(" << p.first << ", " << p.second << ")"; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

vector<ll> divisors(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      res.pb(i);
      if (n / i != i) {
        res.pb(n / i);
      }
    }
  }
  return res;
}

void solve() {
  ll n; cin >> n;
  vector<ll> divs = divisors(n);
  ll ans = 0;
  each(x, divs) {
    ll m = n / x - 1;
    if (m <= 0) continue;
    if (n / m == n % m) {
      ans += m;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
h,w = map(int, input().split())
B = '.'*(w+2)
s = [B]
s.extend(['.' + input() + '.' for _ in range(h)])
s.append(B)

def check():
    for i in range(1,h+1):
        for j in range(1,w+1):
            if s[i][j] == '.':
                continue
            if all([s[x][y]=='.' for x,y in [(i-1,j), (i+1,j), (i,j+1), (i,j-1)]]) :
                return False
    return True

print("Yes" if check() else "No")


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

int main()
{
    string s, t;
    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    string solve = "No";
    if (s < t)
    {
        solve = "Yes";
    }
    
    cout << solve << endl;

    return 0;
}

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

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

using ll = long long;

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

    int ans = 0;
    rep(i, N - 2){
        if(S.substr(i, 3) == "ABC") {
            ans++;
        }
    }
    cout << ans << endl;
    
	return 0;
}


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

int main() {
	int n;cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;++i)cin>>a[i];

	int m;cin>>m;
	vector<int> b(m);
	for(int i=0;i<m;++i)cin>>b[i];

	cout<<(lexicographical_compare(a.begin(), a.end(), b.begin(), b.end())?1:0)<<endl;
  return 0;
}



Measured memory_bytes: 3064
N, K = map(int, input().split())
S = str(input())
count = 0

for n in range(1, N):
    if S[n-1] == 'R' and S[n] == 'R':
        count += 1
    elif S[n-1] == 'L' and S[n] == 'L':
        count += 1

count = count + 2*K
ans = min(count, N-1)
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
//#pragma GCC optimize "trapv"
int main()
{
	// ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];


int p = a[0];
ll ans=0;
for(int i=0;i<n;i++)
{
	if(a[i]<p)
	{
		ans+=p - a[i];
	}	
	else
		p = a[i];
}
cout<<ans<<"\n";
    

}

Measured memory_bytes: 4412
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
	int A, B, C, D, S, o;
	cin >> A >> B >> C >> D;
	S = o = 0;
	if (C >= A) { S = S + C; }
	else { S = S + A; }
	if (D >= B) { o = o + B; }
	else { o = o + D; }
	if (S >o) {
		cout << 0 << endl;

	}
	else
	{
		cout << o - S << endl;
	}

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
int a,b;
int main() {
   cin>>a>>b;
   if(a>=13)
    cout<<b;
   else if(a>=6)
    cout<<b/2;
   else
    cout<<0;

   return 0;
}


Measured memory_bytes: 256
h, n = map(int, input().split())
m = [tuple(map(int, input().split())) for _ in range(n)]

inf = 10 ** 18
d = [inf] * (h+1)

d[h] = 0
for i in reversed(range(h+1)):
    for a, c in m:
        if d[i] != inf:
            d[max(0, i-a)] = min(d[max(0, i-a)], d[i] + c)

print(d[0])

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

using namespace std;

const int N=100005;
const int P=998244353;

int n;
double a[N];
int res;

void init(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lf",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<n;i++){
		if(fabs(a[i]-a[n]/2)<fabs(a[res]-a[n]/2)) res=i;
	}
	printf("%.0lf %.0lf\n",a[n],a[res]);
}

int main(){
	init();
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string.h>
using namespace std;



int main(){
  int cases;
  int n;
  int sum = 0;
  cin >> n;
  int v[n],c[n];
  for(int i=0;i<n;i++){cin >> v[i];}
  for(int i=0;i<n;i++){cin >> c[i];}
  for(int i=0;i<n;i++){
    if (v[i] > c[i] ){
      sum = sum + v[i] - c[i];
      //cout << "v" << v[i] << "c" << c[i] <<  "sum" << sum << endl;
    }
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	var n = input.split("\n")[0];
	var ans = 0;
	input.split("\n")[1].split(" ").forEach(v=>{ans+=parseInt(v)-1});
	console.log(ans);
	
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(){
  long long int i, j, c=0, n, h[100];
  cin >> n;
  for(i=0; i<n; i++)
    cin >> h[i];
  for(i=0; i<n; i++){
    c+=h[i];
    while(0<h[i]){
    for(j=i; j<n; j++)
      if(0<h[j])
        h[j]--;
      else{
        break;
      }
    }
  }
  cout << c;
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
x, k, d = map(int, input().split())

x = abs(x)

remain_k = k - x // d
r = x % d
l = d - r

if remain_k <= 0:
    print(x - k * d)
elif remain_k % 2 == 0:
    print(r)
else:
    print(l)


Measured memory_bytes: 9160
#include<stdio.h>

int main(){
  int n, r, p, c, a[64], b[64];
  int i, j;

  while(scanf("%d%d", &n, &r), n){

    for(i=n; i>0; i--){
      a[n-i]=i;
    }

    for(j=0; j<r; j++){

      scanf("%d%d", &p, &c);
      
      for(i=0; i<c; i++){
	b[i]=a[p-1+i];
      }
      
      for(i=0; i<p-1; i++){
	b[c+i]=a[i];
      }
      
      for(i=0; i<p+c-1; i++){
	a[i]=b[i];
      }

    }
    
    printf("%d\n", a[0]);
  }
  

  return 0;
}

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
    string s;
    cin >> s;
    
    ll count = 0;
    bool flag = false;
    for (int i = s.size()-1; i >= 0; i--) {
        int num = ctoi(s[i]);
        if (flag) {
            num++;
            flag = false;
        }
        if (num < 5 || (num == 5 && ctoi(s[i-1]) < 5))
            count += num;
        else {
            count += 10-num;
            flag = true;
        }
        //cout << count << " " << num << endl;
    }
    
    if (flag)
        count++;
    
    cout << count;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
#define sz(a) ((int)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define eps 1e-12
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos(0))
#define linf (1ll << 60)

#define maxn 3005

int n, a[maxn], f[maxn][maxn];

vector<int> V[maxn];

int cal(int par, int u){
	int &res = f[par][u];
//	cout << par << " " << u << endl;
	if(res != -1) return res;
	if(a[par] <= a[u]){
		res = 0;
		return res;
	}
	res = 1;
	Rep(i, sz(V[u])){
		int v = V[u][i];
		if(v == par) continue;
		if(cal(u, v) == 1){
			res = 0;
		}
	}
	return res;
}

int main(){

//	freopen("in.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    For(i, 1, n) cin >> a[i];
    Rep(run, n - 1){
    	int u, v;
    	cin >> u >> v;
    	V[u].pb(v);
    	V[v].pb(u);
    }

    ms(f, -1);
    For(i, 1, n){
    	bool ok = false;
    	Rep(j, sz(V[i])){
    		int u = V[i][j];
    		if(cal(i, u) == 1){
    			ok = true;
    			break;
    		}
    	}
    	if(ok) cout << i << " ";
    }

    return 0;
}


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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;
typedef vector<unordered_map<lli,lli>> graph;

typedef tuple<lli,char,lli> con;

string a;
queue<con> q;
vector<con> mem;
vector<con> ans;
set<lli> used;


int main(){
  cin >> a;
  q.push(make_tuple(-1,0,-1));
  while(!q.empty()){
    con c = q.front();
    lli point = get<0>(q.front());
    char chr = get<1>(q.front());
    lli prev = get<2>(q.front());
    q.pop();
    if(used.count(point) != 0) continue;
    used.insert(point);
    mem.push_back(c);
    if(point == (lli)a.size()){
      for(lli i = mem.size()-1;i >= 0;){
        ans.push_back(mem[i]);
        i = get<2>(mem[i]);
      }
      for(lli i = ans.size()-2;i >= 0;i--){
        cout << get<1>(ans[i]);
      }
      cout << endl;
      return 0;
    }
    for(char c = 'a';c <= 'z';c++){
      lli p = a.size();
      for(lli i = point+1;i < a.size();i++){
        if(a[i] == c){
          p = i;
          break;
        }
      }
      if(used.count(p) == 0) q.push(make_tuple(p,c,mem.size()-1));
    }

  }
  return 0;
}


Measured memory_bytes: 16560
/* In the name of God */

#include<bits/stdc++.h>

using namespace std;
//#define int long long
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define IOS() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define Dec cout<<fixed<< setprecision
#define endl "\n"
#define nlp printf("\n")
#define nl cout << "\n"
#define MP(make_pair)
#define SZ(x) (int) x.size()
#define tc() int t; cin >> t ; while (t--)
#define debug(x , y) cout << "### " << y << " is : " << x << " ###" << endl
#define clr(a) memset(a , 0 , sizeof a)
#define endl "\n"
#define bit(i , x) ((x >> i) & 1)
#define all(v) v.begin() , v.end()
typedef long long ll;
typedef pair<int,int> pii;
typedef long double ld;
typedef vector<int> VI ;
typedef vector<pii> VPI;

inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }

class FastIO{
public:
    inline FastIO & operator << (const int &a){ printf("%d" , a); return *this; }
//    inline FastIO & operator << (const long long &a){ printf("%I64d" , a); return *this; }
    inline FastIO & operator << (const double &a){ printf("%.9f" , a); return *this; }
    inline FastIO & operator << (const long double &a){ printf("%.9lf" , a); return *this; }
    inline FastIO & operator << (const char * const&a){ printf("%s" , a); return *this; }
    inline FastIO & operator << (const string &a){ printf("%s" , a.c_str()); return *this; }
    inline FastIO & operator >> (int &a){ scanf("%d" , &a); return *this; }
//    inline FastIO & operator >> (long long &a){ scanf("%I64d" , &a); return *this; }
    inline FastIO & operator >> (double &a){ scanf("%lf" , &a); return *this; }
    inline FastIO & operator >> (long double &a){ scanf("%lf" , &a); return *this; }
    inline FastIO & operator >> (char * const&a){ scanf("%s" , a); return *this; }
}fastIO;

const int MOD = 1e9 + 7 ;
const ld EPS = 1e-9 ;
const int INF = 1e9 + 10 ;
const ll LINF = 1e18 ;
const int N = 1e3 + 10 ;
const int maxn = 1e4 + 10 ;
const int MAXN = 1e5 + 10 ;
const int MN = 1e6 + 10 ;
inline int powmod(int x , int y){ ll res = 1 , a = x ; while(y){if(y&1) res = (res*a)%MOD ;  a = (a*a)%MOD ; y >>= 1 ;} return res ; }

string s ;

int32_t main (){
	IOS() ;
	cin >> s ;
	for(int i= SZ(s)-2 ; ~i ; i-= 2 ){
		string t = s.substr(0 , i/2) ;
		string t1 = s.substr(i/2 ,i/2) ;
		if(t == t1)
			return cout << i << endl , 0 ;
	}
	cout << 0 ;
	nl;	return 0 ;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
h = gets.chomp.split.map(&:to_i)
step = 0
count = 0

(n-1).times do |i|
    if h[i] >= h[i+1]
        step += 1
    else
        step = 0
    end
    count = step if step > count
end

puts count

Measured memory_bytes: 9604
def main():
    import sys
    import math
    a, b, h, m = tuple(map(int, sys.stdin.readline().split()))
    
    C = math.radians(abs(360*h/12 + 30*m/60 - 360*m/60))
    print(math.sqrt(a*a + b*b - 2*a*b*math.cos(C)))

if __name__ == "__main__":
    main()

Measured memory_bytes: 62604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define int ll
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'

#define fst first
#define pb push_back

const int MOD = (int)1e9 + 7;

void parse_domino(queue<int>& q, string S1, string S2) {
    REP(i, S1.length()) {
        const char c1 = S1.at(i);
        const char c2 = S2.at(i);
        if (c1 == c2) {
            q.push(1);
        } else {
            q.push(2);
            // 横に2マスなので、インデックスを1つ進める
            i++;
        }
    }
}

signed main() {
    int N;
    string S1, S2;

    cin >> N;
    cin >> S1;
    cin >> S2;

    // 横に見ていって、 1個か、2個かの2通り
    queue<int> q;
    parse_domino(q, S1, S2);

    // 1 1 -> 前と違う色にすればOK。2通り
    // 1 2 -> 2通り
    // 2 1 -> 1通り
    // 2 2 -> 3通り


    int prev = q.front();
    q.pop();

    int ans = 1;
    // 最初の1ブロックだけは単独で場合の数を決定
    if (prev == 1) {
        ans = 3;
    } else if (prev == 2) {
        ans = 3 * 2;
    }

    while(!q.empty()){
        int current = q.front();

        cerr << "--\n";
        debug(prev);
        debug(current);
        cerr << "--\n";

        q.pop();

        if (prev == 1 && current == 1) {
            ans = (ans * 2) % MOD;
        } else if (prev == 1 && current == 2) {
            ans = (ans * 2) % MOD;
        } else if (prev == 2 && current == 1) {
            ;
        } else if (prev == 2 && current == 2) {
            ans = (ans * 3) % MOD;
        } else {
            cerr << "unexpected case: " << prev << current << "\n";
        }

        prev = current;
    }

    cout << ans << endl;

    return 0;


    // for(auto i : queue) {

    //     cout << i << endl;
    // }

}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
 
#define ll long long
#define endl "\n"
#define mod 1000000007
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll a[n];
    bool hasZero = false;
    long double logs = 0;
    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
        logs += log10(a[i]);
        if(a[i] == 0)
            hasZero = true;
    }
    if(hasZero)
    {
        cout<<0<<endl;
        return 0;
    }
    if(logs > 18)
    {
        cout<<"-1\n";
        return 0;
    }
    ll sum = 1;
    for(int i = 0; i < n; i++)
    {
        sum *= a[i];
        if(sum > 1000000000000000000)
        {
            cout<<"-1\n";
            return 0;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

// 基本方針1: 右端でソートして右端が左にあるものから先に処理する
// 区間スケジューリングっぽい原理，厳密には理解してないが強いらしい
// 基本方針2: 右端が同じものがたくさんあるとき，右端のすぐ左で切ると切れる個数は最善になる
// これはほぼ当たり前
 
int main(){
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> v;
	for( int i = 0; i < m; ++i ){
		int a, b;
		cin >> a >> b;
		v.emplace_back(a, b);
	}
	// second が小さいものが先にくるようにソートする
	// JS と違ってラムダ関数内の return の後にセミコロンが必要
	sort( v.begin(), v.end(), []( auto &x, auto y ){ return x.second < y.second; } );
	// rmline が N のとき N と N+1 の間のところにある箸を全部切断している
	int rmline = 0;
	int ans = 0;
	for( int i = 0; i < m; ++i ){
		// rmline < 左端 となる区間はその区間内に rmline が入っていないので再度 rmline をとる
		// rmline を置き直した回数が答え
		if( rmline < v.at(i).first ){
			rmline = v.at(i).second - 1;
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int search(int A[],int N,int key){
    int i=0;
    A[N]=key;
    while(A[i]!=key) i++;
    return i!=N;
}
int main(void){
    int A[10001];
    int N,q,sum=0;
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    cin >> q;
    for(int i=0;i<q;i++){
        int key;
        cin >> key;
        if(search(A,N,key)) sum++;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;

    if (s == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
        return 0;
    }

    bool used[26] = {};
    for (auto c: s) {
        used[c - 'a'] = true;
    }
    if (s.size() == 26) {
        for (int i = 25; i >= 0; i--) {
            used[s[i]++ - 'a'] = false;
            while (s[i] <= 'z' && used[s[i] - 'a']) s[i]++;
            if (s[i] <= 'z') break;
            s.pop_back();
        }
        cout << s << endl;
    } else {
        int i = 0;
        while (used[i]) i++;
        cout << s << (char)(i + 'a') << endl;
    }

    return 0;
}


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

int main(){
  int n;
  cin >>n;
  ll l1 = 1;
  ll l2 = 2;
  ll ans = 0;
  for(int i = 0; i < n-1; i++){
    ans = l1+l2;
    l2 = l1;
    l1 = ans;
  }
  if(n==1) cout << 1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int R, C, N;

int get_num(int x, int y) {
    if(x == 0) return 0;
    if(y == C) return 1;
    if(x == R) return 2;
    if(y == 0) return 3;
    return -1;
}

int get_coor(int p, int x, int y) {
    if(p % 2 == 0) return y;
    else           return x;
}

signed main() {
    cin >> R >> C >> N;

    vector<pii> v[4];
    rep(i,0,N) {
        int x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        int l = get_num(x1, y1);
        int r = get_num(x2, y2);
        if(l < 0 || r < 0) continue;
        int x = get_coor(l, x1, y1);
        int y = get_coor(r, x2, y2);
        v[l].push_back(make_pair(x, i));
        v[r].push_back(make_pair(y, i));
    }

    sort(v[0].begin(), v[0].end());
    sort(v[1].begin(), v[1].end());
    sort(v[2].begin(), v[2].end(), greater<pii>());
    sort(v[3].begin(), v[3].end(), greater<pii>());

    vector<int> merged;
    rep(k,0,4) rep(i,0,v[k].size()) merged.push_back(v[k][i].second);

    stack<int> S;
    rep(i,0,merged.size()) {
        if(S.empty()) S.push(merged[i]);
        else {
            if(merged[i] == S.top()) S.pop();
            else S.push(merged[i]);
        }
    }

    cout << (S.empty() ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 7216
#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
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 1000000007
  #define N 1000001
  

int32_t main()
{




  int n,a,b;
  cin >> n >> a >> b;

  int ans =  (n/(a+b))*a;
  n %= (a+b);
  ans += min(n,a);
  cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    intl a[n],b[n],c[n - 1];
    cin(i,a);
    cin(i,b);
    cin(i,c);
    intl ans = b[a[0] - 1];
    intl bef = a[0] - 1;
    repi(i,1,n){
        ans += b[a[i] - 1];
        if(bef == a[i] - 2)ans += c[bef];
        bef = a[i] - 1;
    }
    cout << ans << endl;
    return 0;
}

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


int main(void){
    // Your code here!
    int n, t;
    cin>>n>>t;
    
    vector<pair<int, int>> c(n); 
    
    for(int i=0; i<n; i++){
        cin>>c[i].second>>c[i].first;
    }

    sort(c.begin(), c.end());
    
    int cmin=c[0].second;
    
    if(c[0].first<=t){
        for(int i=1; i<c.size(); i++){
            if(c[i].first<=t){
                cmin=min(cmin, c[i].second);
            }else{
                break;
            }
        }
        
        cout<<cmin<<endl;
    }else{
        cout<<"TLE"<<endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
using namespace std;
using Int = long long;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<55)+1e9; // ~ 3.6 * 1e16
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
using T = tuple<Int,Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
ostream& operator<<(ostream& o,T t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){Int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){Int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

class BIT{
public:
  typedef long long ll;
  ll n;
  vector<ll> bit;
  BIT():n(-1){};
  BIT(ll n_){
    n=1;
    while(n < n_+2) n *= 2;
    bit.resize(n+1, 0);
  }
  
  //[0, i]までの総和を得る
  ll sum(ll i){
    assert( i >= 0 && i <= n );
    i++;
    
    ll s=0;
    while(i>0){
      s = (s + bit[i]);
      i -= i & -i;
    }
    return s;
  }

  //i番目の要素にx加算(0 オリジン)
  void add(ll i,ll x){
    assert( i >= 0 && i <= n );
    i+=2;
    
    while(i <= n){
      bit[i] = (bit[i] + x);
      i += i & -i;
    }
  }
  
  ll sum(Int l,Int r){ //[l, r) 0オリジン
    assert(l <= r);
    assert( 0 <= l && l <= n);
    assert( 0 <= r && r <= n);
    return sum(r) - sum(l);
  }
};


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int n;
  cin>>n;
  vector<Int> A(n);
  cin>>A;

  auto B = A; sort(B.begin(), B.end());
  cout<<B<<endl;

  map<Int,deque<Int> > Idx;
  for(Int i=0;i<n;i++) Idx[A[i]].push_back(i);

  BIT bit(n);
  for(Int i=0;i<n;i++) bit.add(i,1);
  Int ans = 0;
  for(Int i=0;i<n;i++){
    Int idx = Idx[B[i]][0];
    Idx[B[i]].pop_front();
    ans += bit.sum(0,idx);
    bit.add(idx, -1);
  }

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



Measured memory_bytes: 3224
use proconio::{fastout, input};
use proconio::marker::Chars;

#[fastout]
fn main() {
  input! {
    a: i64,
    s: Chars,
  }
  let mut b = 0;
  for c in s{
    if c.is_digit(10) {
      b = b*10 + c.to_digit(10).unwrap();
    }
  }
  println!("{}", a * b as i64 /100);
}

Measured memory_bytes: 2148
#include<bits/stdc++.h>
#define fr(i,a,b) for(register int i = a;i <= b;++i)
#define int long long
#define N 1000010
using namespace std;

inline int read(){
	int x = 0,f = 1;char c = getchar();
	while(!isdigit(c)){if(c == '-')f = -1;c = getchar();}
	while(isdigit(c)){x = x * 10 + c - '0';c = getchar();}
	return f * x;
}

inline int fread(){
	char c = getchar();
	while(!isdigit(c))c = getchar();
	return c - '0';
}

signed main(){
	string s;
	cin>>s;
	fr(i,0,s.size() - 1){
		if(((i + 1) & 1) && s[i] == 'L'){cout<<"No";return 0;}
		if((i + 1) % 2 == 0 && s[i] == 'R'){cout<<"No";return 0;}
	}
	cout<<"Yes";
	return 0;
}

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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

const int INF = 1e9;
ll gcd(ll a,ll b) {
	if (a%b==0) return(b);
	else return(gcd(b,a%b));
}


int main(void){

	int K; cin >> K;

	ll ans = 0;
	FOR(i,1,K+1){
		FOR(j,1,K+1){
			FOR(k,1,K+1){
				ans += gcd(i, gcd(j, k));
			}
		}
	}

	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

string S;
int cnt;

bool check(char w){
    string ACGT = "ACGT";
    rep(i,4)
        if(w == ACGT[i]) return true;
    return false;
}

void solve(){
    int cnt = 0, ans = 0;
    rep(i, S.size()){
        if(check(S[i])) cnt++;
        else{
            cnt = 0;
        }
        ans = max(cnt, ans);
    }
    cout << ans << endl;
}

int main(){
    cin >> S;

    solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  string S;
  cin >> S;
  ll N = S.size();

  ll ans = 0;
  vector<ll> counts(2019);

  ll R, T;
  
  // Init
  {
    if (S[N - 1] == '0') {
      ++ans;
    }
    R = stoi(S.substr(N - 1, 1)) % 2019;
    counts[R]++;
    T = 1;
  }

  // Iterate
  for (ll i = N - 2; i >= 0; --i) {
    ll d = S[i] - '0';
    T = T * 10 % 2019;
    R = (d * T + R) % 2019;
    if (R == 0) ++ans;
    ans += counts[R];
    counts[R]++;
  }

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


Measured memory_bytes: 3288
#include "bits/stdc++.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

int a[N];
bool seen[N];

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);

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

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    int len = -1;
    map<int, int> pos;
    vector<int> b;
    int curr = 1, p = 1;
    while (1) {
        if (seen[curr]) {
            len = p - pos[curr];
            break;
        }
        seen[curr] = 1;
        pos[curr] = p;
        b.pb(curr);
        curr = a[curr];
        p++;
    }

    // cout << "len = " << len << "\n";

    // for (int i: b) {
    //     cout << i << "\n";
    // }

    int m = b.size();
    if (k < m) {
        cout << b[k];
    } else {
        k -= m;
        cout << b[m - len + k % len];
    }
}

Measured memory_bytes: 18644
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    string S;
    cin >> N >> K >> S;
    int l = 0, r = 0, k = 0, res = 0;
    while (r < N) {
        while (r < N && k < K) {
            if (S[r] == '0' && S[r + 1] == '1') {
                k++;
            }
            r++;
        }
        while (S[r] == '1') {
            r++;
        }
        amax(res, r - l);
        while (k == K) {
            if (S[l] == '0' && S[l + 1] == '1') {
                k--;
            }
            l++;
        }
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;

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

	vector<int> odr(N);
	vector<int> suf(N);
	vector<int> bon(N - 1);

	for (auto &x : odr) cin >> x;
	for (auto &x : suf) cin >> x;
	for (auto &x : bon) cin >> x;

	int suf_val = 0;
	int pre_ord = N;

	for (auto it = odr.begin(); it != odr.end(); it++) {
		suf_val += suf[*(it) - 1];
		if (*(it) == pre_ord + 1) {
			suf_val += bon[pre_ord - 1];
		}
		pre_ord = *(it);
	}

	cout << suf_val << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

/*
int main(){
  int i=0, p=0, sum=0;
  for(i=0;i<10;i++){
    scanf("%d" ,&p);
    sum += p;
  }
  
  printf("%d\n" , sum);
  return 0;
}
*/

int isEq(double a, double b){
  return labs(a-b)<0.001;
}

int main(){
  int c1x, c1y, c1r, c2x, c2y, c2r;
  double br, sr; // Big Radius, Small Radius
  scanf("%d %d %d" ,&c1x ,&c1y, &c1r);
  scanf("%d %d %d" ,&c2x ,&c2y, &c2r);

  double dist = sqrt(pow(c1x-c2x, 2) + pow(c1y-c2y, 2));
  double rad  = sqrt(pow(c1r+c2r, 2));
  if(c1r>c2r){
    br = c1r; sr = c2r;
  }else{
    br = c2r; sr = c1r;
  }
  br = sqrt(pow(br,2));
  sr = sqrt(pow(sr,2));
  if(isEq(dist,rad)){
    printf("3\n");
  }else if(dist>rad){
    printf("4\n");
  }else if( isEq((dist+sr),br) ){
    printf("1\n");
  }else if( (dist+sr) > br ){
    printf("2\n");
  }else{
    printf("0\n");
  }

  return 0;
}



Measured memory_bytes: 2696
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int cmp1(const void *p,const void *q)//昇順
{
    return *(int *)p - *(int *)q;
}

typedef long long int int64;
int64 max2(int64 a, int64 b) { return a > b ? a : b; }

int64 max3(int64 a, int64 b, int64 c) { return ((a > b ? a : b) > c ? (a > b ? a : b) : c); }


int main()
{
    int n,x,y,i;
    int plus[200010];
    int minus[200010];
    int64 ans=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d %d",&x,&y);
        plus[i]=x+y;
        minus[i]=x-y;
    }
    qsort(plus,n,sizeof(int),cmp1);
    qsort(minus,n,sizeof(int),cmp1);

    int64 maxplus=(int64)plus[n-1];
    int64 minplus=(int64)plus[0];
    int64 maxminus=(int64)minus[n-1];
    int64 minminus=(int64)minus[0];

    ans=max2((maxplus-minplus),max3((minminus-maxminus),(maxminus-minminus),(minplus-maxplus)));


    printf("%lld",ans);
}



Measured memory_bytes: 4052
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>

#define N_MAX 200000
#define MODVAL 1000000007

int s[100000];
char ret[100002];
int n;

int fnc(int num, long long int a, long long int b, long long int c){
	int result;

	if( n == num){
		return 0;
	}


	switch(s[num]){
		case 0: //AB
			if(b > 0){
				result = fnc(num+1,a+1,b-1,c);
				if(result == 0){ ret[num] = 'A'; return 0;	}
			}
			if(a > 0){
				result = fnc(num+1,a-1,b+1,c);
				if(result == 0){ ret[num] = 'B'; return 0;	}
			}
			break;

		case 1: //BC

			if(c > 0){
				result = fnc(num+1,a,b+1,c-1);
				if(result == 0){ ret[num] = 'B'; return 0;	}
			}
			if(b > 0){
				result = fnc(num+1,a,b-1,c+1);
				if(result == 0){ ret[num] = 'C'; return 0;	}
			}
			break;

		case 2: //AC

			if(c > 0){
				result = fnc(num+1,a+1,b,c-1);
				if(result == 0){ ret[num] = 'A'; return 0;	}
			}
			if(a > 0){
				result = fnc(num+1,a-1,b,c+1);
				if(result == 0){ ret[num] = 'C'; return 0;	}
			}
			break;

	}
	return -1;

}


int main(void){
	long long int a,b,c;
	int i;
	char str[3];
	int f;


	scanf("%d",&n);
	scanf("%lld",&a);
	scanf("%lld",&b);
	scanf("%lld",&c);

	for(i=0;i<n;i++){
		scanf("%s",str);
		if(strncmp(str,"AB",2)==0){
			s[i] = 0;
		}else if(strncmp(str,"BC",2)==0){
			s[i] = 1;
		}else{
			s[i] = 2;
		}
	}

	f = fnc(0 ,a, b, c);

	if(f==0){
		printf("Yes\n");
		for(i=0;i<n;i++){
			printf("%c",ret[i]);
			printf("\n");
		}
	}else{
		printf("No\n");
	}


	return 0;
}


Measured memory_bytes: 6832
import java.util.Scanner;

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

		int x = sc.nextInt();
		int max = 1;
		for (int i = 2; i <= x; i++) {
			int tmp = i * i;
			while (tmp <= x) {
				max = Math.max(max, tmp);
				tmp *= i;
			}
		}
		System.out.println(max);
		sc.close();
	}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC60(void);
void ABC61(void);
void ABC62(void);
void ABC63(void);
void ABC64(void);
void ABC65(void);
void ABC66(void);
void ABC67(void);
void ABC68(void);
void ABC69(void);

int main(void){
    ABC69();
}

void ABC69(){
    int n,i;
    string s;
    cin>>s;
    cout<<s[0]<<s.length()-2<<s[s.length()-1]<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>

void update(int a,int b);

using namespace std;
/*
#define clear(a) memset((a), 0, sizeof(a))
#define mclear(a) memset((a), -1, sizeof(a))
#define show(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
*/
pair<int, int> seg[1 << 18];



int main(){
  int n,r,l;
  int team[100000]={0};
  
  scanf("%d %d %d",&n,&r,&l);
  for(int i=0; i<n; i++) update(i,0);
  int watch=0,sento=0;

  for (int i=0;i<r;i++){
    int d,t,x;
    scanf("%d %d %d",&d,&t,&x);
    team[sento]+=t-watch;
    update(d-1,x);
    sento=seg[0].second-1;
    watch=t;
  }
  team[sento]+=l-watch;
  
  int maxi = 0;
  for (int i=1;i<n;i++){
    if(team[maxi]<team[i]) maxi=i;
  }
  printf("%d\n",maxi+1);
  return (0);
}



void update(int k, int x){
  int id = k + 1;
  k += (1 << 17) - 1;
  seg[k].first += x;
  seg[k].second = id;
  
  while (k){
    k = (k - 1) / 2;
    if (seg[k * 2 + 1].first > seg[k * 2 + 2].first){
      seg[k] = seg[k * 2 + 1];
    }
    else if (seg[k * 2 + 1].first < seg[k * 2 + 2].first){
      seg[k] = seg[k * 2 + 2];
    }
    else {
      seg[k] = seg[k * 2 + 1];
    }
  }

}

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

bool isPrime(ll n) {
    // n is always >= 2
    ll a = 2;
    ll orig_n = n;
    if (n == 2) return true;
    while (a <= sqrt(orig_n)) {
        if (orig_n % a == 0) return false;
        a++;
    }
    return true;
}

int main() {
    ll X; cin >> X;
    if (X == 2) {
        cout << 2 << endl;
        return 0;
    }
    if (X % 2 == 0) {
        X++;
    }
    while (true) {
        if (isPrime(X)) {
            cout << X << endl;
            return 0;
        }
        X++;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>
#include <cmath>

int main(){
    
   //３の倍数ならそのまま

   //3の倍数でない時

    double y;
    cin >> y;
    y = y / 3.0;

    //普通にcout
    //cout << y << endl;

    //小数点以下の長さを指定
    cout << fixed << setprecision(20) << y * y * y << endl;

   
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
const ll m = (1e+9) + 7;

int main() {
	int a, b;
	cin >> a >> b;
	cout << max(a + b, max(a - b, a * b)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main (){ 
    int v[9]={0};
    int n;
    cin>>n;
    rep(i,0,n){
        int x; cin>>x;
        if(x>=3200){
            v[8]++;
            continue;
        }
        v[x/400]=1;
    }
    cout<<max(accumulate(v,v+8,0),1)<<" ";
    cout<<accumulate(v,v+8,0)+v[8]<<endl;
    return 0;
}


/*
10
9 4
4 3
1 1
4 2
2 4
5 8
4 0
5 3
0 5
5 2
0

*/


Measured memory_bytes: 256
from heapq import heappush, heappop

while True:
    n, m = map(lambda x:int(x), raw_input().split())
    if n == 0: break
    g = [[] for i in range(n)]
    for i in range(m):
        a,b,c = map(lambda x:int(x), raw_input().split())
        a -= 1
        b -= 1
        g[a].append((b,c))
        g[b].append((a,c))
    heap = []
    visited = [False]*n
    edges = []
    heappush(heap, (0,0))
    while len(heap):
        d,v = heappop(heap)
        if visited[v]: continue
        visited[v] = True
        edges.append(d)
        for u,dd in g[v]:
            if not visited[u]:
                heappush(heap, (dd,u))
    print sorted(edges)[len(edges)/2]

Measured memory_bytes: 7872
l = input()
n = len(l)
MOD = 10**9+7

dp0 = [0 for _ in range(n)]
dp1 = [0 for _ in range(n)]

dp0[0] = 1
dp1[0] = 2

for i in range(1,n):
  if l[i] == '0':
    dp1[i] = dp1[i-1]
    dp0[i] = dp0[i-1] * 3
  else:# l[i] == '1'
    dp1[i] = dp1[i-1] * 2
    dp0[i] = dp1[i-1] + dp0[i-1] * 3
  dp1[i] %= MOD
  dp0[i] %= MOD  
print((dp1[-1] + dp0[-1])%MOD)
  

Measured memory_bytes: 11124
s = input()
t = input()

def make_signature(str_):
    dict_ = {}
    sign = []
    cnt = 0
    for s_ in str_:
        if s_ not in dict_:
            dict_[s_] = cnt
            cnt += 1
        sign.append(dict_[s_])
        
    return sign

print('Yes' if make_signature(s) == make_signature(t) else 'No')


Measured memory_bytes: 6832
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	
	string str;
	ll sum = 0;
	cin>>str;
	for(int i=0;i<str.size();++i){
		sum+=(str[i]-'0');
	}
	if(sum%9==0){
		cout<<"Yes";
	}else{
		cout<<"No";
	}				
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  bool con = true;
  vector<int> A(n);
  rep(i, n) cin >> A[i];
  rep(i,n){
    if(A[i] % 2 == 0){
      if(A[i] % 3 == 0 || A[i] % 5 == 0){
        continue;
      } else {
        con = false;
        break;
      }
    }
  }
  cout << (con ? "APPROVED" : "DENIED") << endl;
  return 0;
}

Measured memory_bytes: 256
#include "iomanip"
#include "iostream"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;

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

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

template <typename T>
void drop(const T& x) {
  cout << x << endl;
  exit(0);
}

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

  string S, T;
  cin >> S >> T;
  ll A, B;
  cin >> A >> B;
  string U;
  cin >> U;

  if (S == U) {
    printf("%d %d\n", A - 1, B);
  } else {
    printf("%d %d\n", A, B - 1);
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
int main(){
  int a[N],b[N][N];
  int n,i,j,x,y,z;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d%d",&a[i],&j);
   
  a[n]=j;
   
  for(i=1;i<=n;i++) b[i][i]=0;
  
   for(j=2;j<=n;j++){
    for(i=1;i<=n-j+1;i++){
      y = i+j-1;
      b[i][y] = 10000000;
      for(x=i;x<=y-1;x++){
     
    z = b[i][x]+b[x+1][y]+(a[i-1]*a[x]*a[y]);
         
    if(b[i][y]>z) b[i][y]=z;
    
      }
    }
  }
  printf("%d\n",b[1][n]);
     
  return 0;
}

Measured memory_bytes: 636
#include <stdio.h>

int main(void)
{
     int sort[5];
     int i, j, t;

     for(i=0; i<5; i++){
	  scanf("%d", &sort[i]);
     }
     
     for(i=0; i<5; i++){
	  for(j=0; j<5; j++){     
	       if(sort[i]>sort[j]){
		    t = sort[j];
		    sort[j] = sort[i];
		    sort[i] = t;
	       }
	  }
     }


     for(i=0; i<5; i++){
	  printf("%d", sort[i]);
	  if(i<4) printf(" ");
	  if(i==4) printf("\n");
     }
     
     return 0;
}

Measured memory_bytes: 600