akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
long long min(long long a,long long b){return (a<b)?a:b;}
int main(void)
{
  long long A,B,N,x;
  x=scanf("%lld %lld %lld",&A,&B,&N);
  x=min(N,B-1);
  return printf("%lld",(A*x)/B-(x/B)*A),0;
}

Measured memory_bytes: 1708
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

const int MAX = 1e5+1;
bool isprime[MAX];
int is_similar[MAX];

void era(){
    memset(isprime, true, sizeof(isprime));
    isprime[0] = false;
    isprime[1] = false;

    for(int i=2;i<MAX;i++){
        if(isprime[i]){
            int j=2*i;
            while(j<MAX){
                isprime[j] = false;
                j += i;
            }
        }
    }
}

bool is_sim(int N){
    if(N%2==0) return false;

    return isprime[N] && isprime[(N+1)/2];
}

void count(){
    memset(is_similar, 0, sizeof(is_similar));
    for(int i=0;i<MAX;i++){
        if(is_sim(i)) is_similar[i]++;
    }
    for(int i=1;i<MAX;i++){
        is_similar[i] += is_similar[i-1];
    }
}

int main(){
    era();
    count();
    int Q; cin >> Q;
    int l,r;
    for(int i=0;i<Q;i++){
        cin >> l >> r;
        cout << is_similar[r] - is_similar[l-1] << endl;
    }
    return 0;
}



Measured memory_bytes: 1152
N = int(input())
A = list(map(int, input().split()))

A.sort()


ncand = A[-1]

ccand = A[0]
nhalf = ncand // 2
diff = abs(nhalf - ccand)

for i in range(1, N-1):
    d = abs(nhalf - A[i])
    if diff >= d:
        ccand = A[i]
        diff = d

print(ncand, ccand)


Measured memory_bytes: 14428
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    ll a, b;
    cin >> a >> b;
    if(a == b){
        cout << a << endl;
        return 0;
    }
    if(b - a == 1){
        cout << (a ^ b) << endl;
        return 0;
    }

    ll ans = 0;
    if(a % 2 != 0){
        ans ^= a;
        ++a;
    }
    if(b % 2 == 0){
        ans ^= b;
        --b;
    }
    ans ^= (b - a + 1) / 2 % 2 != 0;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    ll n,sum=0;
    cin>>n;
    ll ans=n;
    while(n>0){
        int a=n%10;
        sum+=a;
        n=n/10;
    }
    if(ans%sum==0) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3612
import math
q,h,s,d = map(int,input().split())
n = int(input())
value = [0]*4
value[0] = q*4
value[1] = h*2
value[2] = s
value[3] = d/2
dum = min(value)
ind = value.index(dum)
if ind == 0:
    print(value[0]*n)
elif ind == 1:
    print(value[1]*n)
elif ind == 2:
    print(value[2]*n)
else:
    if n == 1:
        value.sort()
        print(value[1])
    elif n%2 == 0:
        print(math.floor(d*n//2))
    else:
        dum1 = (n//2)*d
        value.sort()
        print(math.floor(value[1]+dum1))

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define MOD 1000000007
#define PI 3.1415926535897932
#define rep(i, n) for (int i = 0; i < n; i++)
#define repe(i, j, n) for (int i = j; i < n; i++)
#define repi(i, n) for (int i = 0; i <= n; i++)
#define repie(i, j, n) for (int i = j; i <= n; i++)
#define all(x) x.begin(), x.end()
#define println() cout << endl
#define P pair<int, int>
#define fi first
#define se second

typedef long long ll;

long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

void solve1()
{
    int n, m; cin >> n >> m;
    vector<int> a(m), b(m);
    UnionFind g(10000000);
    set<int> s;
    rep(i, m) {
        cin >> a[i] >> b[i];
        g.unite(a[i], b[i]);
        s.insert(a[i]);
        s.insert(b[i]);
    }

    int ans = 0;
    int st = *s.begin();
    rep(i,n) {
        if(!g.same(i+1, st)) {
            g.unite(i+1, st);
            ans ++;
        } 
    }
    cout << ans << endl;


}

int main()
{
    solve1();
}


Measured memory_bytes: 47088
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let mut it = line
        .trim()
        .split_whitespace()
        .map(|x| x.parse::<i32>().ok().unwrap());
    let (n, r) = (it.next().unwrap(), it.next().unwrap());
    if n >= 10 {
        println!("{}", r);
    } else {
        println!("{}", r + 100 * (10 - n));
    }
}


Measured memory_bytes: 2108
# -*- coding: utf-8 -*-

n, m = map(int, input().split())

A = {}
for i in range(1, n+1):
    A[i] = 0
for i in range(m):
    data = list(map(int, input().split()))
    A[data[0]] += 1
    A[data[1]] += 1

for i in range(1, n+1):
    print(A[i])


Measured memory_bytes: 3060
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {
	char a,b,c;
	public void solve() {
		a = next().charAt(0);
		b = next().charAt(0);
		c = next().charAt(0);

		String s = ""+((char)((a-'a')+'A')) + ((char)((b-'a')+'A')) + ((char)((c-'a')+'A'));
		out.println(s);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

Measured memory_bytes: 23124
#!/usr/bin/env python3
import sys

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B = map(int, readline().split())


def solve():
    W = 100
    hw = B // 25 + 2
    hb = A // 25 + 2
    H = hw + hb
    grid = [[i >= hw] * W for i in range(H)]  # true => black

    def paint_black():
        black = 1
        for r in range(0, hw - 1, 2):
            for c in range(0, W, 2):
                if black == B:
                    return
                grid[r][c] = True
                black += 1

    def paint_white():
        white = 1
        for r in range(hw + 1, H, 2):
            for c in range(0, W, 2):
                if white == A:
                    return
                grid[r][c] = False
                white += 1

    paint_black()
    paint_white()
    return grid


def print_grid(grid):
    h, w = len(grid), len(grid[0])
    print(h, w)
    for r in range(h):
        for c in range(w):
            if grid[r][c]:
                print("#", end="")
            else:
                print(".", end="")
        print()


if __name__ == "__main__":
    print_grid(solve())


Measured memory_bytes: 3828
#include<stdio.h>
#include<string.h>

int main(){
char s[100];
int i;
int n;
int a=0,b=0,c=0,g=0;
scanf("%d",&n);

	for(i=0;i<n;i++){
	scanf("%*c%c",&s[i]);
	}
	
//printf("%s\n",s);
for(i=0;i<n;i++){
	if(s[i]=='P'){
		a++;
		
	}else
	if(s[i]=='W'){
		b++;
	}else
	if(s[i]=='G'){
		
		c++;
	}else
	if(s[i]=='Y'){
		g++;
		
	}
	
	
	
	
}
//printf("%d%d%d%d\n",a,b,c,g);
if(a>0&&b>0&&c>0&&g>0){
	printf("Four\n");
	
}else{
	printf("Three\n");
	
}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

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

int main()
{
	string s;
	cin >> s;
	int n = s.size();
	vector<ll> v(n,0);
	int x = 1;
	int tot = 0;
	ll ans = 0;
	for (int i = n - 1; i >= 0; i--)
	{
		tot += (s[i] - '0') * x;
		tot %= 2019;
		v[tot] += 1;
		x = x * 10 % 2019;
		ans += v[tot];
	}
	cout << ans - (n - v[0]) << endl;
	return 0;
}


Measured memory_bytes: 5220
//                             In The Name Of Allah
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 1e6 + 100, OO = 1e16 + 7, T = 13, M = 1e9 + 7, P = 6151, SQ = 800, lg = 32;
typedef pair <int, int> pii;
int dp[N];

int32_t main() {
	use_fast;
	int n, k, c;
	cin >> n >> k >> c;
	string s;
	cin >> s;
	for(int i = n; i >= 1; i--) {
		if(s[i - 1] == 'x') {
			dp[i] = dp[i + 1];
			continue;
		}
		else 
			dp[i] = dp[i + c + 1] + 1;
	}
	int t = 0, num = 0;
	for(int i = 1; i <= n; i++) {
		if(s[i - 1] == 'x' || t >= i)
			continue;
		if(num + dp[i + 1] < k) 
			cout << i << endl;
		t = i + c;
		num++;
	}
	return 0; 
} 
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- ... 
*/

Measured memory_bytes: 3348
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;double a,b,r=0;
	scanf("%d%lf%lf",&n,&a,&b),a-=b;
	for(int i=n;i;i--){
		r+=a+b*i+0.5*b;
		a+=a/i+1.5*b/i;
		b+=b*2.0/i;
	}
	printf("%.10lf\n",r);
} 

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;


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


        int N = scan.nextInt();
        int K = scan.nextInt();
        List<Integer> l = new ArrayList<>();
        for (int i : IntStream.range(0, N).toArray()){
            l.add(scan.nextInt());
        }
        System.out.println(l.stream().sorted(Comparator.reverseOrder()).mapToInt(Integer::valueOf).limit(K).sum());
    }

}

Measured memory_bytes: 27092
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<int> p(n);
	for(int i = 0; i < n; i++) scanf("%d", &p[i]);
	
	int ans = 0;
	for(int i = 1; i < n - 1; i++) {
		std::vector<int> vec = {p[i - 1], p[i], p[i + 1]};
		sort(begin(vec), end(vec));
		
		ans += (vec[1] == p[i]);
	}
	printf("%d\n", ans);
	return 0;
}


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

int main(void)
{
	char s[11];
	int f=0,t=0,i;
	scanf("%s",s);
	if(s[0]!='A')f=1;
	for(i=2;i<strlen(s)-1;i++)if(s[i]=='C')t++;
	if(t!=1)f=1;
	t=0;
	for(i=0;i<strlen(s);i++)if('a'>s[i]||s[i]>'z')t++;
	if(t!=2)f=1;
	puts(f?"WA":"AC");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define N 500005
const int mod = 1e9+7;
using namespace std;
char s[N];
int n, a[N], nxt[3], f[N];
inline void solve() {
  for (int i = 0; i < 3; i++)
    if (i == a[n]) nxt[i] = n;
    else nxt[i] = n+1;
  f[n] = 1;
  for (int i = n-1; i; i--) {
    f[i] = (a[i] == a[n]);
    for (int c = 1; c <= 2; c++) {
      f[i] = (f[i] + f[nxt[(a[i]+c)%3]])%mod;
    }
    nxt[a[i]] = i;
  }
  printf("%d\n", (f[nxt[1]] + f[nxt[2]]) % mod);
}
int main() {
  scanf("%s",s+1);
  n = strlen(s+1);
  for (int i = 1; i <= n; i++) 
    a[i] = (a[i-1]+s[i]-'a'+1)%3;
  for (int i = 2; i <= n; i++)
    if (s[i] == s[i-1]) {
      solve();
      return 0;
    }
  puts("1");
  return 0;
} 

Measured memory_bytes: 2816
# -*- coding: utf-8 -*-


def is_kaibun(s):
    return s == s[::-1]


def main():
    s = input()
    i = len(s)

    check_1 = s[:int((i - 1) / 2)]
    check_2 = s[int(((i - 1) / 2) + 1):]
    if is_kaibun(s) and is_kaibun(check_1) and is_kaibun(check_2):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
  ll n;cin >> n;
  
  vector<ll> a(n);//要素nの配列
  for(ll i=0;i<n;++i) cin >> a.at(i);
  sort(a.begin(),a.end());//小さい順にソート
  reverse(a.begin(),a.end());//配列逆順にする

  ll ans = 0;
  ll cnt = 1;
  for(ll i=0;i<n;++i){
    if( i == 0 ){
      ans += a.at(i);
      cnt++;
      if( cnt == n ) break;
      continue;
    }

    ans += a.at(i);
    cnt++;
    if( cnt == n ) break;

    ans += a.at(i);
    cnt++;
    if( cnt == n ) break;
  }

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



Measured memory_bytes: 4732
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

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

    string s;
    int i=0,x = 0;
    cin >> s;
    while(s[i]) {
        x = x ^ s[i];
        i++;
    }
    
    if(!x) cout << "Yes";
    else cout << "No";
    cout << "\n";
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
struct node{
	string s;
	int data,number;
}f[10000001];
bool cmp(node &a,node &b){
	if(a.s != b.s) return a.s < b.s;
	else return a.data > b.data;
}
int main(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> f[i].s >> f[i].data;
		f[i].number = i;
	}
	sort(f+1,f+1+n,cmp);
	for(int i = 1; i <= n; i++) cout << f[i].number << endl;
}

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

int main(){
    char s;

    cin>>s;

    if(s>='a' && s<='z'){
        cout<<"a"<<endl;
    }else if(s>='A' && s<='Z'){
        cout<<"A"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    double L; cin >> L;
    cout << pow(L / 3, 3) << endl;
    return 0;
}


Measured memory_bytes: 256
Imports System

Module Main
    Sub Main(args As String())
        Dim n As Integer = Console.ReadLine
        Dim words(n - 1) As String
        words(0) = Console.ReadLine
        Dim ans As String = "Yes"
        Dim i As Integer
        Dim str As String

        For i = 1 To n - 1
            str = Console.ReadLine
            '重複していなければ配列に入れる
            Dim test As Integer = Array.IndexOf(words, str)
            If test = -1 Then
                words(i) = str
                '現在行の単語の最後の一文字と、前の単語の最後の一文字が同じかどうか
                If Not words(i).Substring(0, 1).Equals(words(i - 1).Substring(words(i - 1).Length - 1, 1)) Then
                    ans = "No"
                    Exit For
                End If
            Else
                ans = "No"
                Exit For
            End If
        Next
        Console.WriteLine(ans)
        Console.ReadKey(True)
    End Sub
End Module


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


string s;
long long n,ans;
 
void F(long long x,long long y){
	if(x==n){
		ans+=y;
		return;
	}
	long long sum=0;
	for(int i=x;i<n;i++){
		sum=(sum*10)+(s[i]-'0');
		F(i+1, sum+y);
	}
}
 
int main(){
	cin >> s;
	n=s.size();
	F(0,0);
	
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define MAX 51
#define MAX_M 5001
typedef pair<int,int> pii;

int main(){
    int X,Y,Z,N,E,A;
    while(cin >> X >> Y >> Z, X){
        pii M[MAX];
        vector<int> V(X);
        for(int i = 0 ; i < X ; i++){
            cin >> V[i];
        }
        for(int i = 0 ; i < MAX ; i++){
            M[i] = pii(-1,-1);
        }
        for(int i = 0 ; i < Z ; i++){
            cin >> N >> E >> A;
            M[N] = pii(E,A);
        }
        double dp[MAX][MAX_M] = {{0}};
        dp[0][0] = 1;
        for(int i = 0 ; i < Y ; i++){
            for(int j = 0 ; j < MAX_M ; j++){
                if(dp[i][j] == 0) continue;
                for(int k = 0 ; k < X ; k++){
                    int next = min(i+V[k], Y);
                    int v = M[next].first;
                    int v2 = M[next].second;
                    if(v == -1){
                        dp[next][j] += dp[i][j]/X;
                    }else if(v == 2){
                        dp[next][min(j+v2,MAX_M-1)] += dp[i][j]/X;
                    }else if(v == 3){
                        dp[next][max(j-v2,0)] += dp[i][j]/X;
                    }else{
                        next = min(next+v2,Y);
                        dp[next][j] += dp[i][j]/X;
                    }
                }
            }
        }
        double res = 0;
        for(int i = 0 ; i < MAX_M ; i++){
            res += i*dp[Y][i];
        }
        cout << (int)res << endl;
    }
    return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long
const int N=1e5+5;



void solve()
{
   string s,t;
   cin>>s>>t;
   
   //t is substring of s
   
   int n=s.size(),m=t.size();
   int ans=INT_MAX;
   for(int i=0;i<=n-m;i++)
   {
       int change=0;
       for(int j=i,cnt=0;cnt<m;cnt++,j++)
       {
           if(s[j]!=t[cnt])
           {
               change++;
           }
       }
       ans=min(ans,change);
   }
   cout<<ans;
}

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    
	int t=1;
//	cin>>t;
	while(t--)solve();
	    
  
}




Measured memory_bytes: 3612
import java.util.*;

class Point {
  double x;
  double y;

  public Point(double deg, double r) {
    double rad = deg * Math.PI / 180.0;
    x = Math.cos(rad) * r;
    y = Math.sin(rad) * r;
    // System.out.printf("[%f, %f]\n", x, y);
  }

  public double getX() {
    return x;
  }

  public double getY() {
    return y;
  }

  public double distance(Point b) {
    double c = Math.pow(x - b.getX(), 2);
    double d = Math.pow(y - b.getY(), 2);
    return Math.sqrt(c + d);
  }

  public void show() {
    System.out.printf("[%f, %f]\n", x, y);
  }
}

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    try {
      double a = scanner.nextDouble();
      double b = scanner.nextDouble();
      double h = scanner.nextDouble();
      double m = scanner.nextDouble();

      // 長針
      Point bigHand = new Point(m * 6.0, b);

      // 短針
      Point smallHand = new Point(h * 30.0 + m * 0.5, a);

      double ans = bigHand.distance(smallHand);
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  }
}

Measured memory_bytes: 37316
import sys

class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0]*n
        self.weight = [0]*n
    
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y
    
    def union(self, x, y, w):
        px = self.find(x)
        py = self.find(y)
        d = w - self.weight[x] + self.weight[y]
        if self.rank[px] < self.rank[py]:
            self.par[px] = py
            self.weight[px] = d
        else:
            self.par[py] = px
            self.weight[py] = -d
            if self.rank[px] == self.rank[py]:
                self.rank[px] += 1
    
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]

N,M = map(int,input().split())
G = WeightedUnionFind(N)

for i in range(M):
    l,r,d = map(int,input().split())
    l -= 1
    r -= 1
    if G.same(l,r):
        if G.diff(l,r) != d:
            print("No")
            sys.exit()
    else:
        G.union(l,r,d)
    
print("Yes")

Measured memory_bytes: 11640
#include <iostream>
#include <cassert>
#include <cstdio>
#include <cctype>
#include <string>
#include <vector>

namespace {
  
int operate(char op, int arg1, int arg2)
{
  switch (op) {
  case ')':
  case '=': return arg1;
  case '+': return arg1 + arg2;
  case '-': return arg1 - arg2;
  case '*': return arg1 * arg2;
  case '/': assert(arg2 != 0); return arg1 / arg2;
  }
  assert(0);
}

int evaluate(std::string& str, size_t first, size_t last)
{
  size_t current = 0;
  std::vector<int> arg;
  std::vector<char> op;

  arg.push_back(0);
  
  for (size_t pos = first; pos <= last; ) {
  	
    // 数字
    if (isdigit(str[pos])) {
      arg[current] = (arg[current] * 10) + (str[pos] - '0');
       ++pos;
      continue;
    }

    // 括弧
    if (str[pos] == '(') {
      size_t paren_end = pos + 1;
      int nest = 0;

      // 括弧に対応する閉じ括弧の場所を検索
      for (; paren_end <= last; ++paren_end) {
        if (str[paren_end] == ')') {
          if (!nest) break;
          else --nest;
        }
        else if (str[paren_end] == '(') {
          ++nest;
        }
      }

      assert(paren_end != last + 1);
      arg[current] = evaluate(str, pos + 1, paren_end);
      pos = paren_end + 1;
      continue;
    }

    // 演算子
    op.push_back(char(str[pos]));
    if (current == 0) {
      ++current;
      arg.push_back(0);
      ++pos;
      continue;
    }

    if (op[current - 1] == '*' || op[current - 1] == '/') {
      arg[current - 1] = operate(op[current - 1], arg[current - 1], arg[current]);
      op[current - 1] = op[current];
      arg[current] = 0;
      op.pop_back();
    } 
    else {
      ++current;
      arg.push_back(0);
    }
    ++pos;
  }
  
  // + -
  
  for (size_t i = 1; i < current; ++i) {
  	arg[0] = operate(op[i - 1], arg[0], arg[i]);
  }
  
  return arg[0];
}

} // unnamed namespace

int main()
{
  int n;
  std::cin >> n;
  
  for (int i = 0; i < n; ++i) {
    std::string exp;
    std::cin >> exp;

    std::cout << evaluate(exp, 0, exp.size()) << std::endl;
  }

  return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

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

    int m = 1e9;
    for (int i = 0; i < S.size() - 2; ++i){
        int x = ( S[i + 0] - '0') * 100 
              + ( S[i + 1] - '0') * 10
              + ( S[i + 2] - '0') * 1;
        m = min(m, abs(x-753));
    }
	cout << m << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define INPUT_MAX	3

int main(void)
{
	int num[INPUT_MAX];
	int five = 0;
	int seven = 0;
	int idx;

	scanf("%d %d %d", &num[0], &num[1], &num[2]);

	for (idx = 0; idx < INPUT_MAX; idx++) {
		if (num[idx] == 5) {
			five++;
		}
		if (num[idx] == 7) {
			seven++;
		}
	}

	if ((five == 2) && (seven == 1)) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

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

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

    ll N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    Rep (i, N) {
        if ((N-1-i)*C-i*D <= B-A && B-A <= (N-1-i)*D-i*C) {
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    private static int calcScore(int[] hand, int n, boolean[] flag) {
        boolean ace = false;
        int[] score = new int[2];
        for (int i = 0; i < n; i++) {
            if (hand[i] == 1 && !ace) {
                score[0] += 1;
                score[1] += 11;
                ace = true;
            } else {
                score[0] += hand[i];
                score[1] += hand[i];
            }
        }
        if (score[1] < 22) {
            flag[0] = ace;
            return score[1];
        } else {
            flag[0] = false;
            return score[0];
        }
    }
    private static int toInt(char c) {
        if (Character.isDigit(c)) {
            return c - '0';
        } else {
            switch (c) {
                case 'T':
                case 'J':
                case 'Q':
                case 'K':
                    return 10;
                case 'A':
                    return 1;
            }
        }
        return 0;
    }
    private static void solve() {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();

        for (int i = 0; i < n; i++) {
            final char[] cards = new char[10];
            for (int j = 0; j < 10; j++) {
                cards[j] = scanner.next().charAt(0);
            }
            final int[] hand = new int[10];
            hand[0] = toInt(cards[0]);
            int index = 1;
            int score = 0;
            for (; index < 10; index++) {
                hand[index] = toInt(cards[index]);
                boolean[] flag = new boolean[1];
                score = calcScore(hand, index + 1, flag);
                if (!(score < 17 || (score == 17 && flag[0]))) {
                    break;
                }
            }
            if (score > 21) {
                System.out.println("bust");
            } else if (score == 21 && index == 1) {
                System.out.println("blackjack");
            } else {
                System.out.println(score);
            }
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 12000
#define _GLIBCXX_DEBUG
#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++)
#define all(v) v.begin(), v.end()

int main(){
  int64_t N;
  cin >> N;
  int64_t cnt = N-1;
  vector<int64_t> div1(floor(sqrt(N))+1,0);
  vector<int64_t> div2(floor(sqrt(N))+1,0);
  int64_t j = 0;
  
  rep2(i, 1, floor(sqrt(N))+1){
    if(N % i == 0){
      div1.at(j) = i;
      div2.at(j) = N / i;
      j++;
    }
  }
  j = 0;
  
  while(div1.at(j) != 0){
    if(div1.at(j) + div2.at(j) -2 < cnt){
      cnt = div1.at(j) + div2.at(j) -2;
    }
    j++;
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 15872
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_119
{
    class A
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            string s = Read();
            string[] ss = s.Split('/');
            int y = int.Parse(ss[0]);
            int m = int.Parse(ss[1]);
            int d = int.Parse(ss[2]);
            int val = y * 10000 + m * 100 + d;
            if (val <= 20190430)
            {
                WriteLine("Heisei");
            }
            else
            {
                WriteLine("TBD");
            }
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

int main() {
	int A; int B;
	cin >> A >> B;
	vector<int> sum(3);
	sum[0] = A * 2 - 1;
	sum[1] =  B * 2 - 1;
	sum[2] = A + B;
	sort(sum.begin(), sum.end(), greater<int>());
	cout << sum.at(0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int FFTMOD = 119 << 23 | 1;
const int INF = (int) 1e9 + 23111992;
const ll LINF = (ll) 1e18 + 23111992;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ull isqrt(ull k) {ull r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int mrand() {return abs((int) mt());}
#define db(x) cerr << "[" << #x << ": " << (x) << "] ";
#define endln cerr << "\n";

void chemthan() {
    int n, m, k; cin >> n >> m >> k;
    vi a(n), b(m);
    FOR(i, 0, n) cin >> a[i];
    FOR(i, 0, m) cin >> b[i];
    long long res = *min_element(all(a)) + *min_element(all(b));
    FOR(i, 0, k) {
        int x, y, c; cin >> x >> y >> c; x--, y--;
        chkmin(res, (long long) a[x] + b[y] - c);
    }
    cout << res << "\n";
}

int main(int argc, char* argv[]) {
    ios_base::sync_with_stdio(0), cin.tie(0);
    if (argc > 1) {
        assert(freopen(argv[1], "r", stdin));
    }
    if (argc > 2) {
        assert(freopen(argv[2], "wb", stdout));
    }
    chemthan();
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 1024
N, K = map(int, input().split())
A_list = list(map(int, input().split()))

rtn = 0
bit_max = 40

for i in range(bit_max)[::-1]:
    target = 1 << i
    hit_num = len([1 for i in A_list if i & target != 0])
    
    if N-hit_num > hit_num and K >= target:
        K -= target
        hit_num = N - hit_num
    
    rtn += target * hit_num
print(rtn)

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

int main(){
  int a,b;
  int n = 0;
  int k = 1;
  int i = 0;
  int x[200]={};
   
    
    
  while(i < 200 && cin >> a >> b){
      
      //条件に合わないデータの判定
      if(a < 0 || a > 1000000 || b < 0 || b > 1000000){
          cout << "データを入力し直してください!!" << endl;
          break;
      }
      
      else{
          i++;
          n = a+b;
          
    //桁数判定部分
    while(n/10 !=0){
        k++;
        n = n/10;
    }
          x[i-1] = k;
          k = 1;
      }
  }
    
    //表示部分
    for(int j = 0;j < i;j++)
        cout << x[j] << endl;
    
  return 0;
}



Measured memory_bytes: 2984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

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

int main(){
  ll N; cin>>N;
  ll b[N-1]; CINA(b,N-1);
  ll r = b[0];
  for(ll i=1;i<N-1;i++){
    r += min(b[i-1],b[i]);
  }
  r += b[N-2];
  cout << r;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
const ll MOD = 1000000007;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll N;
    cin>>N;
    
    ll ans=1;
    REP1(i,N){
        ans=(ans*i)%MOD;
    }
    cout<<ans;
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;


public class Main {

	ArrayList<LinkedList<Integer>> adjacent;
	Scanner sc;
	
	class Pair{
		int first;
		int second;
		Pair(int e1,int e2){
			first=e1;second=e2;
		}
	}
	
	int ni(){
		return sc.nextInt();
	}
	
	String bfs(int dep,int dest,int TTL,int n){
		LinkedList<Pair> que=new LinkedList<Pair>();
		que.addLast(new Pair(dep,1));

		boolean[] visited=new boolean[n];
		Arrays.fill(visited,false);
		visited[dep]=true;
		
		while(!que.isEmpty()){
			Pair node=que.pollFirst();
			if(node.first==dest)return Integer.toString(node.second);
				
			if(++node.second<=TTL){
				for(int next :adjacent.get(node.first)){
					if(!visited[next]){
						que.addLast(new Pair(next,node.second));
						visited[next]=true;
					}
				}
			}
		}
		return "NA";
	}

	void io(){
		sc=new Scanner(System.in);
		
		int n=ni();
		adjacent=new ArrayList<LinkedList<Integer>>();
		for(int i=0;i<n;++i)adjacent.add(new LinkedList<Integer>());

		for(int i=0;i<n;++i){
			int r=ni(), k=ni();
			for(int j=0;j<k;++j){
				adjacent.get(r-1).add(ni()-1);
			}
		}
		//debug(adjacent);
		
		int m=ni();
		for(int i=0;i<m;++i){
			int dep=ni()-1,dest=ni()-1,TTL=ni();
			System.out.println(bfs(dep,dest,TTL,n));
		}
	}
	
	void debug(Object...os){
		System.err.println(Arrays.deepToString(os));
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().io();
		
	}

}

Measured memory_bytes: 29056
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int n;
int x, y;
int t[105];
int ans;

int main() {
	while(~scanf("%d", &n)) {
		scanf("%d %d", &x, &y);
		for(int i = 1; i <= n; i++) scanf("%d", &t[i]);
		ans = y;
		for(int i = 1; i <= n; i++) {
			int tmp = 1;
			for(int j = 1; j <= x; j++) {
				if(tmp <= x) {
					tmp += t[i];
					ans++;
				}
				else break;
			}
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<numeric>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> d(n);
	for(int i=0;i<n;++i) cin>>d[i];
	sort(d.begin(),d.end());
	d.erase(unique(d.begin(),d.end()),d.end());
	cout << d.size() << endl;
	return 0;		
}
 

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

int main() {
    int i, N;
    string S;
    cin >> N;
    for(i = 0;i < N;i++) {
        cin >> S;
        if(S == "Y") {
            cout << "Four" << endl;
            break;
        }
    }
    if(i == N) {
        cout << "Three" << endl;
    }
}


Measured memory_bytes: 256
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]


from collections import deque

T = deque(sorted(T))

t_ref = T[0]

bus = 0
member = 0

while T != deque([]):
    t = T[0]
    if t - t_ref <= K and member < C:
        member += 1
        t_tmp = T.popleft()
#        print(t_tmp, 'ok')
#        print(member)
    else:
        bus += 1
        member = 0
        t_ref = T[0]
#        print()
#        print(t_ref, 'new')
if member > 0:
    bus += 1
#print()
print(bus)


Measured memory_bytes: 83852
import sys
l,r=map(int,input().split())
#2019の剰余の範囲を調べ、その中で全探索
l_2019=l%2019
r_2019=r%2019
#範囲が2019以上 -> 割り切れるものが1つ以上ある
if r - l >= 2019:
  print(0)
  sys.exit()
#範囲が2018以下かつ0またぐ -> 割り切れるものが1つ以上ある
if l_2019 > r_2019:
  print(0)
  sys.exit()
res=2018
for i in range(l_2019, r_2019):
  for j in range(i+1,r_2019+1):
    res = min(res, (i*j)%2019)
    if res==0:
      break
print(res)
    

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
 
int main(){ 
int n,a=0;
string s;
cin>>n>>s;
for(int i=0; i<n; i++){
  if(s[i]!=s[i+1]){
  a++;
  }
}
  cout<<a<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
//#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std;

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

    cout << ceil(n/2.0) << endl;
    return 0;
}
/** atcoder **/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

//struct edge {Int from, to;};
//typedef pair<int, Int> p;
const Int INF = 1e18;
vector<Int> a(200010);
vector<int> ans(200010);

vector<Int> dp(200010, INF);
vector<vector<int>> G(200010);


void dfs(int x, int last = -1) {

    int changed_index = lower_bound(dp.begin(),dp.end(),a[x]) - dp.begin();
    Int last_value = dp[changed_index];

    dp[changed_index] = a[x];

    ans[x] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin();

    for(int to : G[x]) {
        if(to == last) continue;
        dfs(to, x);
    }

    dp[changed_index] = last_value;
}

int main(){ 
    int N;
    vector<int> u(200010), v(200010);

    cin >> N;
    rep(i,N) cin >> a[i];
    rep(i,N-1) {
        int u, v; cin >> u >> v; u--; v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }


    dfs(0);

    rep(i,N) cout << ans[i] << endl;


}

Measured memory_bytes: 31220
s=input()
AKB={"AKIHABARA","KIHABARA","AKIHBARA","KIHBARA","AKIHABRA","KIHABRA","AKIHBRA","KIHBRA","AKIHABAR","KIHABAR","AKIHBAR","KIHBAR","AKIHABR","KIHABR","AKIHBR","KIHBR"}

print("YES" if s in AKB else "NO")


Measured memory_bytes: 8896
#include "bits/stdc++.h"
using namespace std;

const int N=1e5+20;

int n,m,u,v,dp[N][3],source,dest;
queue <pair <int,int>> q;
bool vis[N][3];
vector <int> adj[N];

void add(int node,int mod,int dist)
{
    q.push({node,mod});
    dp[node][mod]=dist;
    vis[node][mod]=true;
}

int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
    {
        scanf("%d%d",&u,&v);
        adj[u].push_back(v);
    }
    scanf("%d%d",&source,&dest);
    
    add(source,0,0);
    while(not q.empty())
    {
        auto p=q.front();
        q.pop();
        
        int node=p.first,mod=p.second;
        for(auto child:adj[node])
            if(not vis[child][(mod+1)%3])
                add(child,(mod+1)%3,dp[node][mod]+(mod!=2?0:1));
    }
    
    if(not vis[dest][0]) dp[dest][0]=-1;
    printf("%d",dp[dest][0]);
}

Measured memory_bytes: 7168