akhauriyash/Code-Regression huggingface dataset:
function Main(input) {
  	input = input.split(" ");
    var K = parseInt(input[0]);
    var X = parseInt(input[1]);
    if(K == 1) {
      console.log(X);
      return;
    }
    var start = X - K + 1;
    var end = X + K - 1;
    var output = "";
    for(start; start <= end; start++){
      output += start + " ";
    }
    console.log(output);
  }
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main()
{
	int n;
	scanf("%d",&n);
	for(int c=0;c<=n/100;c++)
	{
		int zan=n-c*100;
		if(0<=zan&&zan<=5*c)
		{
			puts("1");
			return 0;
		}
	}
	puts("0");
	return 0;
}

Measured memory_bytes: 256
n = int(input())
x=[]
for i in range(n):
   x.append(int(input()))
maxv = x[1] - x[0]
minv = x[0]
for i in range(1, n):
    if maxv <= x[i] - minv:
        maxv = x[i] - minv
    if minv >= x[i]:
        minv = x[i]
print(maxv)


Measured memory_bytes: 13584
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

#define MAX_N 2000005
ll inv[MAX_N], fac[MAX_N], finv[MAX_N];
void make() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i=2; i<MAX_N; i++) {
    inv[i] = mod - inv[mod%i] * (mod/i) % mod;
    fac[i] = fac[i-1] * (ll)i % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}
ll perm(ll n, ll r) {
  if(n < 0)       return 0;
  else if(n < r)  return 0;
  else            return (fac[n] * finv[n-r]) % mod;
}
ll comb(ll n, ll r) {
  ll ans = 1;
  ans = perm(n, r);
  ans = (ans * finv[r]) % mod;
  return ans;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  make();
  ll n, m, k; cin >> n >> m >> k;
  ll ans = 0;
  rep(i, n) {
    (ans += i*m%mod*m%mod*(n-i)%mod) %= mod;
  }
  rep(i, m) {
    (ans += i*n%mod*n%mod*(m-i)%mod) %= mod;
  }
  (ans *= comb(n*m-2, k-2)) %= mod;
  cout << ans << endk;
  return 0;
}


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

int main(){
	int n;
	cin>>n;
	int res = 0;
	for(int i = 105; i <= n; i+=2){
		int tmp = 0;
		for(int j = 1; j*j <= i; j+=2){
			if(i%j==0 && j*j!=i) tmp+=2;
		}
		if(tmp == 8) res++;
	}
	cout<<res;
}

Measured memory_bytes: 256
fun main(arg: Array<String>) {
    val N = nextInt()
    val A = listOfInt()
    val B = IntArray(3)
    fun mod2mod4(n: Int) = when (Integer.numberOfTrailingZeros(n)) {
        0 -> 0      //odd
        1 -> 1      //mod 2
        else -> 2   //mod 4
    }
    A.forEach { a -> B[mod2mod4(a)] += 1 }
    val ans = if (B[1] == 0) B[0] <= B[2] + 1 else B[0] <= B[2]
    println(if (ans) "Yes" else "No")
}
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }



Measured memory_bytes: 51816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i=s;i<n;i++)
ll mod=1e9+7;

int main(){
	int s,w;
	cin >> s>>w;
	string ans = "safe\n";
	if(w >= s) ans = "unsafe\n";
	cout << ans ;


	return 0;
}

Measured memory_bytes: 3624
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define                           eb                          emplace_back



using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}


 main()

{
    fast
    int n;
    cin>>n;
    vector<pi>ses;
    int one=__builtin_popcount(n);
    if(one==1)
    {
        cout<<"No"<<endl;
        return 0;
    }
    if(n<3)
    {
        cout<<"No"<<endl;
        return 0;
    }
    int last=-1;
    int yo=n;
    if(n%2==0)
    {
        last=n;
        n=n-1;
    }
    f(i,2,n)
    {
        ses.eb(1,i);
        if(i%2==0)ses.eb(i,yo+i+1);
        else ses.eb(i,yo+i-1);
    }
    ses.eb(yo+2,yo+1);
    if(last!=(-1))
    {
        int x=0,y=0,cnt=0;
        for(int j=0;j<=35;j++)
        {
            if(last>>j & 1)
            {
                cnt++;
                if(cnt%2==0)x=x|(1LL<<j);
                else y=y|(1LL<<j);
            }
        }
        x=x|(1LL);
        ses.eb(x,last);
        ses.eb(y,2*last);
    }
    cout<<"Yes"<<endl;
    for(auto x:ses)
    {
        cout<<x.fi<<" "<<x.si<<endl;
    }
    return 0;
}


Measured memory_bytes: 5488
s = input()


for i in range(len(s)- 2):
  t = s[i:i+3]
  if t[0] == t[1] or t[0] == t[2] or t[1] == t[2]:
    print(i + 1, i + 3)
    break
else:
  if len(s) == 2:
    if s[0] == s[1]:
      print(1, 2)
    else:
      print(-1, -1)
  else:
  	print(-1, -1)

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int mountain[10] = { 0 },i;
	for (i = 0; i < 10; i++) {
		cin >> mountain[i];
	}
	sort(mountain, mountain + 10);
	for (i = 0; i < 3; i++) {
		cout << mountain[9 - i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t a, b;
  cin >> a >> b;
  int64_t c = a * b;
  if(a != 1 && b != 1 && c % 2 == 0){
    cout << c / 2 << endl;
  }
  else if(a != 1 && b != 1 && c % 2 == 1){
    cout << c / 2 + 1 << endl;
  }
  else{
    cout << "1" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

typedef long long ll;

const ll mod=1e9+7;

#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define rc(x)  return cout<<x<<"\n",0
#define sz(s)  (int) s.size()
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;

ll t,n;
double a[3003],dp[3003][3003];

int main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n;
	for (int i=0; i<n; i++) {
		cin >> a[i];
	}
	dp[0][0]=1.0;
	for (int i=1; i<n+1; i++) {
		for (int j=0; j<n+1; j++) {
			if (j==0) {
				dp[i][j]=(1.0-a[i-1])*dp[i-1][j];
			}
			else {
				dp[i][j]=a[i-1]*dp[i-1][j-1]+(1.0-a[i-1])*dp[i-1][j];
			}
		}
	}
	double answer=0;
	for (int j=(n+1)/2; j<=n; j++) {
		answer+=dp[n][j];
	}
	/*for (int i=1; i<n+1; i++) {
		for (int j=0; j<=n; j++) {
			cout << dp[i][j] << " ";
		}
		cout << '\n';
	}*/
	cout << setprecision(10) << answer;

}

Measured memory_bytes: 70656
#include<iostream>
using namespace std;
int main(){
int N;
  cin>>N;
 double A[N];
  double sum=0;

  for (int i=0; i<N; i++) cin>>A[i];
  for (int i=0; i<N; i++) sum+=1/A[i];
  
    cout<<1/sum<<endl;}
                                  
                              

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
rec = [0]
i = 0
flag = [0 for _ in range(n + 1)]
while True:
    if flag[rec[i]] == 0:
        flag[rec[i]] = 1
        rec.append(a[rec[i]] - 1)
    else:
        start = rec.index(a[rec[i]] - 1)
        loop = rec[start:]
        pre = rec[:start]
        break
    i += 1
count = (k - len(pre)) % len(loop)
if k <= len(pre):
    print(pre[k] + 1)
else:
    print(loop[count] + 1)


Measured memory_bytes: 115596
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, M, X, Y = map(int, readline().split())
    x = list(map(int, readline().split()))
    y = list(map(int, readline().split()))

    def judge():
        for Z in range(X + 1, Y + 1):
            if all(p < Z for p in x) and all(p >= Z for p in y):
                return True
        return False

    if judge():
        print("No War")
    else:
        print("War")


if __name__ == '__main__':
    main()


Measured memory_bytes: 65484
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    ll x,y;
  cin>>a>>b>>c>>d;
  x=c-a;y=d-b;
  cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x<<endl;
    
    return 0;
}


Measured memory_bytes: 3648
from itertools import groupby

def count(s):
    l = []
    c = 0
    for key,value in groupby(s):
        l.append(list(value))
    for i in l:
        c += len(i)//2
    return c
s = list(input())
k =int(input())
if k <= 10**5:
    print(count(s*k))
else:
    d2 = count(s*3)-count(s*2)
    d3 = count(s*4)-count(s*3)
    if d2 != d3:
        if k%2 == 1:
            print(d2*((k-2)//2+1) + count(s*2) + d3*((k-2)//2))
        else:
            print(d2*((k-2)//2) + count(s*2) + d3((k-2)//2))
    else:
        print(d2*(k-2) + count(s*2))


Measured memory_bytes: 3064
def print_heap():
    for i in range(n):
        if (i-1)//2 in range(n):
            if 2*i+1 in range(n):
                if 2*i+2 in range(n):
                    print("node {}: key = {}, parent key = {}, left key = {}, right key = {}, "
                          .format(i+1, heap[i], heap[(i-1)//2], heap[2*i+1], heap[2*i+2]))
                else:
                    print("node {}: key = {}, parent key = {}, left key = {}, "
                          .format(i+1, heap[i], heap[(i-1)//2], heap[2*i+1]))
            else:
                print("node {}: key = {}, parent key = {}, "
                      .format(i+1, heap[i], heap[(i-1)//2]))
        else:
            if 2*i+1 in range(n):
                if 2*i+2 in range(n):
                    print("node {}: key = {}, left key = {}, right key = {}, "
                          .format(i+1, heap[i], heap[2*i+1], heap[2*i+2]))
                else:
                    print("node {}: key = {}, left key = {}, "
                          .format(i+1, heap[i], heap[2*i+1]))
            else:
                print("node {}: key = {}, ".format(i+1, heap[i]))


if __name__ == "__main__":
    n = int(input())
    heap = list(map(int, input().split()))
    print_heap()

Measured memory_bytes: 7696
#include <iostream>
#include <utility>
#include <queue>
#include <memory>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>

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

using namespace std;
using ll = long long;
const int mod = 1e9+7;

int main(){
    int n,m,c;
    cin >> n >> m >> c;
    int a,cnt=0;
    vector<int> B(m);
    rep(i,m) cin >> B[i];
    ll cross = 0;

    rep(i,n){
        rep(j,m){
            cin >> a;
            cross += (B[j] * a);
        }
        cross += c;
        if(cross > 0) cnt++;
        cross = 0;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N, K, L, R;
  cin >> N >> K >> L >> R;
  ll ans = 0;
  ll lnum = (N + 1) / 2;
  vector<ll> la, ra;
  for (ll i = 0; i < N; ++i) {
    ll a;
    cin >> a;
    if (i < lnum) {
      la.push_back(a);
    }
    else {
      ra.push_back(a);
    }
  }

  vector<vector<ll>> rcoin(N / 2 + 1);
  for (ll i = 0; i < (1 << (N / 2)); ++i) {
    ll num = __builtin_popcountll(i);
    ll sum = 0;
    for (ll j = 0; j < N / 2; ++j) {
      if (i & (1 << j)) {
        sum += ra.at(j);
      }
    }
    rcoin.at(num).push_back(sum);
  }
  for (ll i = 0; i < N / 2 + 1; ++i) {
    sort(rcoin.at(i).begin(), rcoin.at(i).end());
  }

  for (ll i = 0; i < (1 << lnum); ++i) {
    ll num = __builtin_popcountll(i);
    if ((num + N / 2 < K) || (num > K)) {
      continue;
    }
    ll sum = 0;
    for (ll j = 0; j < lnum; ++j) {
      if (i & (1 << j)) {
        sum += la.at(j);
      }
    }
    ll num_left = K - num;
    ll min_need = L - sum, max_need = R - sum;
    ll pattern = lower_bound(rcoin.at(num_left).begin(), rcoin.at(num_left).end(), max_need + 1) - lower_bound(rcoin.at(num_left).begin(), rcoin.at(num_left).end(), min_need);
    ans += pattern;
  }
  cout << ans << "\n";





  // for (ll i = 0; i < N / 2 + 1; ++i) {
  //   for (ll j = 0; j < rcoin.at(i).size(); ++j) {
  //     cout << rcoin.at(i).at(j) << " ";
  //   }
  //   cout << "\n";
  // }
}



Measured memory_bytes: 12264
#include <iostream>

using namespace std;

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

    int length = s.size();
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A') {
            length -= i;
            break;
        }
    }
    for (int i = s.size()-1; i >= 0; i--) {
        if (s[i] == 'Z') {
            length -= (s.size() - i - 1);
            break;
        }
    }
    cout << length << endl;

    return 0;
}

Measured memory_bytes: 640
#![allow(unused_imports)]

#[macro_use]
mod _input {
    use std::fmt;
    use std::io::{self, Read};
    use std::str::{self, FromStr};

    macro_rules! input {
        ($($name:ident : $t:tt),*,) => {
            input!($($name: $t),*)
        };
        ($($name:ident : $t:tt),*) => {
            let mut _scanned = ::_input::Scanned::new(::std::io::stdin(), 1024);
            $(
                let $name = _read_value!(_scanned, $t);
            )*
        };
    }

    macro_rules! _read_value {
        ($scanned:expr, ($($t:tt),*)) => {
            ($(_read_value!($scanned, $t)),*)
        };
        ($scanned:expr, [$t:tt; $n:expr]) => {
            (0..$n).map(|_| _read_value!($scanned, $t)).collect::<Vec<_>>()
        };
        ($scanned:expr, _bytes) => {
            _read_value!($scanned, String).into_bytes()
        };
        ($scanned:expr, _1based) => {
            _read_value!($scanned, usize) - 1
        };
        ($scanned:expr, $t:ty) => {
            $scanned.next::<$t>()
        };
    }

    #[derive(Default)]
    pub struct Scanned {
        buf: Vec<u8>,
        pos: usize,
    }

    impl Scanned {
        pub fn new<R: Read>(mut input: R, estimated: usize) -> Self {
            let mut buf_ = Vec::with_capacity(estimated);
            let _ = io::copy(&mut input, &mut buf_).unwrap();
            if buf_.last() != Some(&b'\n') {
                buf_.push(b'\n');
            }
            debug_assert!(str::from_utf8(&buf_).is_ok());
            debug_assert!(buf_.iter().all(|&c| u32::from(c) <= 0x7F));
            Scanned { buf: buf_, pos: 0 }
        }

        #[inline]
        pub fn next<T: FromStr>(&mut self) -> T
        where
            T::Err: fmt::Debug,
        {
            let mut start = None;
            loop {
                match (self.buf[self.pos], start.is_some()) {
                    (b' ', true) | (b'\n', true) => break,
                    (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                    (_, false) => start = Some(self.pos),
                }
            }
            let target = &self.buf[start.unwrap()..self.pos];
            unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
        }
    }
}

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Stderr, StderrLock, Stdout, StdoutLock, Write};
use std::num::{ParseFloatError, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign,
};
use std::str::{self, FromStr};
use std::{char, cmp, f32, f64, fmt, i16, i32, i64, i8, mem, thread, u16, u32, u64, u8};

fn main() {
    input! {
        n: u32,
        k: u32,
    }
    let p = 2 * k - 1 <= n;
    println!("{}", if p { "YES" } else { "NO" });
}


Measured memory_bytes: 4352
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int c[3][3],f=1;
  REP(i,3)REP(j,3)cin >> c[i][j];
  REP(i,3){
    if(!((c[i][0]-c[(i+1)%3][0]) == (c[i][1]-c[(i+1)%3][1]) && (c[i][1]-c[(i+1)%3][1])  == (c[i][2]-c[(i+1)%3][2]))){
      f = 0;
    }
  }
  REP(i,3){
    if(!(((c[0][i]-c[0][(i+1)%3]) == (c[1][i]-c[1][(i+1)%3])) && ((c[1][i]-c[1][(i+1)%3]) == c[2][i]-c[2][(i+1)%3]))){
      f = 0;
    }
  }
  if(f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

int arr[3];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(3);

    double n;
    while (scanf("%lf", &n) != EOF)
    {
        if (n <= 48.0)
        {
            cout << "light fly" << endl;
        }
        else if (n > 48.0 && n <= 51.0)
        {
            cout << "fly" << endl;
        }
        else if (n > 51.0 && n <= 54.0)
        {
            cout << "bantam" << endl;
        }
        else if (n > 54.0 && n <= 57.0)
        {
            cout << "feather" << endl;
        }
        else if (n > 57.0 && n <= 60.0)
        {
            cout << "light" << endl;
        }
        else if (n > 60.0 && n <= 64.0)
        {
            cout << "light welter" << endl;
        }
        else if (n > 64.0 && n <= 69.0)
        {
            cout << "welter" << endl;
        }
        else if (n > 69.0 && n <= 75.0)
        {
            cout << "light middle" << endl;
        }
        else if (n > 75.0 && n <= 81.0)
        {
            cout << "middle" << endl;
        }
        else if (n > 81.0 && n <= 91.0)
        {
            cout << "light heavy" << endl;
        }
        else
            cout << "heavy" << endl;
    }
    return 0;
}


Measured memory_bytes: 3216
#include <cstdio>
using namespace std;

int main(void){
  int n,k;
  int a[100];
  int ans = 0;
  
  scanf("%d%d",&n,&k);
  for (int i=0; i<n; i++){
    scanf("%d", &a[i]);
    ans += a[i]<k-a[i]?a[i]:k-a[i];
  }
  printf("%d\n",ans*2);
  return 0;
}
  

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  ll i = 0;
  for (auto x : v) {os << " [" << i++ << "]" << x; if (i % 10 == 0) os << std::endl;}
  return os;
}
template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp) {os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}
void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }



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

  ll A, B;
  std::cin >> A >> B;

  if (A == 1) A = 15;
  if (B == 1) B = 15;
  if (A >  B) print("Alice");
  if (A <  B) print("Bob");
  if (A == B) print("Draw");

  return 0;
}


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

struct SegTree
{
  int N;
  vector<int> dat;

  void init(int _n){
    N = 1;
    while (N < _n) N *= 2;
    dat = vector<int>(N * 2 - 1, INT_MAX);
  }

  void update(int k, int val){
    k += N - 1;

    dat[k] = val;
    while (k){
      k = (k - 1) / 2;
      dat[k] = min(dat[k*2+1], dat[k*2+2]);
    }
  }

  int getMin(int a, int b, int k=0, int l=0, int r = -1){
    if (r == -1) r = N;
    if (r <= a || b <= l) return INT_MAX;
    if (a <= l && r <= b) return dat[k];
    int v1 = getMin(a, b, k * 2 + 1, l, (l + r) / 2);
    int v2 = getMin(a, b, k * 2 + 2, (l + r) / 2, r);
    return min(v1, v2);
  }
} st;

int main()
{
  int n, q;
  cin >> n >> q;

  SegTree seg;

  seg.init(n);

  while (q--){
    int com, x, y;
    cin >> com >> x >> y;

    if (com){
      cout << seg.getMin(x, y + 1) << endl;
    } else {
      seg.update(x, y);
    }
  }
}

Measured memory_bytes: 4916
// https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_d
#include <bits/stdc++.h>

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int n;
	string s;
	cin>>n>>s;
	vector<vector<int>> pos(10,vector<int>());
	rep(i,n) pos[s[i]-'0'].push_back(i);

	int number[1000]={};
	rep(i,10)rep(j,10)rep(k,10){
		auto it=lower_bound(all(pos[i]),0);
		if(it==pos[i].end())continue;
		int pos_i = *it;
		auto it2 = lower_bound(all(pos[j]), pos_i+1);
		if(it2==pos[j].end())continue;
		int pos_j = *it2;
		auto it3 = lower_bound(all(pos[k]), pos_j+1);
		if(it3!=pos[k].end()) number[100*i+10*j+k]++;
		// if(it3!=pos[k].end()) cout<<100*i+10*j+k<<endl;
	}
	int ans=0;
	for(auto x:number)if(x>0)ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3824
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }

int k, x;
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> k >> x;
    REP(i, k * 2 - 2) {
        cout << x - k + 1 + i << " ";
    }
    cout << x + k - 1 << endl;

}


Measured memory_bytes: 256
N,M = map(int,input().split())
st = []
ch = []
for i in range(N):
  a,b = map(int,input().split())
  st.append([a,b])
for i in range(M):
  c,d = map(int,input().split())
  ch.append([c,d])
for i in range(N):
  d_list = []
  for j in range(M):
    d = abs(st[i][0] - ch[j][0]) + abs(st[i][1] - ch[j][1])
    d_list.append(d)
  print(d_list.index(min(d_list)) + 1)

Measured memory_bytes: 3064
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()

if len(S)%2 == 1:
	print("No")
	exit()

if S[0:len(S)//2] == S[len(S)//2:]:
	print("Yes")
else:
	print("No")

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

int main() {
	int A, B, C, X, Y, now, best = 2e9 + 999;
	scanf("%d%d%d%d%d", &A, &B, &C, &X, &Y);
	for (int i=0; i<=100000; i++) {
		now = 2 * i * C;
		now += A * max(0, X - i);
		now += B * max(0, Y - i);
		best = min(best, now);
	}
	printf("%d\n", best);
	return 0;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    pos = [
        list(map(int, input().split()))
        for i in range(N)
    ]
    checkpoints = [
        list(map(int, input().split()))
        for i in range(M)
    ]

    for x1, y1 in pos:
        ans = 0
        min_m = float("inf")
        for i, (x2, y2) in enumerate(checkpoints, 1):
            m = abs(x1 - x2) + abs(y1 - y2)
            if min_m > m:
                ans = i
                min_m = m

        print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(30);
#define ll long long
#define pi 3.14159265359
using namespace std;

int main()
{
    IOS;
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)    cin>>a[i];
    sort(a,a+n);
    ll s=a[n-1];
    ll c= n-2;
    ll i = n-2;
    ll j=0;
    while(i>0){
        s+=a[c];
        j+=1;
        i--;
        if(j==2){
            c--;
            j=0;
        }
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 5212
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
  int n;
  ll x;
  ll sum=0;
  cin >> n;
  vector <ll> a(n);
  cin >> x;
  for(int i=0; i<n; i++){
    cin >> a[i];
    if(a[i]+a[i-1]>x && i!=0){
      if(a[i]-(a[i]+a[i-1]-x)>=0){
        sum+=(a[i]+a[i-1]-x);
        a[i]-=(a[i]+a[i-1]-x);
      }else{
        sum+=(a[i]+a[i-1]-x);
        a[i]=0;
      }
    }
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll      long long
#define hell    1000000007
#define ios     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb      push_back


int main()
{
	ios;
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ta=((c-1)/b)+1;
	ll ao=((a-1)/d)+1;
	if(ao<ta)cout<<"No";
	else cout<<"Yes";
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
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;
}
const long long INF = 1LL << 60;

long long gcd (long long a,long long b) {
    if(a % b == 0) {
        return b;
    }else {
        return (gcd(b,a%b));
    }
}

int main() {
    long long a,b;
    cin >> a >> b;
    cout << a/gcd(a,b)*b;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)	
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = pow(10,18);
ll modulo = pow(10,9)+7  ;
#define ld long double
#define MAX (int)(330)


void deal(){
	ll n;
	cin>>n;
	vector<ll> arr(n);
	vector<vector<ll> > dp(n, vector<ll>(n,0));
	fori(n)
		cin>>arr[i], dp[i][i] = arr[i];
	for(ll gap = 1; gap<n; ++gap)
		for(ll i = 0, j = gap; j<n; ++i, ++j)
			dp[i][j] = max(arr[i]-dp[i+1][j], arr[j] - dp[i][j-1]);
	cout<<dp[0][n-1];
}
 
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}
 
/*
 
5 1
1 2 3 4 5


*/

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

int main(){
  int a,b,count=0;
  cin >> a >>b;
  
  int check = 10001;

  int a_1 = 1;
  int a_2 = 0;
  int a_3 = 0;
  int a_4 = 0;
  int a_5 = 1;
  
  while(check <= b){
    if(check >= a){
      count += 1;
    }
    
    if(a_3<9){
      a_3 += 1;
    }else if(a_2<9){
      a_3 = 0;
      a_2 += 1;
    }else if(a_1<9){
      a_3 = 0;
      a_2 = 0;
      a_1 += 1;
    }else{
      a_1 += 1;
    }
    
    a_5 = a_1;
    a_4 = a_2;
    check = a_1*10000 + a_2*1000 + a_3*100 + a_4*10 +a_5;
  }
  
  cout << count << endl;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N="0";
  int i=0;
  
  cin >> N;
  
  if (N[0]=='1') {
    i++;
  }
  
  if (N[1]=='1') {
    i++;
  }
  
  if (N[2]=='1') {
    i++;
  }
  
  cout << i;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define maxn 1010
using namespace std;
typedef long long ll;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n;
struct P{
    int x,y;
}p[maxn];
int a[maxn],cnt;
char ans[maxn],top;
void work(int x,int y)
{
    top=0;
    for(int i=cnt;i>=1;i--)
    {
        if(abs(x)>abs(y))
        {
            if(x<0)
            {
                x+=a[i];
                ans[++top]='L';
            }
            else{
                x-=a[i];
                ans[++top]='R';
            }
        }
        else{
            if(y<0)
            {
                y+=a[i];
                ans[++top]='D';
            }
            else{
                y-=a[i];
                ans[++top]='U';
            }
        }
    }
    for(int i=top;i>=1;i--)  printf("%c",ans[i]);
    puts("");
}
int main()
{
    n=read();
    for(int i=1;i<=n;i++)  p[i].x=read(),p[i].y=read();
    int com=((p[1].x+p[1].y)&1);
    for(int i=1;i<=n;i++)
    {
        if(((p[i].x+p[i].y)&1)!=com)
        {
            puts("-1");
            return 0;
        }
    }
    int mx=0;
    for(int i=1;i<=n;i++)  mx=max(mx,p[i].x+p[i].y-(!com));
    if(com==0)  a[++cnt]=1;
    for(int i=0;;i++)
    {
        if((1ll<<i)>mx)  break;
        a[++cnt]=(1<<i);
    }
    printf("%d\n",cnt);
    for(int i=1;i<=cnt;i++)  printf("%d ",a[i]);
    puts("");
    for(int i=1;i<=n;i++)  work(p[i].x,p[i].y);
    return 0;
}

Measured memory_bytes: 256
N, K = tuple(map(int, input().split()))
D = list(map(int, input().split()))
set_D = set(D)
i = N
while True:
    tmp_set = set([int(c) for c in str(i)])
    if len(set_D.intersection(tmp_set)) > 0:
        i += 1
        continue
    else:
        break
print(i)


Measured memory_bytes: 2940
#include<stdio.h>
void trace(int A[],int N){
  int i;
 
  for(i=0;i<N;i++){
    if(i>0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
}

void swap(int *x,int *y)
{
  int a;
  a=*x;
  *x=*y;
  *y=a;
}

int main(){
  int A[100];
  int i,j,n,N;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);

  for(i=0,N=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(A[j]<A[j-1]){
	swap(&A[j],&A[j-1]);
	N++;
      }
    }
  }
  trace(A,n);
  printf("%d\n",N);
  return 0;
}

Measured memory_bytes: 604
#problems2
#silver fox vs monster
import math
N,D,A=map(int,input().split())
d=[]
for _ in range(N):
    x,h=map(int,input().split())
    d.append((x,h))
d.sort(key=lambda x:x[0])

now_damage=0
from collections import deque
d=deque(d)
ans=0
d_field=deque()
while d:
    x=d.popleft()
    place,life=x
    if d_field:
        while (d_field and d_field[0][0]<place) :
            now_damage-=A*d_field[0][1]
            d_field.popleft()      
    if life<=now_damage:
        pass
    elif life>now_damage:
        K=math.ceil((life-now_damage)/A)
        ans+=K
        now_damage+=K*A
        d_field.append((2*D+place,K))        
print(ans)


Measured memory_bytes: 103876
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>

int main(int,char**){
	int n,cnt;
	while(std::cin >>n){
		cnt = 0;
		for(int a(0);a<10;++a){
			if(a>n) continue;
			for(int b(0);b<10;++b){
				if(a+b>n) continue;
				for(int c(0);c<10;++c){
					if(a+b+c>n) continue;
					for(int d(0);d<10;++d){
						if(a+b+c+d==n) ++cnt;
					}
				}
			}
		}

		std::cout << cnt <<std::endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    int N, K;
    cin >> N >> K;

    int ans;
    ans = K * pow(K - 1, N - 1);
    cout << ans << endl;
    return (0);
}

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

import sys

sys.setrecursionlimit(10 ** 9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
INF=float('inf')

# Union-Find木
class UnionFind:
    def __init__(self, n):
        self.n = n
        # 親要素のノード番号を格納。par[x] == xの時そのノードは根
        # 1-indexedのままでOK、その場合は[0]は未使用
        self.par = [i for i in range(n+1)]
        # 木の高さを格納する（初期状態では0）
        self.rank = [0] * (n+1)
        # あるノードを根とする集合に属するノード数
        self.size = [1] * (n+1)
        # あるノードを根とする集合が木かどうか
        self.tree = [True] * (n+1)

    # 根の検索(グループ番号と言えなくもない)
    def find(self, x):
        # 根ならその番号を返す
        if self.par[x] == x:
            return x
        else:
            # 走査していく過程で親を書き換える
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)

        # 木かどうかの判定用
        if x == y:
            self.tree[x] = False
            return
        if not self.tree[x] or not self.tree[y]:
            self.tree[x] = self.tree[y] = False

        # 木の高さを比較し、低いほうから高いほうに辺を張る
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            # 木の高さが同じなら片方を1増やす
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # あるノードの属する集合のノード数
    def get_size(self, x):
        return self.size[self.find(x)]

    # 木かどうかの判定
    def is_tree(self, x):
        return self.tree[self.find(x)]

    # 集合の数
    def len(self):
        res = set()
        for i in range(self.n+1):
            res.add(self.find(i))
        # グループ0の分を引いて返却
        return len(res) - 1

N,Q=MAP()
uf=UnionFind(N)
for _ in range(Q):
    com,x,y=MAP()
    if com==0:
        uf.union(x, y)
    else:
        print(int(uf.same(x, y)))



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

int main()
{
  int n, m;
  cin >> n >> m;
  int a=pow(10,n);
  string str = to_string(a);
  vector<int> s(m);
  vector<int> c(m);
  for (int i = 0; i < m; i++)
  {
    cin >> s.at(i) >> c.at(i);
  }
  for (int j = 0; j < stoi(str); j++)
  {
    bool flag=true;
    for(int k=0;k<m;k++)
    {
      if(to_string(j).length()<s.at(k))
      {
        flag=false;
        break;
      }
      if(to_string(j).at(s.at(k)-1)-'0'!=c.at(k))
      {
        string test1=to_string(j);
        int test=(to_string(j).at(s.at(k)-1));
        flag=false;
        break;
      }
    }
    if(flag==true&&to_string(j).length()==n)
    {
      cout<<j;
      return 0;
    }
  }
  cout<<-1;
  return 0;
}

Measured memory_bytes: 384
n, m = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
if n >= m:
    print(0)
    exit()
diff = []
for i in range(m-1):
    diff.append(X[i+1] - X[i])
diff.sort()
print(sum(diff[:(m-n)]))


Measured memory_bytes: 13968
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        p: [usize; n],
    }
    let max = p.iter().max().unwrap();
    let sum = p.iter().sum::<usize>();
    println!("{}", sum - max / 2);
}


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

int main(int argc, char* argv[])
{
//TLE
//  int n; cin >> n;
//  vector<string> v(n);
//  int cnt=0;
//
//  for(int i=0; i<n; ++i)
//  {
//    string tmp; cin >> tmp;
//    bool ch=true;
//    for(string x: v)
//    {
//      if(x==tmp)
//      {
//        ch = false;
//        break;
//      }
//    }
//    if(ch)
//    {
//      cnt++;
//      v.push_back(tmp);
//    }
//  }
//
//  cout << cnt << endl;
  
  int n; cin >> n;
  set<string> s;
  for(int i=0; i<n; ++i)
  {
    string tmp;
    cin >> tmp;
    s.insert(tmp);
  }
  cout << s.size() << endl;
  




  return 0;
}





Measured memory_bytes: 19164
// https://atcoder.jp/contests/dp/tasks/dp_e

#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>

using namespace std;

struct Item {
	long long w;
	long long v;
};

int main (int argc, char* argv[]) {
	long long n, w;
	cin >> n >> w;

	vector<Item> items;
	for (long long i = 0; i < n; i++) {
		long long w, v;
		cin >> w >> v;
		items.emplace_back(Item { w, v });
	}

	const long long max_v = 100000;

	// minimum weight for i value
	vector<vector<long long>> dp(n + 1, vector<long long>(max_v + 1, w + 1));
	// knapsack with no value costs no weight
	for (long long i = 0; i < n + 1; i++) {
		dp[i][0] = 0;
	}
	for (long long i = 1; i < n + 1; i++) {
		const auto& c = items[i - 1];
		for (int j = 1; j <= max_v; j++) {
			dp[i][j] = min(dp[i - 1][j], j - c.v >= 0 ? dp[i - 1][j - c.v] + c.w : numeric_limits<long long>::max());
		}
	}

	for (long long i = max_v; i >= 0; i--) {
		if (dp.back()[i] <= w) {
			cout << i << endl;
			return 0;
		}
	}

	cout << 0 << endl;
}


Measured memory_bytes: 80256
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}

int main() {
	cin >> s;
	map<char, ll> a;
	char p = 's';
	char q = 's';
	rep(j, 4) {
		for (char i = 'A'; i <= 'Z'; i++) {
			if (i == s[j]) {
				a[i]++;
				break;
			}
		}
	}
	int cnt = 0;
	for (char i = 'A'; i <= 'Z'; i++) {
		if (a[i]==2) {
			cnt++;
		}
	}
	if (cnt == 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  
  if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 3548
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String revStr, str = in.readLine();
        int a, b, num = Integer.parseInt(in.readLine());
        StringBuffer sb = new StringBuffer(str);
        for (int i = 0; i < num; i++) {
            String[] order = in.readLine().split(" ");
            a = Integer.parseInt(order[1]);
            b = Integer.parseInt(order[2]);
            if (order[0].equals("print")) {
                System.out.println(str.substring(a, b + 1));
            } else if (order[0].equals("reverse")) {
                StringBuffer revSb = new StringBuffer(str.substring(a, b + 1));
                revStr = revSb.reverse().toString();
                str = sb.replace(a, b + 1, revStr).toString();
            } else if (order[0].equals("replace")) {
                str = sb.replace(a, b + 1, order[3]).toString();
            }
        }
    }
}

Measured memory_bytes: 24684
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<lol, lol>;
typedef vector<int> vit;

/*
struct SegmentTree{
  
  vector<lol> SumV(1000005,0);
  vector<lol> MaxV(1000005,0);
  vector<lol> MinV(1000005,0);
  int N;
  
  void update(int i,int x){
    i += N - 1;
    minv[i] = x;
    maxv[i] = x;
    sumv[i] = x;
    while(i > 0){
      i = (i - 1)/2;
      maxv[i] = max(maxv[i*2+1],maxv[i*2+2]);
      minv[i] = min(minv[i*2+1],minv[i*2+2]);
      sumv[i] = sumv[i*2+1]+sumv[i*2+2];
    }
  }
  
  void add(int i,int x){
    i += N - 1;
    sumv[i] += x;
    maxv[i] += x;
    minv[i] += x;
    while(i > 0){
      i = (i - 1)/2;
      sumv[i] = sumv[i*2+1]+sumv[i*2+2];
      minv[i] = min(minv[i*2+1],minv[i*2+2]);
      maxv[i] = max(maxv[i*2+1],maxv[i*2+2]);
    }
  }
  
  int getmax(int a,int b,int k,int l,int r){
    if(r <= a || b <= l) return -INF;
    if(a <= l && r <= b) return maxv[k];
    else{
      int c1 = getmax(a,b,2*k+1,l,(l+r)/2);
      int c2 = getmax(a,b,2*k+2,(l+r)/2,r);
      return max(c1,c2);
    }
  }
  
  int getmin(int a,int b,int k,int l,int r){
    if(r <= a || b <= l) return INF;
    if(a <= l && r <= b) return minv[k];
    else{
      int c1 = getmin(a,b,2*k+1,l,(l+r)/2);
      int c2 = getmin(a,b,2*k+2,(l+r)/2,r);
      return min(c1,c2);
    }
  }
  
  int getsum(int a,int b,int k,int l,int r){
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) return sumv[k];
    else{
      int c1 = getsum(a,b,2*k+1,l,(l+r)/2);
      int c2 = getsum(a,b,2*k+2,(l+r)/2,r);
      return c1+c2;
    }
  }
}
*/

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}
//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}


signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  int ans[s.size() + 5] = {};
  rep(i, s.size()){
    if(s[i] == '<'){
      ans[i + 1] = ans[i] + 1;
    }
  }
  for(int i = s.size() - 1;i >= 0;i --){
    if(s[i] == '>'){
      ans[i] = max(ans[i], ans[i + 1] + 1);
    }
  }
  lol sum = 0;
  rep(i, s.size() + 1){
    sum += ans[i];
  }
  cout << sum << '\n';
  return 0;
}


Measured memory_bytes: 5876
import math
N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]
ans = 0
for i in range(N):
    for j in range(i+1, N):
        s = 0
        for xi, xj in zip(X[i], X[j]):
            s += (xi - xj)**2
        # print(math.sqrt(s) % 1)
        if math.sqrt(s) % 1 == 0:
            ans += 1
print(ans)


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

bool f(int n, string s){
	if(n & 1) return false;
	for(int i=0; i<n/2; i++){
		if(s[i] != s[n/2+i]) return false;
	}
	return true;
}

int main() {
	int n;
	string s;
	cin >> n >> s;
	if(f(n,s)) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256