akhauriyash/Code-Regression huggingface dataset:
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

int n;
string s1;
string s2;
int dp[100][100];
int mod = 1e9 + 7;
vector<int>vec;

void add(int &dest,int x)
{
	dest += x;
	dest %= mod;
}

int32_t main(){_
    //freopen("input","r",stdin);
	cin >> n;
	cin >> s1;
	cin >> s2;
	for(int i = 0;i < sz(s1);i++)
	{
		if(i != sz(s1) - 1 && s1[i] == s1[i + 1])
		{
			continue;
		}
		else
		{
			if(i && s1[i] == s1[i - 1])
			{
				vec.pb(1);
			}
			else vec.pb(0);
		}
	}
	n = sz(vec);
	if(vec[0] == 0)
	{
		dp[0][0] = dp[0][1] = dp[0][2] = 1;
	}
	else
	{
		for(int i = 3;i <= 8;i++) dp[0][i] = 1;
	}
	for(int i = 1;i < n;i++)
	{
		if(vec[i])
		{
			add(dp[i][3],dp[i - 1][2]);
			add(dp[i][4],dp[i - 1][2]);
			add(dp[i][5],dp[i - 1][1]);
			add(dp[i][6],dp[i - 1][1]);
			add(dp[i][7],dp[i - 1][0]);
			add(dp[i][8],dp[i - 1][0]);
			add(dp[i][3],dp[i - 1][4]);
			add(dp[i][3],dp[i - 1][6]);
			add(dp[i][3],dp[i - 1][7]);
			add(dp[i][4],dp[i - 1][3]);
			add(dp[i][4],dp[i - 1][5]);
			add(dp[i][4],dp[i - 1][8]);
			add(dp[i][5],dp[i - 1][4]);
			add(dp[i][5],dp[i - 1][6]);
			add(dp[i][5],dp[i - 1][8]);
			add(dp[i][6],dp[i - 1][3]);
			add(dp[i][6],dp[i - 1][5]);
			add(dp[i][6],dp[i - 1][7]);
			add(dp[i][7],dp[i - 1][6]);
			add(dp[i][7],dp[i - 1][3]);
			add(dp[i][7],dp[i - 1][8]);
			add(dp[i][8],dp[i - 1][4]);
			add(dp[i][8],dp[i - 1][5]);
			add(dp[i][8],dp[i - 1][7]);
		}
		else
		{
			add(dp[i][0],dp[i - 1][1]);
			add(dp[i][0],dp[i - 1][2]);
			add(dp[i][0],dp[i - 1][7]);
			add(dp[i][0],dp[i - 1][8]);
			add(dp[i][1],dp[i - 1][0]);
			add(dp[i][1],dp[i - 1][2]);
			add(dp[i][1],dp[i - 1][5]);
			add(dp[i][1],dp[i - 1][6]);
			add(dp[i][2],dp[i - 1][0]);
			add(dp[i][2],dp[i - 1][1]);
			add(dp[i][2],dp[i - 1][3]);
			add(dp[i][2],dp[i - 1][4]);
		}
	}
	ll ans = 0;
	for(int i = 0;i <= 10;i++) ans += dp[n - 1][i];
	rc(ans % mod);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	string s,t;
	cin>>s>>t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end(),greater<int>());
	if(s<t) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

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

ll N;
vector<ll> A;
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin >> N;
    ll a;
    for(int i=1; i<=N; i++){
        cin >> a;
        A.push_back(a-i);
    }
    sort(A.begin(), A.end());
    ll mid = A[N/2];
    ll ans = 0;
    // cout << "mid " << mid << endl;
    for(int i=0; i<N; i++){
        ans += abs(A[i] - mid);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

using ll=long long;

using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;
using vs=vector<string>;

int main() {
  int A,B,X; cin >>A >>B >>X;
  if (A>X) {
    cout <<"NO" <<endl;
    return 0;
  } else if (A==X) {
    cout <<"YES" <<endl;
    return 0;
  } else if (B>=X-A) {
    cout <<"YES" <<endl;
    return 0;
  }
  cout <<"NO" <<endl;
  return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
using Edge=pair<int,ll>;
using Graph=vector<vector<int> >;//ll or Edge
using Edge=pair<int,ll>;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse...greater<ll>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
int main(){
    int n;cin>>n;
    vector<string>S(n);
    rep(i,n)cin>>S[i];
    ll ans=0;
    ll ABnum=0,Anum=0,Bnum=0;

    rep(i,n){
        int l=(int)S[i].size();
        for(int j=0;j<(int)S[i].size()-1;j++){
            if(S[i][j]=='A' && S[i][j+1]=='B')ans++;
        }
        if(S[i][0]=='B' && S[i][l-1]=='A')ABnum++;
        else if(S[i][0]=='B')Bnum++;
        else if(S[i][l-1]=='A')Anum++;
    }
    if(ABnum==0)ans+=min(Anum,Bnum);
    else if(Anum+Bnum>0)ans+=min(Anum,Bnum)+ABnum;
    else if(Anum+Bnum==0)ans+=min(Anum,Bnum)+ABnum-1;
    cout<<ans<<endl;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
using ll = long long; 
using vpii = vector<pair<int, int>>;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
ll inf = 1e10;

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  ll ans = 0;
  ans += m*1900+(n-m)*100;
  ans *= pow(2, m);
  cout << ans << "\n";
}  

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int[] suujis=new int[a];
		for(int i=0; i<a; i++) {
			suujis[i]=sc.nextInt();
		}

		int tmp1=0;
		int tmp2=0;
		for(int i=0; i<a; i++) {
			for(int j=i; j<a; j++) {
				if(suujis[i]<suujis[j]) {
					tmp1=suujis[i];
					tmp2=suujis[j];
					suujis[j]=tmp1;
					suujis[i]=tmp2;
				}
				else {
				}
			}
		}
		int you=0;
		int opp=0;
		for(int i=0; i<a; i++) {
			if(i%2==0) {
				you+=suujis[i];
			}
			else {
				opp+=suujis[i];
			}
		}
		System.out.println(you-opp);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0, l = 0, r = 0, x = 0, s = 0;
  while(l < n) {
    while(r < n) {
      r++;
      x ^= a[r-1];
      s += a[r-1];
      if(x == s) {
        ans += r-l;
      } else {
        break;
      }
    }
    if(x == s && r == n) break;
    while(l < r) {
      l++;
      x ^= a[l-1];
      s -= a[l-1];
      if(x == s) {
        ans += r - l;
        break;
      }
    }
  }
  cout << ans << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    V< P<ll, int> > a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a.rbegin(), a.rend());

    vvll dp(n + 1, vll(n + 1, 0));
    for (int i= 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i + j >= n) break;
            // to left
            chmax(dp[i + 1][j], dp[i][j] + a[i + j].first * abs(i - a[i + j].second));
            // to right
            chmax(dp[i][j + 1], dp[i][j] + a[i + j].first * abs(n - 1 - j - a[i + j].second));
        }
    }

    ll ans = 0;
    for (int i = 0; i <= n; i++) chmax(ans, dp[i][n - i]);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 34592
#include<ostream>
#include<cstdio>
using namespace std;
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;
static const int INFTY=(1<<21);
int n,H[100][100];
int p()
{
    int u,minv,d[100],p[100],c[100];
    for(int i=0;i<n;i++)
    {
        d[i]=INFTY;
        p[i]=-1;
    }
    d[0]=0;
    while(1)
    {
        minv=INFTY;
        u=-1;
        for(int i=0;i<n;i++)
        {
            if(minv>d[i]&&c[i]!=BLACK)
            {
                u=i;
                minv=d[i];
            }
        }
        if(u==-1) break;
        c[u]=BLACK;
        for(int v=0;v<n;v++)
        {
            if(c[v]!=BLACK&&H[u][v]!=INFTY)
            {
                if(d[v]>H[u][v])
                {
                    d[v]=H[u][v];
                    p[v]=u;
                    c[v]=GRAY;
                }
            }
        }
    }
    int sum=0;
    for(int i=0;i<n;i++)
    {
        if(p[i]!=-1) sum+=H[i][p[i]];
    }
    return sum;
}
int main()
{
    int a;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
    {
        scanf("%d",&a);
        H[i][j]=(a==-1)?INFTY:a;
    }
    printf("%d\n",p());
    return 0;
}

Measured memory_bytes: 2740
L = int(input())
nums = list(map(int,input().split(" ")))
di = {}
for num in nums:
    if num not in di:
        di[num] = 1
    else:
        di[num] += 1
total = 0
minus = {}
for k,v in di.items():
    total += v * (v-1) //2
    minus[k] = v * (v-1) //2 -  max( (v - 2) * (v-1)//2,0)
for num in nums:
    print(total - minus[num])



Measured memory_bytes: 32512
import sys
def input():return sys.stdin.readline()[:-1]
def N(): return int(input())
def NM():return map(int,input().split())
def L():return list(NM())
def LN(n):return [N() for i in range(n)]
def LL(n):return [L() for i in range(n)]
s=input()
print(s[:3])

Measured memory_bytes: 9060
h, w = map(int, input().split())
S = [input() for _ in range(h)]

dp = [[0]*w for _ in range(h)]

if S[0][0] == '#':
    dp[0][0] = 1

for y in range(1, h):
    dp[y][0] = dp[y-1][0]+1 if S[y][0]=='#' and S[y-1][0]=='.' else dp[y-1][0]

for x in range(1, w):
    dp[0][x] = dp[0][x-1]+1 if S[0][x]=='#' and S[0][x-1]=='.' else dp[0][x-1]

for y in range(1, h):
    for x in range(1, w):
        a = dp[y-1][x]+1 if S[y][x]=='#' and S[y-1][x]=='.' else dp[y-1][x]
        b = dp[y][x-1]+1 if S[y][x]=='#' and S[y][x-1]=='.' else dp[y][x-1]
        dp[y][x] = min(a,b)

print(dp[h-1][w-1])

Measured memory_bytes: 3188
void main() {
	auto N = ri;
	auto b = readAs!(int[]);
	ulong[] ans;
	while(b != []) {
		bool flag = false;
		foreach_reverse(i; 0..b.length) {
			if(b[i] == i+1) {
				ans ~= i+1;
				b = b.remove(i);
				flag = true;
				break;
			}
		}
		if(!flag) {
			writeln(-1);
			return;
		}
	}
	ans.retro.each!writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()
#include <stdlib.h>         // qsort()
#include <stdbool.h>

#define MAX_N 100

const int INF = 100000000;
typedef struct rank_tbl
{
	int id;
	int score;
	int rank;
} rank_t;

int
cmp_func(const void *l_, const void *r_)
{
	const rank_t *l = (const rank_t*) l_;
	const rank_t *r = (const rank_t*) r_;

	if (l->score < r->score)
		return 1;

	if (l->score > r->score)
		return -1;

	return 0;
}

int
main(int argc, char **argv)
{
	rank_t data[MAX_N + 1];
	int id, score;
	int i;

	int n = 0;
	while (true)
	{
		scanf("%d,%d", &id, &score);
		if (id == 0 && score == 0)
			break;

		data[n].id = id;
		data[n].score = score;
		data[n].rank = 0;
		n++;
	}

	qsort(data, n, sizeof(rank_t), cmp_func);

	int rank = 0;
	score = INF;
	for (i = 0; i < n; ++i)
	{
		if (data[i].score != score)
		{
			score = data[i].score;
			rank++;
		}

		data[i].rank = rank;
	}

	while (scanf("%d", &id) != EOF)
	{
		for (i = 0; i < n; ++i)
		{
			if (data[i].id == id)
			{
				printf("%d\n", data[i].rank);
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 608
def dctLr(lst1, lst2):
  length = min(len(lst1), len(lst2))
  for i in range(length):
    if lst1[i] < lst2[i]:
      return lst1
    elif lst1[i] > lst2[i]:
      return lst2
  return shorter(lst1, lst2)

def shorter(lst1, lst2):
  diff = len(lst1) - len(lst2)
  if diff < 0:
    return lst1
  else:
    return lst2

inp = input().split(' ')
print(''.join(dctLr(inp[0] * int(inp[1]), inp[1] * int(inp[0]))))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair

using namespace std;

int main()
{
   FAST/**/
   
   ll arr[5];
   for(ll i=0;i<5;i++)
        cin>>arr[i];
   
   sort(arr,arr+5);
   
   ll ans = 100000;
   
   do
   {
       
       ll tim = 0;
       for(ll i=0;i<5;i++)
       {
           tim+=(10-tim%10)%10;
           tim += arr[i];
       }
       
       ans = min(ans,tim);
       
   }while(next_permutation(arr,arr+5));
   cout<<ans;
   
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

ll dfs(ll h) {
    if (h == 1) {
        return 1;
    }
    return 2 * dfs(h / 2) + 1;
}

signed main() {
    cin >> H >> N;
    vi a(N), b(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
    }
    int mx = *max_element(a.begin(), a.end());
    vector<ll> dp(H + mx + 10, LLINF);
    dp[0] = 0;
    for (int h = 0; h < H; h++) {
        for (int i = 0; i < N; i++) {
            if (dp[h] == LLINF) {
                continue;
            }
            dp[h + a[i]] = min(dp[h + a[i]], dp[h] + b[i]);
        }
    }
    dump(dp);
    ans = LLINF;
    for (int h = H; h < dp.size(); h++) {
        ans = min(ans, dp[h]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#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>;
using G = vector<vector<int>>;
ll INF = 1000000000000000000ll;
    
int main(){
    int n;
    cin >> n;
    ll ans = 1ll;
    vector<ll> a(n);

    rep(i,n){
        cin >> a[i];
        if(a[i]==0ll) ans = 0ll;
    }

    if (ans!=0ll){
        ans *= a[0];
        for(int i=1; i<n; i++){
           if(ans <= INF / a[i]){
               ans *= a[i];
           } else {
               ans = -1ll;
               break;
           }
        }
    } 

    cout << ans << endl;
    
    return 0;
}

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

using namespace std;

#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define fi first
#define se second
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
#define pii pair<int,int>
#define wz cout<<"-----"<<endl;

const int N = 1e5 + 10, INF = 0x3f3f3f3f , MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};

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


void init() {

}

int main(){
//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
    ios_base::sync_with_stdio(0);
    init();
    int n;cin>>n;
    vector<int> a;
    for(int i = 0;i < n;i++) {
        int x;cin>>x;
        a.push_back(x);
    }
    sort(a.begin(),a.end());
    n = unique(a.begin(),a.end()) - a.begin();
    cout<<n<<endl;

    return 0;
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<pair<string,pair<int,int>>> a(N);
    REP(i,N){
        cin >> a.at(i).first >> a.at(i).second.first;
        a.at(i).second.second = i+1;
    }
    sort(a.begin(),a.end());
    string z = a.at(0).first;
    int g = -1;
    bool q = 0;
    for(int i=0;;i++){
        if(z != a.at(i).first){
            for(int l = i-1; l > g;l--){
                cout <<a.at(l).second.second<< "\n";
            }
            g = i-1;
        }
        z = a.at(i).first;
        if(i== N-1){
            for(int l = i; l > g;l--){
                cout <<a.at(l).second.second<< "\n";
            }
            q = 1;
        }
        if(q == 1)break;
    } 
}

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

using namespace std;

char grid[2005][2005];

int prevRow[2005][2005];
int prevCol[2005][2005];
int nextRow[2005][2005];
int nextCol[2005][2005];

int main(){
	int N, M;
	scanf("%d%d", &N, &M);
	
	for(int i = 1; i <= N; i ++){
		for(int j = 1; j <= M; j ++){
			scanf(" %c", &grid[i][j]);
		}
	}
	
	for(int i = 1; i <= M; i ++){
		prevRow[0][i] = 0;
		nextRow[N+1][i] = N+1;
	}
	
	for(int j = 1; j <= N; j ++){
		prevCol[j][0] = 0;
		nextCol[j][M+1] = M+1;
	}
	
	for(int j = 1; j <= M; j ++){
		for(int i = 1; i <= N; i ++){
			if(grid[i][j] == '#'){
				prevRow[i][j] = i;
			}else{
				prevRow[i][j] = prevRow[i-1][j];
			}
		}
		for(int i = N; i >= 1; i --){
			if(grid[i][j] == '#'){
				nextRow[i][j] = i;
			}else{
				nextRow[i][j] = nextRow[i+1][j];
			}
		}
	}
	
	for(int i = 1; i <= N; i ++){
		for(int j = 1; j <= M; j ++){
			if(grid[i][j] == '#'){
				prevCol[i][j] = j;
			}else{
				prevCol[i][j] = prevCol[i][j-1];
			}
		}
		for(int j = M; j >= 1; j --){
			if(grid[i][j] == '#'){
				nextCol[i][j] = j;
			}else{
				nextCol[i][j] = nextCol[i][j+1];
			}
		}
	}
	
	int ans = 1;
	for(int i = 1; i <= N; i ++){
		for(int j = 1; j <= M; j ++){
			if(grid[i][j] == '#'){
				continue;
			}
			ans = max(ans, nextRow[i][j]-prevRow[i][j] + nextCol[i][j]-prevCol[i][j] -3);
		}
	}
	
	printf("%d", ans);
	
	return 0;
}


Measured memory_bytes: 66944
#include<iostream>

using namespace std;

typedef long long LL;

const int mod = 1e9+7;

LL qmi(int a, int b, int p)
{
    LL res = 1 % p;
    while (b)
    {
        if (b & 1) res = res * a % p;
        a = a * (LL)a % p;
        b >>= 1;
    }
    return res;
}


int main()
{
    int n;
    cin >> n;
    LL a1 = qmi(10,n,mod);
    LL a2 = qmi(8,n,mod);
    LL a3 = qmi(9,n,mod);
    cout << ( ((a1+a2)%mod - 2*a3)%mod + mod)%mod;
    //LL ans = qmi(10,n,mod) + qmi(9,n,mod) - qmi(8,n,mod);
    //cout << ans << endl;


    return 0;
}


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

char pic[1010][1010];
int mk[1010][1010];
int a[]={-1,1,0,0},b[]={0,0,-1,1};
queue<pair<int,pair<int,int> > > q;

main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++)
	{
		scanf("%s",pic[i]);
		for(int j=0;j<m;j++)
		{
			if(pic[i][j]=='#')
			{
				q.push(make_pair(0,make_pair(i,j)));
			}
		}
	}
	while(!q.empty())
	{
		//printf("d\n");
		int p1=q.front().second.first,p2=q.front().second.second;
		int val=q.front().first;
		q.pop();
		for(int i=0;i<4;i++)
		{
			int g1=p1+a[i],g2=p2+b[i];
			if(g1<0||g1>=n||g2<0||g2>=m)
			{
				continue;
			}
			if(pic[g1][g2]=='.')
			{
				pic[g1][g2]='#';
				mk[g1][g2]=val+1;
				q.push(make_pair(val+1,make_pair(g1,g2)));
			}
		}
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			ans=max(ans,mk[i][j]);
		}
	}
	printf("%d",ans);
}

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
ll mod = 1000000007;
ll inf = 1e18;
int main(){

    int h,w;
    cin >> h >> w;
    vector<vector<int>> c(10,vector<int>(10));
    vector<vector<int>> a(h,vector<int>(w));
    rep(i,10){
        rep(j,10) cin >> c[i][j];
    }
    rep(i,h){
        rep(j,w) cin >> a[i][j];
    }

    vector<int> cost(10);
    vector<bool> t(10);
    t[1]=true;
    cost[1]=0;

    for(int k=0; k<9; k++){
        int x=mod,p;
        rep(i,10){
            if(t[i]) continue;
            rep(j,10){
                if(!t[j]) continue;
                if(x>c[i][j]+cost[j]){
                    x=c[i][j]+cost[j];
                    p=i;
                }
                // cout << i << ' ' << j << endl;
            }
        }
            t[p]=true;
            cost[p]=x;
    }
    
    ll sum=0;
    rep(i,h){
        rep(j,w){
            if(a[i][j]==-1) continue;
            sum+=cost[a[i][j]];
        }
    }
    cout << sum << endl; 

    return 0;
}

Measured memory_bytes: 3764
#include <cstdio>
#include <cstring>
int digitnumber(int number){
  //存入字符数?，求数??度
  char a[256];
  memset(a,0,sizeof(a));
  return sprintf(a,"%d",number);
}
int main(){
  int a,b;
  while (scanf("%d%d",&a,&b)==2) {
    //?入多?数据,且??多个数据?
    printf("%d\n",digitnumber(a+b));
  }
  return 0;
}

Measured memory_bytes: 2664
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }
vector<pair<ll, ll>> primeFac(ll n) {
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////

int main() {
  int n;
  map<int, int> a;
  cin >> n;

  ll s = 0;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    if (!a.count(tmp))
      a[tmp] = 1;
    else
      a.at(tmp)++;
    s += tmp;
  }

  int q;
  cin >> q;
  vector<int> b, c;
  for (int i = 0; i < q; i++) {
    int h, g;
    cin >> h >> g;
    b.push_back(h);
    c.push_back(g);
  }

  for (int i = 0; i < q; i++) {
    if (!a.count(b.at(i))) {
      cout << s << endl;
      continue;
    }
    s += a.at(b.at(i)) * (c.at(i) - b.at(i));
    cout << s << endl;

    if (!a.count(c.at(i))) a[c.at(i)] = 0;
    a.at(c.at(i)) += a.at(b.at(i));
    a.at(b.at(i)) = 0;
  }
}

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

using namespace std;

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

int N, M;
long long X[1005], Y[1005], Z[1005];
long long dp[1005][1005][8];

int main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i] >> Z[i];
  }
  for (int i = 0; i < 1005; i++) {
    for (int j = 0; j < 1005; j++) {
      for (int k = 0; k < 8; k++) {
        dp[i][j][k] = -1e15;
      }
    }
  }
  for (int i = 0; i < 8; i++) {
    dp[0][0][i] = 0;
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= M; j++) {
      for (int k = 0; k < 8; k++) {
        chmax(dp[i + 1][j][k], dp[i][j][k]);
      }
      chmax(dp[i + 1][j + 1][0], dp[i][j][0] + X[i] + Y[i] + Z[i]);
      chmax(dp[i + 1][j + 1][1], dp[i][j][1] + X[i] + Y[i] - Z[i]);
      chmax(dp[i + 1][j + 1][2], dp[i][j][2] + X[i] - Y[i] + Z[i]);
      chmax(dp[i + 1][j + 1][3], dp[i][j][3] + X[i] - Y[i] - Z[i]);
      chmax(dp[i + 1][j + 1][4], dp[i][j][4] - X[i] + Y[i] + Z[i]);
      chmax(dp[i + 1][j + 1][5], dp[i][j][5] - X[i] + Y[i] - Z[i]);
      chmax(dp[i + 1][j + 1][6], dp[i][j][6] - X[i] - Y[i] + Z[i]);
      chmax(dp[i + 1][j + 1][7], dp[i][j][7] - X[i] - Y[i] - Z[i]);
    }
  }
  long long ans = 0;
  for (int i = 0; i < 8; i++) {
    chmax(ans, dp[N][M][i]);
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


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


int main() {
    int a,b;
    cin >> a >> b;
    if(a <= 9 && b <= 9)cout << a*b << endl;
    else cout << "-1" << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	LL S;
	cin>>S;
	cout<<"0 0 1 1000000000 "<<S/(LL)(1000000000)+bool(S%(LL)(1000000000))<<" "<<(LL)(1000000000)*(S/(LL)(1000000000)+bool(S%(LL)(1000000000)))-S<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
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(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;


int main(){
  ll n, r, b;
  ll a, ans = 0;
  cin >> n >> b >> r;

  
  ans = (n / (b + r)) * b;
  a = n % (b + r);
  if(a < b)
    ans += a;
  else
    ans += b;
  
  
  
  cout << ans << endl;
}




Measured memory_bytes: 256
package main

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

const Inf = 1 << 60

func main() {
	V, E, r := ReadInt(), ReadInt(), ReadInt()
	// 辺i は cost[i] で source[i] から target[i] への有向辺
	source := make([]int, E)
	target := make([]int, E)
	cost := make([]int, E)
	for i := 0; i < E; i++ {
		source[i], target[i], cost[i] = ReadInt(), ReadInt(), ReadInt()
	}
	// r から d[i] への最短距離
	d := make([]int, V)
	for i := 0; i < V; i++ {
		d[i] = Inf
	}
	d[r] = 0
	foundNegativeCycle := false
	for v := 0; v < V; v++ {
		update := false
		for i := 0; i < E; i++ {
			if d[source[i]] >= Inf {
				continue
			}
			newDist := d[source[i]] + cost[i]
			if d[target[i]] > newDist {
				d[target[i]] = newDist
				update = true
			}
		}
		if !update {
			break
		}
		if update && v == V-1 {
			foundNegativeCycle = true
			break
		}
	}
	if foundNegativeCycle {
		fmt.Println("NEGATIVE CYCLE")
	} else {
		for i := 0; i < V; i++ {
			if d[i] >= Inf {
				fmt.Println("INF")
			} else {
				fmt.Println(d[i])
			}
		}
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int) { Scan(&i); return }



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


int main() {

  int INF = 1000000001;

  int N, M, R;
  cin >> N >> M >> R;

  int d[201][201];
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      if (i != j) {
        d[i][j] = INF;
      }
    }
  }

  vector<int> r(R);
  for (int i = 0; i < R; i++) {
    cin >> r[i];
  }
  
  sort(r.begin(),r.end());

  int A, B, C;
  for (int i = 1; i <= M; i++) {
    cin >> A >> B >> C;
    if (C < d[A][B]) {
      d[A][B] = C;
      d[B][A] = C;
    }
  }

  // ワーシャルフロイド
  for (int k = 1; k <= N; k++) {
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= N; j++) {
        d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
      }
    }
  }
  
  int answer = INF;

  // たどる順番を探す
  do {
    int a_ = 0;
    for(int i = 0; i < R - 1; i++) {
      a_ += d[r[i]][r[i+1]];
    }
    answer = min(answer, a_);
  } while (next_permutation(r.begin(), r.end())); 

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 384
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int a, p;

  cin >> a >> p;

  cout << (a * 3 + p) / 2 << endl;

  return 0;
}


Measured memory_bytes: 256
to_bin = dict(zip([chr(i) for i in range(ord("A"), ord("Z") + 1)] + [" ", ".", ",", "-", "'", "?"],
                  [bin(i)[2:7].zfill(5) for i in range(2 ** 5)]))
to_chr = {"101":" ", "000000":"'", "000011":",", "10010001":"-", "010001":".", "000001":"?", "100101":"A", "10011010":"B",
          "0101":"C", "0001":"D", "110":"E", "01001":"F", "10011011":"G", "010000":"H", "0111":"I", "10011000":"J",
          "0110":"K", "00100":"L", "10011001":"M", "10011110":"N", "00101":"O", "111":"P", "10011111":"Q", "1000":"R",
          "00110":"S", "00111":"T", "10011100":"U", "10011101":"V", "000010":"W", "10010010":"X", "10010011":"Y", "10010000":"Z"}

while True:
  try:
    s = input()
  except EOFError:
    break
  bs = "".join([to_bin[c] for c in s])
  ans = ""
  while True:
    length = 9
    for i in range(length):
      if bs[:i] in to_chr:
        ans = ans + to_chr[bs[:i]]
        bs = bs[i:]
        break
    else:
      break
  print(ans)


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INF = 999999999;
const int MOD = (int)1e9 + 7;
const int EPS = 1e-9;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  FOR(i,0,a+1)FOR(j,0,b+1)FOR(k,0,c+1){
      if ((500*i+100*j+50*k)==x){
          ans++;
      }
  }
  cout << ans << endl;
}

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

int a,b,c,x;

int main()
{
    cin>>a>>b>>c>>x;

    int ans = 0;

    for (int i = 0; i <= a; i++)
    {
        for (int j = 0; j <= b; j++)
        {
            for (int k = 0; k <= c; k++)
            {
                if(500*i + 100*j + 50*k == x) ans++;
            }
        }
    }

    cout << ans << endl;    
    
    return 0;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int a, b, c; cin >> a >> b >> c;
  int x; cin >> x;
  int ans=0;
  rep(i,0,a+1)rep(j,0,b+1)rep(k,0,c+1)if(500*i+100*j+50*k==x)ans++;
  cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
import std.conv, std.stdio;
import std.algorithm, std.array, std.range, std.string;
void main()
{
    auto
        buf0 = readln.chomp.split.to!(int[]),
        buf1 = readln.chomp.split.to!(int[]);
    ((buf0[0] - buf1[0]) * (buf0[1] - buf1[1])).writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }
    vector<ll> dp(n + 5, 0);
    dp[0] = 1;
    dp[1] = 1;
    if (m != 0 and a[0] == 1) {
        dp[1] = 0;
    }

    for (int i = 2; i <= n; i++) {
        dp[i] = max(dp[i], dp[i - 1] + dp[i - 2]) % MOD;
        for (int j = 0; j < m; j++) {
            if (i == a[j]) {
                dp[i] = 0;
                break;
            }
        }
    }
    cout << dp[n] << endl;
    return 0;
}

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


int main() {
  string s;
  cin >> s;
  long n=s.size();
  vector<int>a(26);
  rep(i,n){
    a.at(s.at(i)-'a')++;
  }
  long ans=0;
  rep(i,n){
    ans+=n-a.at(s.at(i)-'a');
  }
  
    cout<<ans/2+1<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int N;
int h[MAXN], f[MAXN];
int main()
{
	cin >> N;
	for (int i = 1; i <= N; i++)
	{
		cin >> h[i];
	}
	f[N] = 0;
	for (int i = N - 1; i >= 1; i--)
	{
		if (h[i] >= h[i + 1]) f[i] = f[i + 1] + 1; 
		else f[i] = 0; 
	}
	int curMax = -3;
	for (int i = 1; i <= N; i++)
	{
		curMax = max(f[i], curMax);
	}
	cout << curMax << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
#include<map>
#include<set>
using namespace std;

int main() {
    int n, a[100000] = {}, l = 0;
    cin >> n;
    a[0] = a[n + 1] = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i + 1];
    }
    for (int i = 0; i <= n; i++) {
        l += abs(a[i + 1] - a[i]);
    }
    for (int i = 1; i <= n;i++) {
        cout << l - abs(a[i + 1] - a[i]) - abs(a[i] - a[i - 1]) + abs(a[i + 1] - a[i - 1]) << endl;
    }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n;
vector<string> s;
int main(){
	cin>>n;
	REP(i,n){
		string s1;
		cin>>s1;
		sort(s1.begin(),s1.end());
		s.push_back(s1);
	}
	sort(s.begin(),s.end());
	ll k=1;
	ll ans=0;
	for(int i=0;i<n-1;i++){
		if(s[i]==s[i+1]){
			k++;
		}else{
			ans+=(k*(k-1))/2;
			k=1;
		}
	}
	ans+=(k*(k-1))/2;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5748
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define MAX_N 1000 + 10

using namespace std;
typedef long long ll;

const ll MOD = 1000003;
ll n, k, L[MAX_N + 1], L1[MAX_N + 1], L2[MAX_N + 1];
bool is_prime[MAX_N];
vector<ll> divs;
vector<ll> factor;

void init(){
    L1[1] = 2, L2[1] = 0, L[1] = 2;
    for(int i = 2; i <= k && i <= n; i++){
        L1[i] = (L1[i - 1] + L2[i - 1]) % MOD;
        L2[i] = (L1[i - 1] + L2[i - 1]) % MOD;
        L[i] = L1[i] + L2[i];
    }
    ll t1 = 2, t2 = 0;
    for(int i = k + 1; i <= n; i++){
        if(i - k - 1 > 0){
            t1 = L2[i - k - 1];
            t2 = L1[i - k - 1];
        }
        L1[i] = (L1[i - 1] + L2[i - 1] - t1) % MOD;
        L2[i] = (L1[i - 1] + L2[i - 1] - t2) % MOD;
        L[i] = L1[i] + L2[i];
    }
    //prime
    fill(is_prime, is_prime + 32, true);
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i * i <= n; i++){
        if(is_prime[i]){
            for(int j = i * 2; j <= n; j += i){
                is_prime[j] = false;
            }
        }
    }
}
void factorize(){
    factor.clear();
    int m = n;
    for(int i = 1; i * i <= n; i++){
        if(is_prime[i] && m % i == 0){
            factor.push_back(i);
            while(m % i == 0) m /= i;
        }
    }
    if(m != 1) factor.push_back(m);
}
void divisor(){
    divs.clear();
    for(int i = 1; i <= n; i++){
        if(n % i == 0) divs.push_back(i);
    }
}
ll mod_pow(ll a, ll b){
    //a ^ b;
    ll A = a, B = 1;
    while(b > 0){
        if(b & 1) B = B * A % MOD;
        A = A * A % MOD;
        b >>= 1;
    }
    return B;
}
ll calc(int m){
    ll res = L[m];
    if(m <= k && k < n) res -= 2;
    else if(m > k + 1){
        for(int i = 2 * k; i > k; i--){
            // if(m == i + 1 || m == i + 2){
                // res = (res - 2 * (2 * k - i + 1) % MOD) % MOD;
            // }else if(m >= i + 3){
                // res = (res - mod_pow(2, m - i - 1) * (2 * k - i + 1) % MOD) % MOD;
            // }
            if(m >= i + 1){
                res = (res - L1[m - i] * (2 * k - i + 1) % MOD) % MOD;
            }
        }
    }
    // cout << (res + MOD) % MOD << endl;
    return (res + MOD) % MOD;
}
ll solve(){
    init();
    // for(int i = 1; i <= n; i++){
        // printf("L[%d] = %lld\n", i, L[i]);
    // }
    factorize();
    divisor();
    //polya
    ll res = 0;
    for(int i = 0; i < divs.size(); i++){
        ll euler = n / divs[i];
        for(int j = 0; j < factor.size(); j++){
            if((n / divs[i]) % factor[j] == 0) euler = euler / factor[j] * (factor[j] - 1);
        }
        ll tmp = calc(divs[i]) * euler % MOD;
        // printf("divs = %lld  euler = %lld  tmp = %lld\n", divs[i], euler, tmp);
        res += tmp;
    }
    return res * mod_pow(n, MOD - 2) % MOD;
}
int main(){
    while(~scanf("%d %d\n", &n, &k) && (n || k)){
        cout << solve() << endl;
    }
    return 0;
}


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

int main(void) {
    string N;cin>>N;
    char n = N[N.size()-1];
    if (n == '2'||n=='4'||n=='5'||n=='7'||n=='9') cout << "hon" << endl;
    else if (n == '0' || n=='1'||n == '6' || n=='8') cout << "pon" << endl;
    else if (n =='3') cout << "bon" << endl;
    
    return 0;
}

Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);


int main() {
  int n;
  string s;
  cin >> n >> s;
  
  if(n%2==1) puts("No");
  else {
  cout << (s.substr(0,n/2)==s.substr(n/2,n/2)?"Yes":"No") << endl;
  }
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,k;
  cin >> n >> m >> k;
  for(int i=0;i<=n;i++){
    if(n-2*i==0){
      if(k%m==0){
        cout << "Yes" << endl;
        return 0;
      }
    }
    else{
    if(abs(k-i*m)%abs(n-2*i)==0){
      int j=abs(k-i*m)/abs(n-2*i);
      if(i*(m-j)+j*(n-i)==k&&0<=j&&j<=m){
        cout << "Yes" << endl;
        return 0;
      }
    }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int (i)=0;(i)<(int)(a);(i)++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;

        ll n,k;
        cin>>n>>k;
        vll h(n);
        rep(i,n)cin>>h[i];
        sort(all(h));
        n-=k;
        ll sum = 0;
        for(ll i = 0; i<n;i++){
            sum+=h[i];
        }
        cout<<sum<<endl;



return 0;
}







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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long

const int N = 2e5 + 5;

int32_t main()
{
    IOS;
    int t=1;
    // cin>>t;
    while(t--)
    {
        int n; cin>>n;
        string s; cin>>s;
        int ans=0,x=0;
        for (int i = 0; i < n; ++i)
        {
            if(s[i]=='R') x++;
        }
        for (int i = 0; i < x; ++i)
        {
            if(s[i]=='W') ans++;
        }
        int i=0,j=n-1;
        while(i<n&&s[i]=='R') i++;
        while(j>=0&&s[j]=='W') j--;
        int t=max(0ll,j-i+1);
        cout<<min(ans,t)<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
	ll n; cin>>n; char x;
	set<char> s;
	for(int i=0;i<n;i++) cin>>x,s.insert(x);
	if(s.size()==3) cout<<"Three";
	else cout<<"Four";
}


Measured memory_bytes: 3416