akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
const int N = 202020;
ll fac[N];
ll finv[N];
ll inv[N];
void modinv(int max) {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < max; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll comb(int n, int r) {
	if (n < r) return 0;
	if (n < 0 || r < 0) return 0;
	return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}
int main() {
	modinv(N);
	int n, k;
	cin >> n >> k;
	chmin(k, n);
	ll ans = 0;
	rep(i, k + 1) { // 
		int box = n - i;
		ll res = comb(n, i) * comb(n - 1, box - 1) % MOD;
		ans += res;
		ans %= MOD;
		// cout << comb(n - 1, box - 1) << endl;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int N,X;
  cin >> N >> X;
  vector<int> M(N);
  int sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> M.at(i);
    sum += M.at(i); 
  }
  sort(M.begin(),M.end());
  X -= sum;
  int ans = N + X / M.at(0);
  cout << ans << endl;
}

Measured memory_bytes: 3552
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
const int maxn=50;
int time[maxn],minn,pos,n;
bool vis[maxn];
vector <pair<int,int> > ve[maxn];
void init() {
    pos=-1;
    minn=0x7f7f7f7f;
    for(int i=0;i<=n;i++)
        ve[i].clear();
    int m=0;
    for(int i=1;i<=n;i++) {
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        ve[a].push_back(make_pair(b,c));
        ve[b].push_back(make_pair(a,c));
        m=max(m,a);
        m=max(m,b);
    }
    n=m;
}

void spfa(int s) {
    queue <int> qu;
    memset(vis,0,sizeof(vis));
    memset(time,0x7f,sizeof(time));
    qu.push(s);
    time[s] = 0;
    while(!qu.empty()) {
        int now=qu.front(); 
		qu.pop();
        vis[now]=false;
        for(int i=0;i<ve[now].size();i++) {
            int v=ve[now][i].first;
            int d=ve[now][i].second;
            if(d+time[now]<time[v]) {
                time[v]=time[now] + d;
                if(!vis[v]) {
                    qu.push(v);
                    vis[v] = true;
                }
            }
        }
    }
}

bool updatamin() {
    int sum=0;
    for(int i=0;i<=n;i++)
        sum+=time[i];
    if(sum<minn) {
        minn=sum;
        return true;
    }
    return false;
}

int main() {
    while(scanf("%d",&n)) {
    	if(n==0) break;
        init();
        for(int i=0;i<=n;i++) {
            spfa(i);
            if(updatamin()) {
                pos = i;
            }
        }
        printf("%d %d\n",pos,minn);
    }
    return 0;
}


Measured memory_bytes: 2592
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

#import math
#mod = 10**9+7
def main():
  s = input()
  ans = ""
  for a in s:
    if a == '0':
      ans+=a
    elif a == '1':
      ans+=a
    elif a == 'B':
      ans = ans[0:len(ans)-1]
  print(ans)
if __name__ == '__main__':
  main()

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

const int mod = 1000000007;
const int MAX_N = 100005;

ll dp[MAX_N];

int main(void){
    int N,M;
    cin >> N >> M;
    vector<bool> vec(N+1,false);
    for(int i=0;i<M;i++){
        int n;
        cin >> n;
        vec[n] = true;
    }

    for(int i=0;i<=N;i++) dp[i] = 0;
    dp[0] = 1;
    if(vec[1]) dp[1] = 0;
    else dp[1] = 1;

    for(int i=1;i<N;i++){
        if(vec[i+1]) dp[i+1]=0;
        else dp[i+1] = (dp[i]+dp[i-1])%mod;
    }

    cout << dp[N] << endl;
}

Measured memory_bytes: 1024
while 1:
 n=int(input())
 if n==0:break
 d={}
 for _ in[0]*n:
  k,v=input().strip().split()
  d[k]=v
 a=''
 for _ in[0]*int(input()):
  e=input().strip()
  a+=d[e]if e in d else e
 print(a)


Measured memory_bytes: 6480
#include <stdio.h>
#include <math.h>
#include<string.h>
int main(){
    int n, d, e, count = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d%d", &d, &e);
        if(d == e){
            count++;
        }
        else{
            count = 0;
        }
        if(count == 3){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 1660
#![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 = unsafe { _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>()
        };
    }

    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();
            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 unsafe 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];
            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: usize,
        xus: [(f64, String); n],
    }
    let y = xus
        .into_iter()
        .map(|(x, u)| match u.as_ref() {
            "JPY" => x,
            "BTC" => 380000.0 * x,
            _ => unimplemented!(),
        })
        .sum::<f64>();
    println!("{}", y);
}


Measured memory_bytes: 4352
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		sc.close();
		List<String> list = Arrays.asList(str.split(""));
		int size = list.size();
		int i = size / 2;
		int count = 0;
		for (int j = 0; j < i; j++) {
			if (!list.get(j).equals(list.get(size - 1 - j))) {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k,q;
  	cin>>n>>k>>q;
  	vector<int>point(n,k-q);
  	int w;
  	
  	for(int i=0;i<q;i++){
      cin>>w;
    point.at(w-1)++;
    }
  	for(int i=0;i<n;i++){
    if(point.at(i)>0){
    	cout<<"Yes"<<endl;
    }
    else{
    cout<<"No"<<endl;
    }
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ls u*2
#define rs u*2+1
#define mid (l+r)/2
#define int long long
using namespace std;
const int N=3e5;
int n,m,s,t;
int x[N];
int bj[N*2],lmin[N*2],rmin[N*2];
inline int read(){
	char c=getchar();
	register int s=0;
	while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9'){
		s=s*10+c-'0';
		c=getchar();
	}return s;
}
inline void pushdown(register int u){
	if(!bj[u])return ;
	bj[ls]+=bj[u];
	bj[rs]+=bj[u];
	lmin[ls]+=bj[u];
	rmin[ls]+=bj[u];
	lmin[rs]+=bj[u];
	rmin[rs]+=bj[u];
	bj[u]=0;
	return ;
}
void update(int u){
	lmin[u]=min(lmin[ls],lmin[rs]);
	rmin[u]=min(rmin[ls],rmin[rs]);
}
int query(int u,int l,int r,int L,int R)
{
	if(L>R)return 191919810889;
	if(L<=l&&R>=r){
		return lmin[u];
	}
	pushdown(u);
	int minn=1919191989881;
	if(L<=mid)minn=query(ls,l,mid,L,R);
	if(R>mid)minn=min(minn,query(rs,mid+1,r,L,R));
	update(u);
	return minn;
}
int ask(int u,int l,int r,int L,int R)
{
	if(L>R)return 191919818809;
	if(L<=l&&R>=r){
		return rmin[u];
	}
	pushdown(u);
	int minn=1919191988819;
	if(L<=mid)minn=ask(ls,l,mid,L,R);
	if(R>mid)minn=min(minn,ask(rs,mid+1,r,L,R));
	update(u);
	return minn;
}
void add(int u,int l,int r,int k,int summ){
	if(l==r){
		
		lmin[u]=min(lmin[u],summ-l);
		rmin[u]=min(rmin[u],summ+l);
	//	cout<<"hh:"<<rmin[u]<<endl;
		return ;
	}
	pushdown(u);
	if(k<=mid)add(ls,l,mid,k,summ);
	if(k>mid)add(rs,mid+1,r,k,summ);
	update(u);
}
int modify(int u,int l,int r){
	if(l==r){
		return rmin[u]-l;
	}
	pushdown(u);
	int minn=191919818880;
	minn=min(modify(ls,l,mid),modify(rs,mid+1,r));
	return minn;
}
signed main()
{
	n=read();m=read();s=read();t=read();
	x[0]=s;
	for(register int i=1;i<=m;i++){x[i]=read();}
	memset(lmin,10,sizeof(lmin));
	memset(rmin,10,sizeof(rmin));
	add(1,1,n,t,0);
	for(int i=1;i<=m;i++){
		int af=min(query(1,1,n,1,x[i])+x[i],ask(1,1,n,x[i],n)-x[i]);
//		cout<<af<<endl;
		bj[1]+=abs(x[i]-x[i-1]);
		lmin[1]+=abs(x[i]-x[i-1]);
		rmin[1]+=abs(x[i]-x[i-1]);
		add(1,1,n,x[i-1],af);
	}
	printf("%lld",modify(1,1,n));
	return 0;
}

Measured memory_bytes: 18720
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {

int main(void) {
  ll x;cin>>x;
  ll sta=100;
  ll mark=0;
  while(sta<x) {
    sta *= 1.01;
    mark++;
  }
  pr(mark);
  return 0;
}


Measured memory_bytes: 3620
import Data.Char
main = do
  str <- getLine
  let [x,y]=map read $ words str :: [Int]
  putStrLn $ "a"++(poyo $ compare y x)++"b"

toint a c = a*10+digitToInt c
poyo GT =" < " 
poyo LT =" > "
poyo EQ =" == "

Measured memory_bytes: 3484
#include <bits/stdc++.h>
#define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long LL;
const int maxn= 100000 + 10;

int fro, rea , que[maxn*10], K, d[maxn];
bool inq[maxn];
int SPFA(int K){
	for (int i=0; i<K; i++) d[i] = K+1;
	fro= rea= 0;
	que[rea++] = 1; d[1] = 1;
	while ( fro != rea){
		int u = que[fro++] ; inq[u] = false;
		int v= (u*10)%K;
		if ( d[v] > d[u] ){
			d[v] =d[u];
			if ( !inq[v] ){ que[rea++] = v; inq[v] = true;}
		}
		v= (u+1)%K;
		if ( d[v] > d[u]+1){
			d[v] = d[u]+1;
			if ( !inq[v]) { que[rea++] =v; inq[v] = true;}
		}
	}
	return d[0];
}
int main(){

	int K; scanf("%d", &K);
	printf("%d\n", SPFA(K));
	return 0;
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void){

	int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if(x>=r && x<=W-r && y>=r && y<=H-r){
        printf("Yes\n");
    }else{
    	printf("No\n");

    }
    return 0;
}

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

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

const int N = 1e5 + 10;
char s[5];


int main() {
    cin >> s;
    int ret = 0;
    int a = (s[0] - '0') * 10 + s[1] - '0';
    if (a <= 12 && a > 0) ret++;
    a = (s[2] - '0') * 10 + s[3] - '0';
    if (a <= 12 && a > 0) ret += 2;
    if (ret == 0) puts("NA");
    if (ret == 1) puts("MMYY");
    if (ret == 2) puts("YYMM");
    if (ret == 3) puts("AMBIGUOUS");
    return 0;       
}

Measured memory_bytes: 256
fn nine_by_nine() -> Result<i32, &'static str> {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input)
        .map_err(|_| "input error")?;

    let ab: Vec<i32> = input.split_whitespace()
        .map(|n| n.parse::<i32>().unwrap())
        .collect();

    if ab.iter().all(|&n| n <= 9) {
        Ok(ab[0] * ab[1])
    }
    else {
        Ok(-1)
    }
}

fn main() {
    println!("{}", nine_by_nine().unwrap());
}


Measured memory_bytes: 4352
<?php
fscanf(STDIN, "%d", $n);
$x = explode(' ', trim(fgets(STDIN)));
$y = $x;
sort($y);
$i = $n / 2;
$a = $y[$i-1];
$b = $y[$i];
if ($a == $b) {
	echo str_repeat("$a\n", $n - 1), $a;
} else {
	foreach ($x as $v) {
		if ($v <= $a) {
			$t[] = $b;
		} else {
			$t[] = $a;
		}
	}
	echo implode("\n", $t);
}

Measured memory_bytes: 41456
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 5e2 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int d, n;
	cin >> d >> n;
	int x = 1;
	if (d == 1) x = 100;
	else if (d == 2) x = 10000;
	if (n == 100) n++;
	cout << n * x << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		Integer[] a = new Integer[N];
		for (int i = 0; i < N; i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		int alice = 0;
		int bob = 0;
        Arrays.sort(a, Comparator.reverseOrder());
		for (int i = 0; i < N; i++) {
			if (i%2==0) {
				alice += a[i];
			} else {
				bob += a[i];
			}
		}
		System.out.println(alice - bob);
	}
}

Measured memory_bytes: 35772
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>

int main()
{
    int  n,k;
    scanf("%d%d",&n,&k);
    if(n>8||k>8) printf(":(\n");
    else printf("Yay!\n");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a;
		int b;
		String op;
		int count;
		int[] num = new int[20000];
		top: for (count = 0; true; count++) {
			a = sc.nextInt();
			op = sc.next();
			b = sc.nextInt();
			switch (op) {
			case "+":
				num[count] = a + b;
				break;
			case "-":
				num[count] = a - b;
				break;
			case "*":
				num[count] = a * b;
				break;
			case "/":
				num[count] = a / b;
				break;
			case "?":
				break top;
			}
		}
		for (int i = 0; i < count; i++) {
			System.out.println(num[i]);
		}
		sc.close();
	}
}


Measured memory_bytes: 26236
import sys
import bisect
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    UV = [[int(x) for x in input().split()] for _ in range(N - 1)]

    T = [[] for j in range(N + 1)]

    for u, v in UV:
        T[u].append(v)
        T[v].append(u)

    s = collections.deque()

    lis = []
    s.append([1, lis])

    v = set()

    ans = [0] * (N + 1)
    memo = [[] for j in range(N + 1)]

    while s:
        c = s[-1]
        ci, clis = c[0], c[1]

        # lis処理
        if ci not in v:
            if len(clis) == 0:
                clis.append(A[ci - 1])
                memo[ci].append(-1)
            else:
                if clis[-1] < A[ci - 1]:
                    clis.append(A[ci - 1])
                    memo[ci].append(-1)
                else:
                    i = bisect.bisect_left(clis, A[ci - 1])
                    memo[ci].append(i)
                    memo[ci].append(clis[i])
                    clis[i] = A[ci - 1]

            v.add(ci)
            ans[ci] = len(clis)

        if len(T[ci]) >= 1:
            n = T[ci].pop()
            if n in v:
                continue
            s.append([n, clis])
            continue

        if memo[ci][0] == -1:
            if len(clis) >= 1:
                clis.pop()
        else:
            clis[memo[ci][0]] = memo[ci][1]

        s.pop()

    for i in range(1, N + 1):
        print(ans[i])


if __name__ == '__main__':
    main()


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<pair<int,int>> v(N);
    for (int i = 0; i < N; ++i) {
        v[i].first = i;
        cin >> v[i].second;
    }
    sort(v.begin(), v.end(), [](const pair<int,int> &a, const pair<int,int> &b) {
        return a.second > b.second;
    });
    vector<vector<long long>> dp(N+1, vector<long long>(N+1, 0));

    long long ans = 0;

    for (int n = 1; n <= N; ++n) {
        for (int left = 0; left <= n; ++left) {
            int right = n - left;
            long long w = v[n-1].second;
            if (left > 0)
                dp[left][right] = max(dp[left - 1][right] + w * abs(left - 1 - v[n - 1].first), dp[left][right]);
            if (right > 0)
                dp[left][right] = max(dp[left][right - 1] + w * abs(N - right - v[n - 1].first), dp[left][right]);

            if (n == N) {
                ans = max(ans, dp[left][right]);
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 34608
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,c;
  cin >> n >> c;
  vector<vector<int>> d(c,vector<int>(c));
  vector<vector<int>> t(3,vector<int>(c));
  for(int i=0;i<c;i++){
    for(int j=0;j<c;j++){
      cin >> d[i][j];
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      int s;
      cin >> s;
      t[(i+j)%3][s-1]++;
    }
  }
  int ans=1e9;
  for(int i=0;i<c;i++){
    for(int j=0;j<c;j++){
      if(i!=j){
        for(int k=0;k<c;k++){
          if(i!=k&&j!=k){
            int sum=0;
            for(int l=0;l<c;l++){
              sum+=d[l][i]*t[0][l];
            }
            for(int l=0;l<c;l++){
              sum+=d[l][j]*t[1][l];
            }
            for(int l=0;l<c;l++){
              sum+=d[l][k]*t[2][l];
            }
            ans=min(ans,sum);
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    n = int(input())
    ai = list(map(int, input().split()))
    ai = sorted(ai, reverse=True)
    assert len(ai) == n * 3
    res = 0
    for i in range(n):
        res += ai[i * 2 + 1]
    print(res)

main()


Measured memory_bytes: 37596
#include<bits/stdc++.h>
#define Vsort(a) sort(a.begin(), a.end())
#define rep(i,n) for(int i = 0; i < (n); i++)
#define Srep(i,a,n) for(int i = (a); i < (n); i++)
#define ll long long
#define P pair<int, int>
using namespace std;

int main(){
  ll a,b,k;
  cin >> a >> b >> k;
  if(a < k){
    b -= k - a;
    a = 0;
    if(b < 0) b = 0;
  }else{
    a -= k;
  }
  cout << a << " " << b << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    map<long long, int> mp;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        mp[x]++;
    }
    vector<long long> ans(2);
    for (auto p : mp) {
        int j = p.second;
        for (int i = 0; i < 2; i++) {
            if(j < 2) break;
            if (p.first > ans[i]) {
                ans[i] =  p.first;
                j -= 2;
            }
        }
        sort(ans.begin(), ans.end());
        debug(ans);
    }
    cout << ans[0] * ans[1];
    return 0;
}


Measured memory_bytes: 9728
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <iomanip>
#include <iostream>
#include <map>

using namespace std;

const int CMax = 100005;

int main()
{
    int n, k;
    long long num, sum = 0;
    vector<long long> H;
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%lld", &num);
        H.push_back(num);
    }
    sort(H.begin(), H.end());

    for (int i = 0; i < n-k; i++) {
        sum += H[i];
    }

    printf("%lld\n", sum);
}


Measured memory_bytes: 2420
using System.Linq;
using System;

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var arr = new long[n];
        string[] line = Console.ReadLine().Trim().Split(' ');
        for (int i = 0; i < n; i++) arr[i] = int.Parse(line[i]);
        Console.WriteLine("{0} {1} {2}", arr.Min(), arr.Max(), arr.Sum());

    }
}

Measured memory_bytes: 10012
def main():
    problem_num = int(input())
    solve_time = list(map(int, input().split()))
    drink_variation = int(input())
    drinks = [tuple(map(int, input().split())) for _ in range(drink_variation)]
    max_solve_time = sum(solve_time)
    for drink in drinks:
        print(max_solve_time - solve_time[drink[0] - 1] + drink[1])


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int a[200000];
int u[200000];
int t[200000];

int main()
{
    int n;
    int64_t k;
    cin >> n >> k;

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

    int cur = 0;
    int64_t flen = 0;
    int ls = 0;

    while (true)
    {
       u[cur] = 1;
       t[flen++] = cur;

       if (u[a[cur]])
       {
           ls = a[cur];
           break;
       }
       cur = a[cur];
    }

    int64_t clen = 0;
    int64_t nclen = 0;

    for (int i = 0; i < flen; ++i)
    {
        if (t[i]== ls)
        {
            nclen = i;
            clen = flen - nclen;
            break;
        }
    }

    //cout << "clen = " << clen << ", nclen = " << nclen << "\n";
    if (flen > k)
    {
        cout << t[k]+1 << "\n";
    }
    else
    {
        k -= nclen;
        int ix = k%clen;
        cout << t[nclen+ix]+1 << "\n";
    }
    return 0;
}


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

int dx[]={1,0,2,2,0,1,1,0,2};
int dy[]={1,0,2,0,2,0,2,1,1};
int f[3][3],cnt;

bool check(int p, int val, int mod)
{
	if(p==4) return (val==(f[2][0]+f[1][1]+f[0][2])%mod);
	if(p==5) return (val==(f[0][0]+f[1][0]+f[2][0])%mod);
	if(p==6) return (val==(f[0][2]+f[1][2]+f[2][2])%mod)&&(val==(f[1][0]+f[1][1]+f[1][2])%mod);
	if(p==7) return (val==(f[0][0]+f[0][1]+f[0][2])%mod);
	if(p==8) return (val==(f[2][0]+f[2][1]+f[2][2])%mod)&&(val==(f[0][1]+f[1][1]+f[2][1])%mod);
	
	return true;
	
}

void dfs(int p, int mod, int val, int used)
{
	if(p==3)
	{
		val=(f[0][0]+f[1][1]+f[2][2])%mod;
	}
	if(p==9)
	{
		 cnt++;
		 return;
	}
	
	int x=dx[p], y=dy[p];
	if(f[x][y]!=0) 
	{
		if(check(p,val,mod)) dfs(p+1, mod, val, used);
	}
	else
	{
		for(int i=1; i<=10; i++)
		{
			if(used&(1<<i)) continue;
			f[x][y]=i;
			if(check(p,val,mod)) dfs(p+1, mod, val, used|(1<<i));
			f[x][y]=0;
		}
	}
}

int main()
{
	while(1)
	{
		cnt=0;
		int mod, used=0;
		for(int i=0; i<3; i++)
		for(int j=0; j<3; j++)
		{
			scanf("%d", &f[j][i]);
			if(f[j][i]!=-1) used|=(1<<f[j][i]);
		}
		
		if(f[0][0]==-1) break;
		
		scanf("%d", &mod);
		if(mod==0)
		{
			for(int i=1; i<=10; i++)
			{
				if(used&(1<<i)) continue;
				dfs(0, i, -1, used|(1<<i));
			}
		}
		else dfs(0, mod, -1, used|(1<<mod));
		printf("%d\n", cnt);
	}
}

Measured memory_bytes: 760
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int x, y;
  cin >> x >> y;
  for (int i = 0; i <= 100000; ++i) {
    int j = x - i;
    if (0 <= j && j <= 100000 && (i * 2 + j * 4 == y)) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main()
{
    long long l,r;;
    cin >> l >> r;
        if(l/2019!=r/2019)
            cout << 0 << endl;
        else
        {
            long long ans=999999999;
            for(long long i=l;i<=r;i++)
            {
                for(long long j=i+1;j<=r;j++)
                {
                    ans=min(i*j%2019,ans);
                }
            }
            cout << ans << endl;
        }
    return 0;
}


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

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi l(n);
    rep(i, n) cin >> l[i];
    VSORT(l);
    ll ans = 0;
    rep(i, n) for (int j=i+1; j<n; ++j) {
        ans += distance(l.begin(), lower_bound(all(l), l[i]+l[j])) - (j + 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
W, H = (int(i) for i in input().split())
L = []
for i in range(W):
  L.append((int(input()), 0))
for i in range(H):
  L.append((int(input()), 1))
a = W
b = H
ans = 0
L.sort()
for i in range(H + W):
  if L[i][1] == 0:
    ans += (b+1) * L[i][0]
    a -= 1
  else:
    ans += (a+1) * L[i][0]
    b -= 1
print(ans)

Measured memory_bytes: 24536
#include<stdio.h>
int main(){
    long long int n;
    long long int a[200000];
    long long int b[200000];
    scanf("%lld",&n);
    int i;
    for(i=1;i<=n+1;i++){
        scanf("%lld",&a[i]);
    }
    for(i=1;i<=n;i++){
        scanf("%lld",&b[i]);
    }
    long long int k=0;
    for(i=1;i<=n;i++){
        if(b[i]>=a[i]){
            b[i]=b[i]-a[i];
            k+=a[i];
            if(b[i]>a[i+1]){
                k+=a[i+1];
                a[i+1]=0;
            }
            else{
                a[i+1]=a[i+1]-b[i];
                k+=b[i];
            }
        }
        else{
            k+=b[i];
        }
    }
    printf("%lld\n",k);
    return 0;
}

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

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

  int remainingMatches = 15 - results.size();
  int win = 0;
  char o = 'o';
  for(int i = 0; i < results.size(); i++) {
    if(results[i] == o) win += 1;
  }

  if (win + remainingMatches >= 8) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
S = input()
a = "".join(["0" if i%2 else "1" for i in range(len(S))])
b = "".join(["0" if i%2==0 else "1" for i in range(len(S))])
ans1 = 0
ans2 = 0
for i in range(len(S)):
    if a[i] != S[i]:
        ans1 += 1
    if b[i] != S[i]:
        ans2 += 1
print(min(ans1,ans2))

Measured memory_bytes: 4068
N = int(input())
X = list(map(int, input().split()))
Y = []
for i in range(N):
  Y.append(X[i])
Y.sort()
m = (Y[N//2-1] + Y[N//2]) / 2
#print(m)
for i in range(N):
  if X[i] <= m:
    print(Y[N//2])
  else:
    print(Y[N//2-1])


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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int>h(n);
  for(int i=0;i<n;i++)
    cin >> h.at(i);
  sort(h.begin(),h.end());
  int ans=1e9;
  for(int i=0;i<=n-k;i++){
    ans=min(ans,h.at(i+k-1)-h.at(i));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3752
w=input()
count=0
num=len(w)
w1=""
w+=" "
while count<num:
  if w[count]=="A":
    w1+="A"
    count+=1
  elif w[count]=="B":
    if w[count+1]=="C":
      w1+="D"
      count+=2
    else:
      w1+="B"
      count+=1
  else:
    w1+="C"
    count+=1
counta=0
ans=0
num=len(w1)
for i in range(num):
  if w1[i]=="A":
    counta+=1
  elif w1[i]=="D":
    ans+=counta
  else:
    counta=0
print(ans)

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

typedef long long ll;
const int maxn=100010;
int n,m;
vector<int> g[maxn], gg[maxn];
int cnt, vis[maxn], flag, in[maxn], tot[5], t;
ll ans;

void dfs(int x,int bel){
	vis[x]=1; cnt++; in[x]=bel; tot[bel]++;
	for(int i=0;i<g[x].size();i++){
		t++; int v=g[x][i]; if(v==x) flag=1; if(vis[v] && in[v]!=(bel+1)%3) flag=1; if(vis[v]) continue;
		dfs(v, (bel+1)%3);
	}
	for(int i=0;i<gg[x].size();i++){
		int v=gg[x][i]; if(v==x) flag=1; if(vis[v] && in[v]!=(bel-1+3)%3) flag=1; if(vis[v]) continue;
		dfs(v, (bel-1+3)%3);
	}
}

int main(){

	scanf("%d%d",&n,&m);
	int x, y;
	for(int i=1;i<=m;i++) scanf("%d%d", &x, &y), g[x].push_back(y), gg[y].push_back(x);
	for(int i=1;i<=n;i++) if(!vis[i]){
		memset(tot,0,sizeof(tot));
		cnt=0; flag=0; t=0;
		dfs(i,0);
		// printf("i = %d cnt = %d t = %d\n", i, cnt, t);
		if(flag){ ans+=1ll*cnt*cnt; }
		else if(!tot[0] || !tot[1] || !tot[2]) ans+=t;
		else ans+=1ll*tot[0]*tot[1]+1ll*tot[1]*tot[2]+1ll*tot[2]*tot[0];
		// printf("ans = %d\n", ans);
	}
	printf("%lld\n", ans);
	return 0;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  string S;
  cin >> S;
  cout << S.substr(0, 3);
  return 0;
}


Measured memory_bytes: 3580
n = int(input())
a = list(map(int, input().split()))
a.sort()
def Alchemy(x) :
    if len(x) == 1 :
        print(x[0])
    else :
        a = (x[0] + x[1])/2
        l = x[2:]
        l.insert(0,a)
        return Alchemy(l)

Alchemy(a)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define ft front()
#define bk back()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
template <class t>
bool ckmin(t& a, const t& b) {
    return a > b ? a = b, true : false;
}
template <class t>
bool ckmax(t& a, const t& b) {
    return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout \
    if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p);
template <class T>
struct IsC {
    template <class C>
    static char test(typename C::const_iterator*);
    template <class C>
    static int test(...);
    static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
    static const bool value = false;
};
template <class C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream& o,
                                                             const C& c) {
    o << '[';
    for (auto it = c.begin(); it != c.end();)
        o << *it << (++it != c.end() ? ", " : "");
    return o << ']';
}
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p) {
    return o << '(' << p.fi << ", " << p.se << ')';
}

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

    int n;
    ll k;
    cin >> n >> k;
    vi as(n);
    F0R (i, n) {
        cin >> as[i];
        --as[i];
    }
    int pos = 0;
    vi visited(n, -1);
    vi cycle;
    vi precycle;
    precycle.pb(pos);
    for (int i = 0; visited[pos] == -1; ++i) {
        visited[pos] = i;
        pos = as[pos];
        precycle.pb(pos);
    }
    precycle.pop_back();
    F0R (i, SZ(precycle)) {
        if (precycle[i] == pos) {
            cycle = vi(i + ALL(precycle));
            precycle.resize(i);
        }
    }
    dout << dvar(pos) << endl << dvar(precycle) << endl << dvar(cycle) << endl;
    if (k < SZ(precycle)) {
        cout << precycle[k] + 1 << endl;
    } else {
        k -= SZ(precycle);
        k %= (ll)SZ(cycle);
        cout << cycle[k] + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc164/abc164_c.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;
  
  set<string> c;
  rep(i, N) {
    string s;
    cin >> s;
    c.insert(s);
  }

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

Measured memory_bytes: 19192
def get_answer(input_list):
    so = input_list[0]
    t = input_list[1]

    s_len = len(so)

    """
    contest son
    s:5
    o:1 7+2
    n:2 7+3
    
    aabbcc abca
    a:0 0
    b:2 2
    c:4 4
    a:0 0 +6
    
    aa aaaa
    a:0
    a:1
    a:0 + 2
    a:1 + 2   
    
    aabbcc abccba
    a 0
    b 2
    c 4
    c 5
    b 2 6
    a 0 12 = 13
    """

    t_i = [-1] * len(t)
    s = so + so
    s_index = 0
    for i in range(len(t)):
        index = s.find(t[i], s_index)
        if index < 0:
            break
        index = index % s_len
        t_i[i] = index
        s_index = index + 1
        s_index = s_index % s_len

    if -1 in t_i:
        return -1


    t_len = len(t_i)
    ret = 0 #len(t_i)
    ret_i = 0
    for i in range(t_len):
        t1 = t_i[i]
        ret = t1
        if i < t_len - 1:
            t2 = t_i[i + 1]
            if t1 >= t2:
                ret_i += 1


    """
    for i in range((1000 - s_index) * s_len):
        find_flag = True
        ss = s
        for tt in t:
            ii = ss.find(tt)
            if ii < 0:
                find_flag = False
                break
            ss = ss[ii + 1:]
        if find_flag:
            ret = len(s)
            break
        s += so[s_index]
        s_index = (s_index + 1) % s_len
    """
    return ret_i * s_len + ret + 1

# b33 179
if __name__ == "__main__":
    input_list = []
    while True:
        try:
            input1 = input()
            if not input1:
                break
            if len(input1) == 0:
                break
            input_list.append(input1)
        except EOFError:
            break
    print(get_answer(input_list))


Measured memory_bytes: 7444
#include<iostream>
#include <string>
#include <vector>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;

const static ll INF = 1e18;
int main(){
    int H, N; cin >> H >> N;
    vector<int> w(N), v(N);
    for(int i = 0; i < N; i++){
        cin >> w[i] >> v[i];
    }
    int minw = w[0];
    for(int i = 0; i < N; i++) minw = max(minw, w[i]);

    int H_ = H + minw;

    ll dp[N+1][H_+1];
    for(int i = 0; i < N+1; i++) for(int j = 0; j < H_+1; j++) {
        if(j != 0) dp[i][j] = INF;
        else dp[i][j] = 0;
    }
 
    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= H_; j++) {
            if (j < w[i]) { //入れたいアイテムの重さがjを超えてる時、入れられない
                dp[i+1][j] = dp[i][j];
            } 
            else { //
                dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - w[i]] + v[i]);
                //cout << "y" << endl;
            }
        }
    }
    ll mindp = INF;
    for(int i = H; i <= H_; i++) mindp = min(mindp, dp[N][i]);

    cout << mindp << endl;
    /*for(int i = 0; i <= N; i++) {
      for(int j = 0; j <= H_; j++){
        cout << dp[i][j] << " ";
      }
      cout << endl;
    }
    cout << minw << " " << H_ << endl;*/
    
}

Measured memory_bytes: 87808
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,i,ans,x,y,z,w;cin>>N;
  ll A[N],B[N];vector<P>a(N),b(N);
  REP(i,N){
    cin>>A[i]>>B[i];
    a.at(i)=P(A[i],i);
    b.at(i)=P(B[i],i);
  }
  sort(ALL(a));sort(ALL(b));
  if(N%2){
    x=A[a.at(N/2).S];
    y=B[b.at(N/2).S];
    ans=y-x;
  }
  else{
    x=A[a.at(N/2-1).S];
    y=A[a.at(N/2).S];
    z=B[b.at(N/2-1).S];
    w=B[b.at(N/2).S];
    ans=z+w-x-y;
  }
  cout<<ans+1<<endl;
  return 0;
}


Measured memory_bytes: 12752
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, groupby
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()
print(max(A+B, A-B, A*B))

Measured memory_bytes: 5156
while True:
    cal  = input().split()
    a = int(cal[0])
    op = cal[1]
    b = int(cal[2])
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)
    else:
        break


Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a; cin >> a;
	if (a == 25)cout << "Christmas";
	if (a == 24)cout << "Christmas Eve";
	if (a == 23)cout << "Christmas Eve Eve";
	if (a == 22)cout << "Christmas Eve Eve Eve";

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
a = input().split()
b = int(a[0])
c = int(a[1])
if b == 1 and c == 1:
    print(0)
elif b>=2 and c>=2:
    d = b-1
    e = c-1
    f = b*d/2
    g = c*e/2
    print(int(f+g))
elif b<=1 and c>=2:
    d = c-1
    f = c*d/2
    print(int(f))
elif b>=2 and c<=1:
    d = b-1
    f = b*d/2
    print(int(f))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
signed main() {
	int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
	string s; cin >> s;
	bool bl = 1, bp = 0;
	if (c < d)bp = 1;
	for (int i = a; i < c; i++) {//a-1~c-1
		if (s[i - 1] == '#'&&s[i] == '#')bl = 0;
	}
	for (int i = b; i < d; i++) {//b-1~d-1
		if (s[i - 1] == '#'&&s[i] == '#')bl = 0;
		if (s[i - 2] == '.'&&s[i - 1] == '.' &&s[i] == '.')bp = 1;
	}if (s[d - 2] == '.'&&s[d - 1] == '.' &&s[d] == '.')bp = 1;
	cout << (bl && bp ? "Yes\n" : "No\n");
	cin >> n;
}

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

ll lcm(ll a, ll b){
  function<ll(ll, ll)> lcmgcd = [&](ll x, ll y){
    if(y == 0) return x;
    return lcmgcd(y, x % y);
  };
  return a * b / lcmgcd(a, b);
}

int main(){
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll l = (ll)lcm(C, D);
  ll candivide = B/C - (A-1)/C + B/D - (A-1)/D - B/l + (A-1)/l;
  cout << B - A + 1 - candivide << endl;
}


Measured memory_bytes: 256