akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;

#define sl(x) scanf("%d",&x)
#define pl(x) printf("%d\n",x)
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " " << x << "\n";
#define debug2(x, n) cerr << #x << "\n"; f(i, n) cerr << i << " " << x[i] << "\n";
#define r(v) {reverse(all(v));}
#define pb push_back
#define F first
#define S second
#define f(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)

const ll mod = 1000000007;
const ll inf = (ll)5e16;
const ld eps = 1e-12;
const ll N = 1000005;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
template <typename T>
T power2(T a, ll b) { if(b == 0) return 1; if(b == 1) return a; T x = power2(a, b / 2); x = x * x; if(b % 2) x = x * a; return x;}
ll gcd(ll a, ll b) {if(a < b) swap(a, b); while(b) {ll t = b; b = a % b; a = t;} return a;}
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}
ll n, a[N], b[N], c[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    f(i, n) cin >> a[i];
    f(i, n) cin >> b[i];
    f(i, n) cin >> c[i];
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);
    ll ans = 0;
    f(i, n)
    {
        ll x = b[i];
        ll l = 0, r = n - 1, ind = n;
        while(l <= r)
        {
            ll m = (l + r) >> 1;
            if(c[m] > x)
            {
                ind = m;
                r = m - 1;
            }
            else
            {
                l = m + 1;
            }
        }
        ll ind2 = -1;
        l = 0, r = n - 1;
        while(l <= r)
        {
            ll m = (l + r) >> 1;
            if(a[m] < x)
            {
                ind2 = m;
                l = m + 1;
            }
            else
            {
                r = m - 1;
            }
        }
       // cout << x << " " << ind << " " << ind2 << "\n";
        ans += (ind2 + 1) * (n - ind);
    }
    cout << ans << "\n";
    return 0;
}


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

int main() {

   int n;
   cin>>n;
   
   int arr[n];
   int arr1[n];
   
   for(int i=0;i<n;++i)
    cin>>arr[i];
   
   for(int i=0;i<n;++i)
    cin>>arr1[i];
    
    int ct = 0;
    
     for(int i=0;i<n;++i){
         if(arr[i]-arr1[i]>0)
           ct+= arr[i]-arr1[i];
     }
    
       cout<<ct;
 return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

int main()
{
    int n, m, c;
    cin >> n >> m >> c;
    int b[m];
    int a[n][m];
    int okcount = 0;
    REP(i, m) { cin >> b[i]; }
    REP(i, n)
    {
        REP(j, m) { cin >> a[i][j]; }
    }
    lint absum = 0;
    REP(i, n)
    {
        absum = 0;
        REP(j, m)
        {
            absum += a[i][j] * b[j];
        }
        if (absum + c > 0)
        {
            okcount += 1;
        }
    }

    cout << okcount << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

int main(){
    int N, K;
    string S;
    cin >> N >> S >> K;
    for(int i=0; i<N; i++){
        if(S[i] != S[K-1]){
            S[i] = '*';
        }
    }
    cout << S << endl;
}


Measured memory_bytes: 256
import sys
import math
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))

ans = 0
n, d = inm()
for i in range(n):
    x, y = inm()
    if x*x + y*y <= d*d:
        ans += 1
print(ans)

Measured memory_bytes: 9172
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
#define dump(a) cout << (a) << endl;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<double> t(n+1, 0), v(n+2, 0);
    for( int i = 1; i <= n; i++ ) cin >> t[i];
    for( int i = 0; i < n; i++ ) t[i+1] += t[i];
    for( int i = 1; i < n+1; i++ ) cin >> v[i];
    vector<double> g;
    for( double time = 0.0; time <= t.back(); time+=0.5 ) {
        double mi = __DBL_MAX__;
        for( int i = 0; i < n; i++ ) {
            double ma;
            if( 0 <= time && time < t[i] ) {
                ma = v[i+1]+(t[i]-time);
            }
            else if( t[i] <= time && time <= t[i+1] ) {
                ma = v[i+1];
            }
            else if( t[i+1] < time && time <= t.back() ) {
                ma = v[i+1]+(time-t[i+1]);
            }
            ma = min( ma, min( time, t.back()-time ) );
            mi = min( mi, ma );
        }
        g.push_back( mi );
    }
    double sum = 0.0;
    for( int i = 0; i < (int)g.size()-1; i++ ) sum += 0.25*(g[i]+g[i+1]);
    printf( "%lf\n", sum );
    return 0;  
}

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

long long H, W;
long long d[10][10];
long long num[10];

int main(){
	cin >> H >> W;
	for(long long i = 0; i < 10; i++)
		for(long long j = 0; j < 10; j++)
			cin >> d[i][j];

	for(long long i = 0; i < H; i++){
		for(long long j = 0; j < W; j++){
			long long tmp;
			cin >> tmp;
			if(tmp != -1){
				num[tmp]++;
			}
		}
	}


	for(int k = 0; k < 10; ++k){
		for(int i = 0; i < 10; ++i){
			for(int j = 0; j < 10; ++j){
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}



	long long ans = 0;
	for(long long i = 0; i < 10; i++){
		ans += d[i][1] * num[i];
	}
	cout << ans << endl;




}

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

#define lld long long

int main(){
    lld N,M;
    lld sum = 0;
    vector<lld> a;
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        int b;
        cin >> b;
        sum += b;
        a.push_back(b);
    }
    sort(a.begin(),a.end(),greater<lld>());
    int flg = 1;
    for (int i = 0; i < M; i++) {
        if((long double)a[i] < (long double)sum/(long double)(4*M)){
            cout << "No" << endl;
            flg = 0;
            break;
        }
    }
    if(flg){
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a == b + c || b == a + c || c == a + b){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

typedef long long ll;

bool C(vector<ll> &A, vector<ll> &F, ll K, ll d) {
    ll sum = 0;
    for (int i = 0; i < A.size(); i++) {
        sum += max(0LL, A[i] - d / F[i]);
    }
    return sum <= K;
}

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N), F(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> F[i];
    }

    sort(A.begin(), A.end());
    sort(F.begin(), F.end(), greater<ll>());

    ll lb = -1, ub = 1e18;
    while (lb + 1 < ub) {
        ll mid = (lb + ub) / 2;
        if (C(A, F, K, mid)) {
            ub = mid;
        } else {
            lb = mid;
        }
    }

    cout << ub << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
namespace io{
    #define ll long long
    #define inf 0x3f3f3f3f
    #define il inline 
    #define in1(a) read(a)
    #define in2(a,b) in1(a),in1(b)
    #define in3(a,b,c) in2(a,b),in1(c)
    #define in4(a,b,c,d) in2(a,b),in2(c,d)
    il void readl(ll &x){
        x=0;ll f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
    il void read(int &x){
        x=0;int f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
}using namespace io;
int f[105];
bool cmp(int x,int y){
	return x>y;
}
int main(){
	int a,b,k,cnt=0;
	in3(a,b,k);
	for(int i=1;i<=min(a,b);i++){
		if(a%i==0&&b%i==0){
			cnt++;
			f[cnt]=i;
		}
	}
	sort(f+1,f+cnt+1,cmp);
	printf("%d",f[k]);
	return 0;
}

Measured memory_bytes: 128
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC111B
int main(void) {
  int n, k, i, cou=0, tmp;
  scanf("%d", &n);
  if(n<=111) printf("111");
  else if(n<=222) printf("222");
  else if(n<=333) printf("333");
  else if(n<=444) printf("444");
  else if(n<=555) printf("555");
  else if(n<=666) printf("666");
  else if(n<=777) printf("777");
  else if(n<=888) printf("888");
  else if(n<=999) printf("999");
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
	//X+Y+Z=S （ただし、X,Y,ZはK以下の数字）で何パターンあるか？？？
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str0 = sc.nextLine();
		String[] array0 = str0.split(" ");
		int K = Integer.parseInt(array0[0]);//合計値
		int S = Integer.parseInt(array0[1]);//最大値
		int result=0;

		for(int x=0;x <= K;x++){//Xの値パターン

			 for(int y=0;y <= K;y++){//Yの値パターン

				 if(0 <= S-x-y && S-x-y <= K){
					 // Z = S(合計)-X-Y で0以上かつ、K以下ならばカウントする
					 result++;
				 }
			 }
		}
		System.out.println(result);
	}

}

Measured memory_bytes: 9684
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int r, g, b, n;
    scanf("%d %d %d %d", &r, &g, &b, &n);
    int i, j, k, ans = 0;
    for (i = 0; i * r <= n; i++)
    {
        for (j = 0; j * g <= n; j++)
        {
            k = n - (i * r + j * g);
            if (k >= 0 && k % b == 0)
            {
                ans++;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

typedef long long ll;

map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    if (N == 0) {
        ans = 0;
    }
    else if(N%2 == 1)
        ans = 0;
    else {
        ll denom = 10;
        while(denom <= N) {
            ans += N / denom;
            denom *= 5;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int N, a[110];
int cnt[110];

void Possible() {
    cout << "Possible" << endl;
    exit(0);
}
void Impossible() {
    cout << "Impossible" << endl;
    exit(0);
}

void solve() {
    int MAX = 0;
    for (int i = 0; i < N; i++) {
        chmax(MAX, a[i]);
        cnt[a[i]]++;
    }
    int SUM = 0;
    for (int i = (MAX + 1) / 2; i <= MAX; i++) {
        SUM += cnt[i];
        if (MAX % 2 == 0 && i == MAX / 2) {
            if (cnt[i] != 1)
                Impossible();
        } else if (MAX % 2 == 1 && i == (MAX + 1) / 2) {
            if (cnt[i] != 2)
                Impossible();
        } else if (cnt[i] <= 1)
            Impossible();
    }
    if (SUM == N)
        Possible();
    else
        Impossible();
}

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

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

    solve();
    return 0;
}


Measured memory_bytes: 3604
import collections

n = int(input())
v = list(map(int, input().split()))

o = collections.Counter(v[0::2]).most_common(2)
e = collections.Counter(v[1::2]).most_common(2)

if len(o) == 1:
    o.append([0, 0])
if len(e) == 1:
    e.append([0, 0])


if o[0][0] != e[0][0]:
    ans = n - o[0][1] - e[0][1]
else:
    ans = min(n - o[0][1] - e[1][1], n - o[1][1] - e[0][1])

print(ans)

Measured memory_bytes: 15588
N = int(input())
x_list, n_list = [], []
for i in range(N):
  xi, ni = input().split(' ')
  x_list.append(float(xi))
  n_list.append(ni)
  
result = 0
for i in range(len(n_list)):
  result += x_list[i] if n_list[i] == "JPY" else x_list[i] * 380000.0
  
print(result)

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

typedef long long LL;
typedef pair<int, int> P;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;

void solve()
{
    int N;
    cin >> N;
    while (N)
    {
        if (N % 10 == 7)
        {
            std::cout << "Yes" << endl;
            return;
        }
        N /= 10;
    }
    std::cout << "No" << endl;
    return;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 3656
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    l = list(map(int, input().split()))
    print(l.index(0) + 1)
    

def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9824
import sys
from collections import deque

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    H, W = map(int, input().split())
    S = [input() for _ in range(H)]
    seen = [[False] * W for _ in range(H)]

    def dfs(sh, sw):
        q = deque([(sh, sw)])
        seen[sh][sw] = True
        black = 0
        white = 0
        if S[sh][sw] == "#":
            black += 1
        else:
            white += 1

        while q:
            h, w = q.popleft()

            for dh, dw in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
                nh = h + dh
                nw = w + dw

                if 0 <= nh < H and 0 <= nw < W:
                    if seen[nh][nw]:
                        continue
                    if S[h][w] == S[nh][nw]:
                        continue

                    seen[nh][nw] = True
                    q.append((nh, nw))
                    if S[nh][nw] == "#":
                        black += 1
                    else:
                        white += 1

        return black * white

    ans = 0
    for h in range(H):
        for w in range(W):
            if seen[h][w]:
                continue
            ans += dfs(h, w)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 4852
import java.util.Scanner;
import java.util.Vector;

public class Main{

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

    static Vector<Integer> ve = new Vector<Integer>();
    static long cut=0;

    private static void shellSort(int[] a, int length) {
        int h=1;
        while(h<=length){
            ve.add(h);
            h=3*h+1;
        }
        for (int i=ve.size()-1;i>=0;i--){
           insertSort(a,length,(Integer)ve.get(i));
        }
        System.out.println(ve.size());
        for (int  i= ve.size()-1;i>=0;i--){
            System.out.print(ve.get(i)+" ");
        }
        System.out.println("\n"+cut);
        for (int i=0;i<a.length-1;i++){
            System.out.println(a[i]);
        }
        System.out.print(a[a.length-1]);
    }

    private static void insertSort(int[] a, int length, Integer n) {
        for(int i=0;i<n;i++){
            for (int j=i+n;j<length;j=j+n){
                int m= a[j];
                int l =j-n;
                while (l>=i&&a[l]>m){
                    a[l+n]=a[l];
                    l-=n;
                    cut++;
                }
                a[l+n]=m;
            }
        }
    }
}


Measured memory_bytes: 299244
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    vector<pair<int, int>> A(n);
    vector<tuple<int, int, int>> count(0);
    REP(i, n){
        cin >> A[i].first >> A[i].second;
    }
    whole(sort, A);
    REP(i, n){
        FOR(j, i + 1, n){
            int dx = A[j].first - A[i].first, dy = A[j].second - A[i].second;
            bool fd = false;
            REP(k, count.size()){
                if(get<0>(count[k]) == dx and get<1>(count[k]) == dy ){
                    get<2>(count[k])++;
                    fd = true;
                    break;
                }
            }
            if(!fd) count.push_back(make_tuple(dx, dy, 1));
        }
    }
    int maxi = 0;
    REP(i, count.size()) maxi = max(maxi, get<2>(count[i]));

    cout << n - maxi << endl;
}

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

long long N;
long long T[1010];
long long A[1010];


int main()
{
    cin >> N;

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

    for(long long i = 1;i < N;i++)
    {
        /*
        while(T[i - 1] > T[i] || A[i - 1] > A[i])
        {
            T[i] += t;
            A[i] += a;
        }
        */

        long long tc ,ac;

        tc = T[i - 1] / T[i];
        if(T[i - 1] % T[i] != 0) tc++;
        ac = A[i - 1] / A[i];
        if(A[i - 1] % A[i] != 0) ac++;

        long long c;
        
        bool t = T[i - 1] < T[i] * ac;
        bool a = A[i - 1] < A[i] * tc;

        if(t && a)
        {
            if(T[i] * ac - T[i - 1] + A[i] * ac - A[i - 1] > T[i] * tc - T[i - 1] + A[i] * tc - A[i - 1])
            {
                c = tc;
            }
            else
            {
                c = ac;
            }
        }
        else if(t)
        {
            c = ac;
        }
        else
        {
            c = tc;
        }

        T[i] *= c;
        A[i] *= c;
    }

    cout << T[N - 1] + A[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(){
int n,i,a[300],x=0,ans=0;
scanf("%d",&n);
for(i=0;i<n;++i){
	scanf("%d",&a[i]);
}
while(1){
for(i=0;i<n;++i){
	if(a[i]%2==0)
		a[i]/=2;
	else{
      printf("%d",ans);
	  return 0;
	}
	}
	ans++;
	}
}

  

Measured memory_bytes: 128
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

line = require('fs').readFileSync(config.input, 'ascii')
  .trim()
  .split(config.newline);
n = Number(line.shift());
adj = {};
for (i in line) {
  ary = line[i].split(' ');
  j = ary.shift();
  ary.shift();
  adj[j] = ary;
}

for (i = 1; i <= n; i++) {
  ary = [];
  for (j = 1; j <= n; j++) {
    if (adj[i].indexOf(String(j)) !== -1) ary.push(1);
    else ary.push(0);
  }
  console.log(ary.join(' '));
}

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

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

        int N = sc.nextInt();
        int[] L = new int[N];
        for (int i = 0; i < N; i++) {
            L[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(L);

        int count = 0;
        for (int i = N - 1; i >= 2; i--) {
            for (int j = i - 1; j >= 1; j--) {
                if (isTriangle(L[i], L[j], L[j - 1])) {
                    int max = j - 1;
                    int min = 0;
                    while (max > min) {
                        int k = (max + min) / 2;
                        if (isTriangle(L[i], L[j], L[k])) {
                            max = k;
                        } else {
                            min = k + 1;
                        }
                    }
                    count += (j - min);
                }
            }
        }
        out.printf("%d\n", count);
        out.flush();
    }
    static boolean isTriangle(int a, int b, int c) {
        boolean result = false;
        if ((a < b + c) && (b < c + a) && (c < a + b)) {
            result = true;
        }
        return result;
    }
}


Measured memory_bytes: 26924
import sys
input = sys.stdin.readline
inf = float('inf')
mod = 10**9+7


def INT_(n): return int(n)-1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [input() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    import heapq
    N, Q = MI()
    event = []
    for _ in range(N):
        s, t, x = MI()
        event.append((s - x-0.5, 1, x))
        event.append((t - x-0.5, -1, x))

    for _ in range(Q):
        d = I()
        event.append((d, 0))

    # クエリも含めてソート
    event.sort(key=lambda x: x[0])

    # 工事現場が一番近いところを探すのにO(N)かけると死ぬのでlogNで調べることができるように優先度付きキューも使う
    occur = set()
    occur_priority = []

    for e in event:
        # 工事開始
        if e[1] == 1:
            occur.add(e[2])
            heapq.heappush(occur_priority, e[2])

        # 工事終了 occurはsetなので2回先に追加されたあとに2回削除ということを考慮
        elif e[1] == -1:
            if e[2] in occur:
                occur.remove(e[2])
            # heap木の要素の削除は遅いので、クエリのときに消す

        # クエリ
        elif e[1] == 0:
            if occur:
                while 1:
                    if occur_priority[0] in occur:
                        min_occur = occur_priority[0]
                        break
                    else:
                        heapq.heappop(occur_priority)
                print(min_occur)
            else:
                print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 126300
//INCLUDE
//------------------------------------------
#include <iostream>
#include <functional>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string>
#include <cstring>
#include <vector>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------
 
int main(void){
  ll A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;
  ll cost=0;
  ll sum=A+B;
  ll hsum=2*C;
  if(sum<hsum){
    cost=A*X+B*Y;
  }else{
    cost=hsum*min(X,Y);
    if(X<Y){
      cost+=(Y-X)*B;
    }else{
      cost+=(X-Y)*A;
    }
  }
  ll costB=max(X,Y)*C*2;
  cout<<min(cost,costB);
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e9;



signed main(){
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	while(1){
		C -= B;
		if(C <= 0){
			out("Yes");
			return 0;
		}
		A -= D;
		if(A <= 0){
			out("No");
			return 0;
		}
	}
}

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

double solv(vector<pair<double, double>> &pos, vector<int> v) {
  double ans = 0.0;

  rep(i, pos.size() - 1) {
    int l = v[i];
    int r = v[i + 1];
    double x = (pos[l].first - pos[r].first) * (pos[l].first - pos[r].first);
    double y = (pos[l].second - pos[r].second) * (pos[l].second - pos[r].second);
    ans += sqrt(x + y);
  }

  return ans;
}

int main(void) {
  int N;
  cin >> N;
  vector<pair<double, double>> pos(N);
  rep(i, N) {
    cin >> pos[i].first >> pos[i].second;
  }

  vector<int> v(N);
  iota(v.begin(), v.end(), 0);

  double ans = 0;
  int count = 0;
  do {
    ans += solv(pos, v);
    count++;
  } while (next_permutation(v.begin(), v.end()));

  printf("%.10f\n", (ans/count));
 
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define ull unsigned long long
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define FOR(i,start,stop)  for(int i=(start); i < (stop); i++)
#define FORD(i,start,stop) for(int i=(start); i >= (stop); i--)
#define RIP(i,stop) FOR(i,0,stop)
#define PI 3.141592653589793
#define PRECISION(c,f) fixed << setprecision(c) << f
using namespace std;

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

  int ans=0;
  while(true){
    if(X-500 < 0) break;
    X -= 500;
    ans += 1000;
  }
  //cout << X << endl;
  while(true){
    if(X-5 < 0) break;
    X -= 5;
    ans += 5;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3660
n,m,l = map(int,input().split())
a = [[0 for i2 in range(m)] for i1 in range(n)]
b = [[0 for i2 in range(l)] for i1 in range(m)]

for i in range(n):
    row = list(map(int,input().split()))
    for j in range(m):
        a[i][j] = row[j]

for i in range(m):
    row = list(map(int,input().split()))
    for j in range(l):
        b[i][j] = row[j]

c = [[0 for i2 in range(l)] for i1 in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k]*b[k][j]

for i in range(n):
    for j in range(l-1):
        print(c[i][j],end = ' ')
    print(c[i][-1])


Measured memory_bytes: 7056
import java.util.Scanner;


public class Main {

	public static void main(String [] args) {
		
		Scanner sc = new Scanner(System.in);
		
		while(true) {
			
			int H = sc.nextInt();
			int W = sc.nextInt();
			int syoki;
			
			
			if(H == 0 && W == 0)break;
			
			for(int i = 1;i <= H;i++) {
				
				    //初期値が奇数の時シャープから
				
				if(i % 2 == 1) {
					syoki = 1;
					
				}else{
					syoki = 0;
				}
				
				int a = syoki;
				
				
				for(int j = a;j <= (W -1 + a);j++) {
					
					if(j % 2 == 1) {
						System.out.print("#");
						
					}else {
						System.out.print(".");
						
					}
					
					
				}
				
				System.out.println("");
				
			}
			
			System.out.println("");
			
			
		}
				
	}
}


Measured memory_bytes: 35416
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Text.Printf
import Debug.Trace

getInts :: IO [Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

main = do
  [x] <- getInts
  putStrLn $ if x < 1200 then "ABC" else "ARC"


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
// using Graph = vector<vector<int>>;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int n, a, b, c;
int ans = 0;
vector<int> l;

// no...使用済みの本数,x...Aの長さ,...
int dfs(int no, int x, int y, int z) {
  if (no == n) {
    if (!x || !y || !z) return INF;
    return abs(a - x) + abs(b - y) + abs(c - z) -
           30;  // 30は1つもない状態から竹を追加するときにmergeのぶん足しているから
  }
  int x1 = dfs(no + 1, x, y, z);
  int x2 = dfs(no + 1, x + l[no], y, z) + 10;
  int x3 = dfs(no + 1, x, y + l[no], z) + 10;
  int x4 = dfs(no + 1, x, y, z + l[no]) + 10;
  return min({x1, x2, x3, x4});
  return ans;
}

int main() {
  cin >> n >> a >> b >> c;
  l.resize(n);
  rep(i, n) cin >> l[i];
  cout << dfs(0, 0, 0, 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string> 
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define rev(a) a.rbegin(),a.rend()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >



void solve(){
    //ll m = 0, n = 0, i = 0, j = 0, k = 0, ma = -1e9, mi = 1e9, ans = 0, cnt = 0;
    ll n, i;
    char arr[26], start = 'a';
    string res = "";
    arr[0] = 'z';
    f(i, 1, 26){
        arr[i] = start + (i - 1);
        //cout<<arr[i];
    }
    cin>>n;
    while(true){
        res += arr[(n % 26)];
        if(n == 26) break;
        if(n % 26 == 0) n--;
        n /= 26;
        if(n == 0){
            break;
        }
    }
    reverse(all(res));
    cout<<res<<"\n";
}

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

    /* ll t;
    cin>>t;
    while(t--){ */
        solve();
    /* } */

}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define bs binary_search
#define ll long long int
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m); t=(t*t)%m; if(b&1)t=(t*a)%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ipr pair<ll,ll>
#define ps push_back
#define fs first
#define sc second
#define mkp make_pair
#define mod 1000000007
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,m,l,n;
	cin>>n>>m;

	ll fe[m+1]={0};
	for(i=1;i<=n;i++){
		cin>>k;
		for(j=0;j<k;j++){
			cin>>l;
			fe[l]++;
		}
	}

	ll c=0;
	for(i=1;i<=m;i++){
		if(fe[i]>=n) c++;
	}
	cout<<c;
	return 0;
}
//ctrl H replace

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

int main(){
 int W, H, x, y, r;
 cin >> W >> H >> x >> y >> r;
 if(x>=r && x+r <=W && y>=r && y+r <=H){
  cout << "Yes" << endl; }else{
  cout << "No" << endl; }
 return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t,d,k;
    ll l,r;
    cin>>l>>r;
    if(r-l>=2019)
    {
        cout<<"0";
        return 0;
    }
    ll ans=INT_MAX;
    for(i=l;i<=r;i++) for(j=l;j<=r;j++)
    {
        a=i*j;
        if(i<j)
            ans=min(ans,a%2019);
    }
    cout<<ans;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int n,q;
	cin>>n>>q;
	int y;
	string s,ans="kogakubu10gokan";
	rep(i,0,n){
		cin>>y>>s;
		if(y<=q) ans=s;
	}
	o(ans);
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    int k, x, y;
    cin >> k >> x >> y;
    if (k == (abs(x) + abs(y))) {
        printf("1\n%d %d\n", x, y);
        return 0;
    }
    bool swaped = false;
    bool xinversed = false;
    bool yinversed = false;
    if (x < 0) {
        x = x * -1;
        xinversed = true;
    }
    if (y < 0) {
        y = y * -1;
        yinversed = true;
    }
    if (x < y) {
        swap(x, y);
        swaped = true;
    }
    int d = x + y;
    int n = max(2, (d + (k - 1)) / k);
    pair<int, int> pos;
    pos.first = 0; pos.second = 0;
    vector<pair<int, int>> ans;
    if ((n * k - d) % 2 == 1) {
        if (k % 2 == 0) {
            printf("-1\n");
            return 0;
        }
        n++;
    }
    if (n == 3) {
        int a = (n * k - d) / 4;
        int b = (n * k - d - 2 * a) / 2;
        while(pos.first > (-1 * b)) {
            pos.first -= k;
            pos.second += max(0, -1 * pos.first - b);
            pos.first = max(pos.first, -1 * b);
            ans.emplace_back(pos.first, pos.second);
        }
        while(pos.second < (a + y)) {
            pos.second += k;
            pos.first += max(0, pos.second - (a + y));
            pos.second = min(pos.second, a + y);
            ans.emplace_back(pos.first, pos.second);
        }
        while(pos.first < x) {
            pos.first += k;
            pos.second -= max(0, pos.first - x);
            pos.first = min(pos.first, x);
            ans.emplace_back(pos.first, pos.second);
        }
        while(pos.second > y) {
            pos.second -= k;
            ans.emplace_back(pos.first, pos.second);
        }
    }
    else {
        int a = (n * k - d) / 2;
        while(pos.second < (a + y)) {
            pos.second += k;
            pos.first = max(0, pos.second - (a + y));
            pos.second = min(pos.second, a + y);
            ans.emplace_back(pos.first, pos.second);
        }
        while(pos.first < x) {
            pos.first += k;
            pos.second -= max(0, pos.first - x);
            pos.first = min(pos.first, x);
            ans.emplace_back(pos.first, pos.second);
        }
        while(pos.second > y) {
            pos.second -= k;
            ans.emplace_back(pos.first, pos.second);
        }
    }
    printf("%d\n", sz(ans));
    rep(i, sz(ans)) {
        int tx = ans[i].first, ty = ans[i].second;
        if (swaped) swap(tx, ty);
        if (xinversed) tx = tx * -1;
        if (yinversed) ty = ty * -1;
        printf("%d %d\n", tx, ty);
    }
    return 0;
}


Measured memory_bytes: 3952
#include <iostream>

int main(int argc, char const* argv[])
{
	int W, H, x, y, r;
	std::cin >> W >> H >> x >> y >> r;

	if (x-r < 0 || W < x+r || y-r < 0 || H < y+r) {
		std::cout << "No" << std::endl;
	} else {
		std::cout << "Yes" << std::endl;
	}
	return 0;
}



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

using namespace std;

#define ll long long

ll n, x, ans;

void gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (!b) return ;
    // printf("%lld %lld\n", a, b);
    ans += 2 * (a / b) * b;
    if (a % b == 0) ans -= b;
    gcd(b, a % b);
}

int main() {
    cin >> n >> x;
    ans = n;
    gcd(n - x, x);
    cout << ans << endl;
    return 0;
}

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

int k, a, b;

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> k >> a >> b;
    for (int i = a; i <= b; i++)
    {
        if (i % k == 0)
        {
            cout << "OK" << '\n';
            return 0;
        }
    }

    cout << "NG" << '\n';
}

Measured memory_bytes: 3648
#include <stdio.h>

#define tsort long
#define smaxn 200000 //最大要素数
#define smxbit 50 //要素のうち最大の数値のビット数
#define snobit 17 //1-smxbitの間で調整、増やせば速いがメモリを消費する
#define rev 1     //0で昇順、1で降順
#define snosc (1<<(snobit+1))

int sort(tsort *vlist,int *plist,int n){
  int h,i,j,k,l,m,s,p,qlist[smaxn],c[snosc][3],ss;
#if rev
  ss=snosc-1;
#else
  ss=0;
#endif
  tsort vj,vk,mx[snosc];
  for(i=0;i<snosc;i++){
    c[i][0]=-1;
    c[i][1]=-1;
  }
  for(i=0;i<n;i++){
    l=(int)(vlist[i]>>(smxbit-snobit))&(snosc-1)^(1<<snobit);
    if(c[l][0]==-1){
      c[l][0]=i;
      c[l][2]=i;
      mx[l]=vlist[i];
    }else{
      qlist[c[l][1]]=i;
#if rev
      if(vlist[i]<mx[l]){
#else
      if(vlist[i]>mx[l]){
#endif
        c[l][2]=i;
        mx[l]=vlist[i];
      }
    }
    c[l][1]=i;
    plist[i]=-1;
  }
#if rev
  for(h=snosc-1;h>=0;h--){
#else
  for(h=0;h<snosc;h++){
#endif
    s=c[h][0];
    if(s==-1){
#if rev
      if(h==ss) ss--;
      if(h!=snosc-1) c[h][1]=c[h+1][1];
#else
      if(h==ss) ss++;
      if(h!=0) c[h][1]=c[h-1][1];
#endif
      continue;
    }
    qlist[c[h][1]]=-1;
    while(qlist[s]!=-1){
      i=s;
      p=-1;
      while(i!=-1){
        j=i;
        k=qlist[j];
        if(k==-1) break;
        i=qlist[k];
#if rev
        if(vlist[j]<vlist[k])
#else
        if(vlist[j]>vlist[k])
#endif
        {
          if(p==-1){
            s=k;
          }else{
            qlist[p]=k;
          }
          l=j;
          j=k;
          k=l;
        }
        qlist[j]=i;
        p=j;
        vj=vlist[j];
        vk=vlist[k];
        while(k!=-1){
#if rev
          if((j==-1)|(vj<vk))
#else
          if((j==-1)|(vj>vk))
#endif
          {
            l=plist[k];
            plist[k]=plist[m];
            plist[m]=k;
            m=k;
            k=l;
            vk=vlist[k];
          }else{
            m=j;
            j=plist[j];
            vj=vlist[j];
          }
        }
      }
    }
    if(h==ss){
      c[h][0]=s;
    }else{
#if rev
      plist[c[h+1][1]]=s;
#else
      plist[c[h-1][1]]=s;
#endif
    }
    for(i=c[h][2];i!=-1;i=plist[i]) j=i;
    c[h][1]=j;
  }
  return(c[ss][0]);
}

int main(){
  int n,i,j,m,p[smaxn];
  long v[smaxn],l;
  char s[11];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",&s);
    v[i]=0;
    for(j=0;s[j]!=0;j++){
      v[i]|=((long)(s[j]-'a'+1))<<(45-j*5);
    }
  }
  m=1;
  i=sort(&v,&p,n);
  l=v[i];
  for(i=p[i];i!=-1;i=p[i]){
    if(l!=v[i]){
      l=v[i];
      m++;
    }
  }
  printf("%d",m);
  return(0);
}


Measured memory_bytes: 8608
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define gsort(arr) sort(arr, arr+n, greater<ll>()); 
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sync2 cout<<fixed<<setprecision(10)
const ll inf=1e9+7;
const ll inf2=inf*inf;
#define pi 3.14159265358979323846
#define for0(i,n) for (int i = 0; i <(int)n; i++)
#define for1(i,n) for (int i = 1; i<=(int)n; i++)
#define all(vv) vv.begin(),vv.end()
priority_queue <ll, vector<ll>, greater<ll>> mnheap;
priority_queue <ll> mxheap;
#define vc(vv) vector<ll> vv;
ll gcd(ll x,ll y){if (x == 0)return y;return gcd(y%x, x);}
int is_prime(ll x) {if(x<2)return 0;for(ll i=2;i*i<=x;i++){if(x%i==0)return 0;}return 1;}
inline ll modpw(ll x, ll y, ll z) {ll res=1;x=x%z;while(y){if(y&1) res=(res*x)%z;x=(x*x)%z;y/=2;}return res;}
inline ll modinv(ll x,ll z){return modpw(x,z-2,z);}
ll lcm(ll x,ll y){return (x*y)/gcd(x,y);}
#define pYES cout<<"YES"<<endl
#define pNO cout<<"NO"<<endl

ll dp[100005];
int main()
{
     sync;
     int t;
     //cin>>t;
     t=1;
     while(t--)
     {
          int n;
          cin>>n;
          ll a[n];
          for0(i,n)cin>>a[i]; 
          dp[0]=0;
          for(int i=1;i<n;i++)
          {
               if(i==1)
               {
                    dp[i]=abs(a[i]-a[i-1]);
                    continue;
               }
               dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
          }
          cout<<dp[n-1]<<endl;
     }
}

Measured memory_bytes: 5144
N = int(input())
ans = []
q = 1
while q != 0:
    q, r = divmod(N, 26)
    if r == 0:
        r = 26
        q = q - 1
    ans.append(int(r))
    N = (N - r)/26
l = len(ans)
Ans = 'a'
for i in range(l):
    Ans += chr(ans[i]+96)
print(Ans[l:0:-1])    

Measured memory_bytes: 9188
#include<stdio.h>
#include<vector>
#include<string>
#include<iostream>
using namespace std;

void solve(){
    
}
int main() {
    string s;
    cin>>s;
    int c,f;
    c=0,f=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='C')c=1;
        if(s[i]=='F'&&c>0)f=1;
    }
    if(c>0&&f>0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 10010
typedef long long ll;
typedef long double ld;
const int MINI INT_MIN;
const ll MINL LLONG_MIN;
string s;
int main(){
    ios_base::sync_with_stdio(0);
    cin>>s;
    if (s=="ABC") cout <<"ARC"<< endl;
    else cout <<"ABC"<< endl;
}


Measured memory_bytes: 3608