akhauriyash/Code-Regression huggingface dataset:
module app;

import core.bitop;

import std.algorithm;
import std.array;
import std.bigint;
import std.container.rbtree;
import std.conv;
import std.stdio;
import std.string;
import std.traits;

struct Input
{
	int n, x, t;
}

void parseInput(T)(out Input input, T adapter)
{
	with (input)
	{
		adapter.readf!"%d "(n);
		adapter.readf!"%d "(x);
		adapter.readf!"%d"(t);
	}
}

struct Output
{
}

auto main2(Input* input)
{
	with (input)
	{
		return (n + x - 1) / x * t;
	}
}

alias retType = ReturnType!main2;
static if (!is(retType == void))
{
	unittest { writeln("begin unittest"); }
	auto _placeholder_ = ReturnType!main2.init;

	unittest // example1
	{
		string example =
`20 12 6`;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == 12);
	}

	unittest // example2
	{
		string example =
`1000 1 1000`;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == 1000000);
	}

	unittest // example3
	{
		string example =
``;
		if (example.empty) return;
		Input input = void;
		parseExample(input, example);
		auto result = main2(&input);
		printResult(result);
		assert(result == _placeholder_);
	}

	unittest { writeln("end unittest"); }

	void parseExample(out Input input, string example)
	{
		parseInput(input, new StringAdapter(example));
	}
}

class StdinAdapter
{
	// readf!"%s"は使えない
	// https://issues.dlang.org/show_bug.cgi?id=19820
	uint readf(alias format, A...)(auto ref A args) { return std.stdio.readf!format(args); }
	string readln() { return std.stdio.readln().strip(); }
}

class StringAdapter
{
	import std.format;
	string _s;
	this(string input) { _s = input; }
	uint readf(alias format, A...)(auto ref A args) { return _s.formattedRead!format(args); }
	string readln()
	{
		auto i = _s.countUntil("\n");
		if (i == -1) i = _s.length;
		string ret = _s[0..i];
		_s = _s[i..$];
		return ret;
	}
}

void printResult(T)(T result)
{
	static if (isFloatingPoint!T) writefln("%f", result);
	else writeln(result);
}

void main()
{
	Input input = void;
	parseInput(input, new StdinAdapter());
	static if (is(retType == void))
		main2(&input);
	else
	{
		auto result = main2(&input);
		printResult(result);
	}
}


Measured memory_bytes: 2828
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

struct perm {
private:
	int sz;
	vector<ll> p, invp;
public:
	perm(int n) {
		sz = n + 1;
		p.resize(sz), invp.resize(sz);
		p[0] = 1;
		rep1(i, sz - 1) {
			p[i] = p[i - 1] * i%mod;
		}
		invp[sz - 1] = 1;
		ll cop = mod - 2, x = p[sz - 1];
		while (cop) {
			if (cop % 2)invp[sz - 1] = invp[sz - 1] * x%mod;
			cop >>= 1; x = x * x % mod;
		}
		per(i, sz - 1) {
			invp[i] = invp[i + 1] * (i + 1) % mod;
		}
	}
	ll comb(ll x, ll y) {
		if (x < y || y < 0)return 0;
		ll ret = p[x];
		(ret *= invp[y]) %= mod;
		(ret *= invp[x - y]) %= mod;
		return ret;
	}
	ll combP(ll x, ll y) {
		if (x < y || y < 0)return 0;
		return p[x] * invp[x - y] % mod;
	}
};
perm p(1 << 20);

ll t3[700001];

void solve() {
	t3[0] = 1;
	rep(i, 700000)t3[i + 1] = t3[i] * 3 % mod;
	int n, m, k; cin >> n >> m >> k;
	ll ans = 0;
	ll cur = 0;
	rep(t, m + k + 1) {
		ll csum = p.comb(t + n-1, t)*t3[m+k-t]%mod;
		ll ncur = 0;
		if (t == 0) {
			cur = 1;
		}
		else {
			int ple = max(t - 1 - k, 0);
			int pri = min(m, t - 1);
			int le = max(t - k, 0);
			int ri = min(m,t);
			ncur += cur;
			cur += mod-p.comb(t - 1, ple);
			cur += p.comb(t - 1, pri + 1);
			if (le == ple)cur++;
			if (pri == ri) {
				//cur += mod - 1;
				cur += mod - p.comb(t - 1, pri);
				cur += mod - p.comb(t - 1, pri + 1);
			}
			while (cur >= mod)cur -= mod;
			ncur += cur;
			while (ncur >= mod)ncur -= mod;
			cur = ncur;
			//cout << t << " " << ncur << endl;
		}
		ans += cur * csum%mod;
		if (ans >= mod)ans -= mod;
		//cout << ans << endl;
	}
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}

Measured memory_bytes: 22144
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int N, Q; cin >> N >> Q;
    dsu d(N);
    rep(i, Q) {
        int t, u, v; cin >> t >> u >> v;
        if (t) {
            if (d.same(u, v)) cout << 1 << endl;
            else cout << 0 << endl;
        }
        else {
            d.merge(u, v);
        }
    }
}


Measured memory_bytes: 3984
#include <stdio.h>

int main (void)
{
	int n,i,X[100];
	
	scanf("%d/n",&n);
	
	for(i = 0;i < n;i++){

	scanf("%d\n",&X[i]);

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

	}
	
		printf("\n");
	return 0;

}

Measured memory_bytes: 604
N,T = map(int, input().split(" "))

way = []

for i in range(N):
  c,t = map(int, input().split(" "))
  if T >= t:
    way.append(c)
  
if len(way) == 0:
  print("TLE")
else:
  way.sort()
  print(way[0])

Measured memory_bytes: 3060
#include <stdio.h>
int main(void){
    int i,j,k, n;
    int data[4][3][10] = {{{0}}};
    scanf("%d", &n);
    for(i = 0; i < n; i++) {
        int b, f, r, v;
        scanf("%d %d %d %d", &b, &f, &r, &v);
        data[b-1][f-1][r-1] += v;
    }
        for(i=0;i<4;i++){
            for(j=0;j<3;j++){
                for(k=0;k<10;k++){
                    if(data[i][j][k]==0){
                    printf(" 0");
                }
                else{
                    printf(" %d",data[i][j][k]);
                }
            }
            printf("\n");
        }
        if(i!=3){
            printf("####################\n");
        }
    }
    return 0;
}



Measured memory_bytes: 2756
from bisect import bisect_left
import sys
def input():
    return sys.stdin.readline()[:-1]
A,B,Q=map(int,input().split())
s=[int(input()) for i in range(A)]
t=[int(input()) for i in range(B)]
for i in range(Q):
    x=int(input())
    si=bisect_left(s,x)
    ti=bisect_left(t,x)
    a=[]
    if si and si!=A:
        sl=s[si-1]
        sr=s[si]
    elif si:
        sl=s[-1]
        sr=0
    else:
        sl=0
        sr=s[0]
    if ti and ti!=B:
        tl=t[ti-1]
        tr=t[ti]
    elif ti:
        tl=t[-1]
        tr=0
    else:
        tl=0
        tr=t[0]
    if sl and tl:
        a.append(x-min(sl,tl))
    if sr and tr:
        a.append(max(tr,sr)-x)
    if sl and tr:
        a.append(tr-x+tr-sl)
        a.append(x-sl+tr-sl)
    if sr and tl:
        a.append(x-tl+sr-tl)
        a.append(sr-x+sr-tl)
    print(min(a))

Measured memory_bytes: 84572
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll x;
    cin >> x;
    ll w = 100;
    ll cnt = 0;
    while(w < x)
    {
        cnt++;
        w += w / 100;
        //cout << w << endl;
    }
    cout << cnt << "\n";
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using i64=int_fast64_t;

int memo[1<<18];

int calc(int n)
{
    if(~memo[n]) return memo[n];
    int &res=memo[n];
    if(!n) res=0;
    else res=1+calc(n%__builtin_popcount(n));
    return res;
}

main()
{
    fill(begin(memo), end(memo), -1);

    int n; cin>>n;
    string x; cin>>x;
    int pop=0;
    for(char c: x)
    {
        pop+=c-'0';
    }
    reverse(begin(x), end(x));
    vector<int> ans(n);

    if(pop>1)
    {
        pop--;
        int sum=0;
        for(int i=0,j=1; i<n; i++)
        {
            if(x[i]-'0') sum=(sum+j)%pop;
            j=j*2%pop;
        }
        for(int i=0,j=1; i<n; i++)
        {
            if(x[i]-'0')
            {
                ans[i]=1+calc((sum-j+pop)%pop);
            }
            j=j*2%pop;
        }
        pop++;
    }
    if(pop==1)
    {
        for(int i=0; i<n; i++) if(x[i]-'0') ans[i]=0;
    }

    {
        pop++;
        int sum=0;
        for(int i=0,j=1; i<n; i++)
        {
            if(x[i]-'0') sum=(sum+j)%pop;
            j=j*2%pop;
        }
        for(int i=0,j=1; i<n; i++)
        {
            if(x[i]-'1')
            {
                ans[i]=1+calc((sum+j+pop)%pop);
            }
            j=j*2%pop;
        }
        pop--;
    }

    reverse(begin(ans), end(ans));

    for(int x: ans)
        cout << x << "\n";
}

Measured memory_bytes: 5468
#include<iostream>
#include<vector>
using namespace std;
 
int main() {
 
  vector<int> S(2);
  cin >> S.at(0);
  S.at(1) = S.at(0)%100;
  S.at(0) /= 100;
  
  if(0<S.at(0) && S.at(0)<13){
    if(0<S.at(1)&& S.at(1)<13){ 
      cout << "AMBIGUOUS" << endl;
    }else{
      cout << "MMYY" <<endl;
    }
    
  }else{
    if(0<S.at(1)&&S.at(1)<13){
      cout << "YYMM" << endl;
    }else{
      cout << "NA" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
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;
}

#define MAX 1000100
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
// 二項係数計算
ll combi(ll n, ll k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
// mainに   COMinit();   を入れる

int main() {
    COMinit();
    ll s;
    cin >> s;
    if (s < 3) {
        cout << 0 << "\n";
        return 0;
    }

    ll ans = 0;

    rep(i, s / 3 + 1) {
        ll num = s - i * 3;
        ans += combi(num + i - 1, i - 1);
        ans %= mod;
    }

    cout << ans << "\n";
    return 0;
}

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

#define lli long long int
#define pb push_back
#define pii pair <int, int>
#define pll pair <lli, lli>
#define _F first
#define _S second
#define mset(x) memset(x, 0, sizeof(x))
#define fastio() ios_base::sync_with_stdio(0)

using namespace std;

lli tonum(lli, lli, lli);

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

	lli A[n+1];
	for(int i=0; i<n; i++)
		cin >> A[i];

	A[n] = A[0];

	lli sum = 0;
	lli sig = 0;
	for(int i=1; i<=n; i++)
	{
		sum += A[i];
		sig += i;
	}	

	if(sum % sig == 0)
	{
		lli num = sum / sig;

		lli c = 0;

		for(int i=0; i<n; i++)
			if(A[i+1] - A[i] != num)
				c += tonum(A[i+1] - A[i], num, n);

		if(c == num)
			printf("YES\n");
		else
			printf("NO\n");
	}
	else
		printf("NO\n");
}

lli tonum(lli cur, lli tar, lli n)
{
	lli c = 0;

	while(cur < tar)
	{
		c++;
		cur += n;
	}

	return c;
}

Measured memory_bytes: 1024
#define NIL -1
#define MAX 100005
#include <stdio.h>
struct Node {
    int parent;
    int left;
    int right;
};
struct Node T[MAX];

int getDepth(int n) {
    int d = 0;
    while (T[n].parent != NIL) {
        n = T[n].parent;
        d++;
    }
    return d;
}

int main() {
    int n = 0;
    scanf("%d", &n);
    //初始化
    for (int i = 0; i < n; i++) {
        T[i].parent = T[i].left = T[i].right = NIL;
    }
    //构造树，左子右兄
    for (int i = 0; i < n; i++) {
        //v为结点编号 d为子节点数量 l用于内层循环中记录上一个子节点编号
        int v = 0, d = 0, l = 0;
        scanf("%d %d", &v, &d);
        for (int j = 0; j < d; j++) {
            //子节点编号
            int c = 0;
            scanf("%d", &c);
            if (j == 0) {
                T[v].left = c;
            }
            else {
                T[l].right = c;
            }
            //这个技巧要熟练
            l = c;
            T[c].parent = v;
        }
    }
    //输出各结点信息
    for (int i = 0; i < n; i++) {
        printf("node %d: parent = %d, depth = %d, ", i, T[i].parent, getDepth(i));
        if (T[i].parent == NIL) {
            printf("root");
        }
        else if (T[i].left == NIL) {
            printf("leaf");
        }
        else {
            printf("internal node");
        }
        printf(", [");
        int tmp = T[i].left;
        while (tmp != NIL) {
            if (tmp != T[i].left) {
                printf(", ");
            }
            printf("%d", tmp);
            tmp = T[tmp].right;
        }
        printf("]\n");
    }
    return 0;
}


Measured memory_bytes: 3028
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <time.h>

#define loop(i, num)  for (int i = 0; i < num; i++)

using namespace std;

int n, m;

int main() {
    
    cin >> n >> m;
    
    m /= 1000;
    
    for (int i = 0; i <= n; i++) {
        
        for (int j = 0; j <= n; j++) {
            
            if (4 * i + 9 * j == m - n && i + j <= n) {
                
                cout << j << ' ' << i << ' ' << (n - i - j) << endl;
                
                return 0;
                
            }
            
        }
        
    }
    
    cout << "-1 -1 -1" << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,i;
    while(cin>>n>>k)
    {
        string s[106];
        for(i=0;i<n;i++){

            cin>>s[i];
        }
            sort(s+0,s+n);


        for(i=0;i<n;i++)
        {
            cout<<s[i];
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3600
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;

int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対グラフ

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

int main(){
    int n;
    cin >>n;
    int ans =n;
    int h[n];
    rep(i,n){
        cin >> h[i];
        rep(j,i){
            if(h[i]<h[j]){
                ans-=1;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn.{readInt, readLine};
import scala.collection.mutable.PriorityQueue;

object Main {
    def main(args: Array[String]): Unit = {
        val size = readInt;
        val graph: Array[List[(Int, Int)]] = new Array[List[(Int, Int)]](size); // (index, cost)
        for (i <- (0 until size)) {
            val input = readLine.split(" ").map(_.toInt).drop(2);
            val dstNum = input.length / 2;
            val dsts = (0 until dstNum).foldLeft[List[(Int,Int)]](Nil) { (dsts, j) => 
                (input(j * 2), input(j * 2 + 1)) :: dsts
            }
            graph(i) = dsts;
        }
        val output = shortestPath(size, graph).zipWithIndex.map(e => "%d %d".format(e._2, e._1));
        println(output.mkString("\n"));
    }
    
    def shortestPath(size: Int, graph: Array[List[(Int, Int)]]): Array[Int] = {
        val dist = new Array[Int](size).map(a => Int.MaxValue);
        val stat = new Array[Int](size); // 0 : 未追加, 1 : 追加済み
        implicit val ord = Ordering.by((e: (Int, Int)) => e._2).reverse;
        val pq = new PriorityQueue[(Int, Int)]();
        def go(): Unit = {
            if (!pq.isEmpty) {
                val (index, cost) = pq.dequeue;
                if (stat(index) == 0) {
                    stat(index) = 1;
                    graph(index).filter(e => stat(e._1) == 0).foreach { e =>
                        val dstIndex = e._1;
                        val newDstCost = e._2 + dist(index);
                        if (newDstCost < dist(dstIndex)) {
                            dist(dstIndex) = newDstCost;
                            pq.enqueue((dstIndex, newDstCost));
                        }
                    }
                }
                go();
            }
            
        }
        dist(0) = 0;
        pq.enqueue((0, dist(0)));
        go();
        dist;
    }
}


Measured memory_bytes: 215116
#include <iostream>
#include <set>
#include <cmath>
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b)
{
	while (1)
	{
		if (b==0) return a;
		a=a%b;
		if (a==0) return b;
		b=b%a;
		if (b==0) return a;
	}
}
ll lcm(ll a, ll b)
{
	return a*b/gcd(a,b);
}
int main()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll e=lcm(c,d);
	ll s1=b/c-(a-1)/c;
	ll s2=b/d-(a-1)/d;
	ll s3=b/e-(a-1)/e;
	ll ans=s1+s2-s3;
	
	cout << (b-a+1)-ans;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

int main(){
    int n=in(),m=in(),x=in();
    vec c(n);
    vector<vec> a(n,vec(m));
    rep(i,n){
        c[i]=in();
        rep(j,m)a[i][j]=in();
    }
    int ans = INT_MAX;
    rep(k,1<<n){
        vec t(m);
        int cost=0;
        rep(i,n)if(k&(1<<i)){
                cost+=c[i];
                rep(j,m)t[j]+=a[i][j];
        }
        bool flag=true;
        rep(i,m)if(t[i]<x)flag=false;
        if(flag)ans=min(ans,cost);
    }
    if(ans==INT_MAX)ans=-1;
    cout<<ans<<endl;
}


Measured memory_bytes: 3704
sx,sy,tx,ty = map(int,input().split())

def invert(T):
    d = dict([('R','L'),('L','R'),('U','D'),('D','U')])
    return (''.join(map(lambda x:d[x],list(T))))[::-1]

dist = lambda a,b:abs(a-b)
O = ""

O +=        "L" +  "U"*dist(sy  ,ty+1) + "R"*dist(sx-1,tx  )        + "D"
O += invert("U" +  "U"*dist(sy+1,ty  ) + "R"*dist(sx  ,tx-1)        + "R")
O +=        "R" + ("U"*dist(sy  ,ty-1) + "R"*dist(sx+1,tx  ))[::-1] + "U"
O += invert("D" + ("U"*dist(sy-1,ty  ) + "R"*dist(sx  ,tx+1))[::-1] + "L")

print(O)

Measured memory_bytes: 3064
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main() {

	string s;
	cin >> s;

	int l = s.length();


	cout << s[0] << l-2 << s[l - 1] << endl;


	

	return 0;
}

Measured memory_bytes: 256
int main(void)
{
    int a,b,k;
    
    scanf("%d%d%d",&a,&b,&k);
    int i=a,j=b-k+1;
    while((i<a+k)&&(i<=b)){
        printf("%d\n",i);
        i++;
    }
    if(i>j) j=i;
    while(j<=b){
        printf("%d\n",j);
        j++;
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
const int MOD = 1e9 + 7;
const int INF = 1e9;
const double EPS = 1e-9;
const double pi = acos(-1);
int main(){
  int q;
  scanf("%d", &q);
  while(q--){
    LL a, b;
    scanf("%lld%lld", &a, &b);
    if(a > b) swap(a, b);
    LL rank = 1LL * a * b - 1;
    LL akar = (LL) sqrtl(rank);
    if(akar){
      LL bagi = rank / akar;
      LL tot = akar * 2;
      if(akar >= a) tot--;
      if(akar == bagi) tot--;

      printf("%lld\n", tot);
    }
    else{
      puts("0");
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

long count_two(long x){
    int cnt = 0;
    while(x % 2 == 0){
        x /= 2;
        cnt++;
    }
    return cnt;
}

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

int main(){
    long n,m;
    cin >> n >> m;
    vector<long> a(n);
    long cnt = 0;
    rep(i,n){
        cin >> a.at(i);
        if(i == 0) cnt = count_two(a.at(i));
        else{
            if(count_two(a.at(i)) != cnt){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    long mcd = 1;
    rep(i,n){
        long g = gcd(mcd,a.at(i));
        mcd = mcd * a.at(i) / g;
        if(mcd / 2 > m){
            cout << 0 << endl;
            return 0;
        }
    }
    long tmp = m - mcd/2;
    long ans = tmp / mcd + 1;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = unsigned int;

int main()
{
	ll S;
	cin >> S; cin >> hex; cout << hex;
	while (S--) {
		ll res = 0, A8;
		vector<ll> A(8), bit(32);
		for (ll i = 0; i < 8; i++) {
			cin >> A[i];
			for (ll j = 0; j < 32; j++) {
				if ((A[i] >> j) & 1) {
					bit[j]++;
				}
			}
		}
		cin >> A8;
		ll sub = 0;
		for (ll i = 0; i < 32; i++) {
			if ((bit[i] & 1) != (((A8 - sub) >> i) & 1)) {
				res |= 1 << i;
				bit[i] = 8 - bit[i];
				A8 ^= (1 << i);
			}
			sub += bit[i] << i;
		}
		cout << res << endl;
	}
	return 0;
}

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

#define mp       make_pair
#define mt	 make_tuple
#define pb       push_back
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    pair<int,int>      pii;
typedef    pair<long,long>    pll;

const int INF=1<<29;
const double EPS=1e-9;
const int MOD = 100000007;

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

int main(){
  while (cin >> N >> M){
    if (N == 0 and M == 0)break;
    vector<int> darts;
    vector<int> d_darts;
    for (int i = 0; i < N; i++){
      int x;
      cin >> x;
      darts.push_back(x);
    }
    darts.push_back(0);
    for (int i = 0; i < darts.size(); i++){
      for (int j = i + 1; j < darts.size(); j++){
	d_darts.push_back(darts[i] + darts[j]);
      }
    }
    sort(d_darts.begin(), d_darts.end());
    int res = 0;
    for (int i = 0; i <d_darts.size(); i++){
      int query = M - d_darts[i];
      int index = (lower_bound(d_darts.begin(), d_darts.end(), query) - d_darts.begin());
      if (index - 1 >= 0){

	res = max(res, d_darts[index - 1] + d_darts[i]);
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 5040
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

n = int(input())
p = LI()

ans = 0
for i in range(1, n-1):
    if (p[i-1] < p[i]) and (p[i] < p[i+1]):
        ans += 1
    elif (p[i-1] > p[i]) and (p[i] > p[i+1]):
        ans += 1

print(ans)

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

using namespace std;

int main()
{
  int a, b;

  scanf("%d %d", &a, &b);

  if ((a > b || a == 1) && b != 1)
  {
    printf("Alice");
  }
  else if (a == b)
  {
    printf("Draw");
  }
  else
  {
    printf("Bob");
  }
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


 
signed main() {
    string s;
    cin>>s;
    
    int C=INF;
    int F=-INF;
    rep(i,s.size()) if(s[i]=='C'){ C=i; break;}
    for(int i=s.size()-1;i>=0;i--)
        if(s[i]=='F'){F=i; break;}
    
    if(C==INF || F==-INF) No;
    else if(C<F) Yes;
    else No;
    
    return 0;
}


Measured memory_bytes: 256
/******************************\
*  Everyone has a different way of thinking, so God Created us
Hope You Respect My Way..,Thank You ):  *
*                            *
*   Created by : Murad   *
\******************************/
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
#include<bits/stdc++.h>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define MP make_pair
#define fi first
#define se second
#define INF 2147483647
#define _INF -2147483647
#define pq priority_queue
#define MM multimap
#define PB push_back
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define MAXN 100004
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
LL MMIN(LL a, LL b)
{
	if (a <= b)
		return a;
	else
		return b;
}
LL MMAX(LL a, LL b) {
	if (a >= b)
		return a;
	else
		return b;
}
int main()
{
	El3zba;
	LL r, d, rr;
	cin >> r >> d >> rr;
	LL ans = 0;
	for (int i = 0; i < 10; i++) {
		ans = r*rr - d;
		rr = ans;
		cout << ans<< endl;
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var n int 
  fmt.Scan(&n)
  s := 0
  for i := 1; i <= n; i++ {
    if i % 3 != 0 && i % 5 != 0 {
      s += i
    }
  }
  fmt.Println(s)
}

Measured memory_bytes: 1752
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <unordered_map>
#include <queue>
#include <sstream>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e13+7;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
#define rep(i,n) for(int i=0;i<(n);i++)

int main(){
    ll N,TP[5];
    cin>>N;
    rep(i,5)cin>>TP[i];
    ll min=1e16;
    rep(i,5)if(min>TP[i])min=TP[i];
    ll ans=ceil(double(N)/double(min))+4;
    cout<<ans<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    int n;
    cin >> n;
    map<ll, int> mp;
    VL c;
    REP(i,n){
        ll a;
        scanf("%lld", &a);
        mp[a]++;
        if (mp[a] == 2 || mp[a] == 4) c.push_back(a);
    }
    sort(ALL(c));
    reverse(ALL(c));
    ll ans = 0;
    if (c.size() >= 2) ans = c[0] * c[1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6528
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int top,s[1000];
void push(int x)
{
	s[++top]=x;
}
int pop()
{
	top--;
	return s[top+1];
}
int main()
{
	int a,b;
	top=0;
	char s[100];
	while(scanf("%s",s)!=EOF)
	{
		if(s[0]=='+')
	{
		a=pop();
		b=pop();
		push(a+b);
    } 
	else if(s[0]=='-')
	{
		b=pop();
		a=pop();
		push(a-b);
	}else if(s[0]=='*')
	{
		a=pop();
		b=pop();
		push(a*b);
	}else
	{
		push(atoi(s));
	}
    }
    printf("%d\n",pop());
    return 0;
	
}

Measured memory_bytes: 2752
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<vector<int>>S(M);
  vector<int>P(M);
  for(int i=0;i<M;i++){
    int k;
    cin>>k;
    for(int j=0;j<k;j++){
      int a;
      cin>>a;
      S.at(i).push_back(a);
    }
  }
  for(int i=0;i<M;i++){
    cin>>P.at(i);
  }
  int count=0;
  for(int tmp=0;tmp<(1<<N);tmp++){
    bitset<10>r(tmp);
    string R=r.to_string();
    reverse(R.begin(),R.end());
    bool flag=true;
    for(int i=0;i<M;i++){
      int sum=0;
      for(int j=0;j<S.at(i).size();j++){
        if(R.at(S.at(i).at(j)-1)=='1'){
          sum=sum+1;
        }
      }
      if(sum%2!=P.at(i)){
        flag=false;
        break;
      }
    }
    if(flag==true){
      count=count+1;
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 1e6 + 1;

map<char, int> mp;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<int> v(3);
	cin >> v[0] >> v[1] >> v[2];
	mp['p'] = v[1];
	mp['r'] = v[2];
	mp['s'] = v[0];
	string t;
	cin >> t;
	vector<bool> vis(n, false);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (vis[i]) continue;
		for (int j = i; j < n; j += k) {
			vis[j] = true;
			if (j == i) {
				ans += mp[t[j]];
				continue;
			}
			if (t[j] == t[j - k]) {
				t[j] = '?';
			}
			else {
				ans += mp[t[j]];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
  public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	// 整数の入力
    HashMap<String,Integer> map = new HashMap<String,Integer>();
	int n = sc.nextInt();
    boolean f = true;
    for (int i=0; i< n;i++) {
      int a = sc.nextInt();
      if (map.containsKey(""+a)) {
        f = false;
        break;
      }
      map.put(""+a,new Integer(a));
    }
    if (f){
  	System.out.print("YES");  
    } else {
  	System.out.print("NO");  

    }
  }
}








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

// macros
#define M 1000000007
#define addmod(a,b,m) (a%m + b%m)%m
#define submod(a,b,m) (a%m - b%m)%m
#define mulmod(a,b,m) ((a%m)*(b%m))%m
#define F first
#define S second
#define APSUM(a,b,n) n*((a*.5)+(b*.5))
#define GPSUM(a,b,k) (b*k-a)/(k-1)
#define INFGP(a,k) a/(1-r)
#define CEIL(a,b) ceil(double(a)/double(b))
#define FLOOR(a,b) floor(double(a)/double(b))
#define T(t) while(t--)
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;

//typedefs
typedef long long int ll ;
typedef vector<ll> vi ;
typedef pair<ll,ll> pi ;
typedef map<ll,ll> mps;

ll power(ll base,ll val)
{
    ll res=1;
    while(val)
    {
        if(val&1)
    {
        res = (res*base)%M;
    }
     base = (base*base)%M;
     val/=2;
    }
    return res;
}
ll digit(ll n)
{
    double phi = (1 + sqrt(5))/2;
    ll value = round(pow(phi,n)/(sqrt(5)));
    ll count=0;
    while(value)
    {
        count++;
        value/=10;
    }
    return count;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
/*
when files are giving the inputs and outputs
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);

*/
    ll n;
    cin>>n;
    bool game=false;
    while(n)
    {
        if(n%10==7)
        {
            game=true;
            break;
        }
        else
        {
            n/=10;
        }

    }
    if(game)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}


Measured memory_bytes: 3668
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *a,int n,char middle=' '){
	for(int i=0;i<n;i++)printf("%d%c",a[i],(i!=n-1?middle:'\n'));
}
void array_show(LL *a,int n,char middle=' '){
	for(int i=0;i<n;i++)printf("%lld%c",a[i],(i!=n-1?middle:'\n'));
}
bool check2(int a,int b,int c,int d){
	if(a==0 && b==2 && c==1)return false;
	if(b==0 && c==2 && d==1)return false;
	return true;
}

bool check(int n){
	int a=n>>6,b=(n>>4)%4,c=(n>>2)%4,d=n%4;
	if(!check2(a,b,c,d))return false;
	if(!check2(b,a,c,d))return false;
	if(!check2(a,c,b,d))return false;
	if(!check2(a,b,d,c))return false;
	return true;
}

LL dp[105][1<<8];

int main(){
	int n;
	int i,j,k;
	int a;
	LL s=0;
	cin>>n;
	dp[0][(1<<8)-1]=1;
	for(i=0;i<n;i++){
		for(j=0;j<(1<<8);j++){
			if(dp[i][j]==0)continue;
			if(!check(j))continue;
			if(dp[i][j]>=MAX)dp[i][j]%=MAX;
			for(k=0;k<4;k++){
				a=(j<<2)%(1<<8)+k;
				dp[i+1][a]+=dp[i][j];
			}
		}
	}
	for(i=0;i<(1<<8);i++){
		if(!check(i))continue;
		s+=dp[n][i];
		if(s>=MAX)s%=MAX;
	}
	cout<<s<<endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <climits>
#include <set>
#include <numeric>

using namespace std;

const int N = 201;

int g[N][N];
int t[8];

int main() {
    int n, m, r;
    scanf("%d %d %d", &n, &m, &r);

    fill_n((int *)g, n * n, -1);

    for (int i = 0; i < r; ++ i) {
        scanf("%d", t + i);
    }

    for (int i = 0; i < m; ++ i) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        g[a][b] = g[b][a] = c;
    }

    long gd[r][n + 1];

    for (int i = 0; i < r; ++ i) {
        int s = t[i];
        auto &d = gd[i];
        set<int> q;
        for (int j = 1; j <= n; ++ j) {
            d[j] = INT_MAX;
            q.insert(j);
        }
        d[s] = 0;

        while (!q.empty()) {
            int m, md = INT_MAX;
            for (auto x : q) {
                if (d[x] < md) {
                    m = x;
                    md = d[x];
                }
            }
            q.erase(m);

            for (int j = 1; j <= n; ++ j) {
                if (g[m][j] > 0 && d[m] + g[m][j] < d[j]) {
                    d[j] = d[m] + g[m][j];
                }
            }
        }
    }

    int town[r];
    iota(town, town + r, 0);

    long res = INT_MAX;
    do {
        long tmp = 0;
        for (int i = 1; i < r; ++ i) {
            int c = town[i], p = town[i - 1];
            tmp += gd[c][t[p]];
        }
        res = min(res, tmp);
    } while (next_permutation(town, town + r));

    printf("%ld\n", res);

    return 0;
}

Measured memory_bytes: 384
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <bits/stdc++.h>
#include <cstdio>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef std::vector<int> VI;
typedef std::pair<int,int> P;
int read()
{
    int x=0,flag=1; char c=getchar();
    while((c>'9' || c<'0') && c!='-') c=getchar();
    if(c=='-') flag=0,c=getchar();
    while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return flag?x:-x;
}

const int maxn=2005;
int n,a[maxn<<2],f[maxn][maxn],maxd[maxn];
struct node {int x,y,z;} que[maxn*maxn];
int tail,maxx,extadd;

void add(int x,int y,int z)
{
    que[++tail]=(node){x,y,z};
}

void update()
{
    for(int i=1;i<=tail;i++)
    {
        node d=que[i];
        f[d.x][d.y]=max(f[d.x][d.y],d.z);
        f[d.y][d.x]=max(f[d.y][d.x],d.z);
        maxx=max(maxx,d.z);
        maxd[d.x]=max(maxd[d.x],d.z);
        maxd[d.y]=max(maxd[d.y],d.z);
    }
    tail=0;
}

int main()
{
    n=read();
    REP(i,1,n*3) a[i]=read();

    REP(i,1,n) REP(j,1,n) f[i][j]=-10000000;
    REP(i,1,n) maxd[i]=-100000000;
    f[a[1]][a[2]]=f[a[2]][a[1]]=0;
    maxd[a[1]]=maxd[a[2]]=0;

    for(int i=1;i<n;i++)
    {
        if(a[i*3]==a[i*3+1] && a[i*3]==a[i*3+2])
        {
            extadd++;
            continue;
        }
        if(a[i*3]==a[i*3+1] || a[i*3]==a[i*3+2] || a[i*3+1]==a[i*3+2])
        {
            int p=a[i*3],q=a[i*3+1];
            if(p==q) q=a[i*3+2];
            else if(a[i*3+2]==q) swap(p,q);
            for(int k=1;k<=n;k++)
                add(k,q,f[k][p]+1);
        }

        {
            int p=a[i*3],q=a[i*3+1],r=a[i*3+2];
            add(q,r,f[p][p]+1);
            add(q,p,f[r][r]+1);
            add(p,r,f[q][q]+1);
        }

        int p=a[i*3],q=a[i*3+1],r=a[i*3+2];
        add(p,q,maxx);
        add(p,r,maxx);
        add(q,r,maxx);

        REP(j,0,2)
        {
            int p=a[i*3+j];
            for(int k=1;k<=n;k++)
                add(k,p,maxd[k]);
        }

        update();
        //REP(i,1,n) REP(j,1,n) cout<<f[i][j]<<' ';
        //cout<<endl<<endl;
    }
    REP(i,1,n) REP(j,1,n) maxx=max(maxx,f[i][j]);
    maxx=max(maxx,f[a[n*3]][a[n*3]]+1);
    cout<<maxx+extadd;

    return 0;
}


Measured memory_bytes: 19356
# https://atcoder.jp/contests/abc144/tasks/abc144_d

import math

a, b, x = map(int, input().split())

w_max = a * a * b

# 対角線の水量
w_middle = w_max / 2

degree = 0

# 対角線以下の水量の時
if x <= w_middle:
    degree = math.degrees(math.atan((a*(b**2)) / (2*x)))

else:
    degree = math.degrees(math.atan(((w_max - x)*2) / (a**3)))

print(degree)


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,k;
  while(cin>>n>>k,n){
    int x[k];
    for(int i=0;i<k;i++) cin>>x[i];
    int e[n+2];
    memset(e,0,sizeof(e));
    for(int i=0;i<k;i++) e[x[i]]=1;
    int c[2][n+2];
    memset(c,0,sizeof(c));
    for(int i=1;i<=n;i++)
      if(e[i]) c[0][i]=c[0][i-1]+1;
    for(int i=n;i>=0;i--)
      if(e[i]) c[1][i]=c[1][i+1]+1;
    int ans=0;
    for(int i=1;i<=n;i++){
      if(e[0]&&!e[i])
	ans=max(ans,c[0][i-1]+c[1][i+1]+1);
      ans=max(ans,c[0][i]);
      ans=max(ans,c[1][i]);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 6076
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,m;
  cin >> n >> m;
  set<int> h,w;
  rep(i,n){
    int o;
    cin >> o;
    if(h.count(o)){
      cout << 0 << endl;
      return 0;
    }
    h.insert(o);
  }
  rep(i,m){
    int o;
    cin >> o;
    if(w.count(o)){
      cout << 0 << endl;
      return 0;
    }
    w.insert(o);
  }
  long long ans=1;
  long long p=1000000007;
  long long hh=0,ww=0;
  long long cnt=0;
  rep(i,n*m){
    int q=n*m-i;
    if(h.count(q)&&w.count(q)){
      hh++;
      ww++;
      cnt++;
    }
    if(h.count(q)){
      if(w.count(q))int c;
      else{
        ans=ans*ww%p;
        hh++;
        cnt++;
      } 
    }
    else{
      if(w.count(q)){
        ans=ans*hh%p;
        ww++;
        cnt++;
      }
      else{
        ans=(hh*ww-cnt)*ans%p;
        cnt++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
    long long n, m; cin >> n >> m;
    
    if (n == 1 && m != 1) {
        cout << m-2 << endl;
        return 0;
    }

    else if (n != 1 && m == 1) {
        cout << n-2 << endl;
        return 0;
    }

    else {
        cout << (n-2) * (m-2) << endl;
        return 0;
    }
}

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

using namespace std;

int A, B, C, D;

int main()
{
    cin >> A >> B >> C >> D;

    int cnt = 0;
    for (int i = 0; i < 100; i++) {
        if (A <= i && i < B && C <= i && i < D) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
a=[]
b=[]
for i in range(n):
    a.append(arr[i][0])
for i in range(n):
    b.append(arr[i][1])
num_min = max(a)
score_min = min(b)
print(num_min + score_min)


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

int main(){
  string S; cin >> S;
  
  int num = 0;
  
  for(int i = 0; i < 4; i++){
    if(S[i] == '+'){
      num++;
    }
    else if (S[i] == '-'){
      num--;
    }
  }
  
  cout << num << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#include <bitset>
#include <complex>
#include <cassert>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define GLL(i) (scanf("%lld",&i))
#define GD(i)  (scanf("%lf",&i))
#define PB          push_back
#define MP          make_pair
#define MT          make_tuple
#define GET0(x)     (get<0>(x))
#define GET1(x)     (get<1>(x))
#define GET2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       (1LL<<60)
#define LLMIN       -(1LL<<60)
#define IMAX        (1<<30)
#define IMIN        -(1<<30)
typedef long long LL;
using namespace std;

LL patee[51];
LL thickness[51];

LL rec(int N, LL X){
    // printf("N = %d, X = %lld, patee = %lld, thickness = %lld\n", N, X, patee[N], thickness[N]);
    if(X==0)
        return 0;
    if(thickness[N] <= X)
        return patee[N];
    else{
        LL a = rec(N-1, X-1);
        if(1+thickness[N-1]+1<=X)
            a++;
        if(1+thickness[N-1]+1<X)
            a += rec(N-1, X-1-thickness[N-1]-1);
        return a;
    }
}

int main(void){
    REP(i,51){
        if(i==0){
            patee[0] = 1;
            thickness[0] = 1;
        }
        else{
            patee[i] = patee[i-1]*2 + 1;
            thickness[i] = 3 + thickness[i-1] * 2;
        }
    }
    int N;
    LL X;
    GI(N);GLL(X);
    printf("%lld\n", rec(N,X));
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;


#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

double r;

int main() {
	cin >> r;
	double pi = acos(-1);
	cout << fixed << setprecision(10)<<r * 2 * pi << endl;
}


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


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

    for(int i=1; i<10; i++){
        for(int j=1; j<10; j++){
            if(N == i*j){
                cout << "Yes";
                return 0;
            }
        }
    }

    cout << "No";
    return 0;
}

Measured memory_bytes: 256