akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
const ll inf = 1e6+5;
typedef pair<int, bool> pib;

int main() {
    int n; cin >> n;
    int goal = n%100;
    int item = n/100;
    if (goal==0){cout << 1;exit(0);}
    queue <int> q;
    q.push(0);
    vector<int> p = {1,2,3,4,5};
    vector<bool> visit (goal+1);
    vector<int> dist(goal + 1, inf);
    visit[0] = true;
    dist[0] = 0;
    while (!q.empty()){
        int cur = q.front();
        q.pop();
        for (int j : p){
            if (cur + j <= goal && item >= min(dist[cur] +1, dist[cur + j]) && !visit[cur + j]){
                visit[cur + j] = true;
                dist[cur + j] = min(dist[cur] +1, dist[cur + j]);
                q.push(cur + j);
            }
        }
    }
    if (dist[goal] <= item){
        cout << 1;
    }
    else{
        cout << 0;
    }
}



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

using namespace std;

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

struct SegTree{
	int mx[1<<20];
	int s;
	void Init(int n,int *v){
		s=1;
		while(s<n)s*=2;
		REP(i,s)
			mx[i+s]=i<n?v[i]:0;
		for(int i=s-1;i>=1;i--)
			mx[i]=max(mx[i*2],mx[i*2+1]);
	}
	void Update(int i,int v){
		mx[i+=s]=v;
		while((i/=2)>=1)
			mx[i]=max(mx[i*2],mx[i*2+1]);
	}
	int Get(int b,int e,int l,int r,int i){
		if(e<=l||r<=b)
			return -1;
		if(b<=l&&r<=e)
			return mx[i];
		return max(Get(b,e,l,(l+r)/2,i*2),Get(b,e,(l+r)/2,r,i*2+1));
	}
	int Get(int b,int e){
		if(e<=b)
			return -1;
		else
			return Get(b,e,0,s,1);
	}
} seg;

int p[500000],idx[500001],n,k;

priority_queue<int> pq;
void Add(int i){
	if(seg.Get(max(0,i-k+1),min(n,i+k))<=p[i])
		pq.push(i);
}

int main(){
	n=read();
	k=read();
	REP(i,n)
		idx[p[i]=read()]=i;
	seg.Init(n,p);
	REP(i,n)
		Add(i);
	int x=n;
	while(!pq.empty()){
		int i=pq.top();
		pq.pop();
		if(p[i]<0)
			continue;
		p[i]=-(x--);
		seg.Update(i,-1);
		int g=seg.Get(i+1,min(n,i+k));
		if(g>0)
			Add(idx[g]);
		int h=seg.Get(max(0,i-k+1),i);
		if(h>0)
			Add(idx[h]);
	}
	REP(i,n)
		printf("%d\n",-p[i]);
}

Measured memory_bytes: 13680
n = gets.chomp.to_i
p_t, p_h = 0,0
for i in 1..n do
  s_t,s_h = gets.chomp.split(" ")
  if s_t > s_h
    p_t += 3
  elsif s_t < s_h
    p_h += 3
  else
    p_t += 1
    p_h += 1
  end
end
printf("%d %d\n",p_t,p_h)


Measured memory_bytes: 6864
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
using namespace std;
// type alias
typedef long long LL;
typedef vector < int > VI;
typedef unordered_map < int, int > MAPII;
typedef unordered_set < int > SETI;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// minmax
#define SMAX(a,b) a = max(a,b)
#define SMIN(a,b) a = min(a,b)
// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }

// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG x.cpp && ./a.out
// 21:00-21:04
const int MAX_N=1e2+1;
int N;
LL A[MAX_N];
void solve() {
  int res=0,cur=0;
  REP(i,N-1) {
    if(A[i]==A[i+1]) ++cur;
    else {
      res+=(cur+1)/2;
      cur=0;
    }
  }
  if(cur) res+=(cur+1)/2;
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>N;
  REP(i,N) cin>>A[i];
  solve();
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    int A[N];
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    int ans=0;
    bool flag=true;
    while(flag){
        flag=false;
        for(int i=N-1;i>0;i--){
            if(A[i]<A[i-1]){
                int v=A[i];
                A[i]=A[i-1];
                A[i-1]=v;
                ans++;
                flag=true;
            }
        }
    }
    for(int i=0;i<N;i++){
        cout<<A[i];
        if(i==N-1) cout<<endl;
        else cout<<' ';
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3096
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int p = in.nextInt();
            int ans = (3 * a + p) / 2;
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 23252
main :: IO ()
main = do ls <- getContents
          putStr (compose ls)

compose :: String -> String
compose = unlines . processLine . zip [1..] . lines

processLine :: [(Integer, String)] -> [String]
processLine [] = []
processLine ((n,x):xs) | x == "0" = []
                       | otherwise = ("Case " ++ show n ++ ": " ++ x) : processLine xs

Measured memory_bytes: 5036
#include "bits/stdc++.h"

using namespace std;

#define cerr if(false)cerr
#define what(x) cerr<<#x<<" = "<<x<<endl
 
typedef long long ll;
typedef pair<ll, ll> ii;

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 322;

int main(){

	ios_base::sync_with_stdio(false); 
	cin.tie(0);
	cout.tie(0);


	int n;
	cin >> n;

	vector<int> arr(n);

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

	vector<int> cont(n, 0);

	for(int i = 0; i < n; i++){
		if(arr[i] + i + 1 < n){
			++cont[arr[i] + i + 1];
		}
	}

	ll ans = 0;

	for(int i = n-1; i >= 0; i--){
		if(i - arr[i] + 1 >= 0)
			ans += cont[i - arr[i] + 1];
	}

	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 4792
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define reps(i, s, n) for(int i = (int)s; i < (int)n; i++)
#define in(i) std::cin >> i;
#define print(i) std::cout << i;
#define println(i) std::cout << i << std::endl;
using namespace std;

int main() {
    int k, a, b, i=0;
    string ans = "NG";
    
    cin >> k >> a >> b;
    
    while(1){
       if(k * i >= a && k * i <= b) {
            ans = "OK";
            break;   
       } else if(k * i > b){
           break;
       }
       i++;
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define lo long long
using namespace std;
int n,k,A[505],sum;
vector<int> v;
int main(){
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++) {scanf("%d",&A[i]);sum+=A[i];}
	for(int i=1;i*i<=sum;i++){
		if(sum%i==0){
			v.pb(i);
			if((sum/i)!=i) v.pb(sum/i);
		}
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	for(int i=0;i<(int)v.size();i++){
		int go=v[i];
		int cev=0;
		for(int j=1;j<=n;j++){
			cev+=A[j]%go;
		}
		int x=cev/go;
		x=n-x;
		vector<int> faruk;
		for(int j=1;j<=n;j++){
			faruk.pb(A[j]%go);
		}
		sort(faruk.begin(),faruk.end());
		int topla=0;
		for(int j=0;j<x;j++){
			topla+=faruk[j];
		}
		if(topla<=k){
			printf("%d\n",go);
			return 0;
		}
	}
	return 0;
}




Measured memory_bytes: 256
from itertools import permutations
from math import sqrt, factorial
n = int(input())
cities = [list(map(int, input().split())) for _ in range(n)]

ans = 0

for p in permutations(range(n)):
    for c1, c2 in zip(p, p[1:]):
        x1, y1 = cities[c1]
        x2, y2 = cities[c2]
        d = sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
        ans += d
print(ans / factorial(n))


Measured memory_bytes: 40684
H,W = map(int,input().split())
src =[list(map(int,input().split())) for i in range(H)]

order=[]
for i in range(H):
    if i%2==0:
        for j in range(W):
            order.append((i,j))
    else:
        for j in reversed(range(W)):
            order.append((i,j))

ans=[]

for(y1,x1),(y2,x2) in zip(order,order[1:]):
    if src[y1][x1]%2:
        ans.append((y1+1,x1+1,y2+1,x2+1))
        src[y2][x2]+=1
print(len(ans))
for row in ans:
    print(*row)


Measured memory_bytes: 48360
n= int(input())
s = input()

cnt_r = s.count('R')
cnt_g = s.count('G')
cnt_b = s.count('B')

ans = cnt_r * cnt_g * cnt_b

for i in range(n):
    for d in range(n):
        j = i + d
        k = j + d
        if k >= n:
            break
        if s[i] != s[j] and s[j] != s[k] and s[i] != s[k]:
            ans -= 1

print(ans)

Measured memory_bytes: 9184
package main

import "fmt"

func main() {
	var (
		a, b int
		s    string
	)
	fmt.Scan(&a, &b, &s)

	_ = b

	ans := "Yes"
	for _, c := range s[:a] {
		if c == '-' {
			ans = "No"
		}
	}
	if s[a] != '-' {
		ans = "No"
	}
	for _, c := range s[a+1:] {
		if c == '-' {
			ans = "No"
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cassert>
#include <bitset>
#include <fstream>
#include <cstring>
#include <stack>
using namespace std;
#define fst first
#define snd second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define ld long double
template<typename T>
T abs(T x)
{
    return x > 0 ? x : -x;
}
template<typename T>
T sqr(T x)
{
    return x * x;
}
template<typename T>
ostream& operator << (ostream &s, const vector<T> &x)
{
    s << "[";
    for (auto it : x)
    {
        s << it << ", ";
    }
    s << "]";
    return s;
}
template<typename T>
ostream& operator << (ostream &s, const set<T> &x)
{
    s << "{";
    for (auto it : x)
    {
        s << it << ", ";
    }
    s << "}";
    return s;
}
template<typename U, typename V>
ostream& operator << (ostream &s, const pair<U, V> &x)
{
    s << "(" << x.fst << ", " << x.snd << ")";
    return s;
}
template<typename T>
bool chmax(T &x, const T &y)
{
    if (x < y)
    {
        x = y;
        return true;
    }
    return false;
}
template<typename T>
bool chmin(T &x, const T &y)
{
    if (x > y)
    {
        x = y;
        return true;
    }
    return false;
}
//---------------------------------------------------------------------
const int maxn = 1e5 + 5;
vector<int> g[maxn];
int ans = 0;
int k;
int dfs(int v) {
    int depth = 0;
    for (int to : g[v])
    {
        int r = 1 + dfs(to);
        if (r == k && v != 1)
        {
            ans++;
        }
      	else
        {
            chmax(depth, r);
        }
    }
    //cout << v << " " << depth << endl;
    return depth;
}
int main() {
    int n;
    cin>>n>>k;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin>>a[i];
    }
    if (a[1] != 1)
    {
        a[1] = 1;
        ans++;
    }
    for (int i = 2; i <= n; i++)
    {
        g[a[i]].pb(i);
    }
    dfs(1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13784
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int a, b, c, k;
    cin >> a >> b >> c >> k;

    if (k <= a + b) {
        cout << min(a, k) << endl;
    } else {
        cout << a - (k - a - b) << endl;
    }

    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <map>
#include <utility>
using namespace std;

using Segment = pair<int, int>;

template <typename T>
struct FenwickTree {
    int n;
    vector<T> dat;

    FenwickTree(vector<T>& d) {
        n = d.size();
        dat.resize(n + 1, 0);
        for (int i = 0; i < n; i++) dat[i + 1] = d[i];
    }

    FenwickTree(int size) {
        n = size;
        dat = vector<T>(n + 1, 0);
    }

    // 0-indexed
    T sum(int i) {
        if (i < 0) return 0;

        i++;
        T res = 0;
        while (i > 0) {
            res += dat[i];
            i -= i & -i;
        }
        return res;
    }

    // [i, j]
    T sum(int i, int j) {
        return sum(j) - sum(i - 1);
    }

    void add(int i, T x) {
        i++;
        while (i <= n) {
            dat[i] += x;
            i += i & -i;
        }
    }
};

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

    map<int, vector<Segment>> manager;

    for (int i = 0; i < N; i++) {
        int l, r;
        cin >> l >> r;
        manager[r - l + 1].emplace_back(l, r);
    }
    
    FenwickTree<int> ft(M + 2);
    int sum = N;
    for (int d = 1; d <= M; d++) {
        int ans = sum;
        for (int i = 1; i * d <= M; i++) {
            ans += ft.sum(0, i * d);
        }
        cout << ans << endl;

        sum -= manager[d].size();
        for (Segment& s : manager[d]) {
            ft.add(s.first, 1);
            ft.add(s.second + 1, -1);
        }

    }

    return 0;
}

Measured memory_bytes: 13440
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int , int> ii;
typedef pair<ii , int> iii;
const ll mod = 1e9;
int n , half;
bool visited[3050][3050];
double a[3050] , memo[3050][3050];
double dp(int x , int tails){
	if(x > n + 1)return 0;
	if(x == n + 1){
		if(tails < half)return 1;
		else return 0;
	}
	if(visited[x][tails])return memo[x][tails];
	visited[x][tails] = true;
	memo[x][tails] = (a[x]*dp(x + 1 , tails)) + ((1 - a[x])*dp(x + 1 , tails + 1));
	return memo[x][tails];
}
void input(){
	cin >> n;
	for(int i = 1 ; i <= n ; i++){
		cin >> a[i];
	}
}

void solve(){
	half = n/2;
	if(n % 2 == 1)half++;
	memset(visited , false , sizeof(visited));
	memset(memo , -1 , sizeof(memo));
	printf("%.10lf\n" , dp(1 , 0));
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	input();
	solve();
}

Measured memory_bytes: 85712
def check(arr):
    # 横チェック
    for i in range(len(arr)):
        if arr[i] == ["x", "x", "x"]:
            return True

    # 縦チェック
    for i in range(3):
        if arr[0][i] == "x" and arr[1][i] == "x" and arr[2][i] == "x":
            return True

    # 斜めチェック
    if arr[0][0] == "x" and arr[1][1] == "x" and arr[2][2] == "x":
        return True
    elif arr[0][2] == "x" and arr[1][1] == "x" and arr[2][0] == "x":
        return True

    return False

arr = []
for _ in range(3):
    arr.append(list(map(int, input().split(' '))))

n = int(input())
for _ in range(n):
    b = int(input())
    for i in range(len(arr)):
        tmp_arr = []
        for ele in arr[i]:
            if b == ele:
                tmp_arr.append("x")
            else:
                tmp_arr.append(ele)
        arr[i] = tmp_arr

if check(arr) == True:
    print("Yes")
else:
    print("No")


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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P = pair<int, int>;

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

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

//---------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------

signed main() {
    int K;
    cin >> K;
    queue<i64> q;
    rep(i, 1, 10) q.push(i);
    int k = 0;
    while (!q.empty()) {
        i64 x = q.front();
        q.pop();
        k++;
        if (k == K) {
            cout << x << "\n";
            return 0;
        }
        i64 a = x % 10;
        if (a != 0) q.push(x * 10 + a - 1);
        q.push(x * 10 + a);
        if (a != 9) q.push(x * 10 + a + 1);
    }
}


Measured memory_bytes: 1792
/*input
6 15
6 5
5 6
6 4
6 6
3 5
7 2
*/
 
// author - Madhav Thakker
 
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace std;
 
#define ll long long
#define ld long double
#define int ll
#define endl '\n'

typedef pair<int, int> pii; 
typedef pair<ld, ld> pdd;
 
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FileIn(file) freopen(file, "r", stdin)
#define FileOut(file) freopen(file, "w", stdout)
#define all(c) c.begin(), c.end() 
#define tr(container, it )\
for(__typeof__(container.begin()) it = container.begin(); it != container.end(); it++) 
#define present(container, element) (container.find(element) != container.end())  //map, set
#define cpresent(container, element) (find(aint(container),element) != container.end()) //vector
#define what_is(x) cout << #x << " is " << x << endl; 
#define all(c) c.begin(), c.end() 
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
const int MOD = 1e9+7;
 
 
int fast_pow(int a, int b){
	int res = a, ret = 1;
	while(b>0){
		if(b%2)
			ret = (ret*res)%MOD;
		res = (res*res)%MOD;b/=2;
	}
	return ret;
}
 
// --
// -- 
// -- 
// std::cout << std::fixed;
// std::cout << std::setprecision(26) << f << '\n';
// str = to_string(n)
// stoi , stoll, stol
// sort(arr, arr+n, greater<int>());
// fill(prefix.begin(), prefix.end(), 0);
// 
// 
 
 
 
////
const int maxN = 1e5+700;
pii arr[105];
int dp[maxN][105];
////


signed main(){
 
	fastio;
	time_t time_t1, time_t2;
	time_t1 = clock();
 
	////////////////////////////////

	int t = 1;
	// cin >> t ;

	while(t--){

		int n, w;
		cin >> n >> w;
		int wt, val;
		for (int i = 1; i <= n; ++i){
			cin >> wt >> val;
			arr[i] = {wt, val};
		}
		for (int i = 0; i <= w; ++i){
			dp[i][0] = 0;
		}
		// sort(arr+1, arr + n+1);
		for (int i = 0; i <= w; ++i){
			for (int j = 1; j <= n; ++j){
				dp[i][j] = dp[i][j-1];
				if(arr[j].first > i){
					continue;
				}
				dp[i][j] = max(dp[i][j], dp[i-arr[j].first][j-1] + arr[j].second);
			}
		}
		int ans = 0;
		for (int j = 1; j <= n; ++j){
			ans = max(ans, dp[w][j]);
		}
		cout << ans << endl;

	}
 	
	///////////////////////////////
	// 
 
	time_t2 = clock();
	// cerr << "time taken :" << time_t2 - time_t1 << endl;
 
	return 0;
}


Measured memory_bytes: 82304
# B
N = int(input())
A, B = map(int, input().split())
P_list = list(map(int, input().split()))
c1 = 0
c2 = 0
c3 = 0

for p in P_list:
    if p <= A:
        c1 +=1
    elif p <= B:
        c2 += 1
    else:
        c3 += 1
        
print(min(c1, c2, c3))



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
using vi  = vector<int>;
using ii  = pair<int,int>;
using vii = vector<ii>;
using ll  = long long;

typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;

#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) int((x).size())
#define REP(i, a, b) for (auto (i) = (a); (i) <= (b); (i)++)
#define PER(i, a, b) for (auto (i) = (a); (i) >= (b); (i)--)
#define ITR(i, x) for (auto (i) = (x).begin(); (i) != (x).end(); (i)++)

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int n;
	cin >> n;
	string s;
	cin >> s;

	int i;
	for (i = 0; i < n; i++) {
		if (s[i] == 'W') break;
	}
	int j;
	for (j = n-1; j >= 0; j--) {
		if (s[j] == 'R') break;
	}

	int cnt = 0;
	while (i < j) {
		s[i] = 'R';
		s[j] = 'W';
		cnt++;
		for (; j >= 0; j--) {
			if (s[j] == 'R') break;
		}
		for (; i < n; i++) {
			if (s[i] == 'W') break;
		}
	}
	cout << cnt << '\n';
	return 0;
}

Measured memory_bytes: 3732
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

vector<pii>g[1111];

const lint inf=1e17;
lint dis[1111];

int main(){
  int n,m;
  cin>>n>>m;
  rep(i,m){
    int a,b,c;
    cin>>a>>b>>c;
    a--,b--;
    g[a].push_back(pii(b,c));
  }
  rep(i,n)dis[i]=-inf;
  dis[0]=0;
  vector<lint> ans(2);
  rep(i,2*n){
    rep(j,n){
      rep(k,g[j].size()){
	pii wc=g[j][k];
	int w=wc.first,c=wc.second;
	dis[w]=max(dis[w],dis[j]+(lint)c);
      }
    }
    if(i%n==n-1)ans[i/n]=dis[n-1];
  }
  if(ans[0]!=ans[1])cout<<"inf"<<endl;
  else cout<<ans[0]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d;
    cin>>n;
    d=n%10;
    if(d==2||d==4||d==5||d==7||d==9)
    {
        cout<<"hon"<<endl;
    }
    else if(d==0||d==1||d==6||d==8)
    {
        cout<<"pon"<<endl;
    }
    else if(d==3)
    {
        cout<<"bon"<<endl;
    }

}


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

int main() {

  int N;
  cin >> N;

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

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

  int k = 1;
  for(int i = 0; i < N-1; i++){
    if(a[i] < a[i+1]) k++;
  }

  if(k % 2 == 0) cout << k-1 << endl;
  else cout << k << endl;

}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int N;
int arr[55555];

void Eratosthenes()
{
  for (int i = 0; i < 55555; i++)
  {
    arr[i] = 1;
  }
  for (int i = 2; i < sqrt(55555); i++)
  {
    if (arr[i])
    {
      for (int j = 0; i * (j + 2) < 55555; j++)
      {
        arr[i * (j + 2)] = 0;
      }
    }
  }
}
int main()
{
  cin >> N;
  vector<int> res = vector<int>(60);
  Eratosthenes();
  int temp = 2;
  for (int i = 0; i < N; i++)
  {
    for (int h = temp; h < 55555; h++)
    {
      if (arr[h] == 1 && h % 10 == 1)
      {
        res[i] = h;
        temp = h + 1;
        break;
      }
    }
  }
  for (int i = 0; i < N; i++)
  {
    cout << res[i] << " ";
  }

  return 0;
}

Measured memory_bytes: 512
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e8
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	N := nextInt()
	D := make([][]int, N)
	for i := 0; i < N; i++ {
		D[i] = make([]int, 2)
		D[i][0], D[i][1] = nextInt(), nextInt()
	}
	count := 0
	result := "No"
	for i := 0; i < N; i++ {
		if D[i][0] == D[i][1] {
			count++
		} else {
			count = 0
		}
		if count == 3 {
			result = "Yes"
			break
		}
	}
	fmt.Println(result)
}


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

Measured memory_bytes: 9848
#include "bits/stdc++.h"
#define ll long long

using namespace std;

const int MX = 2e5;
vector<int> g[MX];
int d[MX], p[MX];

int main() {
      cin.sync_with_stdio(0);

      int n, m;
      cin >> n >> m;

      for (int i = 0; i < m; ++i) {
            int u, v;
            cin >> u >> v;
            g[u].push_back(v);
            g[v].push_back(u);
      }

      fill(d, d + MX, 1e9);
      d[1] = 0;

      queue<int> q;
      q.push(1);
      while (!q.empty()) {
            int u = q.front();
            q.pop();
            for (int v : g[u]) {
                  if (d[v] > d[u] + 1) {
                        d[v] = d[u] + 1;
                        p[v] = u;
                        q.push(v);
                  }
            }
      }

      cout << "Yes\n";
   
      for (int i = 2; i <= n; ++i)
            cout << p[i] << " ";

      return 0;
}

Measured memory_bytes: 13700
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int mi = 1000;
  int ma = 0;
  if (a + b <= n) {
    mi = 0;
  }else{
    mi=(a+b)-n;
  }
  ma = min(a, b);
  cout << ma <<" "<< mi << endl;

  return 0;
}


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


int main()
{
	int N;
	cin>>N;
	int x;
	cin>>x;
	vector<ll> A(N);
	rep(i,N) cin>>A[i];
	sort(A.begin(),A.end());
	int ans=0;
	rep(i,N)
	{
		if(x>=A[i])
		{
			x-=A[i];
			ans++;
		}
		if(x<=0) break;
	}
	if(ans==N&&x!=0) ans--;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define m_p make_pair
#define sz(x) (int)x.size()
#define line cerr<<"--------------------\n";
#define see(x) cerr<<x<<" "
#define seeln(x) cerr<<x<<endl
#define out(x) cerr<<#x<<" = "<<x<<" "
#define outln(x) cerr<<#x<<" = "<<x<<endl
#define outarr(x,l,r) cerr<<#x"["<<l<<"-"<<r<<"] = "; for (int _i=l;_i<=r;++_i) cerr<<x[_i]<<" ";cerr<<endl;
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define gc() getchar()
//char buf[1<<23],*p1=buf,*p2=buf;
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <class T> void read(T &x)
{
    x=0; char c=gc(); int flag=0;
    while (c<'0'||c>'9') flag|=(c=='-'),c=gc();
    while (c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=gc();
    if (flag) x=-x;
}
template <class T> inline T _max(T a,T b){return a>b ? a : b;}
template <class T> inline T _min(T a,T b){return a<b ? a : b;}
template <class T> inline bool checkmax(T &a,T b){return b>a ? a=b,1 : 0;}
template <class T> inline bool checkmin(T &a,T b){return b<a ? a=b,1 : 0;}
const int N=500005,inf=1000000000000;
int n;
struct node
{
	int x,y;
	node(int x=0,int y=0):x(x),y(y){}
}a[N];

void init()
{
	read(n);
	for (int i=1;i<=n;++i)
	{
		read(a[i].x); read(a[i].y);
	}
}

void solve()
{
	int ans=0;
	int max1=a[1].x+a[1].y,max2=a[1].x-a[1].y,min1=a[1].x+a[1].y,min2=a[1].x-a[1].y;
	for (int i=2;i<=n;++i)
	{
		checkmax(max1,a[i].x+a[i].y);
		checkmax(max2,a[i].x-a[i].y);
		checkmin(min1,a[i].x+a[i].y);
		checkmin(min2,a[i].x-a[i].y);
	}
	ans=_max(max1-min1,max2-min2);
	printf("%lld\n",ans);
}

#undef int
int main()
{
	init();
	solve();
	return 0;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    ll n; cin >> n;
    vector<ll> x(n), y(n);
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    // 元の配列ととっておく
    y = x;
    sort(all(y));
    ll m1 = y[n / 2 - 1]; // 小さい方
    ll m2 = y[n / 2]; // 大きい方
    for(int i = 0; i < n; i++){
        if(x[i] < m2) cout << m2 << endl;
        else cout << m1 << endl;
    }
}


Measured memory_bytes: 5376
x1, y1, x2, y2 = list(map(int, input().split()))
x3 = x2 - (y2 - y1)
y3 = y2 + (x2 - x1) 
x4 = x3 - (y3 - y2)
y4 = y3 + (x3 - x2)
print(x3, y3, x4, y4)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
const long long MOD = 1e9 + 7;
int main()
{
    ll N;
    cin >> N;
    vector<ll> T(N), A(N), Ti(N), Ai(N);
    rep(i, N) cin >> T[i];
    rep(i, N) cin >> A[i];

    Ti[0] = -1; Ai[N - 1] = -1;
    repd(i, 1, N) {
        if (T[i - 1] < T[i]) {
            Ti[i] = -1;
        }
        else {
            Ti[i] = T[i];
        }
    }

    for (int i = N - 2; i >= 0; i--) {
        if (A[i + 1] < A[i]) {
            Ai[i] = -1;
        }
        else {
            Ai[i] = A[i];
        }
    }
/*
    rep(i, N) {
        cout << Ti[i] << " " << Ai[i] << endl;
    }
*/
    ll cnt = 1;
    bool flag = true;
    rep(i, N) {
        if (Ti[i] == -1 && Ai[i] == -1) {
            if (A[i] != T[i]) flag = false;
        }
        else {
            if (Ti[i] == -1) {
                if (T[i] > A[i]) flag = false;
            }
            else if (Ai[i] == -1) {
                if (A[i] > T[i]) flag = false;
            }
            else if (Ti[i] != -1 && Ai[i] != -1) {
                cnt *= min(Ti[i], Ai[i]);
            }
        }
        cnt %= MOD;
    }

    cout << (flag ? cnt : 0) << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <cmath>
#include <stdio.h>
#include <sstream>
#define int_inf 1000000000 //1e9
#define ll_inf  1000000000000000000 //1e18
using namespace std;
template <typename T> std::string to_string(const T& t){
	std::ostringstream os; os<<t; return os.str();
}




int main(){
	int n;
	cin >> n;
	set<int> d;
	int a;
	for(int i=0; i<n; i++){
		cin >> a;
		d.insert(a);
	}
	
	cout << d.size() << endl;
	
	return 0;
}




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

typedef pair<int,int> P;

int n, K;
vector<int> G[100005];
map<P,int> memo;

void dfs(int x, int px, int c){
  
  int color = 0;
  
  for(int nx : G[x]){

    if( nx == px ) continue;
    
    if( color == c ) color++;
    
    memo[P(x,nx)] = memo[P(nx,x)] = color;
    
    dfs(nx,x,color++);
    
  }
  
}

int A[100005], B[100005];

signed main(){
  
  cin>>n;
  
  for(int i=0;i<n-1;i++){
    int a, b;
    cin>>a>>b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
    A[i] = a-1;
    B[i] = b-1;
  }
  
  for(int i=0;i<n;i++){
    K = max( K, (int)G[i].size() );
  }
  
  dfs(0,-1,-1);
  
  cout<<K<<endl;
  
  for(int i=0;i<n-1;i++){
    cout<<memo[P(A[i],B[i])]+1<<endl;
  }
  
  return 0;
}


Measured memory_bytes: 22784
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll cnt = 1;

    ll flag = 0;

    for(size_t i = 1; i < n; i++) {
        if(flag == 0 && a.at(i - 1) == a.at(i)) {
            flag = 0;

        } else if(flag != -1 && a.at(i - 1) <= a.at(i)) {
            flag = 1;
        } else if(flag != 1 && a.at(i - 1) >= a.at(i)) {
            flag = -1;
        } else {
            flag = 0;
            cnt++;
        }
    }
    cout << cnt;
}

Measured memory_bytes: 1024
I=lambda:list(map(int,input().split()))
n,m,q=I()
l=[[0]*-~n for _ in range(n+1)]
for _ in range(m):
  s,g=I()
  l[s][g]+=1
for i in range(1,n+1):
  for j in range(1,n+1):
    l[i][j]+=l[i][j-1]
  for j in range(1,n+1):
    l[i][j]+=l[i-1][j]
for _ in range(q):
  s,g=I()
  print(l[g][g]-l[s-1][g]-l[g][s-1]+l[s-1][s-1])

Measured memory_bytes: 15188
// https://atcoder.jp/contests/abc159/tasks/abc159_d

use proconio::input;

fn main() {
    input! {
        n: usize,
        a_s: [usize; n],
    }
    let mut counts: Vec<i32> = vec![0; 200001];
    for &a in &a_s {
        counts[a] += 1;
    }
    let mut combs: Vec<i64> = vec![0; 200001];
    for (i, &c) in counts.iter().enumerate() {
        combs[i] = combinations(c);
    }
    let sum: i64 = combs.iter().sum();
    for &a in &a_s {
        let c = counts[a];
        let diff = combs[a] - combinations(c - 1);
        println!("{}", sum - diff)
    }
}

fn combinations(x: i32) -> i64 {
    let x = x as i64;
    x * (x - 1) / 2
}


Measured memory_bytes: 7668
#include <stdio.h>

int main(void) {
    int a, b;
    scanf("%d%d", &a, &b);
    int keta = 1;
    while(1) {
        if(b/keta == 0) break;
        keta *= 10;
    }
    int ans = a * keta + b;
    for(int i = 1;; i++) {
        if(i*i > ans) {
            printf("No\n");
            break;
        }
        if(ans == i*i) {
            printf("Yes\n");
            break;
        }
    }
    return 0;
}


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
	os << "(" << pair_var.first << ", " << pair_var.second << ")";
	return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	os << "{";
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
	}
	os << "}";
	return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
	os << "{";
	repi(itr, map_var) {
		os << *itr;
		itr++;
		if (itr != map_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
	os << "{";
	repi(itr, set_var) {
		os << *itr;
		itr++;
		if (itr != set_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}

#define DUMPOUT cerr

void dump_func() {
	DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
	DUMPOUT << head;
	if (sizeof...(Tail) > 0) {
		DUMPOUT << ", ";
	}
	dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


signed main() {

	int A, B;
	cin >> A >> B;
	cout << max(0LL, A - 2 * B) << endl;
	

	
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    set<string> S;
    REP(i, N) {
        string s; cin >> s;
        S.insert(s);
    }

    cout << S.size() << endl;
    
}


Measured memory_bytes: 19284
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
 
using namespace std;
 
#define eb emplace_back
#define pb push_back
#define MP make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define rep(i,j,n) for (int i = j; i < n; ++i)
#define repn(i,j,n) for (int i = j; i <= n; ++i)
#define revn(i,j,n) for (int i = j; i >= n; --i)
#define sz(i) i.size()
#define mem(i,v) memset(i,v,sizeof(i))
#define all(v) v.begin(), v.end()
#define endl '\n'
#define int long long
#define INF 1e18
#define ss second
#define ff first

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
const int mod=1e9+7;
//const int mod=998244353;
const int up=1e5+10;
const int MAXN=1e6+10;
int par[up];

int spf[MAXN];

void sieve() 
{ 
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (int i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        {  
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 

map<int,int>mp;

void solve()
{
    int n,get,ans=0,p;
    cin>>n;
    set<int>v;
    int x=n,j=sqrt(n),small;
    repn(i,2,j)
    {
        if(x%i==0)
        {
            small=spf[i];
            v.insert(small);
            while(x%small==0)
            {
                x/=small;
                mp[small]++;
            }
            if(x==1)
            {
                break;
            }
        }
    }
    if(x!=1)
    {
        v.insert(x);
        mp[x]++;
    }
    for(auto &u:v)
    {
        p=mp[u];
        //cout<<p<<" "<<u<<endl;
        get=(-1+sqrt(floor(1+8*p)))/2;
        //cout<<get<<endl;
        ans+=max(get,0LL);
    }
    cout<<ans<<endl;
}

int32_t main()
{
    int t;
    t=1;
    sieve();
    //cin>>t;
    while(t--)
    {
        solve();
    }
}



Measured memory_bytes: 11540
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6+7;
const long long module = 1e9+7;
int n,m;
long long gt[N+100];
void nhap()
{
    scanf("%d%d",&n,&m);
    gt[0] = 1;
    for (int i=1; i<N; i++) {gt[i] = (gt[i-1] * (long long)i) % module;}
    if (n>m) {swap(n,m);}
    //printf("%lld",(module-1)*(module-1));
}
void solve()
{
    if (m-n>1) {printf("%lld",0); return;}
    if (n==m)
    {
        long long res = (gt[n] * gt[m]) % module;
        res = (res*(long long)2) % module;
        printf("%lld",res);
    }
    else
    {
        long long res = (gt[n] * gt[m]) % module;
        printf("%lld",res);
    }
}
int main()
{
    nhap();
    solve();
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N[3],K;
    cin >> N[0] >> N[1] >> N[2] >> K;
    vector<ll> V[3];
    rep(i,0,3)V[i].resize(N[i]);
    rep(i,0,3)rep(j,0,N[i])cin >> V[i][j];

    vector<ll> vec,ans;
    rep(i,0,N[0])rep(j,0,N[1])vec.push_back(V[0][i] + V[1][j]);
    sort(vec.rbegin(), vec.rend());

    rep(i,0,min(N[0]*N[1], K))rep(j,0,N[2])ans.push_back(vec[i] + V[2][j]);
    sort(ans.rbegin(), ans.rend());
    rep(i,0,K)cout << ans[i] << endl;
}

Measured memory_bytes: 43368
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

typedef long long ll;

ll a[5], b[5];

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld %lld %lld",&a[1], &a[2] ,&a[3]);
	for(ll i = 1; i <= 3; i++)
		if(a[i]%2){
			puts("0");
			return 0;
		}
	for(ll i = 1; i <= 300; i++){
		for(ll j = 1; j <= 3; j++){
			ll top = 0;
			for(ll k = 1; k <= 3; k++)
				if(k != j)
					top += a[k];
			b[j] = top/2;
			if(b[j] % 2){
				printf("%lld\n", i);
				return 0;
			}
		}
		for(ll j = 1; j <= 3; j++)
			a[j] = b[j];

	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
        static void SolveA()
        {
            int o = ReadAndParseInt();
            int[] d = new int[] { o % 10, -o % 10 };
            o /= 10;
            int[] c = new int[] { o % 10, -o % 10 };
            o /= 10;
            int[] b = new[] { o % 10, -o % 10 };

            int a = o / 10;

            for(int i=0;i<b.Length;++i)
            {
                int b2 = b[i];

                for (int j=0;j<c.Length;++j)
                {
                    int c2 = c[j];

                    for (int k = 0;k<d.Length;++k)
                    {
                        int d2 = d[k];
                        if( a+b2 + c2 + d2 == 7)
                        {
                            string ans = a.ToString();
                            ans += AddMsg(b2);
                            ans += AddMsg(c2);
                            ans += AddMsg(d2);
                            ans += "=7";
                            Console.WriteLine(ans);
                            return;
                        }
                    }
                }
            }

        }
        private static string AddMsg(int val)
        {
            string tmp = val >= 0 ? "+" : "-";
            return tmp + Math.Abs(val);
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if( x == 2) { return true; }
            if( x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while( i * i <= x)
            {
                if( x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }

        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

int main()
{
  int N;
  vector<Pii> x;
  int ans[250000] = {0};

  cin >> N;
  Rep(i, N) {
    int a; cin >> a; a--;
    ans[a] = i+1;
    x.pb( Pii(a, i+1) );
  }

  sort( All(x) );
  Rep(i, N) {
    int p = x[i].fr, num = x[i].sc, cnt = 0;
    Rep(i, p) {
      if( cnt == num-1 ) break;
      if( !ans[i] ) { //ans[i]に値が入っていなかったら
	ans[i] = num;
	cnt++;
      }
    }
    if( cnt != num-1 ) {
      cout << "No" << endl;
      return 0;
    }
  }
  Rep(i, N) {
    int p = x[N-i-1].fr, num = x[N-i-1].sc, cnt = 0;
    for(int i=N*N-1; i>p; i--) {
      if( cnt == N - num ) break;
      if( !ans[i] ) { //ans[i]に値が入っていなかったら
	ans[i] = num;
	cnt++;
      }
    }
    if( cnt != N - num ) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  Rep(i, N*N-1) {
    cout << ans[i] << " ";
  }
  cout << ans[N*N-1] << endl;
}

Measured memory_bytes: 2176