akhauriyash/Code-Regression huggingface dataset:
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;



int main(void)
{
	//変数の宣言
	int n,m;
	char s[3][10];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int temp3=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;
	char stemp[11];
	
	//データの読み込み


//	scanf("%d %d",&n,&m);
//	scanf_s("%d %d",&n,&m);

//	scanf("%s",&s);
//	scanf_s("%s",&s,10);


/*	for(i=0;i<n;i++){
//		scanf("%d",&b[i]);
		scanf_s("%d",&b[i]);
	}*/


	for(i=0;i<3;i++){
		scanf("%s",&s[i]);
//		scanf_s("%s",&s[i],10);
	}


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

//	clock_t start=clock();

	printf("%c%c%c",s[0][0],s[1][1],s[2][2]);

//	clock_t end=clock();

	//	printf("計算部分終了\n");

	//出力
	//printf("%d",min(sum+2*m,n-1));

//	printf("time=%lf",(double)(end-start)/CLOCKS_PER_SEC);
	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 256
#import <Foundation/Foundation.h>
@interface Solution: NSObject
+ (NSInteger)leastAttackCountWithN: (NSInteger)N;
@end
@implementation Solution
+ (NSInteger)leastAttackCountWithN: (NSInteger)N {
  if(N==1) {
    return 1;
  }
  return [self leastAttackCountWithN: N / 2] * 2 + 1;
}
@end
int main(int argc, char **argv) {
  	NSInteger v;
	scanf("%ld", &v);
  	printf("%ld", [Solution leastAttackCountWithN: v]);
  	return 0;
}

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

void insertionSort(int A[], int N) {
  int v, j;
  for (int i = 1; i <= N - 1; i++) {
    v = A[i];
    j = i - 1;

    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
      A[j + 1] = v;
    }

    for (int i = 0; i < N - 1; i++) {
      cout << A[i] << " ";
    }
    cout << A[N - 1] << endl;
  }
}

int main()
{
  const int MAX = 100;
  int N;
  cin >> N;
  int A[N];

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

  for (int i = 0; i < N - 1; i++) {
    cout << A[i] << " ";
  }
  cout << A[N - 1] << endl;

  insertionSort(A, N);
}

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

typedef long long ll;
typedef pair<ll, ll> P;
struct edge { ll to, cost; };

const int MAX_V =100000;
const ll INF = 1LL<<60;

int V;
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(ll s) {
    // greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        rep(i,G[v].size()) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int u, v, A, B;
    cin >> V >> u >> v;
    u--;
    v--;
    rep(i, V - 1) {
        cin >> A >> B;
        A--;
        B--;
        G[A].push_back({B, 1});
        G[B].push_back({A, 1});
    }
    dijkstra(u);
    vector<int> du(V);
    rep(i, V) du[i] = d[i];
    dijkstra(v);
    vector<vector<int>> dv(V, vector<int>(2));
    rep(i, V) {
        dv[i][0] = -d[i];
        dv[i][1] = i;
    }
    sort(dv.begin(), dv.end());
    //rep(i, V) cout << dv[i][0] << " " << dv[i][1] << endl;
    //cout << endl;
    vector<int> dw(V, -1);
    rep(i, V) {
        dw[dv[i][1]] = -dv[i][0];
        rep(j, G[dv[i][1]].size()) {
            dw[dv[i][1]] = max(dw[dv[i][1]], dw[G[dv[i][1]][j].to]);
        }
        //cout << dv[i][1] << " " << dw[dv[i][1]] << endl;
    }
    //cout << endl;
    //rep(i, V) cout << i << dw[i] << endl;
    int maxd = d[u];
    rep(i, V) {
        if (d[i] > du[i]) maxd = max(maxd, dw[i]);
    }
    cout << maxd - 1 << endl;
}

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

int main() {
    int a[4], b[4];
    while(true) {
        int hit = 0, blow = 0;
        for (int i = 0; i < 4; i++) {
            if (!(cin >> a[i])) {
                return 0;
            }
        }
        for (int i = 0; i < 4; i++) {
            if (!(cin >> b[i])) {
                return 0;
            }
        }
        for (int i = 0; i < 4; i++) {
            if (a[i] == b[i]) {
                hit++;
            }
            for (int j = 0; j < 4; j++){
                if (a[i] == b[j]) {
                    blow++;
                }
            }
        }
        blow -= hit;

        cout << hit << ' ' << blow << endl;
    }
}

Measured memory_bytes: 1160
n, k = gets.chomp.split(' ').map(&:to_i)
arr = gets.chomp.split(' ').map(&:to_i)
cost = Float::MAX
(0...(1 << n)).each do |i|
  bit = sprintf("%0#{n}d", i.to_s(2))
  next if bit.count('1') != k
  bitmap = bit.split('')
  height = 0
  current_cost = 0
  (0...n).each do |j|
    if arr[j] <= height && bitmap[j] == '1'
      height += 1
      current_cost += height - arr[j]
    end
    height = [height, arr[j]].max
  end
  cost = [cost, current_cost].min
end
puts cost

Measured memory_bytes: 1788
import java.util.*;
import java.util.stream.*;

public class Main {
	Scanner sc;
	int N, M;
	int[][] d;
	int[] st;
	int B;
	
	public Main() {
		sc = new Scanner(System.in);
	}
	
	private void calc() {
		N = sc.nextInt();
		M = sc.nextInt();
		d = new int[N][2];
		for (int i = 0; i < N; i++) {
			d[i][0] = sc.nextInt();
			d[i][1] = sc.nextInt();
		}
		
		B = 1 << (Integer.toBinaryString(N-1).length());
		st = new int[2*B-1];
		Arrays.fill(st, -1);
		
		Comparator<int[]> c = (a,b) -> Integer.compare(a[0],b[0]);
		Arrays.sort(d, c);
		
		int result = 0;
		int day = 1;
		int i = 0;
		while (true) {
			while (i < N && d[i][0] < day) i++;
			while (i < N && d[i][0] == day) {
				insert(i, i);
				i++;
			}
			int mi = st[0];
			insert(st[0], -1);
			if (mi > -1) result += d[mi][1];
			day++;
			if (day > M) break;
		}
		System.out.println(result);
		System.out.flush();
	}
	
	private void insert(int index, int val) {
		int i = B-1+index;
		st[i] = val;
		while (i > 0) {
			i = (i-1) >>> 1;
			int l = 2*i+1;
			int r = 2*i+2;
			if (st[l] == -1) st[i] = st[r];
			else if (st[r] == -1) st[i] = st[l];
			else if (d[st[l]][1] > d[st[r]][1]) st[i] = st[l];
			else st[i] = st[r];
		}
	}
	
	public static void main(String[] args) {
		Main m = new Main();
		m.calc();
	}

}

Measured memory_bytes: 93164
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
#define ll long long
using namespace std;
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
    int n;
    scanf("%d",&n);
    printf("%d",a[n-1]);
    return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
	
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;

	int N;
	
	cin >> N;
	vector<int> v(N);
	vector<pair<int, int > > m1(1e5+10), m2(1e5+10);
	forn(i, m1.size())
		m1[i].second = i, m2[i].second = i;
	forn(i, N)
	{
		cin >> v[i];
		if (i & 1)
			m1[v[i]].first++;
		else
			m2[v[i]].first++;
	}
	sort(all(m1));
	sort(all(m2));
	reverse(all(m1));
	reverse(all(m2));
	N /= 2;
	int res = 1e9;
	forn(i, min<int>(m1.size(),2))
	forn(j, min<int>(m2.size(), 2))
	{
		if (m1[i].second == m2[j].second)
		{
			res = min<int>(res, N + N - m1[i].first);
			res = min<int>(res, N + N - m2[j].first);
		}
		else
		{
			res = min<int>(res, N+N-m1[i].first - m2[j].first);
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;

using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main() {
    int h, w, n;
    cin>>h>>w>>n;
    VVL g(h, VL(w, 0));
    rep(i, n) {
        ll y, x, v;
        cin>>y>>x>>v;
        y--;x--;
        g[y][x]=v;
    }
    VVVL dp(h, VVL(w, VL(4, -1)));
    dp[0][0]={ 0, g[0][0], 0, 0 };
    rep(i, h)rep(j, w) {
        rep(k, 4) {
            if (i+1<h) {
                dp[i+1][j][0]=max(dp[i+1][j][0], dp[i][j][k]);
                dp[i+1][j][1]=max(dp[i+1][j][1], dp[i][j][k]+g[i+1][j]);
            }
            if (j+1<w) {
                dp[i][j+1][k]=max(dp[i][j+1][k], dp[i][j][k]);
            }
            if (k<3 && j+1<w) {
                dp[i][j+1][k+1]=max(dp[i][j+1][k+1], dp[i][j][k]+g[i][j+1]);

            }
        }
    }
    cout<<max({ dp[h-1][w-1][0], dp[h-1][w-1][1], dp[h-1][w-1][2], dp[h-1][w-1][3] })<<endl;
    return 0;
}

Measured memory_bytes: 706712
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int A, B, C; cin >> A >> B >> C;

cout << max(0, C - A + B) << "\n";


return 0;
}

// 境界，出力文字列 チェック



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Dynamic;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            int j = N / 2;
            string a = S.Substring(0, j);
            string b = S.Substring(j);
            if (N % 2 != 0)
            {
                Console.WriteLine("No");
                return;
            }
            if(a == b)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


//文字配列の取得
//string[] strArray = Console.ReadLine().Split(' ').ToArray();
//string S = strArray[0];
//string T = strArray[1];

//文字列の取得
//string s = Console.ReadLine();

//数字配列の取得
//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
//int H = intArray[0];
//int W = intArray[1];

//数字の取得
//int N = int.Parse(Console.ReadLine());

//リスト型(int)の取得
//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());

//出力
//Console.WriteLine(ans);
//Console.WriteLine("Yes");
//Console.WriteLine("No");
//Console.WriteLine(cnt);



Measured memory_bytes: 27264
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
n, k = map(int, input().split())
import math
import numpy as np
pro = 0
for i in range(1,n+1,1):
    if i < k:
        #print("i", i)
        #print(math.ceil(np.log2(k/i)))
        pro += 0.5**math.ceil(np.log2(k/i))
    else:
        pro += 1
print(pro/n)

Measured memory_bytes: 21276
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <numeric>
#include <string>
using namespace std;

struct node
{
    int count{ 0 };
    node* next[26]{ nullptr };
};

node* trie;
int n;
vector<string> s;
int c[26];
long long r;

int main()
{
    ios_base::sync_with_stdio(false);
    trie = new node();
    cin >> n;
    s.resize(n);
    for (int i = 0; i < n; i++) cin >> s[i];
    sort(s.begin(), s.end(),
        [](const string& l, const string& r)
        {
            auto p = l.length();
            auto q = r.length();
            return p != q ? p < q : l < r;
        }
    );
    for (int i = 0; i < n; i++)
    {
        node* curr = trie;
        for (int j = s[i].length() - 1; j >= 0; j--)
        {
            c[s[i][j] - 'a']++;
        }
        for (int j = s[i].length() - 1; j >= 0; j--)
        {
            for (int k = 0; k < 26; k++)
            {
                if (curr->next[k] != nullptr && curr->next[k]->count > 0 && c[k] > 0)
                {
                    r += curr->next[k]->count;
                }
            }
            c[s[i][j] - 'a']--;
            if (curr->next[s[i][j] - 'a'] == nullptr) curr->next[s[i][j] - 'a'] = new node();
            curr = curr->next[s[i][j] - 'a'];
        }
        curr->count++;
    }
    cout << r << '\n';
    return 0;
}

Measured memory_bytes: 223120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
#define pb push_back
#define all(c) c.begin(),c.end()
#define MOD 998244353
typedef double ld;
#define PI 3.14159265



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

    int n;
    cin >> n;
    cout << n / 3 << endl;

    return 0;
}


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

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

int main(){
	io;
	cin>>n>>a;
	for(int i=0;a[i]!='\0';i++){
		a[i]-='A';
		a[i]+=n;
		a[i]%=26;
		a[i]+='A';
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <stack>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

const int INF = 1 << 28;

int main()
{
  int n;
  while( cin >> n, n ) {
    int w, h;
    cin >> w >> h;
    int field[h + 1][w + 1];
    rep(y, h) {
      rep(x, w) {
        field[y + 1][x + 1] = 0;
      }
    }
    rep(i, n) {
      int x, y;
      cin >> x >> y;
      field[y][x] = 1;
    }

    int ax = 0;
    int s, t;
    cin >> s >> t;
    rep(y, h - t + 1) {
      rep(x, w - s + 1) {
        int cnt = 0;
        rep(i, t) {
          rep(j, s) {
            cnt += field[y+i+1][x+j+1];
//          cerr << (x+j+1) << ", " << (y+i+1) << endl;
          }
        }
        ax = max(ax, cnt);
      }
    }

    cout << ax << endl;
  }

  return 0;
}

Measured memory_bytes: 1192
#include<stdio.h>

using namespace std;

int main(){
    char b;
    scanf("%c", &b);

    if(b == 'A'){
        printf("T\n");
    }
    else if(b == 'C'){
        printf("G\n");
    }
    else if(b == 'G'){
        printf("C\n");
    }
    else{
        printf("A\n");
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 2e7 + 9, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
AC;

  int n, x;
  cin >> n >> x;

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

  int answer = abs(array[0] - x);

  for (int i = 0; i < n; i++){
    int gcd_ = abs(array[i] - x);
    answer = __gcd(gcd_ , answer);
  }

  cout << answer << endl;





    return 0;
}


Measured memory_bytes: 640
N, D = map(int, input().split())
XY =[]
for i in range(N):
    xy = list(map(int, input().split()))
    XY.append(xy)
import math
total = 0
for j in range(N):
    a = abs(XY[j][0])
    b = abs(XY[j][1])
    c = a**2 + b**2
    d = math.sqrt(c)
    if d <= float(D):
        total = total + 1
print(total)

Measured memory_bytes: 45460
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;

constexpr static ll MOD = 1000000007ll;
constexpr static int INF = 1 << 28; // for x <= 10^9
constexpr static ll INFL = 1ll << 60; // for x <= 10^19

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

    string ans;
    if (s == "Sunny") {
        ans = "Cloudy";
    } else if (s == "Cloudy") {
        ans = "Rainy";
    } else {
        ans = "Sunny";
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int f[100001];
const int r=1000000007;
int binpower(int a,int b) {
    if (b==0)
        return 1;
    if (b%2==1)
        return ((long long)a*binpower(a,b-1))%r;
    int x=binpower(a,b/2);
    return ((long long)x*x)%r;
}
int c(int n,int m) {
    if (m>n)
        return 0;
    int x=((long long)f[m]*f[n-m])%r;
    return ((long long)f[n]*binpower(x,r-2))%r;
}
int main() {
    f[0]=1;
    int n,k;
    cin>>n>>k;
    int mas[n+1];
    for (int i=1;i<=n;i++) {
        cin>>mas[i];
        f[i]=((long long)i*f[i-1])%r;
    }
    sort(mas+1,mas+n+1);
    int ans=0;
    for (int i=1;i<=n;i++) {
        ans=(ans+(long long)mas[i]*c(i-1,k-1))%r;
        ans=(ans-(long long)mas[i]*c(n-i,k-1))%r;
        ans=(ans+r)%r;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#coding:utf-8
 
def main():
    h, n = map(int, input().split())
    ab = []
    for _ in range(n):
        ab.append(list(map(int, input().split())))
    
    inf = 100000000000
    # indexがモンスターに与えたダメージで、中身がトキのダメージ
    damages = [inf for _ in range(100000)]
    damages[0] = 0
    pre_damage = -1
    for i in range(h):
        if damages[i] == inf:
            continue
        for j in range(n):
            new_damage = ab[j][0]
            if damages[i + new_damage] > damages[i] + ab[j][1]:
                damages[i + new_damage] = damages[i] + ab[j][1]
        
 
    print(min(damages[h:]))
main()

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end()
#define P pair<int , int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void){

  int n;  cin >> n;
  V v(n);
  //firstに出てきた回数,secondに数本体を格納
  vector<pair<int, int>> Odd(100000), Even(100000);
  for(int i = 0 ; i < 100000 ; i++){
    Even[i].first = 0;
    Odd[i].first = 0;
    Even[i].second = i;
    Odd[i].second = i;
  }

  for(int i = 0 ; i < n ; i++){
    cin >> v[i];
    if(i % 2 == 0){
      Even[v[i] - 1].first += 1;
    }else{
      Odd[v[i] - 1].first += 1;
    }
  }
  sort(ALL(Even), greater<pair<int, int>>());
  sort(ALL(Odd), greater<pair<int, int>>());
  if(Even[0].second != Odd[0].second)
    cout << n - Even[0].first - Odd[0].first << endl;
  else
    cout << min(n - Even[0].first - Odd[1].first, n - Even[1].first - Odd[0].first) << endl;
  
  return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
  string s;

  cin>>s;
  
  int ans = 700;
  for(int i = 0;i<3;i++){
    if(s[i]=='o')
      ans += 100;

  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <utility>

#define MOD 1000000007
#define INF 1e9 + 7

#define min3(a, b, c) min(a, min(b, c))
// #define max3(a, b, c) max(a, max(b, c))
#define F first
#define S second
#define pb push_back
#define all(p) p.begin(), p.end()
#define isOdd(n) n % 2
#define isEven(n) n % 2 == 0
#define sz(x) x.size()
#define DEBUG(x) cout << '>' << #x << ' : ' << x << endl;

using namespace std;

typedef long long int lli;

typedef pair<lli, lli> pii;
typedef vector<lli> vi;
typedef set<lli> si;
typedef unordered_map<lli, lli> umii;
typedef unordered_set<lli> usi;

lli mod = 1000000007;

void dispvec(vi);
struct CustomCompare;

pair<int, pii> max3(pair<int, pii> a, pair<int, pii> b, pair<int, pii> c)
{
    return a.first > b.first && a.first > c.first ? a : b.first > c.first ? b : c;
}

//-------------------------------------SOLVE HERE-------------------------------------

void solve()
{
    string s, t;
    cin >> s;
    cin >> t;

    int rows = s.length();
    int cols = t.length();

    vector<vector<pair<int, pii>>> dp(rows + 1, vector<pair<int, pii>>(cols + 1, {0, {0, 0}}));

    for (int r = 0; r < rows; r++)
    {
        for (int c = 0; c < cols; c++)
        {
            dp[r + 1][c + 1] = {s[r] == t[c], {r + 1, c + 1}};
        }
    }

    for (int r = 1; r <= rows; r++)
    {
        for (int c = 1; c <= cols; c++)
        {
            dp[r][c] = max3({dp[r - 1][c - 1].first + dp[r][c].first, {r - 1, c - 1}}, dp[r - 1][c], dp[r][c - 1]);
        }
    }

    string out;
    pair<int, pii> cur = dp[rows][cols];
    while (1)
    {
        if (cur.first == 0)
            break;
        int r = cur.second.first;
        int c = cur.second.second;
        if (s[r] == t[c])
        {
            out += s[r];
        }
        cur = dp[r][c];
    }
    reverse(all(out));
    cout << out << endl;
}

//-------------------------------------MAIN HERE--------------------------------------

int main()
{
#ifndef ONLINE_JUDGE
    freopen("/home/mufaddal/Mufaddal/Programs/Competitive/input", "r", stdin);
    freopen("/home/mufaddal/Mufaddal/Programs/Competitive/output", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    int i = 1;
    while (i <= t)
    {
        // cout << "Case #" << i << ": ";
        solve();
        i++;
    }

    return 0;
}

void dispvec(vi arr)
{
    vi::iterator itr = arr.begin();
    while (itr != arr.end())
    {
        cout << *itr << " ";
        itr++;
    }
    cout << endl;
}

struct CustomCompare
{
    //stable sort by first then second both in increasing
    bool operator()(const pii &i, const pii &j)
    {
        if (i.first == j.first)
            return i.second < j.second;
        return i.first < j.first;
    }
};

Measured memory_bytes: 214396
import java.util.Scanner;

//Square Coins
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int[][] dp = new int[18][300];
		for(int i=0;i<300;i++)dp[0][0]=1;
		for(int i=1;i<18;i++){
			int x = i*i;
			for(int j=0;j<300;j++){
				if(j-x>=0)dp[i][j]=dp[i][j-x];
				dp[i][j] += dp[i-1][j];
			}
		}
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			System.out.println(dp[17][n]);
		}
	}

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

Measured memory_bytes: 0
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

std::string s[100100],ans;
int a[3],n;

bool solve(int i){
	char x = s[i][0], y = s[i][1];
	if(!(a[x-'A']||a[y-'A'])){
		return false;
	}
	if(!(a[x-'A'])){
		++a[x-'A'];
		--a[y-'A'];
		ans.push_back(x);
		return true;
	}
	if(!(a[y-'A'])){
		--a[x-'A'];
		++a[y-'A'];
		ans.push_back(y);
		return true;
	}
	if(i<n && s[i]!=s[i+1]){
		if(x == s[i+1][0] || x == s[i+1][1]){
			++a[x-'A']; --a[y-'A'];
			ans.push_back(x);
			return true;
		}else if(y == s[i+1][0] || y == s[i+1][1]){
			--a[x-'A']; ++a[y-'A'];
			ans.push_back(y);
			return true;
		}
	}
	if(a[x-'A']>a[y-'A']){
		--a[x-'A']; ++a[y-'A'];
		ans.push_back(y);
	}else{
		++a[x-'A']; --a[y-'A'];
		ans.push_back(x);
	}
	return true;
}

int main(void){
	int i;
	std::cin >> n >> a[0] >> a[1] >> a[2];
	for(i=0; i<n; ++i){
		std::cin >> s[i];
	}
	for(i=0; i<n; ++i){
		if(!solve(i)){
			std::cout << "No" << std::endl;
			return 0; 
		}
	}
	std::cout << "Yes" << std::endl;
	for(i=0; i<n; ++i){
		std::cout << ans[i] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 6888
//I am so vegetable
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = 3.141593;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }

int main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
    string s;cin>>s;
    if(s=="ABC")cout<<"ARC";
    else cout<<"ABC";
	return 0;
}

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

dx = abs(tx - sx)
dy = abs(ty - sy)

s = ['U'] * dy + ['R'] * dx + ['U'] + ['L'] * (dx+1) + ['D'] * (dy+1) + ['R'] + ['R'] * dx + ['U'] * dy + ['R'] + ['D'] * (dy+1) + ['L'] * (dx + 1) + ['U']

print("".join(s))


Measured memory_bytes: 9208
/* **************************************************** */
/*                      Author : rakati                 */
/* **************************************************** */

#include <bits/stdc++.h>

using namespace std;

#define RP(i,a,b) for(int i = (a); i < (int)(b); i++)
#define RV(i,a,b) for(int i = (a); i > (int)(b); i--)
#define SHOW(v,d) {RP(i,0,v.size()) cout << v[i] << d;cout << '\n';}
#define ALL(x) x.begin(),x.end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

const double EPS = 1e-9;
const double PI = 2 * acos(0.0);
const int INF = 1e9;

using ll    = long long;
using ull   = unsigned long long;
using vi    = vector<int>;
using vl    = vector<ll>;
using vb    = vector<bool> ;
using vc    = vector<char>;
using vii   = vector<vi>;
using vll   = vector<vl>;
using pii   = pair<int, int>;
using pll   = pair<ll, ll>;
using vpii  = vector<pii>;
using vpll  = vector<pll>;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    int n;
    cin >> n;
    int dp[n][3];
    cin >> dp[0][0] >> dp[0][1] >> dp[0][2];
    RP(i,1,n){
        int a,b,c;
        cin >> a >> b >> c;
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a;
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b;
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c;
    }
    cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]}) << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define pii 3.14
#define mod (ll)(1e9 + 7)
#define inf (ll)(1e18)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pi pair<int,int>
#define N (ll)(2e5+5)

void solve()
{
    ll n;
    cin>>n;


    ll arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];

    ll dp[n] = {0};
    dp[1] = abs(arr[0] - arr[1]);

    for(int i=2;i<n;i++)
        dp[i] = min(dp[i-1] + abs(arr[i]-arr[i-1]) , dp[i-2] + abs(arr[i]-arr[i-2]));

    cout<<dp[n-1]<<"\n";
}

int main()
{
    fio;
    ll tc = 1;
   // cin>>tc;
    while(tc--)
    {
        solve();
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  string s; cin >> s;
  string ans = "NA";
  string front = s.substr(0,2);
  string back = s.substr(2,2);
  auto isMonth = [](string s) {
    if (s[0] == '0' || s[0] == '1') {
      if (s[1] == '0' && s[0] == '0') return false;
      if (s[1] - '0' > 2 && s[0] == '1') return false;
      else return true;
    } 
    return false;
  };
  if (isMonth(back)) {
    if (isMonth(front)) ans = "AMBIGUOUS";
    else ans = "YYMM";
  } else {
    if (isMonth(front)) ans = "MMYY";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	ll h, w, least;
	cin >> h >> w;
	if (h % 3 == 0 || w % 3 == 0) cout << 0 << endl;
	else{
		least = min(h, w);
		ll aw, bw, ah, bh, area[3];
		aw = w / 2;
		bw = w - aw;
		for (ah = 1; ah < h; ah++){
			bh = h - ah;
			area[0] = w*bh;
			area[1] = aw*ah;
			area[2] = bw*ah;
			least = min(least, *max_element(area, area + 3) - *min_element(area, area + 3));
		}
		ah = h / 2;
		bh = h - ah;
		for (aw = 1; aw < w; aw++){
			bw = w - aw;
			area[0] = h*bw;
			area[1] = ah*aw;
			area[2] = bh*aw;
			least = min(least, *max_element(area, area + 3) - *min_element(area, area + 3));
		}
		cout << least << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])
x = inp()
if x < 600:
    ans = 8
elif x < 800:
    ans = 7
elif x < 1000:
    ans = 6
elif x < 1200:
    ans = 5
elif x < 1400:
    ans = 4
elif x < 1600:
    ans = 3
elif x < 1800:
    ans = 2
elif x < 2000:
    ans = 1

print(ans)

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;
typedef tuple<long long, long long, long long> tllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair1(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
bool compPair2(const pint& arg1, const pint& arg2) { return arg1.second > arg2.second; }
bool compTuple(const tllint& arg1, const tllint& arg2) { return get<2>(arg1) > get<2>(arg2); }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    vector<llint> z(n);
    vector<llint> w(n);
    llint x, y;
    for(llint in=0;in<n;++in) {
        cin >> x >> y;
        z[in] = x + y;
        w[in] = x - y;
    }

    llint zmax = z[0], zmin = z[0], wmax = w[0], wmin = w[0];
    for(llint in=0;in<n;++in) {
        chmax(zmax, z[in]);
        chmin(zmin, z[in]);
        chmax(wmax, w[in]);
        chmin(wmin, w[in]);
    }

    cout << max(zmax-zmin, wmax-wmin) << endl;
    return 0;
}


Measured memory_bytes: 6420
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <unordered_set>
//#define local
#ifdef local
#include "dbg-macro/dbg.h"
#endif
#define ll long long
#define ull unsigned long long
#define pi (acos(-1))
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
int main()
{
    int n;
    cin >> n;
    unordered_set<ll> rec;
    ll t;

    rep(i, n)
    {
        cin >> t;
        if (rec.find(t) != rec.end())
        {
            cout << "NO" << endl;
            return 0;
        }
        rec.insert(t);
    }
    cout << "YES" << endl;
    return 0;
}

ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}


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

int main() {

  long long N;
  cin >> N;
  vector<long long> P(N);

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

  int count=0;
  long long min=P[0];
  for(long long i=0;i<N;i++){
    if(i>0){
      if(min > P[i]){
        min = P[i];
      }
      if(P[i] > min){
        count++;
        continue;
      }
    }else{
      continue;
    }
    // for(long long j=0;j<i+1;j++){
      // if(P[i] > P[j]){
        // count++;
        // break;
      // }
    // }
  }

  cout << N-count << endl;
}


Measured memory_bytes: 1792
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt()
  val Y = sc.nextInt() / 1000
  val patterns = for {
    x <- 0 to N
    y <- 0 to N
    z = N - x - y
    if 0 <= z
    if x * 10 + y * 5 + z == Y
  } yield Seq(x, y, z)
  println(if (patterns.isEmpty) "-1 -1 -1" else patterns.head.mkString(" "))
}


Measured memory_bytes: 57776
import java.util.Scanner;

public class Main {

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

		int H = sc.nextInt();
		int N = sc.nextInt();
		int sum = 0;

		for (int i = 0; i < N; i++) {
			sum += sc.nextInt();
		}

		if (sum >= H) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}

}


Measured memory_bytes: 50480
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
//const ll MOD=(ll)1e9+7;
const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

ll dp[110][110];
int row[110],col[110];

ll dfs(int l, int r){
    if(r-l<=1) return 0;
    ll ret=INF;
    for(int i=l+1;i<r;++i){
        if(dp[l][i]==INF) dp[l][i]=dfs(l,i);
        if(dp[i][r]==INF) dp[i][r]=dfs(i,r);
        chmin(ret,dp[l][i]+dp[i][r]+row[l]*col[r-1]*row[i]);
    }
    return dp[l][r]=ret;
}

void solve(int ca){
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        cin>>row[i]>>col[i];
    }
    for (int i = 0; i <= N; ++i) {
        for(int j=0;j<=N;++j) dp[i][j]=INF;
    }

    cout<<dfs(0,N)<<endl;

}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(1);
#endif
    return 0;
}



Measured memory_bytes: 3180
# https://atcoder.jp/contests/aising2019/tasks/aising2019_c

import sys
sys.setrecursionlimit(10 ** 7)

H, W = map(int, input().split())
M = [list(input()) for _ in range(H)]
seen = [[False for _ in range(W)] for _ in range(H)]


def dfs(h, w, ph, pw):
    if M[h][w] == '.':
        bc, wc = 0, 1
    else:
        bc, wc = 1, 0
    for (dh, dw) in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
        nh, nw = h + dh, w + dw
        if nh < 0 or H <= nh or nw < 0 or W <= nw:
            continue
        if nh == ph and nw == pw:
            continue
        if seen[nh][nw]:
            continue
        if M[nh][nw] == M[h][w]:
            continue
        seen[nh][nw] = True
        b_add, w_add = dfs(nh, nw, h, w)
        bc += b_add
        wc += w_add
    return bc, wc

ans = 0
for h in range(H):
    for w in range(W):
        if seen[h][w] == False:
            seen[h][w] = True
            b, w = dfs(h, w, -1, -1)
            ans += b * w
print(ans)

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (int)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

    ll n,k;
    vll a;

bool dfs(ll i,ll sum)
{
    cout << '(' << i << ',' << sum << ')' << endl;
    if(i == n)return sum == k;

    if(dfs(i+1,sum))return true;

    if(dfs(i+1,sum + a[i]))return true;

    return false;
}

struct edge {
    //ll from;
    int to;
    int cost;
};

// <最短距離, 頂点の番号>
//using P = pair<int, int>;

int V;
vector<edge> G[100007];
vll d;

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    //fill(d, d+V, INF);
    d[s] = 0;
    //cout << " 000 " << endl;
    que.push(P(0, s));
    //cout << 1 << endl;
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        //cout << p.first << " " << p.second << endl;
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
    //cout << 1 << endl;
}

int main() {
    cin >> V;
    d.resize(V,M);
    int E,r;
    cin >> E >> r;
    //cout << 4 << endl;
    for (int i=0; i<E; ++i) {
        edge e;
        int a;
        cin >> a >> e.to >> e.cost;
        G[a].pb(e);
        //G.pb(e);
    }
    //cout << 3 << endl;
    dijkstra(r);
    for (int i=0; i<V; ++i) {
        if(d[i] != M){
           cout << d[i] << endl;
        }

        else cout << "INF\n";
           // cout << "0から" << i << "までのコスト: " << d[i] << endl;
    }
}


Measured memory_bytes: 14484
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  string s;
  cin >> s;
  int N = sz(s);
  string ans = "";
  ans += s[0];
  ans += to_string(N-2);
  ans += s.back();
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/*
      author  : nishi5451
      created : 14.08.2020 19:12:59
*/

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


int main(){
    int a,b;
    cin >> a >> b;
    int dif = b-a;
    int hb = dif*(dif+1)/2;
    cout << hb-b << endl;    
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

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

  vector<int> A(N), B(N);
  int minA = INF;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i) >> B.at(i);
    if (minA > A.at(i)) minA = A.at(i);
  }

  vector<int> dp(H + 1, INF);
  dp.at(0) = 0;
  for(int i = 0; i < N; i++) {
    for(int k = 0; k <= H; k++) {
      if (dp.at(k) == INF) continue;
      dp.at(min(k + A.at(i), H)) = min(dp.at(min(k + A.at(i), H)), dp.at(k) + B.at(i));
    }
  }

  cout << dp.at(H) << endl;

  return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<map>
#define maxn 250005
#define ll long long 
using namespace std;

const int M1=1000000007,mo1=998244353,M2=19260817,mo2=1000000007,maxh=19260817;
int n,i,j,k,a[maxn];char ch;ll hs[maxh][3],ans;
struct hash{
	ll M,mo,s[maxn],c[maxn],mul[maxn],inv[maxn],invM;
	ll cm(int k){return (k<0)?inv[-k]:mul[k];}
	ll ksm(ll x,ll y){
		ll s=1;
		for(;y;y/=2,x=x*x%mo) if (y&1)
			s=s*x%mo;
		return s;
	}
	void prepare(){
		mul[0]=1;for(i=1;i<=n;i++) mul[i]=mul[i-1]*M%mo;
		inv[0]=1,invM=ksm(M,mo-2);for(i=1;i<=n;i++) inv[i]=inv[i-1]*invM%mo; 
		for(int i=n;i>=1;i--) {
			c[i]=c[i+1];
			if (a[i]=='<') s[i]=s[i+1]*M%mo,c[i]++; else 
			if (a[i]=='>') s[i]=s[i+1]*invM%mo,c[i]--; else 
			if (a[i]=='+') s[i]=(s[i+1]+1)%mo; else s[i]=(s[i+1]+mo-1)%mo;
		}		
	}
	ll get(int x){return (s[i]-s[1]+mo)*cm(-c[i])%mo;}
	ll get2(int x){return s[i]*cm(-c[i])%mo;}
} hs1,hs2;

void add(ll x,ll y){
	ll i=(x*23333333+y)%maxh;
	while (hs[i][2]&&(hs[i][0]!=x||hs[i][1]!=y))
		i=(i+1)%maxh;
	hs[i][0]=x,hs[i][1]=y,hs[i][2]++;
}
ll sum(ll x,ll y){
	ll i=(x*23333333+y)%maxh;
	while (hs[i][2]&&(hs[i][0]!=x||hs[i][1]!=y))
		i=(i+1)%maxh;
	return hs[i][2];
}

int main(){
	scanf("%d",&n),ch=getchar();
	while (ch!='<'&&ch!='>'&&ch!='+'&&ch!='-') ch=getchar();
	for(i=1;i<=n;i++) a[i]=ch,ch=getchar();
	hs1.M=M1,hs1.mo=mo1,hs2.M=M2,hs2.mo=mo2;
	hs1.prepare(),hs2.prepare();
	add(0,0);
	for(i=n;i>=1;i--){
		ll v1=hs1.get(i),v2=hs2.get(i);
		ans+=sum(v1,v2);
		add(hs1.get2(i),hs2.get2(i));
	}
//	for(i=1;i<=n;i++) for(j=i+1;j<=n+1;j++)
//		if (((s[i]-s[j]*cm(c[i]-c[j])%mo)%mo+mo)%mo==s[1])
//			ans++;
//	printf("%lld\n",ans),ans=0;
//	for(i=n;i>=1;i--) {
//		ll v=(s[i]-s[1]+mo)*cm(-c[i])%mo;
//		if (S.find(v)!=S.end()) 
//			ans+=S[v];
//		S[s[i]*cm(-c[i])%mo]++;
//	}
	printf("%lld",ans);
}

Measured memory_bytes: 410024
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int main(void)
{
	int A, B, K;
	cin >> A >> B >> K;

	vector<int> ret;
	for(int i=0; i<K; i++)
		if(A+i<=B)
			ret.push_back(A+i);
	for(int i=0; i<K; i++)
		if(B-i>=A)
			ret.push_back(B-i);

	sort(ret.begin(), ret.end());
	ret.erase(unique(ret.begin(), ret.end()), ret.end());

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

	return 0;
}


Measured memory_bytes: 256