akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int n,m;
	cin >> n;
	int s,l,p;
	int w[400]={0,};
	for(int i=0;i<n;i++){
		cin >> s >> l >> p;
		for(int j=s;j<=l;j++){
			for(int k=0;k+j<=399;k++){
				w[k+j]=max(w[k+j],w[k]+p);
			}
		}
	}
	cin >> m;
	int d[m];
	bool ans = true;
	for(int i=0;i<m;i++){
		cin >> d[i];
		if(!w[d[i]])ans=false;
	}
	if(!ans)cout << -1 << endl;
	else{
		for(int i=0;i<m;i++){
			cout << w[d[i]] << endl;
		}
	}
}

Measured memory_bytes: 3100
public class Main {
	public static void main(String[] args){
		java.util.Scanner scan = new java.util.Scanner(System.in);
		while(true){
			String str = scan.next();
			if("-".equals(str)){
				break;
			}
			int n = scan.nextInt();
			for(int i = 0; i < n;i++){
				int h = scan.nextInt();
				str = str.substring(h)+str.substring(0, h);
			}
			System.out.println(str);

		}
	}

}

Measured memory_bytes: 26532
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
using namespace std;

const int N=5005;

int n,k;
int a[N];
int b[N];
int f[N][N];
int g[N][N];

int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	f[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=k;j++)
			f[i][j]=f[i-1][j];
		for(int j=0;j<=k-a[i];j++)
			if(f[i-1][j]) f[i][j+a[i]]=1;
	}
	g[n+1][0]=1;
	for(int i=n;i;i--)
	{
		for(int j=0;j<=k;j++)
			g[i][j]=g[i+1][j];
		for(int j=0;j<=k-a[i];j++)
			if(g[i+1][j]) g[i][j+a[i]]=1;
	}
	for(int i=1;i<=n+1;i++)
	{
		for(int j=0;j<=k;j++)
			if(g[i][j]) g[i][j]=j;
			else g[i][j]=g[i][j-1];
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int mx=0;
		for(int j=0;j<k;j++) if(f[i-1][j]) mx=max(mx,j+g[i+1][k-1-j]);
		if(mx+a[i]>=k) ans++;
	}
	cout<<n-ans<<endl;
}
		

Measured memory_bytes: 195840
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>

using namespace std;

int main() {
    int t[31] = {}, x = 1;
    for (int i=1; i<31; ++i) {
        t[i] = t[i-1] + x;
        x *= 3;
    }
    int res[31];
    for (int i=0; i<31; ++i) {
        res[i] = i;
        for (int j=0; j<i; ++j) {
            res[i] += 2 * t[min(j, i-1-j)];
        }
    }
    int n;
    while (cin >> n) {
        cout << res[n] << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	ll n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	
	ll mn = min(a, b);
	mn = min(mn, c);
	mn = min(mn, d);
	mn = min(mn, e);
	
	ll ans = 5;
	ans += (n + mn - 1) / mn - 1;
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <nmmintrin.h>
#include <chrono>
const double EPS = 1e-8;
#define Scan(a) int a;scanf("%d", &a);
#define ScanS(a) char a[500];scanf("%s", a);
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1LL)
#define bitset(a,b)      ( a |= (1LL << b))
#define bitunset(a,b)    (a &= ~(1LL << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

pii Dir[8] = {
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};


pii operator+(pii obj, pii obj2) {
	return MP(obj.first + obj2.first, obj.second + obj2.second);
}
pii operator-(pii obj, pii obj2) {
	return MP(obj.first - obj2.first, obj.second - obj2.second);
}

struct Edge {
	int from, to, weight;
};

typedef vector<vector<Edge>> Graph;


int randxor()
{
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t;
	t = (x ^ (x << 11)); x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))) % INT_MAX;
}

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

	int dist[10][10];
	REP(i, 10) {
		REP(j, 10) {
			scanf("%d", &dist[i][j]);
		}
	}

	for (int k = 0; k < 10; k++)
		for (int i = 0; i < 10; i++)
			for (int j = 0; j < 10; j++)
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
	ll ans = 0;

	REP(i, n) {
		REP(j, m) {
			int a;
			scanf("%d", &a);
			if(a != -1)
				ans += (ll)dist[a][1];
		}
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Bite Eating
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int sum = l * n + n * (n - 1) / 2;
  int a = l, b = l + n - 1;

  if (a >= 0) sum -= a;
  else if (b <= 0) sum -= b;

  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    //長方形の中に円が含まれるかを判定する
    int W = 0, H = 0;           //長方形の左下座標(0,0), 右上座標(W,H)
    int x = 0, y = 0, r = 0;    //円の中心座標(x,y), 半径r

    scanf("%d %d %d %d %d",&W, &H, &x, &y, &r);  //区切りの空白は問題文による指定

    //入力された値が条件の範囲内かチェック
    if(x < -100 || x > 100 || 
       y < -100 || y > 100 || 
       W < 0    || W > 100 ||
       H < 0    || H > 100 ||
       r < 0    || r > 100 )
    {
        //異常な入力の場合エラーメッセージを表示して終了する
        printf("Invalid Input\n");
        return 0;
    }

    //円の中心座標±rが長方形の中に収まっているかどうかで判別する
    if( x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
    {
        printf("Yes\n");  //出力内容は問題文による指定
    }
    else
    {
        printf("No\n");  //出力内容は問題文による指定
    }

    return 0;
}



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

int main(){
  string s;
  cin >> s;
  rep(i,s.size()) s[i] = 'x';
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
/**
 *  winners never quit
**/

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define pp pop_back
#define mp make_pair
#define IO cin.tie(0),cout.tie(0)
#define ISWS ios::sync_with_stdio(0)
typedef long long Long;
void FastIO(){ISWS;IO;}

const int N = 1e5;

Long m = 1e9 + 7;

int main()
{
  FastIO();
  int tc, ca = 0;
  Long n;
  cin >> n;
  vector <Long> a(n);
  Long ps = 0;
  Long ans = 0;
  for (int i = 0;i < n;i++){
    cin >> a[i];
    ans += a[i] * ps;
    ps += a[i];
    ans %= m;
    ps %= m;
  }

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


Measured memory_bytes: 4752
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	double d;
	cin >> d;
	printf("%1.10f\n", d*d*d/27.0);

    return 0;
}


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

int main(){

    # ifdef FILEs
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif
    ios_base::sync_with_stdio( false );

    long long k, a, b;
    cin >> k >> a >> b;
    long long cnt = 1;

    if( a+1 >= b || k <= a){
        cout << k + 1;
        return 0;
    }
    else{
        cnt += a-1;
        k -= a-1;
        cnt += k % 2;
        k -= k % 2;
        cnt += (b-a)*(k/2);

        cout << cnt;
        return 0;
    }

    

}   

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  int N; cin>>N;
  map<int,int> mp;
  REP(count,N-1){
    int a; cin>>a;
    mp[a]++;
  }
  for(int i=1;i<=N;++i){
    printf("%d\n",mp[i]);
  }
}

Measured memory_bytes: 13096
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,D;
int A[11][21];

bool check(int n){
	for(int i=0;i<=100000;i++){
		if(i*i==n){
			return true;
		}
	}
	return false;
}

signed main(){
	cin>>N>>D;
	REP(i,N){
		REP(j,D){
			cin>>A[i][j];
		}
	}
	int ans=0;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			int sum=0;
			for(int k=0;k<D;k++){
				sum+=abs(A[i][k]-A[j][k])*abs(A[i][k]-A[j][k]);
			}
			if(check(sum)==true){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll n, a;
  cin >> n >> a;
  print(n * n - a);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define sz(a) (int)a.size()
#define de(a) cout<<#a<<" = "<<a<<endl
#define dd(a) cout<<#a<<" = "<<a<<" "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
inline int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
inline int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
inline int mul(int a, int b) {return 1ll * a * b % P;}
inline int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//----
const int N = 8080;
char s[N];
int a, b;
bitset<N * 2> x, y, f, g;
int main(){
	scanf("%s", s);
	scanf("%d%d", &a, &b);
	int n = strlen(s), m = 0, cur = 0;
	vi st[2];
	rep(i, 0, n) {
		if(s[i] == 'T') {
			st[cur].pb(m);
			cur ^= 1;
			m = 0;
		} else m++;
	}
	if(m) st[cur].pb(m);
	x[N] = y[N] = 1;
	for(int i = 0; i < sz(st[0]); i++) {
		int it = st[0][i];
		if(i == 0) {
			f = x << it;
		} else {
			f = x >> it;
			f |= x << it;
		}
		swap(x, f);
	}
	for(auto it : st[1]) {
		g = y >> it;
		g |= y << it;
		swap(y, g);
	}
	puts((x[a + N] && y[b + N]) ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 3764
#include <stdio.h>

#define N 15

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  for ( ; ; )
  {
    int M[ N ][ N ] = { { 0 } };
    int x, y;
    int n, c;

    scanf ( "%d", &n );
    if ( !n ) break;

    x = n / 2; y = x + 1;
    for ( c = 1; c <= n * n; ++c )
    {
      while ( M[ x ][ y ] )
      {
        x = ( n + x - 1 ) % n;
        y = ( y + 1 ) % n;
      }
      M[ x ][ y ] = c;
      x = ( x + 1 ) % n;
      y = ( y + 1 ) % n;
    }

    for ( y = 0; y < n; ++y )
    {
      for ( x = 0; x < n; ++x )
      {
        printf ( "%4d", M[ x ][ y ] );
      }
      puts ( "" );
    }
  }

  return ( 0 );
}

Measured memory_bytes: 0
def selectionSort(A, N):
    count = 0
    # preA = copy.deepcopy(A)
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        A[i], A[minj] = A[minj], A[i]
        
        if i != minj:
            count += 1
        # if A != preA:
        #     count += 1
        # preA = copy.deepcopy(A)
        
    return count

def main():
    N = int(input())
    list = input().split(" ")
    list = [int(s) for s in list]
    
    count = selectionSort(list, N)

    for i in range(len(list)):
        if i == len(list)-1:
            print(list[i])
        else:
            print(list[i], end=" ")

    print(count)

if __name__ == "__main__":
    main()


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

int main() {
    int n, ma, ans = 0;
    cin >> n;
    double root = sqrt(n - 1);
    ma = int(root);
    for (int a = 1; a <= n - 1; a++) {
        ans += (n - 1)/a;
    }
    cout << ans << endl;
}

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

int main(){
	string s;
	cin>>s;
	int cnt =1;
	int best=0;
	
	for(int i=0; i+1< s.size() ; i++) {
		if(s[i] == s[i+1]){
			cnt++;
		}
		else{
			best= max(cnt, best);
			cnt= 1;
		}
	}
	//cout<< best<<"\n";
	best= max(cnt, best);
	//cout<< best<< "\n";
	if(best >= 3) cout<<"Yes"<<"\n";
	else cout<< "No"<<"\n";


return 0;
}


Measured memory_bytes: 256
using System;

namespace B
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			var a = int.Parse(Console.ReadLine());
			var b = int.Parse(Console.ReadLine());
			var c = int.Parse(Console.ReadLine());
			var x = int.Parse(Console.ReadLine()) / 50;

			var result = 0;
			for (var aNum = 0; aNum <= x / 10 && aNum <= a; aNum++)
			{
				var diffWithX = x - aNum * 10;
				for (var bNum = 0; bNum <= diffWithX / 2 && bNum <= b; bNum++)
				{
					if (diffWithX - bNum * 2 <= c) { result++; }
				}
			}

			Console.WriteLine(result);
		}
	}
}

Measured memory_bytes: 11092
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main{
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = br.readLine().split(" ");
		int a = Integer.parseInt(line[0]);
		int b = Integer.parseInt(line[1]);
		int c = Integer.parseInt(line[2]);
		int cnt = 0;
		for(int i= a; i <= b; i++){
			int x = c % i;
			if( x==0) cnt++;
		}
		System.out.println( cnt );
	}
}

Measured memory_bytes: 24420
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    a, b, c, d = LI()
    print(max(a * c, a * d, b * c, b * d))
    return


#main
if __name__ == '__main__':
    solve()


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

int main(){
  int w, a, b;
  cin >> w >> a >> b;
  if(a>b+w)cout << a - (b + w) << endl;
  else if(a+w<b)cout << b - (a + w) << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65
//おまじない



int main() {

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

	return 0;
}


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

int main(){
	int i,n;
	cin >> n;
	for (i=1;i<=n;i++){
		if (i%3==0 || i%10==3||i/10%10==3||i/100%10==3||i/1000%10==3){
			cout << " " << i;
		}
	}
	cout << endl;

	return 0;
}


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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;

    vector<int> a(n), b(n);
    for (auto &x : a) cin >> x;
    for (auto &x : b) cin >> x;

    const int size = log2(*max_element(a.begin(), a.end())
                          + *max_element(b.begin(), b.end())) + 1;

    int ans = 0;
    vector<int> bb(n);
    for (int i = 0, t = 1; i < size; ++i) {
        for (int j = 0; j < n; ++j)
            bb[j] = b[j] % (2 * t);

        sort(bb.begin(), bb.end());

        ll cnt = 0;
        for (int j = 0; j < n; ++j) {
            const int aa = a[j] % (2 * t);

            // a_j + b_k \in [T, 2T)
            cnt += distance(lower_bound(bb.begin(), bb.end(), t - aa),
                            lower_bound(bb.begin(), bb.end(), 2 * t - aa));

            // a_j + b_k \in [3T, 4T)
            cnt += distance(lower_bound(bb.begin(), bb.end(), 3 * t - aa),
                            lower_bound(bb.begin(), bb.end(), 4 * t - aa));
        }

        // Update
        ans += (cnt % 2) * t;
        t *= 2;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int digits(ll n) {
    if (n / 10 == 0) return 1;
    return digits(n / 10) + 1;
}
int main() {
    ll n; cin >> n;
    //cout << digits(10000 / 1) << endl;
    int ans = 11;
    rrep(i, 1, sqrt(n) + 1) {
        if (n % i != 0) continue;
        //cout << digits(n / i) << " " << digits(i) << endl;
        ans = min(ans, max(digits(n / i), digits(i)));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,t,k,a,b;
    scanf("%d",&k);
    scanf("%d %d",&a,&b);

    n=b/k;
    t=n*k;
    if(t>=a && t<=b) printf("OK\n");
    else printf("NG\n");


    return 0;
}


Measured memory_bytes: 1644
def readints():
    return list(map(int, input().split()))


# n, d = map(int, input().split())
# x = [input().split() for i in range(n)]
# print(x)

a = input()
b = input()
c = input()

print(a[0], end="")
print(b[1], end="")
print(c[2], end="")


Measured memory_bytes: 2940
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <regex>
#include <complex>

using ll = long long;
using ull = unsigned long long;
using ld = long double;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

template <class T>
constexpr bool in(T min, T max, T t)
{
    return t >= min && t <= max;
}

template <class T>
constexpr bool nin(T min, T max, T t)
{
    return !in(min, max, t);
}

template <class T>
void ninDebug(T min, T max, T t)
{
    using namespace std;
    if (nin(min, max, t))
    {
        cout << "ERROR" << endl;
    }
}

int main()
{
    using namespace std;
    // cerr.rdbuf(nullptr);

    while (true)
    {
        string s;
        cin >> s;
        if (s == "-")
            break;
        int m;
        cin >> m;

        for (int i = 0; i < m; ++i)
        {
            int h;
            cin >> h;

            //cout << s.substr(h) + s.substr(0, h) << endl;
            s = s.substr(h) + s.substr(0, h);

            //cout << s << endl;
        }

        cout << s << endl;
    }

    return 0;
}


Measured memory_bytes: 3196
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long x, y;
  cin >> x >> y;

  long ans = 0;

  if (abs(x) == abs(y)) {
    if (x * y < 0) ans++;
  } else if (abs(x) < abs(y)) {
    if (x < 0) {
      x *= -1;
      ans++;
    }
    long tmp = abs(y) - abs(x);
    ans += tmp;
    x += tmp;
    if (y < 0) {
      x *= -1;
      ans++;
    }
  } else if (abs(x) > abs(y)) {
    if (x > 0) {
      x *= -1;
      ans++;
    }
    long tmp = abs(x) - abs(y);
    ans += tmp;
    x += tmp;
    if (y > 0) {
      x *= -1;
      ans++;
    }
  }

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)

N=int(input())
graph=[[] for _ in range(N)]
for _ in range(N-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    graph[a].append(b)
    graph[b].append(a)


dist=[float("inf")]*N
dist[0]=0
prev=[None]*N

def dfs1(v,parent,d):
    prev[v]=parent
    dist[v]=d
    for v2 in graph[v]:
        if v2==parent:
            continue
        dfs1(v2,v,d+1)

dfs1(0,-1,0)

x=N-1
for _ in range((dist[-1]-1)//2):
    x=prev[x]
cant_go=prev[x]

sunuke_score=0
def dfs2(v,parent):
    global sunuke_score
    sunuke_score+=1
    for v2 in graph[v]:
        if v2==parent:
            continue
        if v2==cant_go:
            continue
        dfs2(v2,v)

dfs2(x,-1)

fennec_score=N-sunuke_score
if sunuke_score>=fennec_score:
    print("Snuke")
else:
    print("Fennec")

Measured memory_bytes: 114352
s = list(input())
l = ["#"] * (len(s)-1)
ans = 0
for i in range(2**(len(s)-1)):
    for j in range(len(s)-1):
        if (i>>j)&1:
            l[j] = "+"
    x = []
    for j in range(len(s)*2-1):
        if j % 2 == 0:
            x.append(s[j//2])
        else:
            if l[(j-1)//2] == "+":
                x.append("+")
    ans += sum(list(map(int, "".join(x).split("+"))))
    l = ["#"] * (len(s)-1)
print(ans)

Measured memory_bytes: 9232
#include<bits/stdc++.h>
using namespace std;
long long a[200005],b[200005],c,x=0;
int main()
{
	long long n,i;
	scanf("%lld",&n);
	for(i=0;i<n;i++)
	{
		scanf("%lld",&a[i]);
		b[a[i]]++;
	}
	for(i=1;i<=200000;i++)
	{
		if(b[i])
		{
			int c=b[i];
			c--;
			while(c)
			{
				x+=c;
				c--;
			}
		}
	}
	for(i=0;i<n;i++)
	{
		printf("%lld\n",x-b[a[i]]+1);
	}
} 

Measured memory_bytes: 4736
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
short int imos[5001][5001];
int n,m,x[5000],y[5000];
vector<int> ashx,ashy;
int main(){
	cin>>n>>m;
	rep(i,n){
		cin>>x[i]>>y[i];
		ashx.pb(x[i]);
		ashy.pb(y[i]);
	}
	sort(all(ashx));
	sort(all(ashy));
	ashx.erase(unique(all(ashx)),ashx.end());
	ashy.erase(unique(all(ashy)),ashy.end());
	rep(i,n) x[i]=lower_bound(all(ashx),x[i])-ashx.begin();
	rep(i,n) y[i]=lower_bound(all(ashy),y[i])-ashy.begin();
	int h=ashx.size(),w=ashy.size();
	rep(i,n) imos[x[i]+1][y[i]+1]++;
	rep(i,h+1) rep(j,w) imos[i][j+1]+=imos[i][j];
	rep(i,h) rep(j,w+1) imos[i+1][j]+=imos[i][j];
	rep(i,m){
		int sx,sy,tx,ty,isx,isy,itx,ity;
		cin>>sx>>sy>>tx>>ty;
		isx=lower_bound(all(ashx),sx)-ashx.begin();
		isy=lower_bound(all(ashy),sy)-ashy.begin();
		itx=upper_bound(all(ashx),tx)-ashx.begin();
		ity=upper_bound(all(ashy),ty)-ashy.begin();
		cout<<imos[itx][ity]-imos[itx][isy]-imos[isx][ity]+imos[isx][isy]<<endl;
	}
}

Measured memory_bytes: 50188
# Binary Indexed Tree (Fenwick Tree)
class BIT:
  def __init__(self, n):
    self.n = n
    self.bit = [0]*(n+1)
    self.el = [0]*(n+1)
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.bit[i]
      i -= i & -i
    return s
  def add(self, i, x):
    # assert i > 0
    self.el[i] += x
    while i <= self.n:
      self.bit[i] += x
      i += i & -i
  def get(self, i, j=None):
    if j is None:
      return self.el[i]
    return self.sum(j) - self.sum(i-1)

mod = 998244353
N, K = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(K)]
A.sort()
dp = BIT(N)
dp.add(1,1)
for i in range(2,N+1):
  for l,r in A:
    if i-l<=0:
      continue
    if i-r>0:
      dp.add(i,dp.get(i-r,i-l)%mod)
    else:
      dp.add(i,dp.sum(i-l)%mod)
print(dp.el[-1]%mod)



Measured memory_bytes: 77876
#include <stdio.h>

int main(void)
{
	int n, x, i, j;
	int a[100];
	
	scanf("%d", & n);
	for(i = 0; i < n;i++)
	{
		scanf("%d", &x);
		a[i] = x;
	}
	
	for(j = n-1; j >= 0; j--)
	{
		printf("%d", a[j]);
		if(j != 0) printf(" ");
	}
	
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define MOD 1000000007
#define inf -100000
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ll int n,k;
    cin>>n>>k;
    ll int z=n+1;
    ll int p,val,count=0,maxi,i,o;
    for(i=k;i<=z;i++)
    {

    	p=(i*(i-1))/2;
    	o=(i*(2*n-i+1))/2;
    	
    		count=(count+o-p+1)%MOD;
    		maxi=o;
    	
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3652
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;

int gcd(int a, int b) {
    while (a > 0 && b > 0)
        if (a > b) a %= b;
        else b %= a;
    return a + b;
}

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


ll visited[100000];





int main ( ){

    ll a,b;
    cin >> a>>b;
    if(a > 2*b){
        cout<<a-2*b;
    }else{
        cout<<0;
    }
    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    char s[4];
    int i, ans=0;

    scanf("%s", s);

    for(i=0; i<4; i++){
        if(s[i] == '+')
            ans++;
        else
            ans--;
    }

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

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rfor(i, a, b) for (int i=a; i<(b); i++)
#define zfor(i, a) for (int i=0; i<(a); i++)
#define brfor(i,a,b) for (int i = (b)-1; i >= a; i--)
#define bzfor(i,a) for (int i = (a)-1; i >= 0; i--)

int main(){
    double a , b;
    cin>>a>>b;
    double ans = a*b;
    ll ans2 = (ll)ans;
    cout<<ans2;
}

Measured memory_bytes: 3720
#include <stdio.h>

int main(int argc, const char * argv[]) {

    int x,y,x1,y1;
    scanf("%d %d",&x,&y);
    x1=x*y;
    y1=(x*2)+(y*2);
    printf("%d %d\n",x1,y1);
    return 0;
}



Measured memory_bytes: 2044
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#include<climits>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<map>
#include<set>
#include<queue>
#include<assert.h>
#include<iomanip>

using namespace std;
	
#define f first
#define s second
#define sz(a) int((a).size()) 
#define pb push_back 
#define mp make_pair
#define all(c) (c).begin(),(c).end() 
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);

typedef long long ll;

typedef struct node{
	ll val,more=0,less=0;
	bool operator <(const node& a){
		return val<a.val;
	}
}node;

typedef pair<int,int> pi;
typedef pair<pi,int> pii;
typedef pair<pi,pi > pi2;

typedef pair<ll,ll> pl;
typedef pair<pl,ll> pll;
typedef pair<pl,pl > pl2;

typedef vector<node> vn;

typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
typedef vector<pi2 > vpi2;

typedef vector<ll> vl;
typedef vector<pl> vpl;
typedef vector<pll> vpll;
typedef vector<pl2 > vpl2;

const int M=1000000007;

int main(){
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int count=0;
	bool changed[n]={0};

	for(int i=1;i<n;i++){
		if(!changed[i-1]){
			if(a[i-1]==a[i]){
				changed[i]=true;
				count++;
			}
		}
	}

	cout<<count;

	return 0;
}

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

  int h,w,m;
  cin>>h>>w>>m;
int   r[h+1]={0},c[w+1]={0};
  set<pair<int,int>>p;
while(m--){
    int a,b;
    cin>>a>>b;
    p.insert({a,b});
    r[a]++;
    c[b]++;
}
int x=1,y=1;
for(int i=1;i<=h;i++){
    if(r[i]>r[x])
        x=i;
}
for(int i=1;i<=w;i++){
    if(c[i]>c[y])
        y=i;
}
int ans=0;
for(int i=1;i<=w;i++){
    if(p.find({x,i})!=p.end())
        ans=max(ans,r[x]+c[i]-1);
        else
            ans=max(ans,r[x]+c[i]);
}
for(int i=1;i<=h;i++){
    if(p.find({i,y})!=p.end())
        ans=max(ans,r[i]+c[y]-1);
    else
        ans=max(ans,r[i]+c[y]);
}
cout<<ans;
}


Measured memory_bytes: 19984
import os

import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, K = list(map(int, sys.stdin.buffer.readline().split()))

a = K
b = N - K
c = 0
d = min(a, b)
while not a == b == c:
    a, b, c = sorted([a, b, c])
    if a != b:
        d = b - a
    cnt = (c - b) // d
    b += d * cnt
    a += d * cnt + d
print(a + b + c)


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = { -1, 0, 1, 0 }; const int dy[] = { 0, 1, 0, -1 };
int cnt;
int n, k, s;
void dfs(int add,int sum,int re) {
	if (k == re) {
		if (sum == s)
			cnt++;
		return;
	}
	for (int i = add + 1;i<=n;i++) {
		dfs(i, sum + i, re + 1);
	}
}
int main() {
	
	while (cin >> n >> k >> s, n){
		cnt = 0;
		dfs(0,0,0);
		cout << cnt << endl;
	}
}

Measured memory_bytes: 2968
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18

using Field = vector<vector<char>>;
Field field;
int H,W;
int ans = 0;

void bfs(){
    vector<vector<int>> d(H,vector<int>(W,-1));
    queue<pair<int,int>> q;
    rep(i,H){
        rep(j,W){
            if(field[i][j] == '#'){
                d[i][j] = 0;
                q.push(make_pair(i,j));//多点スタートなのでそれらをqueueに積んでおく
            }
        }
    }
    vector<int> k = {-1,0,1,0};
    while(!q.empty()){
        pair<int,int> u = q.front();
        q.pop();
        rep(i,4){
            if(u.first+k[i] >=0 && u.first+k[i] < H && u.second+k[3-i] >= 0 && u.second+k[3-i] < W){
                if(field[u.first+k[i]][u.second+k[3-i]] == '.'){
                    if(d[u.first+k[i]][u.second+k[3-i]] == -1){
                        d[u.first+k[i]][u.second+k[3-i]] = d[u.first][u.second] + 1;
                        ans = max(ans,d[u.first+k[i]][u.second+k[3-i]]);
                        q.push(make_pair(u.first+k[i],u.second+k[3-i]));
                    }
                }
            }
        }
    }
}


int main(){
    cin >> H >> W;
    field = vector<vector<char>>(H,vector<char>(W));
    rep(i,H)rep(j,W){
        cin >> field[i][j];
    }
    bfs();
    cout << ans << endl;

}

Measured memory_bytes: 13328
#include <iostream>
#include <string>
using namespace std;
string Sa,Sb,Sc;
int a_cnt = 0;
int b_cnt = 0;
int c_cnt = 0;
string ans = "A";

void make_turn(char id){
    if(id == 'a'){
    	if(a_cnt < Sa.size()){
    	    a_cnt++;
    	    make_turn(Sa[a_cnt-1]);
    		}
    	else{
    	    ans = "A";
    		}
    	}
    else if(id == 'b' ){
    	if(b_cnt < Sb.size()){
    	    b_cnt++;
    	    make_turn(Sb[b_cnt-1]);
    	    }
    	else{
    	    ans = "B";
    		}
    	    
    	}
    else if(id == 'c'){
    	if(c_cnt < Sc.size()){
    	    c_cnt++;
        	make_turn(Sc[c_cnt-1]);
         }
    	else{
    	    ans = "C";
    		}	
    	}
	}

int main(){
	
	cin >> Sa >> Sb >> Sc;
	
	make_turn('a');
	
	cout << ans << endl;
		
		
	return 0;
	}


Measured memory_bytes: 3608
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <math.h> 
#include <iomanip>
#include <string.h>
#include<sstream>
#include <vector>
#include <set>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define PI 3.14159265358979323846264338327950L

#define INF 0x3f3f3f3f
//const int N = 2e5 + 5;

 
 


int32_t  main() {

	IOS;
  
	int N, M;

	cin >> N >> M;

	for (int i = 0; i < M; i++) {

		int tmp;

		cin >> tmp;

		N -= tmp;

	}

	if (N < 0) {
		cout << "-1" << endl;
	}
	else {
		cout << N << endl;
	}
}

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

int main() {
	vector<int> a;
	for (int i = 0;i < 3;i++) {
		int x;
		cin >> x;
		a.push_back(x);
	}
	sort(a.begin(), a.end());
	if (a[0] == a[1]) cout << a[2] << endl;
	else cout << a[0] << endl;
	return 0;
}

Measured memory_bytes: 256
// clang-format off
	#define BADSEED random_device{}()
	#include <bits/stdc++.h>
	using namespace std;
	using ll = long long;
	using uint = unsigned int;
	ostream &operator<<(ostream &os, int8_t c) { return os << short(c); }
	istream &operator>>(istream &is, int8_t &c) { short x; is >> x; c = x; return is; }
	#define TM_(...) template <class __VA_ARGS__>
	namespace narut {
	TM_(T) using TupSz = tuple_size<decay_t<T>>;
	TM_(T) constexpr auto spc(T const &t, int) -> decltype((cout << t), 'a') { return ' '; }
	constexpr auto spc(string const &s, int) { return '\n'; }
	TM_(T) constexpr auto spc(T const &t, char) { return '\n'; }
	struct IO {
		TM_(T) static auto out_(ostream &os, T const &t, int) -> decltype(void(os << t)) { os << t; }
		TM_(T, class OS) static auto out_(OS &os, T const &t, int) -> decltype(void(begin(t))) {
			auto it = begin(t), e = end(t);
			if (it != e) out_(os, *it++, 0);
			for (; it != e; out_(os, *it++, 0)) os << spc(*it, 0);
		}
		TM_(T, size_t... Is) static void out_tup(ostream &os, T const &t, index_sequence<Is...>) { (void)initializer_list<int>{0, ((Is == 0) ? 0 : ((os << ' '), 0), (os << get<Is>(t)), 0)...}; }
		TM_(T) static decltype(void(TupSz<T>{})) out_(ostream &os, T const &t, char) { out_tup(os, t, make_index_sequence<TupSz<T>::value>{}); }
		TM_(Sep, class F, class... Ts) static ostream &print(ostream &os, Sep sep, F const &f, Ts const &... ts) { return void(initializer_list<int>{(out_(os, f, 0), 0), (out_(os << sep, ts, 0), 0)...}), os; }
		TM_(T) static auto in_(istream &is, T &t, int) -> decltype(void(is >> t)) { is >> t; }
		TM_(T, class IS) static auto in_(IS &is, T &t, int) -> decltype(void(begin(t))) { for (auto &x : t) in_(is, x, 0); }
		TM_(T, size_t... Is) static void in_tup(istream &is, T &t, index_sequence<Is...>) { (void)initializer_list<int>{0, (in_(is, get<Is>(t), 0), 0)...}; }
		TM_(T) static decltype(void(TupSz<T>{})) in_(istream &is, T &t, char) { in_tup(is, t, make_index_sequence<TupSz<T>::value>{}); }
	};
	} // namespace narut
	#define Cout(...) narut::IO::print(cout, ' ', __VA_ARGS__) << '\n'
	#ifdef NARUT_LOCAL
	#define Debug(...) narut::IO::print(cerr << "\033[0;31m", ", ", __VA_ARGS__) << "\033[0m\n"
	#else
	#define Debug(...) 0
	#endif
	[[maybe_unused]] struct Cin { 
		template <class T> Cin const &operator>>(T &t) const { return narut::IO::in_(cin, t, 0), *this; }
		template <class T> operator T() const { T t; return *this >> t, t;  }	
	} Cin;
	TM_(T) auto operator%(T &t, size_t n) -> decltype(t.resize(n), t)& { return t.resize(n), t; }
	#define FOR(i, j, n) for (int i = int(j); i < int(n); ++i)
	#define ROF(i, j, n) for (int i = int(n) - 1; i >= int(j); --i)

// clang-format on





auto Main() {
	int n = Cin;

	unordered_map<int,int> M;
	ll ans = 0;
	FOR(i,1,n+1) {
		int h=Cin;
		
		ans += M[i-h];
		++M[h+i];
	}
	cout << ans;
	
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(10);
#ifdef NARUT_LOCAL
	assert(freopen("io/test.in", "r", stdin));
	cin.exceptions(cin.badbit | cin.failbit);
	cerr << fixed << setprecision(10);
#endif

	Main();
}


Measured memory_bytes: 18432
//
// Created by yamunaku on 2020/02/19.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    string s;
    cin >> s;
    int n = s.size();
    reverse(all(s));
    s.push_back('0');
    n++;
    ll a = 0, b = IINF;
    rep(i, n){
        ll na = IINF, nb = IINF;
        int c = s[i] - '0';
        rep(j, 10){
            if(j >= c){
                na = min(na, a + j + j - c);
            }else{
                nb = min(nb, a + j + 10 + j - c);
            }
            if(j >= c + 1){
                na = min(na, b + j + j - (c + 1));
            }else{
                nb = min(nb, b + j + 10 + j - (c + 1));
            }
        }
        a = na, b = nb;
    }
    cout << a << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int like[n];
    rep(i,n) {
        int a;
        cin >> a;
        a--;
        like[i] = a;
    }
    int ans = 0;
    rep(i,n) if (i == like[like[i]]) ans++;
    ans /= 2;
    cout << ans << endl;
}

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

namespace program
{
    class Program
    {
        static void Main()
        {
          var s = Input.ScanIntArray();
          
          Out(Math.Max(0,(Math.Min(s[1],s[3]) - Math.Max(s[0],s[2]))));
        }
        static public void Out(object s) { Console.WriteLine(s); }
    }
    
    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 DistanceL1(int[] a, int[] b){
            if(a.Length != b.Length) return -1;
            int[] c = new int[a.Length];
            for(int i=0;i<a.Length;i++)
              c[i] = Math.Abs(a[i]-b[i]);
            return c.Sum();
        }

        public static double DistanceL2(int[] a, int[] b){
            if(a.Length != b.Length) return -1;
            int[] c = new int[a.Length];
            for(int i=0;i<a.Length;i++)
              c[i] = (a[i]-b[i])*(a[i]-b[i]);
            return Math.Sqrt(c.Sum());
        }
        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>
#include<queue>
using namespace std;

int main(){
  int h, w; cin >> h >> w;
  int wn=0;
  char s[h][w];
  bool b[h][w];
  for(int i=0;i<h;i++) {
    string str; cin >> str;
    for(int j=0;j<w;j++){
      s[i][j] = str[j]; b[i][j] = false;
      if(s[i][j]=='.')wn++;
    }
  }

  queue< pair< int, pair< int, int > > > q;
  q.push( make_pair(1, make_pair(0, 0)));

  int num = 0;
  bool found = false;
  while(!q.empty()){
    auto n = q.front().first;
    auto p = q.front().second;
    q.pop();

    if(p.first<0 || p.second<0 || p.first>=h || p.second>=w)continue;
    if(s[p.first][p.second]=='#')continue;
    if(b[p.first][p.second])continue;
    if(p.first == h-1 && p.second == w-1){
      num = n;
      found = true;
      break;
    }

    b[p.first][p.second] = true;
    q.push( make_pair(n+1, make_pair(p.first, p.second+1)));
    q.push( make_pair(n+1, make_pair(p.first, p.second-1)));
    q.push( make_pair(n+1, make_pair(p.first+1, p.second)));
    q.push( make_pair(n+1, make_pair(p.first-1, p.second)));
  }
  if(found){
    cout << wn - num << endl;
  }else{
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256