akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int f(ll A, ll B, ll C, ll D) {
    bool answer = true;
    answer &= (A >= B);
    answer &= (D >= B);
    if (C >= B) return answer;

    ll g = __gcd(D, B);
    ll x = (A % g) + C - (C % g);
    if (x <= C) x += g;
    answer &= (x >= B);

    return answer;
}

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

    int T;
    cin >> T;

    for (int t = 0; t < T; t++) {
        ll A, B, C, D;
        cin >> A >> B >> C >> D;

        bool answer = f(A, B, C, D);

        cout << (answer ? "Yes" : "No") << endl;
    }

    return 0;
}



Measured memory_bytes: 256
from decimal import *
import math

if __name__ == "__main__":
    A, B = input().split()
    A = Decimal(A)
    B_ = B[:-3] + B[-2:]
    B = Decimal(B_)
    ans = str(B*A)[:-2]
    print(0 if len(ans)==0 else ans)
    

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

int main(){
  int a, b, t;
  cin >> a >> b >> t;
  cout << b*(t/a) << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
T = [0]
X = [0]
Y = [0]
for _ in range(N):
    t, x, y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)
for i in range(N):
    diff = abs(X[i + 1] - X[i]) + abs(Y[i + 1] - Y[i])
    if T[i + 1] - T[i] < diff:
        print("No")
        exit()

    if (diff - (T[i + 1] - T[i])) % 2 != 0:
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 11816
n = int(input())
dic = {}
for _ in range(n):
    s = input()
    if s not in dic:
        dic[s] = 1
    else:
        dic[s] += 1
m = max(dic.values())
anslis = []
for k, v in dic.items():
    if v == m:
        anslis.append(k)
print('\n'.join(sorted(anslis)))

Measured memory_bytes: 34140
# -*- coding: utf-8 -*-
#! python3

n = int(input())

word = []
word.append(input())

ans = 'Yes'

for _ in range(n-1):
    shiritori = input()
    if shiritori in word:
        ans = 'No'
        break
    elif shiritori[0] != word[-1][-1]:
        ans = 'No'
        break
    else:
        word.append(shiritori)
        
print(ans)


Measured memory_bytes: 3060
import fractions
N = int(input())
list_number = list(map(int,input().split(" ")))
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
number_max = lcm_list(list_number)
newlist = list(map(lambda x: number_max // x, list_number))
print(sum(newlist) % 1000000007)

Measured memory_bytes: 264660
#include <bits/stdc++.h>
using namespace std;
#define NIL -1

vector<int> G[100003];
int color[100003];
int n;

int nextPoint(int curPoint){
    int next;
    for(int i=0;i<G[curPoint].size();++i){
        next = G[curPoint][i];
        if(color[next] == NIL){
            return next;
        }
    }
    return -1;
}

void dfs(int point, int value){
    color[point] = value;
    while(1){
        int next = nextPoint(point);
        if(next != -1){
            dfs(next,value);
        }
        else{
            color[point] = value;
            return;
        }
    }
}

int main(){
    int m, s, t;
    scanf("%d %d",&n, &m);
    for(int i=0;i<m;++i){
        scanf("%d %d",&s, &t);
        G[s].push_back(t);
        G[t].push_back(s);
    }
    for(int i=0;i<n;++i){
        color[i] = NIL;
    }
    int id = 0;
    for(int i=0;i<n;++i){
        if(color[i]==NIL){
            id += 1;
            dfs(i,id);
        }
    }
    int q;
    scanf("%d",&q);
    for(int i=0;i<q;++i){
        scanf("%d %d",&s, &t);
        if(color[s]==color[t]) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}



Measured memory_bytes: 12152
i=int(input())
lists=list(map(int,input().split()))

sumA=0
sumB=0

while lists!=[]:
    a=max(lists)
    sumA=sumA+a
    lists.remove(a)
    if lists!=[]:    
        b=max(lists)
        sumB=sumB+b
        lists.remove(b)

d=sumA-sumB
print(d)

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

int main(int, char**) {
    int x, y, z, res;
    res = 0;
    cin >> x >> y >> z;
    for( int i = 1; i <= z; ++i )
    {
        
        if( z % i == 0 && ( x <= i ) && ( y >= i ) ) ++res;
    }
    cout << res << endl;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define HohleFeuerwerke using namespace std
#define int long long
HohleFeuerwerke;
inline int read(){
	int f=1,s=0;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9'){s=s*10+c-'0';c=getchar();}
	return f*s;
}
signed main()
{
	int n=read();
	cout<<ceil(n/2.0)<<endl;
}

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

int main(void){
    int n;
    cin >> n;
    
    if(n == 1){
        cout << "Hello World" << endl;
    }else{
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
string s;
int a[10],b[10];
vector<int>v;
bool ch(int d){
  if(d==5)return 1;
  if(!d){
    for(int i=1;i<10;i++){
      if(b[i]>=2){
        b[i]-=2;
        if(ch(d+1))return 1;
        b[i]+=2;
      }
    }
  }
  else{
    for(int i=1;i<10;i++){
      if(b[i]>=3){
        b[i]-=3;
        if(ch(d+1))return 1;
        b[i]+=3;
      }
    }
    for(int i=1;i<8;i++){
      if(b[i]&&b[i+1]&&b[i+2]){
        b[i]--;b[i+1]--;b[i+2]--;
        if(ch(d+1))return 1;;
        b[i]++;b[i+1]++;b[i+2]++;
      }
    }
  }
  return 0;
}
void dfs(){
  for(int i=1;i<10;i++){
    if(a[i]<4){
      a[i]++;
      for(int j=0;j<10;j++)b[j]=a[j];
      if(ch(0))v.push_back(i);
      a[i]--;
    }
  }
}
int main(){
  while(cin>>s){
    v.clear();
    memset(a,0,sizeof(a));
    for(int i=0;i<s.size();i++)
      a[s[i]-'0']++;
    dfs();
    if(v.size()){
      for(int i=0;i<v.size();i++){
        if(i)cout<<' ';
        cout<<v[i];
      }
      cout<<endl;
    }
    else cout<<0<<endl;
  }
}

Measured memory_bytes: 3136
N = int(input())
location = list(map(int, input().split())) 

count = 0
max_count =0
for i in range(N-1):
    if location[i] >= location[i+1]:
        count = count+1
        if count > max_count:
            max_count=count
    else:
        count = 0
        
print(max_count)
    

Measured memory_bytes: 14252
//set many funcs
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1145141919
#define llinf 1145141919810364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int n,i,a,d[131072]={0},r=0;
    scanf("%d",&n);
    for(i = 1;i <= n;i++){
        scanf("%d",&a);
        if(a==0){d[0]++;d[1]++;}else{d[a-1]++;d[a]++;d[a+1]++;}
    }
    for(i=0;i<=131071;i++){r=max(r,d[i]);}
    printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

ll gcd(ll a, ll b) {
	while (b > 0) {
		ll tmp = b;
		b = a % b;
		a = tmp;
	}
	return a;
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

ll ndiv(ll a, ll b, ll c) {
	ll x = a / c;
	if (a%c == 0) --x;
	return b / c - x;
}

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	ll a, b, c, d;
	scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
	ll answer = ndiv(a, b, c) + ndiv(a, b, d) - ndiv(a, b, lcm(c, d));
	answer = b - a + 1 - answer;
	printf("%lld\n", answer);
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int i, N, l ,r, sum = 0;

	scanf("%d", &N);

	for (i = 0; i < N; i++) {
		scanf("%d %d", &l, &r);
		sum = sum + r - l + 1;
	}

	printf("%d\n", sum);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
#define PB push_back
#define all(v) (v).begin(),(v).end()
const int INF = 10000;

int main()
{
	int h;
	while (scanf("%d", &h), h){
		VI v[5];
		
		for (int i = 0; i < h; i++){
			for (int j = 0; j < 5; j++){
				int a;
				scanf("%d", &a);
				v[j].PB(a);
			}
		}
		
		for (int i = 0; i < 5; i++){
			reverse(all(v[i]));
		}
		
		int res = 0;
		while (true){
			bool update = false;
			
			for (int i = 0; i < h; i++){
				int chain[5] = {1, 1, 1, 1, 1};
				for (int j = 1; j < 5; j++){
					if (v[j][i] == v[j - 1][i] && v[j][i] != INF) chain[j] = chain[j - 1] + 1;
				}
				for (int j = 4; j >= 2; j--){
					if (chain[j] >= 3){
						for (int k = j; k > j - chain[j]; k--){
							res += v[k][i];
							v[k][i] = INF;
						}
						update = true;
						break;
					}
				}
			}
			
			if (!update) break;
			
			for (int i = h - 1; i >= 0; i--){
				for (int j = 0; j < 5; j++){
					if (v[j][i] == INF){
						for (int k = i; k < h - 1; k++){
							swap(v[j][k], v[j][k + 1]);
						}
					}
				}
			}
			
			/*
			for (int i = h - 1; i >= 0; i--){
				for (int j = 0; j < 5; j++){
					if (v[j][i] == INF) printf("-1 ");
					else printf("%2d ", v[j][i]);
				}
				puts("");
			}
			puts("");
			*/
			
		}
		
		cout << res << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1232
s=input()
k=int(input())
n=len(s)
koho=[]
for i in range(n):
    for j in range(k):
        if len(s[i:i+j+1])<=k:
            koho.append(s[i:i+j+1])

print(sorted(list(set(koho)))[k-1])

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

int main()
{
    int x, a, b;
    cin >> x >> a >> b;
    if(b > (x+a)) cout << "dangerous" << endl;
    else if(b < (x+a) && b <= x) cout << "delicious" << endl;
    else cout << "safe" << endl;
    return 0;
}

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

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] a = Input.ScanIntArray();
          
          Console.WriteLine(a[0]%a[1]==0 ? 0 : 1);
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  int a,b,c,d;
  d = N % 10;
  N /= 10;
  c = N % 10;
  N /= 10;
  b = N % 10;
  N /= 10;
  a = N;
  
  if(a == b && b == c)
    cout << "Yes" << endl;
  else if(b == c && c == d)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a,b,c,x;
	scanf("%d %d %d",&a,&b,&c);
        if(a>b){
		x=b;
		b=a;
		a=x;
	}
	if(b>c){
		x=c;
		c=b;
		b=x;
	}
	if(a>b){
		x=a;
		a=b;
		b=x;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int ans = 0;
        int N = sc.nextInt();
        for(int i = 0; i < N; i++){
            ans += sc.nextInt() - 1;
        }
        System.out.println(ans);

    }

}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int T;
double XA,YA,RA;
double XB,YB,RB;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>T;
	while(T--) {
		cin>>XA>>YA>>RA;
		cin>>XB>>YB>>RB;
		double D=hypot(XA-XB,YA-YB);
		
		double X=0.5/RA;
		double r1=X-1/(RA+D-RB);
		double r2=X-1/(RA+D+RB);
		
		//_P("X:%.12lf %.12lf %.12lf\n",X,r1,r2);
		
		double a = 3;
		double b = -2*(r1+r2);
		double c = r1*r2;
		double d =b*b-4*a*c;
		double x = sqrt(c);
		double r3 = 0.5/x;
		double r4 = 0.5/(x-r1);
		double r5 = 0.5/(x-r2);
		double r6 = abs(r5-r4);
		//_P("%.12lf %.12lf\n",r3,r6);
		double dif=(r6-r3)/2;
		double at = asin(dif/(r3+dif));
		_P("%d\n",(int)(atan(1)*4/at));
		
		
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 1024
a = int(input())
b = int(input())
c = int(input())
d = int(input())
ans = 0
for i in range(a + 1):
  for j in range(b + 1):
    for k in range(c + 1):
      if d == 500 * i + 100 * j + 50 * k:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define Set(a,b) memset(a,b,sizeof(a))
template<class T>inline void init(T&x){
	x=0;char ch=getchar();bool t=0;
	for(;ch>'9'||ch<'0';ch=getchar()) if(ch=='-') t=1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch-48);
	if(t) x=-x;return;
}typedef long long ll;
const int N=2001;
const int mod=1e9+7;
template<class T>inline void Inc(T&x,int y){x+=y;if(x>=mod) x-=mod;}
int R[N][N],L[N][N],U[N][N],D[N][N];
int H,W;
char s[N][N];
int main()
{
	init(H),init(W);
	for(int i=1;i<=H;++i) scanf("%s",s[i]+1);
	for(int i=1;i<=H;++i) {
		for(int j=1;j<=W;++j) {
			if(s[i][j]!='#') L[i][j]=L[i][j-1]+1,U[i][j]=U[i-1][j]+1;
		}
	}
	int ans=0;
	for(int i=H;i;--i) {
		for(int j=W;j;--j) {
			if(s[i][j]!='#') R[i][j]=R[i][j+1]+1,D[i][j]=D[i+1][j]+1,ans=max(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j]-3);
			
		}
	}cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 66688
# 問題 https://atcoder.jp/contests/abc103/tasks/abc103_d

# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N, M = read_ints()

AB = [tuple(map(int, read().split())) for _ in range(M)]

from operator import itemgetter

AB.sort(key=itemgetter(1))  # リスト1は2次元以の配列

# . - . - . - .

i = -1  # いま考慮している島の位置
ans = 0
for a, b in AB:
    # zero-based index
    a -= 1
    b -= 1
    if a < i:
        # 考えなくてもいい(もう満たしている)要望は飛ばす
        # 同じ島からスタートする橋は許容できるので<=ではなく<
        continue
    ans += 1
    i = b

print(ans)


Measured memory_bytes: 56924
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char x;
  cin >> x;
  if(x=='A') {
    cout << 'T';
  }
  else if(x=='T') {
    cout << 'A';
  }
  else if(x=='G') {
    cout << 'C';
  }
  else {
    cout << 'G';
  }
}

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())
if A > C:
    tmpA = A
    tmpB = B
    A = C
    B = D
    C = tmpA
    D = tmpB
if D > B:
    if C > B:
        print(0)
    else:
        print(B-C)
else:
    print(D-C)


Measured memory_bytes: 2940
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    A=list(map(int,input().split()))
    A.sort()
    BC=[list(map(int,input().split())) for _ in range(m)]
    BC.sort(lambda x:x[1],reverse=1)

    now=0
    for b,c in BC:
        while(b>0 and now<n and A[now]<c):
            A[now]=c
            now+=1
            b-=1
    print(sum(A))
resolve()

Measured memory_bytes: 73256
#include <bits/stdc++.h>
using namespace std;
 
string s;
 
int main(){
  cin >> s;
  string res = "No";
  if(s[0] == s[1]){
    if(s[2] == s[3]){
      if(s[0] != s[2]){
        res = "Yes";
      }
    }
  }else if(s[0] == s[2]){
    if(s[1] == s[3]){
      if(s[0] != s[1]){
        res = "Yes";
      }
    }
  }else if(s[0] == s[3]){
    if(s[1] == s[2]){
      if(s[0] != s[1]){
        res = "Yes";
      }
    }
  }
  cout << res << endl;
}

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

const int N = 1e6 + 5;
typedef long long LL;

int h, w, k, a[N], f[N], x, y, xx, yy;
int dx[5] = {0, 1, 0, 0, -1};
int dy[5] = {0, 0, 1, -1, 0};
struct node {
	int r, c;
} q[N<<2];

int p(int x, int y) { return (x - 1)*w + y; }

int Bfs() {
	memset(f, 0x7f, sizeof(f));
	f[p(x, y)] = 0;
	int l = 1, r = 1;
	q[l] = (node) {x, y};
	while(l <= r) {
		int x = q[l].r, y = q[l].c;
		if(x == xx && y == yy) return f[p(x, y)];
		for(int i = 1; i <= 4; i++) {
			int nx = x, ny = y;
			for(int j = 1; j <= k; j++) {
				nx += dx[i], ny += dy[i];
				if(nx > h || nx < 1 || ny < 1 || ny > w) break;
				if(a[p(nx, ny)]) break;
				if(f[p(nx, ny)] <= f[p(x, y)]) break;
				if(f[p(nx, ny)] > f[p(x, y)] + 1) {
				    f[p(nx, ny)] = f[p(x, y)] + 1;
				    q[++r] = (node) {nx, ny};
				}
			} 
		}
		l++;
	}
	return -1;
}

int main() {
	cin>>h>>w>>k>>x>>y>>xx>>yy;
	for(int i = 1; i <= h; i++)
		for(int j = 1; j <= w; j++) {
			char ch;
			cin>>ch;
			if(ch != '.') a[p(i, j)] = 1;
		}
	cout<<Bfs()<<endl;
	return 0;
}

Measured memory_bytes: 15392
#include <bits/stdc++.h>
using namespace std;
int main()
{
  	cin.tie(0);
	ios::sync_with_stdio(false);
    int x, y, z, K;
    cin >> x >> y >> z >> K;
    vector<long long> A(x), B(y), C(z);
    for (int i = 0; i < x; i++)
    {
        cin >> A[i];
    }
    for (int i = 0; i < y; i++)
    {
        cin >> B[i];
    }
    for (int i = 0; i < z; i++)
    {
        cin >> C[i];
    }
  	sort(A.rbegin(),A.rend());
  	sort(B.rbegin(),B.rend());
  	sort(C.rbegin(),C.rend());
    priority_queue<long long> P;
  	vector<long long>v;
    for (long long i = 0; i < x; i++)
    {
        for (long long j = 0; j < y; j++)
        {
            for (long long k = 0; k < z; k++)
            {
              if(i*j*k>=3000)continue;
              v.push_back(A[i]+B[j]+C[k]);
            }
        }
    }
	sort(v.rbegin(),v.rend());
    for (int i = 0; i < K; i++)
    {
      cout<<v[i]<<endl;
    }
}
 

Measured memory_bytes: 35176
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include<vector>

using namespace std;
typedef long long ll;

ll ans,mx,sum,mn=1e18,cnt,flag;
ll alice,bob,charlie;
int main(){
	string a,b,c;
	cin>>a>>b>>c;
	char t[1];
	t[0]='a';
	while(1){
		if(alice>a.size()){
			cout<<"A";
			break;
		}
		if(bob>b.size()){
			cout<<"B";
			break;
		}
		if(charlie>c.size()){
			cout<<"C";
			break;
		}
		if(t[0]=='a'){
			t[0]=a[alice];
			alice++;
		}
		else if(t[0]=='b'){
			t[0]=b[bob];
			bob++;
		}
		else if(t[0]=='c'){
			t[0]=c[charlie];
			charlie++;
		}
	}

}



Measured memory_bytes: 256
S = input()

while len(S) > 4:
    if S[-5:] == 'dream':
        S = S[:-5]
        continue
    elif S[-5:] == 'erase':
        S = S[:-5]
        continue
    elif S[-6:] == 'eraser':
        S = S[:-6]
        continue
    elif S[-7:] == 'dreamer':
        S = S[:-7]
        continue
    else:
        break

if S == '':
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <vector>
using namespace std;
const int INF = 0x3f3f3f3f;

int main(){
	int S[100005], T[50005];
	int n, q, ans = 0;
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> S[i];
	cin >> q;
	for(int i = 0; i < q; i++)
		cin >> T[i];
	for(int i = 0; i < q; i++){
		int left = 0, right = n, mid;
		while(left < right){
			mid = (left + right) / 2;
			if(S[mid] == T[i]){
				ans++;
				break;
			}
			else if(S[mid] < T[i])
				left = mid + 1;
			else
				right = mid;
		}
	}
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 3548
#define _CRT_SECURE_NO_WARNINGS
//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(void) {
#ifdef DEBUG
	printf("");
#endif

	int X, t;
	int ans;

	scanf("%d %d", &X, &t);
	if (X > t) {
		ans = X - t;
	}
	else {
		ans = 0;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <fstream>
#include <queue>
#include <cstdio>
#include <deque>
#include <map>
#define fol(i,n) for(int i=0;i<n;i++)
#define db(a) cout << a<< endl;
using namespace std;

int main(){
    int a,b,count=0;
    cin >>a;
    int pr[100001]={};
    for(int i=1;i<=a;i++){
        cin >>b;
        pr[i]=b;
        if (pr[b]==i) count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	num, _ := strconv.Atoi(sc.Text())
	nodes := make(map[int]*node)

	for i := 0; i < num; i++ {
		sc.Scan()
		id, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		nodeNum, _ := strconv.Atoi(sc.Text())
		n := node{id, make([]int, 0), -1}
		for j := 0; j < nodeNum; j++ {
			sc.Scan()
			nid, _ := strconv.Atoi(sc.Text())
			n.nexts = append(n.nexts, nid)
		}
		nodes[id] = &n
	}
	nodes[1].depth = 0

	walk(1, 0, &nodes)
	for i := 1; i < len(nodes)+1; i++ {
		fmt.Printf("%v %v\n", (*nodes[i]).id, (*nodes[i]).depth)
	}
}

var time int
var record [100][100]bool
var q Queue

func walk(nid int, from int, nodes *map[int]*node) {
	q.Enqueue((*nodes)[nid])
	for !q.IsEmpty() {
		n := q.Dequeue().(*node)
		for _, v := range n.nexts {
			n2 := (*nodes)[v]
			if n2.depth != -1 {
				continue
			}
			n2.depth = n.depth + 1
			q.Enqueue((*nodes)[v])
		}
	}
}

type node struct {
	id    int
	nexts []int
	depth int
}

// Queue is Queue
type Queue struct {
	val []interface{}
}

// Enqueue value
func (queue *Queue) Enqueue(val interface{}) {
	queue.val = append(queue.val, val)
}

// Dequeue value
func (queue *Queue) Dequeue() interface{} {
	res := queue.val[0]
	queue.val = queue.val[1:len(queue.val)]
	return res
}

// IsEmpty return true when queue is empty
func (queue *Queue) IsEmpty() bool {
	return len(queue.val) == 0
}



Measured memory_bytes: 1136
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <queue>
typedef long long ll;
using namespace std;
const int mod=1e9+7;
const ll inf=(1e14);

int extended_euclidean(int a,int b,ll &x,ll &y){
	if(!b){
		x=1;y=0;
		return a;
	}
	ll x1,y1;
	int g=extended_euclidean(b,a%b,x1,y1);
	x = y1;
	y = x1 - y1*(a/b);
	return g;
}

ll c(ll n,ll r){
	ll nf=1;
	for(ll i=2;i<=n;i++) nf=(nf*i)%mod;
	ll rf=1,nrf=1;
	for(ll i=2;i<=r;i++) rf=(rf*i)%mod;
	for(ll i=2;i<=n-r;i++) nrf=(nrf*i)%mod;
	ll rfi,nrfi,t;
	extended_euclidean(mod,rf,t,rfi);
	extended_euclidean(mod,nrf,t,nrfi);
	rfi%=mod;nrfi%=mod;
	rfi=(rfi+mod)%mod;
	nrfi=(nrfi+mod)%mod;
	return (((nf*rfi)%mod)*nrfi)%mod;
}

ll solve(){
	int x,y;
	cin>>x>>y;
	int a = (2*x-y)/3, b = (2*y-x)/3;
	if( (a<0) || (b<0) || (2*a+b != x) || (2*b+a != y) ) return 0;
	return c(a+b,a);
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    int t=1;
    //cin>>t;
    while(t--) cout<<solve()<<'\n';
    //while(t--) solve(),cout<<'\n';
    return 0;
}


Measured memory_bytes: 3600
S = list(input())
hantei = 1
kaisu = 0

for i in range(0,4):
    for j in range(0,4):
        if S[i] == S[j]:
            kaisu += 1
    if kaisu != 2:
        hantei = 0
        
    kaisu = 0

if hantei == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  print(n*(n-1)/2);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<stdlib.h>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<math.h>
using namespace std;
int main()
{
    
    long long int k, a[100];
    cin>>k;
    long long mod, ad;
    if(k==0)
    {

        cout<<2<<endl<<1<<' '<<0<<endl;
        return 0;
    }
    else if(k==1)
    {
        cout<<3<<endl<<1<<' '<<0<<' '<<3;
        return 0;
    }
    else if(k<=50)
    {
        cout<<k<<endl;
        for(int i=k;i>0;i--)
        {
           a[i]=i;
        }
        for(int i=1;i<=k;i++)
        {
            cout<<a[i]<<' ';
        }
        return 0;
    }
    else
    {
        mod=(k%50);
        (mod==0)? ad=k/50-1:ad=k/50;
        (mod==0)? mod=50:mod=mod;
        int counting=0;
        cout<<50<<endl;
        for(long long int i=50;i>0;i--)
        {
            if(counting<mod)
            {
               a[i]=i+ad;
                counting++;
            }
            else
            {
               a[i]=ad+i-1;
            }
        }
        for(int i=1;i<=50;i++)
        {
            cout<<a[i]<<' ';

        }
        return 0;
    }

return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#define REP(i, n) for(int i=0;i<n;++i)

typedef long long ll;
using namespace std;

int n, A[50];

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

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

    return 0;
}



Measured memory_bytes: 2592
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <cmath> 
#include <cctype>

using namespace std;

int main() {
    int Num[3], K;
    for (int i = 0; i < 3; i++) {
        cin >> Num[i];
    }
    cin >> K;

    sort(Num, Num + 3);

    for (int i = 1; i <= K; i++) {
        Num[2] *= 2;
    }
    int total = 0;
    for (int i = 0; i < 3; i++) {
        total += Num[i];
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int d;
	cin>>d;
	if(d==25) cout<<"Christmas";
	if(d==24) cout<<"Christmas Eve";
	if(d==23) cout<<"Christmas Eve Eve";
	if(d==22) cout<<"Christmas Eve Eve Eve";
	return 0;
} 

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace CsharpSpiral {
    partial class Program {
        static void Main(string[] args) {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }
        public void Solve(ConsoleInput cin) {
            long N = cin.ReadLong;
            long A = cin.ReadLong;
            long B = cin.ReadLong;
            var sets = N / (A + B);
            Console.WriteLine(sets * A + Math.Min((N % (A + B)), A));
        }


    }

    static class ExtendClass {
        public static void Swap<T>(this T[] X, int i, int j) {
            T tmp = X[i];
            X[i] = X[j];
            X[j] = tmp;
        }
        public static string Join<T>(this T[] X, string separator = " ") => string.Join(separator, X);
        public static S[] Clone<S>(this S[] src) where S : struct {
            var res = new S[src.Length];
            Array.Copy(src, res, src.Length);
            return res;
        }
    }

    class ConsoleInput {
        private readonly TextReader _stream;
        private readonly char _separator = ' ';
        private readonly Queue<string> inputStream;
        public ConsoleInput(TextReader stream, char separator = ' ') {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read {
            get {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) {
            var ret = new string[N];
            for(long i = 0; i < N; ++i)
                ret[i] = Read;
            return ret;
        }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13268
import java.util.*;
import java.io.*;

public class Main {

	void solve() {
		int n = in.nextInt();
		int[] a= new int[n];
		int ans = 0;
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt() - 1;
			if (a[i] == i) {
				ans++;
			}
		}
		
		for (int i = 0; i + 1 < n; ) {
			if (a[i] == i && a[i + 1] == i + 1) {
				ans--;
				i += 2;
			} else {
				i++;
			}
		}
		out.println(ans);
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 35724
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        System.out.print("Christmas");
        for(int i=0;i<25-d;i++) System.out.print(" Eve");
        System.out.println();

    }
}


Measured memory_bytes: 22996
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int n = stdin.nextInt();
        int m = stdin.nextInt();
        int[] l = new int[m];
        int[] r = new int[m];
        long[] d = new long[m];
        for (int i = 0; i < m; i++) {
            l[i] = stdin.nextInt() - 1;
            r[i] = stdin.nextInt() - 1;
            d[i] = stdin.nextInt();
        }
        
        UnionFind uf = new UnionFind(n);
        boolean ok = true;
        for (int i = 0; i < m; i++) {
            if (uf.isSame(l[i], r[i])) {
                if (uf.diff(l[i], r[i]) != d[i]) {
                    ok = false;
                    break;
                }
            } else {
                uf.union(l[i], r[i], d[i]);
            }
        }
        
        System.out.println(ok ? "Yes" : "No");
    }
    
    private static class UnionFind {
        private int[] parent;
        private long[] weight;
        
        public UnionFind(int n) {
            parent = IntStream.range(0, n).toArray();
            weight = new long[n]; // filled by zero.
        }
        
        public int find(int x) {
            if (parent[x] == x) {
                return x;
            } else {
                int y = find(parent[x]);
                weight[x] += weight[parent[x]];
                parent[x] = y;
                return y;
            }
        }
        
        public void union(int x, int y, long w) {
            int rx = find(x);
            int ry = find(y);
            if (rx != ry) {
                parent[rx] = ry;
                weight[rx] = w - weight[x] + weight[y];
            }
        }
        
        public boolean isSame(int x, int y) {
            return find(x) == find(y);
        }
        
        public long diff(int x, int y) {
            return weight[x] - weight[y];
        }
    }
}


Measured memory_bytes: 158020
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
	cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	cout << head;
	if (sizeof...(tail) != 0) cout << " ";
	print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
	for (auto& a : vec) {
		cout << a;
		if (&a != &vec.back()) cout << " ";
	}
	cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
	for (auto& vec : df) {
		print(vec);
	}
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	vector<int> V(3);
	for (auto& v : V)
	{
		cin >> v;
	}
	ALL(sort, V);

	int ans = ceil((double)(V[1] - V[0]) / 2.0);
	V[0] += ans * 2;
	if (V[0] == V[1])
	{
		ans += V[2] - V[1];
	}
	else
	{
		ans += V[2] - V[1] + 1;
	}
	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
/*
Task:
Author: John_05
State: Unknown
Lang: C++
Solution:
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int INF=2e9+10;
#define fi first
#define se second
#define pb push_back
#define mp make_pair

int read() {
	int xx=0,ww=1;
	char ch=getchar();
	while(ch>'9'||ch<'0') {
		if(ch=='-') ww=-ww;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') {
		xx=10*xx+ch-48;
		ch=getchar();
	}
	return xx*ww;
}

int main() {
	char s[100010];
	scanf("%s",s);
	printf("%c%d%c\n",s[0],strlen(s)-2,s[strlen(s)-1]);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define ll                 long long                            
#define ra                 return a;                                          
#define pb                 push_back                                                     
#define sti                stack<ll>
#define spi                stack<pair<ll,ll>>
#define S                  second
#define msi                map<string,ll >
#define msi                map<string,ll >
#define mii                map<ll ,ll >
#define dbg(x)             { cerr<<#x<<": "<<x<< endl; }
#define dbg2(x,y)          { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z)        { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define mis                map<ll , string>
#define rep(i,a,b)         for(ll  i=a;i<b;i++)
#define mpi                map<pair<ll ,ll >,ll >                                                
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define F                  first 
#define vi                 vector<ll >
#define vii                vector<pair<ll , ll >>
#define si                 set <ll>
#define vs                 vector<string>
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define hell               1000000007
#define bs                 binary_search
#define mp                 make_pair
#define qi                 queue<ll>
#define qs                 queue<string>
#define qpi                queue<pair<ll,ll>>
#define qps                queue<pair<ll,string>> 
#define endl               '\n' 
#define itr(a,it)          for(typeof(a.begin()) it=a.begin();it!=a.end();it++)// This will produce const_iterator for const object and normal iterator for non-const object
#define ss                 set<string>
using namespace std;
#define N  300005
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
//    cin>>t;
    while(t--)
{
    ll n,l;
    cin>>n>>l;
    ll ans=0;
    rep(i,0,n)
    ans+=l+i;
    if(l<0&&l+n-1<0)
    {
    	ans-=l+n-1;
    }
    else if(l<0&&l+n-1>=0)
    {
    	;
    }
    else if(l==0)
    {
    	;
    }
    else if(l>0)
    {
    	ans-=l;
    }
    cout<<ans;
}
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i,0,n)
#define BFOR(bit,a,b) for(int bit = (a); bit < (1<<(b)); ++bit)
#define BREP(bit,n) BFOR(bit,0,n)
using namespace std;
using ll = long long;

int main() {
  ll ans = 0;
  int cnt = 0;
  string s;
  cin >> s;
  int n = s.size();
  vector<string> ss;
  
  BREP(bit,n-1){
    cnt++;
    string s1;
    int ii = 0;
    REP(i,n){
      s1.push_back(s[ii]);
      if (bit & (1<<i)) {
        s1.push_back('+');
      }
      ii++;
    }
    ss.push_back(s1);
  }
  
  int cnts = 0;
  
  REP(i,cnt){
    string sc;
    int m = ss[i].size();
    int ii = 0;
    while(1){
      if(ss[i][ii] == '+'){
        ll nn = atoll(sc.c_str());
        ans += nn;
        sc = "";
      }
      else{
        sc.push_back(ss[i][ii]);
      }
      ii++;
      if(ii == m) break;
    }
    ll nn = atoll(sc.c_str());
    ans += nn;
      
  }

  
  cout << ans << endl;
  
  
  
  

}

Measured memory_bytes: 3668
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const AB = arg.slice(1, N + 1).map(n=>n.split(" ").map(l=>parseInt(l)));
    
    // 締め切り早い順に並べる
    AB.sort((a,b)=>a[1] - b[1]);
    
    let now = 0;
    let answer = "Yes";
    
    for(let i in AB) {
        let timeConsuming = AB[i][0];
        let deadLine = AB[i][1];

        if(now + timeConsuming > deadLine) {
            answer = "No";
            break;
        }
        
        now += timeConsuming;
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return true; } return false;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return true; } return false;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 h,w,k;
  cin >> h >> w >> k;
  vector<string> a(h);
  REP(i,h)cin >> a[i];
  int32 sy=-1,sx=-1;
  REP(i,h)REP(j,w)if(a[i][j] == 'S')tie(sy,sx) = tie(i,j);
  
  vector<vector<int32>> dist(h,vector<int32>(w,inf));
  dist[sy][sx] = 0;
  priority_queue<pair<int32,pii>,vector<pair<int32,pii>>,greater<pair<int32,pii>>> que;
  que.emplace(0,pii(sy,sx));
  while(!que.empty()){
    int32 d,y,x;
    d = que.top().fi;
    tie(y,x) = que.top().se;
    que.pop();
    if(dist[y][x] < d)continue;
    REP(i,4){
      int32 ny=y+dy[i];
      int32 nx=x+dx[i];
      if(ny < 0 || h <= ny)continue;
      if(nx < 0 || w <= nx)continue;
      if(d >= k)continue;
      if(a[ny][nx] == '#')continue;
      if(chmin(dist[ny][nx], dist[y][x] + 1))que.emplace(dist[ny][nx], pii(ny,nx));
    }
  }
  REP(i,h)REP(j,w){
    if(dist[i][j] <= k){
      dist[i][j] = 0;
      que.emplace(0,pii(i,j));
    }
  }
  // REP(i,h){
  //   REP(j,w){
  //     cout << dist[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  while(!que.empty()){
    int32 d,y,x;
    d = que.top().fi;
    tie(y,x) = que.top().se;
    que.pop();
    if(dist[y][x] < d)continue;
    REP(i,4){
      int32 ny=y+dy[i];
      int32 nx=x+dx[i];
      if(ny < 0 || h <= ny)continue;
      if(nx < 0 || w <= nx)continue;
      if(chmin(dist[ny][nx], dist[y][x] + 1))que.emplace(dist[ny][nx], pii(ny,nx));
    }
  }
  // REP(i,h){
  //   REP(j,w){
  //     cout << dist[i][j] << " ";
  //   }
  //   cout << endl;
  // }

  int32 ans = inf;
  REP(i,h){
    chmin(ans, (dist[i][0] + k - 1) / k + 1);
    chmin(ans, (dist[i][w-1] + k - 1) / k + 1);
  }
  REP(j,w){
    chmin(ans, (dist[0][j] + k - 1) / k + 1);
    chmin(ans, (dist[h-1][j] + k - 1) / k + 1);

  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 32624