akhauriyash/Code-Regression huggingface dataset:
import java.io.*;

class Main{
        static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        public static void main(String[] args) throws IOException{
                int n1 = Integer.parseInt(br.readLine());
                int[] a1 = new int[n1];
                String[] s1 = br.readLine().split(" ");
                for(int i=0; i<n1; i++)
                        a1[i] = Integer.parseInt(s1[i]);
                int n2 = Integer.parseInt(br.readLine());
                int[] a2 = new int[n2];
                String[] s2 = br.readLine().split(" ");
                for(int i=0; i<n2; i++)
                        a2[i] = Integer.parseInt(s2[i]);

                int ans = 0;
                for(int i: a2)
                        for(int j: a1){
                                if(j==i){
                                        ans++;
                                        break;
                                }
                        }
                System.out.println(ans);
        }
}

Measured memory_bytes: 27028
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
#include<tuple>
using namespace std;
#define INF 11000000000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

int main(){
    int N,A[20];
    cin>>N;
    ll sum=1,odd=1;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int i=0;i<N;i++){
        sum*=3;
        if(A[i]%2==0){
            odd*=2;
        }
    }
    cout<<sum-odd<<endl;
}



Measured memory_bytes: 256
#include<stdio.h>
main()
{
int s;
int h,m,s0;
scanf("%d",&s);
h = s / 3600;
s = s - 3600 * h;
m = s / 60;
s0 = s - 60 * m;
printf("%d:%d:%d\n",h,m,s0);
return 0;
}

Measured memory_bytes: 1020
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

//各位の和を返す
int GetDigitSum(int num){
	int N = 0;
	while (num > 0){
		N += num % 10;
		num /= 10;
	}
	return N;
}

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

	int n;
	cin >> n;
	bool flg;

	if(n%GetDigitSum(n)==0){
		flg = true;
	}else{
		flg = false;
	}

	yn(flg);

	return 0;
}

Measured memory_bytes: 256
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

class Program
{
    static void Main()
    {
        var count = int.Parse(ReadLine());
        var input = MyUtil.ReadintArray();

        int[] array = new int[100];



        var min = array.Select((_, i) => GetDistSum(i + 1, input)).Min();

        WriteLine(min);
        ReadKey();
    }

    static int GetDistSum(int n, IEnumerable<int> input)
    {
        return input.Select(x =>
        {
            var dist = x - n;
            return dist * dist;
        }).Sum();
    }
}


static class MyUtil
{
    /// <summary>
    /// 指定の桁のビットを取得します。
    /// </summary>
    /// <param name="num"></param>
    /// <param name="count">取得する桁。</param>
    /// <returns></returns>
    public static int GetBit(this int num, int count)
    {
        int mask = (int)Math.Pow(2, count - 1);
        return (num & mask) == 0 ? 0 : 1;
    }

    /// <summary>
    /// <c>int</c>を2進数ビット配列に変換します。
    /// </summary>
    /// <param name="num"></param>
    /// <returns></returns>
    public static int[] ToBitArray(this int num)
    {
        const int size = sizeof(int) * 8;
        var array = new int[size];
        for (int i = 0; i < size; i++)
        {
            array[i] = num.GetBit(size - i);
        }
        return array;
    }

    public static long[] ReadlongArray()
    {
        return ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
    }

    public static int[] ReadintArray()
    {
        return ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
    }

    /// <summary>
    /// <see cref="IEnumerable{T}"/>の各要素を並べてコンソールに出力します。各要素の間には半角スペースが一つ入ります。
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="ts"></param>
    public static void WriteToConsole<T>(this IEnumerable<T> ts)
    {
        StringBuilder stringBuilder = new StringBuilder();
        foreach (T t in ts)
        {
            stringBuilder.Append(t.ToString());
            stringBuilder.Append(" ");
        }
        stringBuilder.Remove(stringBuilder.Length - 1, 1);
        Console.WriteLine(stringBuilder.ToString());
    }

    public static void WriteToDebugConsole<T>(this IEnumerable<T> ts)
    {
        StringBuilder stringBuilder = new StringBuilder();
        foreach (T t in ts)
        {
            stringBuilder.Append(t.ToString());
            stringBuilder.Append(" ");
        }
        stringBuilder.Remove(stringBuilder.Length - 1, 1);
        System.Diagnostics.Debug.WriteLine(stringBuilder.ToString());
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, m;
        cin >> n >> m;
        if(n == 0 && m == 0)
            return 0;

        vector<string> rule(n);
        vector<bool> permit(n, false);
        for(int i=0; i<n; ++i){
            string s;
            cin >> s;
            if(s == "permit")
                permit[i] = true;
            cin >> rule[i] >> s;
            rule[i] += s;
        }

        vector<string> ret;
        for(int i=0; i<m; ++i){
            string s, s1, s2, message;
            cin >> s1 >> s2 >> message;
            s = s1 + s2;

            bool deny = true;
            for(int j=n-1; j>=0; --j){
                bool same = true;
                for(int k=0; k<16; ++k){
                    if(rule[j][k] != '?' && s[k] != rule[j][k]){
                        same = false;
                        break;
                    }
                }
                if(same){
                    deny = !permit[j];
                    break;
                }
            }

            if(!deny)
                ret.push_back(s1 + ' ' + s2 + ' ' + message);
        }

        cout << ret.size() << endl;
        for(unsigned i=0; i<ret.size(); ++i)
            cout << ret[i] << endl;
    }
}

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


using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;




int main() {

	
	map<string, int> m;
	int n;
	cin >> n;
	REP(i, n) {
		string s;
		cin >> s;
		m[s]++;
	}

	vector<string> v;
	int a = 0;
	for (auto i : m) {

		if (i.second > a) {
			a = i.second;
			v.clear();
			v.push_back(i.first);
		}
		else if (a == i.second) {
			v.push_back(i.first);
		}


	}

	sort(ALL(v));

	REP(i, v.size()) {
		cout << v[i] << endl;
	}

	


}


Measured memory_bytes: 28400
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var list = Console.ReadLine().Split(" ").Select(x => long.Parse(x)).ToList();
            var result = list.Sum() - n;
            Console.WriteLine(result);
        }
    }
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N; cin >> N;
    ll X = (ll) ((double) N / 1.08);
    ll Y = X + 1;
    if ((ll) ((double)X * 1.08) == N){
        cout << X << endl;
    } else if ((ll) ((double)Y * 1.08) == N){
        cout << Y << endl;
    } else {
        cout << ":(" << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3536
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

template <typename T>
struct min_ {
    T operator()(T x, T y) {
        return min(x, y);
    }
};

template <typename T, class F=min_<T>>
struct SegmentTree {
    size_t n;
    T e;
    vector<T> tree;
    F qfunc;
    SegmentTree(size_t m, T e=0): n(1), e(e) {
        qfunc = F();
        while (n < m) n <<= 1;
        tree = vector<T>(n<<1, e);
    }
    T range_query(size_t a, size_t b, size_t i=1, size_t l=0, size_t r=-1) {
        if (!~r) r = n;
        if (a<=l && r<=b) return tree[i];

        T vl=e, vr=e;
        size_t c=(l+r)>>1;

        if (a < c) vl=qfunc(e, range_query(a, b, i<<1|0, l, c));
        if (c < b) vr=qfunc(e, range_query(a, b, i<<1|1, c, r));

        return qfunc(vl, vr);
    }
    void update(size_t i, T x) {
        i += n;
        tree[i] = x;
        while (i>>1) {
            tree[i>>1] = qfunc(tree[i^1], tree[i]);
            i >>= 1;
        }
    }
};

int main() {
    size_t n, q;
    scanf("%zu %zu", &n, &q);

    SegmentTree<int> tree(n, (1LL<<31)-1);
    for (size_t i=0; i<q; ++i) {
        int com;
        scanf("%d", &com);
        if (com) {
            size_t s, t;
            scanf("%zu %zu", &s, &t);
            printf("%d\n", tree.range_query(s, t+1));
        } else {
            size_t i;
            int x;
            scanf("%zu %d", &i, &x);
            tree.update(i, x);
        }
    }

    return 0;
}

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

static const int MAX = 1000001;

struct Proc {
    string name;
    int t;
};

Proc Q[MAX];
int head, tail;

bool isEmpty() {
    if (head == tail) {
        return true;
    } else {
        return false;
    }
}

bool isFull() {
    if (head == (tail + 1) % MAX) {
        return true;
    } else {
        return false;
    }
}

void enqueue(Proc x) {
    if (isFull()) {
        throw string("queue is full error");
    }
    Q[tail] = x;
    if (tail + 1 == MAX) {
        tail = 0;
    } else {
        tail++;
    }
}

Proc dequeue() {
    if (isEmpty()) {
        throw string("queue is empty error");
    }
    Proc x = Q[head];
    if (head + 1 == MAX) {
        head = 0;
    } else {
        head++;
    }
    return x;
}

int main (void) {
    int n, q;
    cin >> n >> q;

    for (int i = 0; i < n; i++) {
        cin >> Q[i].name >> Q[i].t;
    }
    head = 0;
    tail = n;
    int elapsedTime = 0;

    try {
        while (head != tail) {
            Proc p = dequeue();
            int time = min(q, p.t);
            p.t -= time;
            elapsedTime += time;
            if (p.t > 0) {
                enqueue(p);
            } else {
                cout << p.name << " " << elapsedTime << endl;
            }
        }
    } catch (string e) {
        cout << e << endl;
        return 1;
    }
    return 0;
}

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

int read()
{
	int ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=0;
	if(ch=='-')flag=1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10+ch-'0';
	if(flag)ans=-ans;
	return ans;
}

long long rell()
{
	long long ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=0;
	if(ch=='-')flag=1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10ll+(long long)(ch-'0');
	if(flag)ans=-ans;
	return ans;
}

void writ(int n)
{
	char ch[25];
	int m=0;
	if(n<0)putchar('-'),n=-n;
	if(n==0)
	{
		putchar('0');
		return;
	}
	for(;n;n/=10)ch[m++]=n%10ll+'0';
	for(;m;)putchar(ch[--m]);
}

void wrll(long long n)
{
	char ch[25];
	int m=0;
	if(n<0)putchar('-'),n=-n;
	if(n==0)
	{
		putchar('0');
		return;
	}
	for(;n;n/=10ll)ch[m++]=n%10ll+'0';
	for(;m;)putchar(ch[--m]);
}

int main()
{
	int n=read(),x=0,y=0,z=0;
	for(int i=0;i<n;i++)
	{
		int k=read();
		if(k%4==0)z++;
		else if(k%2==0)y++;
		else x++;
	}
	//bool ans=true;
	int last=233;
	for(int i=0;i<n;i++)
	{
		if(last==0)z--,last=2;
		else if(last==1)
		{
			if(y)y--,last=1;else z--,last=2;
		}
		else
		{
			if(x)x--,last=0;
			else if(y)y--,last=1;
			else z--,last=2;
		}
	}
	if(z>=0)puts("Yes");else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, N, M, a[100001];
	scanf("%d %d", &N, &M);
	for (i = 1; i <= N; i++) scanf("%d", &(a[i]));
	
	long long j, dp[3] = {1};
	for (i = 1, j = 1; i <= N; i++) {
		if (a[j] == i) {
			j++;
			dp[i%3] = 0;
		} else dp[i%3] = (dp[(i+1)%3] + dp[(i+2)%3]) % 1000000007;
	}
	printf("%lld\n", dp[N%3]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using P = pair<int, int>; // <P, D>

int main() {
    int N, M;
    while(cin >> N >> M, N) {
        vector<P> v(N);
        int ret = 0;
        for(int i=0; i<N; ++i) {
            cin >> v[i].second >> v[i].first;
            ret += v[i].first * v[i].second;
        }
        sort(v.begin(), v.end(), greater<P>());

        for(int i=0; i<v.size(); ++i) {
            if(M < v[i].second) {
                ret -= v[i].first * M;
                M = 0;
            } else {
                ret -= v[i].second * v[i].first;
                M -= v[i].second;
            }
            if(M == 0) {
                break;
            }
        }
        cout << ret << endl;
    }
}


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

// 引数の役割:
// isThree -> 3があるかないかのフラグ,
// isFive -> 5があるかないかのフラグ,
// isSevem -> ７があるかないかのフラグ,
// digit -> 現在の桁数,
// state -> 現在の値,
// limit -> 最大数,
int dfs(bool isThree,bool isFive, bool isSeven,int digit,long long state,long long limit){

    if(limit < state) return 0;

    int result=0;
    result += dfs(true, isFive, isSeven, digit+1, state+3*pow(10,digit),limit);
    result += dfs(isThree, true, isSeven, digit+1, state+5*pow(10,digit),limit);
    result += dfs(isThree, isFive, true, digit+1, state+7*pow(10,digit),limit);

    if(isThree && isFive && isSeven) result++;

    return result;
}
int main() {
  long long n;
  cin >> n;
  cout << dfs(false,false,false,0,0,n) << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>

using namespace std;

const int X = 2e5;

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

    bool isp[X];
    fill(isp, isp+X, true);
    isp[0] = isp[1] = false;
    for (int i = 2; i < X; i++) {
        if (isp[i]) {
            for (int j = i + i; j < X; j += i) {
                isp[j] = false;
            }
        }
    }

    int x;
    cin >> x;

    while (!isp[x]) {
        x++;
    }

    cout << x << endl;

    return 0;
}


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

int main() {
  int N;
  cin >> N;
  string A[N];
  for (int i = 0; i < N; i++) cin >> A[i];

  map<string, int> prize;
  for (int i = 0; i < N; i++) {
    prize.insert(make_pair(A[i], i));
  }

  cout << prize.size() << endl;

  return 0;
}

Measured memory_bytes: 25372
#[allow(unused_imports)]
use std::collections::HashSet;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let whxy = read_vec::<i32>();
    let w = whxy[0];
    let h = whxy[1];
    let x= whxy[2];
    let y = whxy[3];

    let answer = solve(w, h, x, y);
    println!("{} {}", answer.0, answer.1);
}

fn solve(w: i32, h: i32, x:i32, y:i32) -> (f64, i32) {
    let half = (w as f64) * (h as f64) / 2.0;

    let is_center = 
    if x == w / 2 && w % 2 == 0 && y == h / 2 && h % 2 == 0 {
        1
    } else {
        0
    };

    return (half, is_center);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;

struct D {
  int n;
  string s;

  D() {
  }

  D(const D &obj) {
    this->n = obj.n;
    this->s = obj.s;
  }

  D &operator=(const D &obj) {
    this->n = obj.n;
    this->s = obj.s;
  }
};

std::ostream &operator<< (std::ostream &out, const D &obj) {
  out << obj.s;
  return out;
}

D buf4[4];
D buf3[3];
D buf2[2];

D op(int x, D l, D r) {
  D tmp;
  switch (x) {
    case 0:
      tmp.n = l.n + r.n;
      tmp.s = "(" + l.s + "+" + r.s + ")";
      break;
    case 1:
      tmp.n = l.n * r.n;
      tmp.s = "(" + l.s + "*" + r.s + ")";
      break;
    case 2:
      tmp.n = l.n - r.n;
      tmp.s = "(" + l.s + "-" + r.s + ")";
      break;
  }
  return tmp;
}

int main() {
  int a[4], x;
  bool flg;
  D ans;
  while (1) {
    scanf("%d %d %d %d", &a[0], &a[1], &a[2], &a[3]);
    if (!a[0] && !a[1] && !a[2] && !a[3]) break;

    for (int i=0; i<4; i++) {
      buf4[i].n = a[i];
      buf4[i].s = "";
      buf4[i].s += (char)('0' + a[i]);
    }
    flg = false;
    for (int i=0; i<4; i++) {
      for (int j=0; j<4; j++) {
        if (i==j) continue;
        x = 0;
        for (int y=0; y<4; y++) {
          if (y!=i && y!= j) {
            buf3[x++] = buf4[y];
          }
        }
        for (int k=0; k<3; k++) {
          buf3[2] = op(k, buf4[i], buf4[j]);
          for (int l=0; l<3; l++) {
            buf2[0] = buf3[l];
            for (int m=0; m<3; m++) {
              buf2[1] = op(m, buf3[(l+1)%3], buf3[(l+2)%3]);
              for (int n=0; n<3; n++) {
                ans = op(n, buf2[0], buf2[1]);
                if (ans.n == 10) {
                  flg = true;
                  break;
                }
                ans = op(n ,buf2[1], buf2[0]);
                if (ans.n == 10) {
                  flg = true;
                  break;
                }
              }
              if (flg) break;
              buf2[1] = op(m, buf3[(l+2)%3], buf3[(l+1)%3]);
              for (int n=0; n<3; n++) {
                ans = op(n, buf2[0], buf2[1]);
                if (ans.n == 10) {
                  flg = true;
                  break;
                }
                ans = op(n ,buf2[1], buf2[0]);
                if (ans.n == 10) {
                  flg = true;
                  break;
                }
              }
              if (flg) break;
            }
            if (flg) break;
          }
          if (flg) break;
        }
        if (flg) break;
      }
      if (flg) break;
    }
    if (ans.n == 10) {
      printf("%s\n", ans.s.c_str());
    } else {
      printf("0\n");
    }

  }

  return 0;
}

Measured memory_bytes: 1208
from collections import defaultdict
import sys
input = sys.stdin.readline
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse = 1)
B.sort(reverse = 1)
C.sort(reverse = 1)
dic = {}
for x in range(1, min(X + 1, K + 1)):
    t = K // x + 1
    for y in range(1, min(Y + 1, t + 1)):
        s = t // y + 1
        for z in range(1, min(Z + 1, s + 1)):
            if (x, y, z) not in dic:
                dic[(x, y, z)] = A[x-1] + B[y-1] + C[z-1]
dic = sorted(dic.values(), reverse = 1)
for i in range(K):
    print(dic[i])

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

const int N = 500005;

int n, b[N], cur;
char a[N];

long long ans;

set<int> s;

int main()
{
	scanf("%s",a+1);
	n = strlen(a+1);
	s.insert(0);
	for(int i=1;i<=n;i++) {
		if(a[i] == '<') {
			cur++;
			ans += (n+1-i);
			b[i] = 1;
			s.insert(-i);
		}
		else {
			if(cur <= 1) {
				b[i] = -1;
				ans -= (n+1-i);
				if(cur == 0) {
					int I = -*s.begin();
					ans += (n+1-I);
					if(++b[I] == -1) s.erase(*s.begin());
				}
				cur = 0;
			}
			else {
				b[i] = -cur;
				ans -= 1ll * cur * (n+1-i);
				s.insert(-i);
				cur = 0;
			}
		}
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 26112
n = int(input())
#a, b = map(int, input().split())
#l = list(map(int, input().split()))
#s = input()

for i in range(1,10):
    q, mod = divmod(n,i)
    if mod == 0:
        if (q >= 1 and q <= 9):
            print("Yes")
            exit()
print("No")




Measured memory_bytes: 9144
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353;
constexpr int MAX = 5000000;

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	ll K, X; cin >> K >> X;
	K *= 500;
	if (K >= X) cout << "Yes" << "\n";
	else cout << "No" << "\n";
	return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
int main(void){
  int i;
  char a[6];
  for(i=0;i<6;i++)
    scanf("%c",&a[i]);
//  printf("%c%c%c%c",a[0],a[1],a[2],a[3]);
  if(a[2]==a[3]){
    if(a[4]==a[5]){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }else{
    printf("No\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
typedef bitset<16> BS;

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 1E+05;

struct edge {
    int to;
    ll cost;
};

int N, M;

vector<edge> G[MAX_N + 1];
ll d[MAX_N + 1];
bool used[MAX_N + 1];

bool dfs(int t, int l);

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

    cin >> N >> M;

    for (int i = 0; i < M; i++) {
        int l, r;
        ll di;
        cin >> l >> r >> di;
        G[l].push_back((edge) { r, di });
        G[r].push_back((edge) { l, -di });
    }

    fill(d, d + N + 1, INF);
    bool ans = true;
    for (int i = 1; i <= N; i++) {
        if (!used[i]) {
            ans &= dfs(i, 0);
        }
    }
    if (ans) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    /*
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << "i = " << i << ", j = " << j << ", dp = " << dp[i][j] << "\n";
        }
    }
    */

    return 0;
}

bool dfs(int t, int l)
{
    used[t] = true;
    d[t] = l;
    bool res = true;
    for (const auto& e : G[t]) {
        if (used[e.to] && d[e.to] != l + e.cost) {
            return false;
        } else if (!used[e.to]) {
            res &= dfs(e.to, l + e.cost);
        }
    }
    return res;
}


Measured memory_bytes: 21724
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int A, B; cin >> A >> B;
    cout << ceil(((double)B-1)/(A-1)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
int main(){
    int n,r;
    cin>>n>>r;
    if(n<10){
        cout<<r+(100*(10-n))<<endl;
    }else cout<<r<<endl;
}


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

public class Main {
	
	public static void main(String args[]) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] parts = br.readLine().split(" ");
	
		
		int N = Integer.parseInt(parts[0]);
		int M = Integer.parseInt(parts[1]);
		
		if(N==M) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}

}


Measured memory_bytes: 20948
fun main(args: Array<String>) {
    val N = readLine()!!.map { it - '0' }
    val l = N.size
    val dp = Array(l + 1) { IntArray(2) {0} }

    dp[0][1] = 1

    for (i in 0 until l) {
        dp[i + 1][0] = Math.min(dp[i][0] + N[i], dp[i][1] + 10 - N[i])
        dp[i + 1][1] = dp[i][1] + 9 - N[i]
        if (N[i] < 9) {
            dp[i + 1][1] = Math.min(dp[i + 1][1], dp[i][0] + N[i] + 1)
        }
    }
    println(dp[l][0])
}


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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

const int N = 4;
int A [N];

int main()
{
	FOR(i,0,N){
		scanf("%1d",&A [i]);
	}

	FOR(i,0,16){
		if(i & 1) continue;
		int sum = 0;
		FOR(j,0,4){
			sum += A [j] * ((i >> j & 1) ? -1 : 1);
		}
		if(sum == 7){
			printf("%d",A [0]);
			FOR(j,1,4){
				printf("%s",(i >> j & 1) ? "-" : "+");
				printf("%d",A [j]);
			}
			printf("=7\n");
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll W, H, x, y;
    cin >> W >> H >> x >> y;
    long double ans = (long double)W * H / 2;
    cout << fixed;
    cout << setprecision(11) << ans;
    if (x * 2 == W && y * 2 == H)
    {
        cout << ' ' << 1 << endl;
    }
    else
    {
        cout << ' ' << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <climits>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i , j , n) for(long long i = j ; i <= n ; i++)
#define per(i , j , n) for(long long i = j ; i >= n ; i--)
const long long N = 2e5 + 5;
const long long mod = 1e9 + 7;
ll MODULAR_POWER(ll a , ll b , ll MOD) {
    if(b == 0) return 1LL;
    ll d = MODULAR_POWER(a , b / 2 , MOD);
    d *= d;
    d %= MOD;
    if(b % 2) d *= a;
    d %= MOD;
    return d;
}
ll MODULAR_INVERSE(ll a , ll MOD) {
    return MODULAR_POWER(a , MOD - 2 , MOD);
}
int a[N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(8);
    cout << fixed;
    int n;
    cin >> n;
    rep(i , 1 , n) cin >> a[i];
    if(n % 2 == 0) {
        per(i , n , 2) {
            cout << a[i] << " ";
            i--;
        }
        rep(i , 1 , n) {
            cout << a[i] << " ";
            i++;
        }
    }
    else {
        per(i , n , 1) {
            cout << a[i] << " ";
            i--;
        }
        rep(i , 2 , n) {
            cout << a[i] << " ";
            i++;
        }
    }
    return 0;
}

Measured memory_bytes: 2944
import sys
sys.setrecursionlimit(10 ** 6)
import sys
def input():
    return sys.stdin.readline()[:-1]
N , Q = map(int,input().split())
graph = [[] for _ in range(N)]
point = [0] * N
for _ in range(N - 1):
    a , b = map(int,input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
#print(graph)
for _ in range(Q):
    a , b = map(int,input().split())
    a = a - 1
    point[a] += b
# dfsを用いて累積和を計算する
# 初期状態だと前の値がないためデフォルト引数に-1を代入
def dfs(now , prev = -1):
    for next in graph[now]:
        # 次のノードが前に参照した値の時はcontinue
        if next == prev:
            continue
        # 現在の値を次のポイントに加算することで累積和をとる
        point[next] += point[now]
        # 次のノードと現在のノードを引数にdfsを継続する
        dfs(next , now)

dfs(0)
print(*point)


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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int s = 0;
    for (int x : a) s += x;
    int c = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] * 4 * m >= s) c++;
    }
    if (c >= m) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}

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

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

// qsort(array, size, sizeof(int),comp);
TLong comp(const TLong *a,const TLong *b){
	return (*a - *b);
}

int main(int argc, char const *argv[])
{
	TLong block[3] = {0,0,0};
	for (int i = 0; i < 3; ++i)	scanf("%lld",&block[i]);
	if(block[0] % 2 == 0 || block[1] % 2 == 0 || block[2] % 2 == 0){
		puts("0");
	}
	else{
		qsort(block,3,sizeof(TLong),comp);
		printf("%lld\n", block[0] * block[1]);
	}
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
//const long long mod = 998244353;


int main() {
	int N;
	scanf("%d", &N);
	int *A = new int[N];
	for (int i = 0; i < N; i++)scanf("%d", A + i);
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] != i + 1)cnt++;
	}
	printf(cnt <= 2 ? "YES" : "NO");
	return 0;
}

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

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    ll N,D;
    cin >> N >> D;
    ll ans = N/(2*D+1) + (N%(2*D+1)!=0);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define repd(i,a,b) for (ll i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;

int main(void)
{
	int K, N;
	cin >> K >> N;
	int A[N];
	rep(i, N) cin >> A[i];
	int max_k = 0;
	rep(i, N-1)	max_k = max(max_k, A[i+1] - A[i]);
	max_k = max(max_k, K-A[N-1]+A[0]);
	cout << K-max_k << endl;
	return 0;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
# モジュールのインポート
import math
import numpy as np

# 標準入力を取得
N = int(input())
A = list(map(int, input().split()))

# 求解処理
A = sorted(A, reverse=True)
A = np.array(A)
ans = 2 * np.sum(A[:(N // 2)]) - A[0] + (N % 2) * A[math.floor(N / 2)]

# 結果出力
print(ans)


Measured memory_bytes: 49528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
const char endk = '\n';
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll mod = 1e9 + 7;
	//const ll mod = 998244353;

	ll l, r, d;
	cin >> l >> r >> d;
	ll ans = 0;
	for (ll i = l; i <= r; i++) {
		if (i % d == 0) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3568
#include <atcoder/all>
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

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

    int n, m;
    cin >> n >> m;
    vector<int> a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];

    auto c = atcoder::convolution(a, b);

    rep(i, c.size()) cout << c[i] << " \n"[i + 1 == c.size()];

    return 0;
}

Measured memory_bytes: 19052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll k;
    cin >> k;
    set<ll> s;
    ll cv = 0;
    rep(i, k + 1) {
        cv *= 10;
        cv += 7;
        cv %= k;
        if (cv == 0) {
            cout << (i + 1) << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

long long arr[128];

int N, X;

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

    long long sum = 0;
    for(int i=0; i<N; i++){ cin >> arr[i]; sum += arr[i]; }

    if(sum == X){
        cout << N << endl;
        return 0;
    }

    if(sum < X){
        cout << N-1 << endl;
        return 0;
    }

    sort(arr,arr+N);

    long long ans = 0;
    for(int i=0; i<N; i++){
        if(X < arr[i]) break;

        ans++;
        X -= arr[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = sorted(list(map(int,input().split())))
maxa = max(a)+1
dp = [0]*maxa

for i in a:
    dp[i] += 1
    if dp[i] == 1:
        for j in range(2*i,maxa,i):
            dp[j] += 2
print(dp.count(1))

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

//パテ　p0 = 1, pi = 2p(i-1)+1 pn = 2^(n+1)-1
//高さ　h0 = 1, hi = 3h(i-1)+2 hn = 2^(n+2)-3

ll rec(int n,ll x){
    if(n==0)return 1;
    ll len = (1LL<<(n+1)) - 3;//n-1レベルのバーガーの高さ
    ll num = (1LL<<n)-1;//n-1レベルのバーガーのパテ数
    if(x == 1)return 0;
    else if(x <= len+1)return rec(n-1,x-1);
    else if(x == len+2)return num+1;
    else if(x <= (len+1)*2)return num+1+rec(n-1,x-len-2);
    else return num*2+1;
}

int main(){
    int N;
    ll X;
    cin >> N >> X;
    ll ans = rec(N,X);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<vector<int>> to(n);
    rep(i, n) {
        int u, k;
        cin >> u >> k;
        u--;
        rep(j, k) {
            int v;
            cin >> v;
            to[u].push_back(--v);
        }
    }

    queue<int> q;
    vector<int> dist(n, -1);
    q.push(0);
    dist[0] = 0;
    
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int i = 0; i < to[v].size(); ++i) {
            int nv = to[v][i];
            if (dist[nv] >= 0) continue;
            q.push(nv);
            dist[nv] = dist[v] + 1;
        }
    }

    rep(i, n) cout << i+1 << " " << dist[i] << endl;
}


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

int main() {
    int H, N;
    cin >> H >> N;
    int sum_a = 0;
    int a = 0;
    for(int i = 0; i < N; i++) {
        cin >> a;
        sum_a += a;
    }
    if(sum_a < H) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int h,w;
  cin>>h>>w;
  char a[h][w];
  int s=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a[i][j];
      if(a[i][j]=='#') s++;
    }
  }
  if(a[0][0]=='.'||a[h-1][w-1]=='.'){
    cout<<"Impossible"<<endl;
    return 0;
  }
  
  int x=0,y=0,flag=0,ss=1;
  while(1){
    if(x+1<h&&y+1<w){
      if(a[x+1][y]=='#'&&a[x][y+1]=='.') x++;
      else if(a[x+1][y]=='.'&&a[x][y+1]=='#') y++;
      else{
        cout<<"Impossible"<<endl;
        return 0;
      }
    }else if(x+1<h){
      if(a[x+1][y]=='#') x++;
      else{
        cout<<"Impossible"<<endl;
        return 0;
      }
    }else if(y+1<w){
      if(a[x][y+1]=='#') y++;
      else{
        cout<<"Impossible"<<endl;
        return 0;
      }
    }else{
      flag=1;
      break;
    }
    ss++;
  }
  if(flag&&s==ss) cout<<"Possible"<<endl;
  else cout<<"Impossible"<<endl;
  return 0;
}


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

int max_in_set(multiset<int> &st) {
	return *st.rbegin();
}

bool erase_max(multiset<int> &st) {
	if (st.empty()) return false;
	st.erase(--st.end());
	return true;
}

int main() {
	int n, m;
	cin >> n >> m;
	multiset<int> st;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		st.insert(a);
	}
	for (int i = 0; i < m; i++) {
		int x = max_in_set(st);
		erase_max(st);
		st.insert(x/2);
	}
	long long ans = 0;
	for (int x : st) {
		ans += x;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}
int main() {
 string s;
 cin >> s;
 int t = s.size();
 cout << s[0] << s.size() - 2 << s[t-1] << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
        String t = sc.next();
        sc.close();

        // 主処理
        int result = 2 * n;
        for (int i = 0; i < n; i++) {
            String foot = t.substring(0, n - i);
            if (s.endsWith(foot)) {
                result -= foot.length();
                break;
            }
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 23380
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var u = xArray(1,n);
  var e = xArray("[]",n);
  for(var i = 1; i < n; i++){
    var t = o.l().map(a=>a-1);
    e[t[0]].push(t[1]);
    e[t[1]].push(t[0]);
  }
  var q = [0], q2 = [], v;
  u[0] = 0;
  while(q.length || q2.length){
    if(q.length === 0){
      l++;
      q = q2;
      var q2 = [];
    }
    var x = q.pop();
    v = x;
    for(var i = 0; i < e[x].length; i++){
      if(u[e[x][i]]){
        q2.push(e[x][i]);
        u[e[x][i]] = 0;
      }
    }
  }
  var q = [v], q2 = [], l = 0;
  u = xArray(1,n);
  u[v] = 0;
  while(q.length || q2.length){
    if(q.length === 0){
      l++;
      q = q2;
      var q2 = [];
    }
    var x = q.pop();
    for(var i = 0; i < e[x].length; i++){
      if(u[e[x][i]]){
        q2.push(e[x][i]);
        u[e[x][i]] = 0;
      }
    }
  }
  return l%3 === 1 ? "Second":"First";
}

Measured memory_bytes: 101440
#include<iostream>
#include<string>

using namespace std;
int main(){
	string x;
	while(1){
		cin>>x;
		if(x=="0")break;
		int sum=0;
		for(int i=0;i<x.size();i++){
			sum+=x[i] - '0';
		}
		cout<<sum<<endl;
	}
}
		
		

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

#define io ios::sync_with_stdio(false)
#define pb push_back
#define pqueue priority_queue
#define fi first
#define se second
#define ls rt<<1
#define rs rt<<1|1
#define sz(x) (int)(x).size()
#define dbg(x) cout<<#x<<" --- "<<x<<endl
#define mst(x,a) memset(x,a,sizeof(x))
#define fin(a) freopen(a,"r",stdin)
#define fout(a) freopen(a,"w",stdout)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }
ll qpow(ll a,ll b,ll m){ ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r; }
const int inf=0x7fffffff;
const int maxn=2e5+10;
int a[maxn];
int n;

int main(){
	io;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	ll ans=0;
	for(int i=2;i<=n;i++){
		if(a[i]<a[i-1]){ ans+=a[i-1]-a[i];a[i]=a[i-1]; }
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4396
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
N = int(input())
ans = map(str,sorted(prime_factorize(N)))
print(str(N)+': '+' '.join(ans))


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

long long int knapSack(long long int W, long long int wt[], long long int val[], long long int n)
{
   long long int i, w;
   long long int K[n+1][W+1];

   for (i = 0; i <= n; i++)
   {
       for (w = 0; w <= W; w++)
       {
           if (i==0 || w==0)
               K[i][w] = 0;
           else if (wt[i-1] <= w)
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]);
           else
                 K[i][w] = K[i-1][w];
       }
   }

   return K[n][W];
}

int main()
{
    ios_base::sync_with_stdio(false);

    long long int n,i,j,k,w;
    cin>>n>>w;
    long long int val[n],wt[n];
    for(i=0;i<n;i++)
    {
      cin>>wt[i]>>val[i];
    }

    cout<<knapSack(w, wt, val, n)<<"\n";
    return 0;
}




Measured memory_bytes: 79232
from collections import deque
h, w = map(int, input().split())
S = [[] for _ in range(h)]
ans = 0
for i in range(h):
    S[i] = list(input())
    ans += S[i].count('.')

direct = [[0,1],[0,-1],[1,0],[-1,0]]
# BFS
## 距離を初期化.
D = [[-1]*w for _ in range(h)]
D[0][0] = 0
## 現在地でキューを初期化.
que = deque([[0,0]])
## キューがなくなるまで探索を行う.
while que:
    ### キューを一つ取り出す.
    chi, cwi = que.pop()
    for (dh,dw) in direct:
        #### 迷路の範囲外なら探索しない.
        if not (0<=chi+dh<=h-1 and 0<=cwi+dw<=w-1): continue
        #### 探索済みや探索不可なところは探索しない.
        if D[chi+dh][cwi+dw]!=-1 or S[chi+dh][cwi+dw]=='#': continue
        #### 距離の計算.
        D[chi+dh][cwi+dw] = D[chi][cwi]+1
        #### 次に探索する場所の追加.
        que.appendleft([chi+dh, cwi+dw])
dist = D[-1][-1]
print(ans-(dist+1) if dist!=-1 else -1)

Measured memory_bytes: 9352
#include <iostream>
#include <string>

using namespace std;
int main() {
	// your code goes here
	int max = 0;
	int all = 0;
	string s;
	cin >> s;
	for (int i = 0; i < 3; i++) { 
	    if (s[i] == 'R') {
	        max += 1;
	    } else {
	        max = 0;
	    }
	    if (max > all) {
	        all = max;
	    }
    }
    cout << all;
	return 0;
}

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

using namespace std;

long long int gcd(long long int x, long long int y)
{
    if (y == 0)
        return x;

    return gcd(y, x % y);
}

int main()
{
    long long int a, b;

    cin >> a >> b;

    cout << (a * b) / gcd(a, b) << "\n";

    return 0;
}

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

int main(){
    int N,K,d,A;

    cin >> N >> K;
    int ans = N;

    int buf[100];
    for(int i = 0;i < 100;i++)buf[i] = 1;

    for(int i = 0;i < K;i++){
        cin >> d;
        for(int j = 0;j < d;j++){
            cin >> A;
            if(buf[A] == 1){
                ans--;
                buf[A] = 0;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3608