akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int DP[4000000] = {};

int main(){
	
	int N;
	cin >> N;
	
	int a[30][30];
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			cin >> a[i][j];
		}
	}
	
	DP[0] = 1;
	
	for(int i = 0; i < (1 << N); i++){
		int cnt = 0;
		for(int j = 0; j < N; j++){
			if(i & (1 << j)){
				cnt += 1;
			}
		}
		for(int j = 0; j < N; j++){
			if(i & (1 << j) && a[cnt - 1][j]){
				DP[i] += DP[i - (1 << j)];
				DP[i] %= MOD;
			}
		}
	}
	
	cout << DP[(1 << N) - 1] << endl;
	
	return 0;
}


Measured memory_bytes: 18688
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    static int[] nums = { 3, 5, 7 };

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> list = new ArrayList<>();
        System.out.println(dfs(n, list));
    }

    static int dfs(int n, List<Integer> list) {
        int ret = 0;
        if (list.size() > 0) {
            //nを超えている場合は探索しない
            if (convertListToNumber(list) > n) {
                return ret;
            } else {
                boolean flg = true;
                for (int x : nums) {
                    if (!list.contains(x))
                        flg = false;
                }
                if (flg)
                    ret++;
            }
        }
        //数字加えるパート
        for (int x : nums) {
            list.add(x);
            ret += dfs(n, list);
            list.remove(list.size() - 1);
        }
        return ret;
    }

    static int convertListToNumber(List<Integer> list) {
        int num = 0;
        for (int i = 0; i < list.size(); i++) {
            num += list.get(i) * Math.pow(10, list.size() - 1 - i);
        }
        return num;
    }

}

Measured memory_bytes: 24436
city=[0,0,0,0]

for i in range(3):
    a,b=map(int,input().split())
    city[a-1]+=1
    city[b-1]+=1

flag=0
for i in range(4):
    if city[i]==0:
        print("NO")
        flag=1
    elif city[i]>=3:
        print("NO")
        flag=1

if flag==0:
    print("YES")

Measured memory_bytes: 3064
package main

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

func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanInt64() int64 {
	sc.Scan()
	i, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return i
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func scanInts64(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		res[i] = scanInt64()
	}
	return res
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	money := int64(100)
	var x int64
	fmt.Scan(&x)
	cnt := 0

	for money < x {
		money = int64(float64(money) * 1.01)
		cnt++
	}
	fmt.Println(cnt)
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/21  Problem: ABC 058 D / Link: http://abc058.contest.atcoder.jp/tasks/abc058_d  ----- */

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

	LL H, W; cin >> H >> W;
	vector<LL> a(H);
	for (int i = 0; i < H; ++i) {
		cin >> a[i];
	}
	vector<LL> b(W);
	for (int i = 0; i < W; ++i) {
		cin >> b[i];
	}
	auto f = [](const VL& a) {
		LL N = SZ(a);
		LL res = 0;
		FOR(i, 0, N) {
			LL b = 2 * i + 1 - N;
			(b += MOD) %= MOD;
			LL c = a[i];
			(c += MOD) %= MOD;
			(res += c * b)%=MOD;
		}
		return res;
	};
	LL ans = (f(a)*f(b)+MOD)%MOD;



	cout <<(ans) << "\n";

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
const int mod = 1000000007;

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

int main(void){
  int h, w;
  cin >> h >> w;

  vector<vector<char>> grid(h, vector<char>(w));
  REP(i, h) REP(j, w) cin >> grid[i][j];

  vector<vector<int>> dp(h, vector<int>(w, 0));
  dp[0][0] = 1;
  REP(i, h){
    REP(j, w){
      REP(k, 2){
        int dj = dx[k], di = dy[k];
        if(i+di >= h || j+dj >= w) continue;
        if(grid[i+di][j+dj] == '#') continue;
        dp[i+di][j+dj] = (dp[i+di][j+dj]+dp[i][j])%mod;
      }
    }
  }
  cout << dp[h-1][w-1] << endl;
  return 0;
}

Measured memory_bytes: 5248
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun String.sort() = toCharArray().sortedArray().joinToString("")

fun main(args: Array<String>) {
    val N = readInt()
    val s = Array(N) { readString() }.run {
        map { it.sort() }.toTypedArray()
    }

    var res = 0L
    val sMap = mutableMapOf<String, Int>()
    for (i in 0 until s.count()) {
        val cnt = sMap[s[i]]
        if (cnt != null) {
            res += cnt
            sMap[s[i]] = cnt + 1
        } else {
            sMap[s[i]] = 1
        }
    }

    println(res)
}

Measured memory_bytes: 66768
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
	"unicode/utf8"
)

func main() {
	var sc = bufio.NewScanner(os.Stdin)
	var str string

	for utf8.RuneCountInString(str) != 3 {
		if sc.Scan() {
			str = sc.Text()
		}
	}
	if strings.Contains(str, "a") && strings.Contains(str, "b") && strings.Contains(str, "c") {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

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

int modinv(int a, int m){
	return modpow(a,m-2,m);
}
const int mod = 1e9 + 7;

map<int,int> getDiv(int n){
	map<int,int> m;
	for(int i = 2; i*i <= n; i++){
		if(n % i == 0)
			while(n % i == 0){
				m[i]++;
				n /= i;
			}
	}
	if(n > 1)
		m[n]++;
	return m;
}

int32_t main(){
	int n;
	cin >> n;
	
	int a[n];
	for(int i = 0; i < n; i++)
		cin >> a[i];
	map<int,int> maxi;
	for(int i = 0; i < n; i++){
		map<int,int> m = getDiv(a[i]);
		for(auto x : m){
			if(x.S > maxi[x.F])
				maxi[x.F] = x.S;
		}
	}
	
	int lcm = 1;
	
	for(auto x : maxi){
		lcm = (lcm * modpow(x.F,x.S,MOD)) % MOD;
	}
	int ans = 0;
	for(int i = 0; i < n; i++){
		ans = (ans + lcm * modinv(a[i],MOD)) % MOD;
	}
	
	ans %= mod;
	if(ans < 0)
		ans += MOD;
		
	cout << ans << endl;

	return 0;
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll N,K;
ll mo=1000000007;

vector<pair<ll,ll>> V;
int tar[150505];

ll from[101010];
ll S[101010];
ll to[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	
	for(i=1;;i++) {
		V.push_back({i,i});
		if(i*i>N) break;
	}
	i++;
	V.push_back({i,i});
	while(i>=1) {
		ll L=N/(i+1)+1;
		ll R=N/i;
		//cout<<L<<" "<<R<<endl;
		L=max(L,V.back().second+1);
		if(L<=R) V.push_back({L,R});
		i--;
	}
	
	while(V.back().first>N) V.pop_back();
	V.back().second=min(V.back().second,N);
	
	FOR(i,V.size()) {
		x=0;
		for(j=20;j>=0;j--) if(x+(1<<j)<V.size() && 1LL*V[i].second*V[x+(1<<j)].second<=N) x+=1<<j;
		tar[i]=x;
		from[i]=V[i].second-V[i].first+1;
		//cout<<i<<" "<<V[i].first<<" "<<V[i].second<<" "<<tar[i]<<endl;
	}
	
	
	K--;
	while(K--) {
		FOR(i,V.size()) S[i+1]=(S[i]+from[i])%mo;
		FOR(i,V.size()) to[i]=S[tar[i]+1]*(V[i].second-V[i].first+1)%mo;
		swap(from,to);
	}
	
	ll ret=0;
	FOR(i,V.size()) ret+=from[i];
	cout<<ret%mo<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)


int main() {
    int n,m; cin >> n >> m;
  	int ans = 0;
  	ans += (n*(n-1))/2;
  	ans += (m*(m-1))/2;
  	cout << ans << endl;
}

Measured memory_bytes: 3560
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
 
		Integer[] a = { 1, 3, 5, 7, 8, 10, 12 };
        Integer[] b = { 4, 6, 9, 11};
	    Integer[] c = { 2};
    
		if (Arrays.asList(a).contains(x)==true && Arrays.asList(a).contains(y)==true ||Arrays.asList(b).contains(x)==true && Arrays.asList(b).contains(y)==true||Arrays.asList(c).contains(x)==true && Arrays.asList(c).contains(y)==true) {
			System.out.print("Yes");
		}else{
			System.out.print("No");
		}
	}
}

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

#define lld long long
#define pi pair<int, int>
#define pl pair<lld, lld>
#define mem0(x) memset(x, 0, sizeof(x))
#define fillnum(x, n) fill(begin(x), end(x), n)
#define asort(x) sort(x.begin(), x.end())
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>())

int main() {
    string N;
    cin >> N;
    if(N == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
}

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

int main() {
	char b;
	cin >> b;

	if (b == 'A') {
		cout << 'T' << endl;
	} else if(b == 'T') {
		cout << 'A' << endl;
	}else if (b == 'C') {
		cout << 'G' << endl;
	}else if (b == 'G') {
		cout << 'C' << endl;
	}
 }

Measured memory_bytes: 256
n, m = map(int,input().split())
if m >= 3 and n >= 3:
    print((m-2) * (n-2))
elif (m == 2 or n == 2):
    print(0)
elif m >= 3 or n >= 3:
    print((max(m,n)-2) * min(m,n))
else:
    if (m * n) % 2 == 0:
        print(0)
    else:
        print(m * n)

Measured memory_bytes: 3064
A, B = map(int,input().split())

import math 
a = [x for x in range(math.ceil(A*12.5),math.ceil((A+1)*12.5))]
b = [x for x in range(math.ceil(B*10),math.ceil((B+1)*10))]

c = set(a) & set(b)

if c != set():
  print(min(c))
else:
  print(-1)


Measured memory_bytes: 3060
#include <stdio.h>
//#include <limits.h>

int main(void){
    
   int X = 0;
   //int Y = 0;
   int i = 2;
   int j = 0;
   
   scanf("%d",&X);
   
   for(j=0;j<1000000;j++){
       while(X%i != 0){
           i++;
       }
       if(X != i){
           X++;
           i = 2;
       }else{
           break;
       }
   }
   
   // if(X == i){
        printf("%d\n",i);
    //}
    
    return 0;
}


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

using namespace std;

int n, A[220];

long long ans = 1000;

int main() {
	cin >> n;
	for(int i = 1;i <= n; ++i)
		cin >> A[i];
	for(int i = 2;i <= n; ++i) {
		if(A[i] > A[i - 1]) {
			ans = (ans / A[i - 1] * A[i]) + (ans % A[i - 1]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
#define REP(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
const lli inf = 1e18;

int main(){
    int n,x;
    cin >> n >> x;
    vector<lli> a(n);
    REP(i, n) cin >> a[i];
    
    lli ans = inf;
    REP(r, 2){
        lli sub = 0;
        vector<lli> tmp = a;
        if(r==1) reverse(tmp.begin(), tmp.end());
        if(tmp[0] > x){
            sub += tmp[0]-x;
            tmp[0] = x;
        }
        REP(i, n-1){
            if(tmp[i] +tmp[i+1] > x){
                sub += tmp[i] +tmp[i+1] -x;
                tmp[i+1] -= tmp[i] +tmp[i+1] -x;
            }
        }
        ans = min(ans, sub);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1804
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    for i in range(h):
        for j in range(w):
            if i == 0 or i == h - 1 or j == 0 or j == w - 1: 
                print("#", end = "")
            else:
                print(".", end = "")
        print()
    print()


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

constexpr int INF = std::numeric_limits<int>::max();

bool isM(int i) {
    return i != 0 && i <= 12;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;

    string ans;
    scanf("%2d%2d", &A, &B);
    if (!isM(A) && isM(B)) {
        ans = "YYMM";
    } else if (!isM(B) && isM(A)) {
        ans = "MMYY";
    } else if (isM(A) && isM(B)) {
        ans = "AMBIGUOUS";
    } else {
        ans = "NA";
    }

    cout << ans << endl;
}

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

int main(){
	int a, b, c, d;
	scanf("%d%d%d%d", &a, &b, &c, &d);
	int m = 0, n = 0;
	while(a > 0) {
		a -= d;
		m++;
	}
	while(c > 0) {
		c -= b;
		n++;
	}
	if(m < n)
		printf("No\n");
	else
		printf("Yes\n");
}


Measured memory_bytes: 3764
N, P = map(int, input().split())
A = list(map(lambda x:int(x)%2, input().split()))
one = A.count(1)
zero = A.count(0)
if P == 1:
    if one == 0:
        print(0)
    else:
        print(2**(one-1)*2**zero)
else:
    if one == 0:
        print(2**zero)
    else:
        print(int(2**(one-1)*2**zero))

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); 
	
	string s;
	cin >> s;
	int n = s.size(), p = 0;
	for(int i = 0; i < n; i++) {
		if(s[i] == 'p') p++;
	}
	cout << n / 2 - p << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <stack>
#include <tuple>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_reverse(i, n) for (int i = (n)-1; (i) >= 0; --(i))
using namespace std;
template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

int main() {
    // input
    int h, w; cin >> h >> w;
    vector<string> s(h);
    repeat (y, h) cin >> s[y];
    // solve
    auto hist = vectors(h - 1, w, int());
    repeat (y, h - 1) {
        hist[y][w - 1] = 1;
        repeat_reverse (x, w - 1) {
            bool p = ((s[y][x] == s[y + 1][x]) == (s[y][x + 1] == s[y + 1][x + 1]));
            hist[y][x] = (p ? hist[y][x + 1] + 1 : 1);
        }
    }
    int result = max(h, w);
    repeat (x, w - 1) {
        stack<pair<int, int> > stk;
        repeat (i, (h - 1) + 1) {
            int h_i = (i < h - 1 ? hist[i][x] : 0);
            int j = i;
            while (not stk.empty() and stk.top().second > h_i) {
                int h_j; tie(j, h_j) = stk.top();
                stk.pop();
                setmax(result, h_j * (i - j + 1));
            }
            if (stk.empty() or stk.top().second < h_i) {
                stk.emplace(j, h_i);
            }
        }
    }
    // output
    printf("%d\n", result);
    return 0;
}


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

int main() {
  string N;
  cin >> N;
  string ex = "CODEFESTIVAL2016";

  int ans = 0;
  for (int i = 0; i < 16; i++)
    if (N.at(i) != ex.at(i)) ans++;
    
  cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n){
    cin >> h[i];
  }
  int maxs=0;
  int count=0;
  rep(i,n-1){
    if(h[i]>=h[i+1]){
      count++;
    }else{
      maxs = max(maxs,count);
      count =0;
    }
    //cout << count << endl;
  }
  cout << max(maxs,count) << endl;

  


  return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    int n;
    ll a = 1;
    cin >> n;
    for(int i = 1;i <= n;i++){
        a = a*i % (1000000000+7);
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
/*************************************************************************
>>> Author: WindCry1
>>> Mail: lanceyu120@gmail.com
>>> Website: https://windcry1.com
>>> Date: 12/22/2019 11:08:25 PM
*************************************************************************/
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <iostream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <stack>
#include <bitset>
#include <iomanip>
#include <list>
#include <sstream>
#include <fstream>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ll long long
#define ull unsigned long long
#define DEBUG(x) cout<<#x<<" : "<<x<<endl;
#define lowbit(x) x&(-x)
#define ls u<<1
#define rs u<<1|1
using namespace std;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const double clf = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
ostream& operator <<(ostream &out, pii &p){
	return out<<p.first<<" "<<p.second;
}
istream& operator >>(istream &in, pii &p){
	return in>>p.first>>p.second;
}
vector<int> v[200010];
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//ifstream cin("C:\\Users\\LENOVO\\Desktop\\in.txt");
	//ofstream cout("C:\\Users\\LENOVO\\Desktop\\out.txt");
	int n;cin>>n;
	for(int i=0;i<n;i++){
		int t;cin>>t;v[t].push_back(i);
	}
	int res=1;
	if(v[1].empty()) {
		cout<<-1<<endl;
		return 0;
	}
	int pos=v[1][0];
	for(int i=2;i<=n;i++){
		if(!v[i].empty()){
			auto it=lower_bound(v[i].begin(),v[i].end(),pos);
			if(it==v[i].end()) break;
			else pos=*it; 
		}
		else break;
		++res;
	}
	cout<<n-res<<endl;
	return 0;
}


Measured memory_bytes: 11264
/* *****fireice**** */

#include<bits/stdc++.h>

#define ll long long int
#define vi vector<int>
#define vc vector<char>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define pb emplace_back
#define el '\n'
#define N 1000000007
#define re return
#define PI 3.14159265
#define take(a,n) for(int i=0;i<n;i++) cin>>a[i]
#define out(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" ";
#define all(a) (a).begin(),(a).end()
#define forup(i,n) for(int (i)=0;i<(n);(i)++)
#define ford(i,n) for(int (i)=(n)-1;i>=0;(i)--)
using namespace std;

int gcdExtended(int a, int b, int *x, int *y)
{
    // Base Case
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    int x1, y1; // To store results of recursive call
    int gcd = gcdExtended(b%a, a, &x1, &y1);

    // Update x and y using results of recursive
    // call
    *x = y1 - (b/a) * x1;
    *y = x1;

    return gcd;
}

ll modInverse(int a, int m)
{
    int x, y;
    int g = gcdExtended(a, m, &x, &y);
        // m is added to handle negative x
    ll res = ((ll)x%m + (ll)m) % m;

    return res;
}

void fastscan(int &number)
{
    bool negative = false;
    register int c;
    number = 0;
    c = getchar();
    if (c=='-')
    {
        negative = true;
        c = getchar();
    }
    for (; (c>47 && c<58); c=getchar())
        number = number *10 + c - 48;
    if (negative)
        number *= -1;
}

ll poww(ll a,ll b)
{
  ll ans=1;
  for(int i=1;i<=b;i++)
  {
    ans*=a;
  }
  return ans;
}

inline ll max(ll a, ll b)
{
  if(a>b) re a;
  else re b;
}

inline ll min(ll a, ll b)
{
  if(a>b) re b;
  else re a;
}

ll ncr(int n,int r)
{
  ll ans=1;
  r=min(r,n-r);
  forup(i,r)
  {
    ans=(ans*(n-i)/(i+1))%N;
  }
  re ans;
}


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

  int t=1;
  //fastscan(t);
  while(t--)
  {
    int n,m,k;
    cin>>n>>k;
    string s;
    cin>>s;
    int ans=0;
    for(int i=1;i<n;i++)
    {
      if(s[i]==s[i-1]) continue;
      else if(k>0)
      {
        k--;
        while(i<n && s[i]!=s[i-1]) {s[i]=s[i-1];i++;}
      }
    }
    for(int i=1;i<n;i++)
    {
      if(s[i]==s[i-1]) ans++;        
    }

      cout<<ans<<el;
    }



  return 0;
}


Measured memory_bytes: 512
import java.util.*;

class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		if(s.matches(".+(keyence)$") ||
				s.matches("keyence") ||
				s.matches("^(keyence).+") ||
				s.matches("(k).+(eyence)") ||
				s.matches("(ke).+(yence)") ||
				s.matches("(key).+(ence)") ||
				s.matches("(keye).+(nce)") ||
				s.matches("(keyen).+(ce)") ||
				s.matches("(keyenc).+(e)") 
			) System.out.println("YES");
		else System.out.println("NO");
	}
}


Measured memory_bytes: 23508
#include <stdio.h>

int main() {
	int line_v[100], matrix_v[100][100], ans_v[100], n = 0, m = 0;

	//input
	scanf("%d %d", &n, &m);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			scanf("%d", &matrix_v[i][j]);
		}
	}

	for (int i = 0; i < m; i++) {
		scanf("%d", &line_v[i]);
	}

	//calc
	for (int i = 0; i < n; i++) {
		ans_v[i] = 0;
		for (int j = 0; j < m; j++) {
			ans_v[i] += matrix_v[i][j] * line_v[j];
		}
	}

	for (int i = 0; i < n; i++) {
		printf("%d\n", ans_v[i]);
	}

	return 0;
}


Measured memory_bytes: 2144
#include <stdio.h>

int main(){
  int A,B,C,D;
  scanf("%d %d %d %d",&A,&B,&C,&D);
  
  int turn=1;
  while(A>0 && C>0){
  if(turn==1){
   C=C-B;
  }else if(turn==-1){
   A=A-D;
  }
    turn=-turn;
 }
  if(A>0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

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

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

    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    ll res = 1ll<<60;
    rep(ab, 2*max(x, y) + 1){
        int nx = max(0ll, x-ab/2);
        int ny = max(0ll, y-ab/2);

        res = min(res, nx*a + ny*b + ab*c);
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3576
#include <cmath>
#include <limits>
#include<iostream>
using namespace std;
int main()
{
	// 入力 h:体力
	unsigned long long h;


	cin >> h;
	unsigned long long count = 0;
	while (1) {
		++count;
		h /= 2;
		if (h == 0) {
			break;
		}
	}

	unsigned long long ans = 0;
	for (unsigned long long i = 0; i < count; ++i) {
		ans += pow(2, i);
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 1111
#define mod 1000000007
const long long  inf = 20000000000000000;
using namespace std;
bool g[MAX][MAX];
int main(){ 
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);  
    int a,b;
    cin>>a>>b;
    if(a + b == 15)cout<<"+";
    else if(a * b == 15) cout<<"*";
    else cout<<"x";
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { cout << p.first << ' ' << p.second; return os; }

void solve() {
  int N; cin >> N;
  vi32 a(N); cin >> a;

  int mi = 1e9, ma = -1e9, mii, mai;
  rep(i, N) {
    if (mi > a[i]) amin(mi, a[i]), mii = i;
    if (ma < a[i]) amax(ma, a[i]), mai = i;
  }
  vector<pair<int, int>> ans;
  if (abs(mi) > abs(ma)) {
    rep(i, N) if (mii != i) ans.emplace_back(mii + 1, i + 1);
    rrep(i, N - 1) ans.emplace_back(i + 2, i + 1);
  } else {
    rep(i, N) if (mai != i) ans.emplace_back(mai + 1, i + 1);
    rep(i, N - 1) ans.emplace_back(i + 1, i + 2);
  }
  cout << ans.size() << '\n';
  rep(i, ans.size()) cout << ans[i] << '\n';
}


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

struct Node{
    ll key;
    Node *parent, *left, *right;
};
Node *root;

void insert(ll k){
    Node *x = root;
    Node *y = nullptr;
    Node *z;
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = nullptr;
    z->right = nullptr;

    while(x != nullptr){
        y = x;
        if(z->key < x->key) x = x->left;
        else x = x->right;
    }

    z->parent = y;
    if(y == nullptr) root = z;
    else if(z->key < y->key) y->left = z;
    else y->right = z;
    return;
}

void inorder(Node* n){
    if(n == nullptr) return;
    inorder(n->left);
    cout << ' ' << n->key;
    inorder(n->right);
    return;
}

void preorder(Node* n){
    if(n == nullptr) return;
    cout << ' ' << n->key;
    preorder(n->left);
    preorder(n->right);
    return;
}

Node* find(ll k){
    Node *n = root;
    while(n != nullptr && k != n->key)
        (n->key < k) ? n = n->right : n = n->left;
    return n;
}

int main(int argc, char* argv[]){
    // ifstream in(argv[1]);
    // cin.rdbuf(in.rdbuf());
    ll n; cin >> n;
    rep(i, 0, n){
        string com; cin >> com;
        ll k;
        if(com[0] == 'i'){
            cin >> k;
            insert(k);
        } else if(com[0] == 'f'){
            cin >> k;
            cout << (find(k) ? "yes" : "no") << endl;
        } else {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        };
    }
    return 0;
}


Measured memory_bytes: 21924
from collections import deque

n = int(input())
ed = [[] for _ in range(n)]
al,be = [],[]
for _ in range(n-1):
    a,b = map(int,input().split())
    al.append(a-1)
    be.append(b-1)
    ed[a-1].append(b-1)
    ed[b-1].append(a-1)
    
c = list(map(int,input().split()))
c.sort(reverse = True)

ans = [0]*n

q = deque()
q.append(0)
used = [False]*n
used[0] = True
ans[0] = c[0]
j = 1
 
while q:
    p = q.popleft()
    for i in ed[p]:
        if not used[i]:
            used[i] = True
            ans[i] = c[j]
            j += 1
            q.append(i)
        
sc = 0
for i in range(n-1):
    sc += min(ans[al[i]],ans[be[i]])
    
print(sc)
print(*ans)

Measured memory_bytes: 77600
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		solve100();
	}

	public static void solve100(){
		Scanner sc = new Scanner(System.in);
		int E = 'E';
		int S = 'S';
		int W = 'W';
		int N = 'N';

		for(;;) {
			int n = sc.nextInt();
            if (n == 0) {
                break;
            }

            int x[] = new int[n];
            int y[] = new int[n];

            for(int i=0; i<n; i++) {
            	x[i] = sc.nextInt();
            	y[i] = sc.nextInt();
            }

            int m = sc.nextInt();

            int cx =10,cy=10;

            boolean[] visited = new boolean[n];

            for(int i=0; i<m; i++) {
            	int ch = sc.next().charAt(0);
            	int d = sc.nextInt();

    			for(int ii=0;ii<d;ii++){
    				if(ch == N) {
    					cy++;
    				}
    				if(ch == S) {
    					cy--;
    				}
    				if(ch == E) {
    					cx++;
    				}
    				if(ch == W) {
    					cx--;
    				}
    				for(int j=0;j<n;j++) {
    					if(cx==x[j]&&y[j]==cy) {
    						visited[j]=true;
    					}
    				}
    			}
	        }
            boolean ans = true;
            for(boolean v: visited){
                ans &= v;
            }
            System.out.println(ans?"Yes":"No");
		}
	}

}


Measured memory_bytes: 42860
n, x, m = [int(x) for x in input().split()]
val = [0, x]
d = {x}
prev = x
ans = x
for i in range(2, n+1):
    cur = prev*prev%m
    if cur==0:
        break
    if cur in d:
        pos = val.index(cur)
        length = len(val)-pos
        left = n-i+1
        temp = 0
        for j in range(pos, len(val)):
            temp += val[j]
        ans += (left//length)*temp
        left -= (left//length)*length
        while left:
            ans += val[pos]
            pos += 1
            left-= 1
        break
    else:
        ans += cur
        prev = cur
        d.add(cur), val.append(cur)

print(ans)


Measured memory_bytes: 12788
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define DFZERO 1E-13
signed main(){
	double x1,y1,x2,y2,x3,y3,x4,y4;
	while( scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4) != EOF ){
		double xa = x2-x1, ya = y2-y1;
		double xb = x4-x3, yb = y4-y3;
		if( abs(xa*xb+ya*yb)/sqrt(xa*xa+ya*ya)/sqrt(xb*xb+yb*yb) < DFZERO) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3208
#include <stdio.h>

int N=100;

int main(){
  int M[N][N];
  int i,j,n,u,k,v;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j==0){
	printf("%d",M[i][j]);
      }else{
	printf(" %d",M[i][j]);
      }
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2108
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("no-stack-protector")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,avx,avx2,tune=native")

#include <bits/stdc++.h>

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

const ll LINF = 9187201950435737471;
const ll nLINF = -9187201950435737472;
const ll INF = 2139062143;
const int nINF = -2139062144;
const ull ULINF = numeric_limits<ull>::max();
const ll MAXN = 1e8 + 15;
const ll MAXE = 5761456 + 5;
const double PI = acos(-1);
const ll MOD = 998244353;
const double EPS = 1e-8;
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rnd(seed);

bool isEqual(double a, double b) {
    return abs(a - b) <= EPS;
}

#define all(_v) _v.begin(), _v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define sqr(_v) ((_v) * (_v))
#define vpi vector<pair<int, int>>
#define eb emplace_back
#define pb push_back
#define mod(x, m) ((x) % m + ((x) < 0  && ((x % m) != 0) ? m : 0))
#define vi vector<int>
#define pi pair<int, int>
#define minq(x, y) (x) = min(x, y)
#define maxq(x, y) (x) = max(x, y)


inline void IO() {
#if(DEBUG_LEVEL > 0)
    freopen("../input.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
}

template <typename T>
istream& operator >> (istream& in, vector<T>& a) {
    for (auto& i : a)
        in >> i;
    return in;
}

template <typename T>
ostream& operator << (ostream& out, const vector<T>& a) {
    for (auto& i : a) {
        out << i << " ";
    }
    return out;
}

template <typename T, typename D>
istream& operator >> (istream& in, pair<T, D>& a) {
    in >> a.first >> a.second;
    return in;
}

template <typename T, typename D>
ostream& operator << (ostream& out, const pair<T, D>& a) {
    out << a.first << " " << a.second;
    return out;
}

#define int ll

inline void solve() {
    int n, a, b, ans = 0;
    cin >> n >> a >> b;
    vi arr(n);
    cin >> arr;
    for (int i = 1; i < n; ++i) {
        int now = arr[i] - arr[i - 1];
        ans += min(now * a, b);
    }
    cout << ans;
}

signed main() {
    IO();
    int t = 1;
//    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}






Measured memory_bytes: 4008
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

int main(){
    int a[5]={};
    rep(i,5)cin>>a[i];
    int sum=0;
    int b=10;
    rep(i,5){
        int s=a[i]%10;
        int t=a[i]/10;
        if(s!=0){
            a[i]=(t+1)*10;
            b=min(b,s);
        }
        sum+=a[i];
    }
    cout<<sum-10+b<<endl;
}





Measured memory_bytes: 3564
/*
	obvious lose position : 
		(1, 0), (1,1) end of the game
		(a, a) Bob could always imitate Alice's move
		
		one more :

		(a, a + 1) Bob could imitate Alice's move as well
	obvious win position :
		(a, b) when exist c > 0
			a - c = b + c or a - c = b + c + 1, a - c = b + c - 1
		such c always exist then |a - b| > 1
*/
#include <cstdio>
#define rep(i,a,b) for(int i = a; i <= b; i++)
using namespace std;
int main() {
	int a, b; scanf("%d%d",&a,&b);
	int x = a - b; if (x < 0) x = -x;
	if (x <= 1) printf("Brown\n"); else printf("Alice\n");
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

signed main()
{
  int h, w;
  string s;

  cin >> h >> w;
  
  for (int j = 0; j < w + 2; j++) {
    printf("#");
  }
  puts("");
  
  for (int i = 0; i < h; i++) {
    cin >> s;
    printf("#");
    cout << s;
    printf("#");
    puts("");
  }
  
  for (int j = 0; j < w + 2; j++) {
    printf("#");
  }
  puts("");

  return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a,b,c,i,j,h,sum = 0;
    cin>>h>>n;
    for(i=0;i<n;i++)
    {
        cin>>a;
        sum+=a;
    }
    if(sum>=h)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;

int main() {
    int n; cin >> n;
    vector<ll> da(n);
    rip(i,n,0) cin >> da[i];
    vector<Pll> dp(n+1), dpp(n+1);
    dp[0] = {1000, 0};
    dpp[0] = {1000, 0};
    rip(i,n,0) {
        dp[i+1].first = max(dp[i].first, dpp[i].first + dpp[i].second*da[i]);
        dp[i+1].second = 0;
        ll tmp = max(dp[i].first, dpp[i].first + dpp[i].second*da[i]);
        dpp[i+1].second = tmp/da[i];
        dpp[i+1].first = tmp%da[i];
    }
    cout << dp[n].first << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define REP(i,n) for(int i=0;i<(n);++i)
typedef long long llong;
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	int k;
	cin >> k;

	int n;
	if(a == b) n = a;
	else n = max(a, b) - min(a, b);
	

	int cnt = 0;
	while(1){
		if(a%n == 0 && b%n == 0){
			cnt++;
			if(cnt == k) break;//while.
		}
		n--;
	}

	cout << n << endl;
}

Measured memory_bytes: 256
import math
def lcm(l: list):
    n=len(l)
    lcm=(l[0]*l[1])//math.gcd(l[0],l[1])
    for i in range(2,n):
        lcm=(l[i]*lcm)//math.gcd(l[i],lcm)

    return lcm

n=int(input())
t=[]
for i in range(n):
    t.append(int(input()))

if n==1:
    print(t[0])
else:
    print(lcm(t))

Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define endl "\n"
#define ii pair<int, int>
#define fi first
#define se second
#define vi vector<int>
#define pb push_back
#define make_pair mp
#define MAX (int)1e5+5
#define INF (int)1e9
#define K 26
#define rep(i,a,b) for(int i = a; i<b; i++)
#define vi vector<int>



int32_t main() {
	int n;
	string s;
	set<string>set;
	cin >> n;
	while(n--){
		   cin >> s;
		   set.insert(s);	
	}
	
	cout << set.size();
	return 0;
}

Measured memory_bytes: 19228
#include<stdio.h>
#include<string.h>
int main(){
  char a[10000],b[10000];
  int i,l,n,k=0;
  scanf("%d",&n);
  while(n--){
    char c[81]={0};
    char d[81]={0};
    k=0;
    for(i=0;i<80;i++)c[i]=d[i]='0';
    scanf("%s",a);
    l=strlen(a);//printf("%d ",l);
    if(l<81)strcpy(c+80-l,a);//printf("%s\n",c+80-l);
    else k=1;
    scanf("%s",b);
    l=strlen(b);//printf("%d\n",l);
    if(l<81)strcpy(d+80-l,b);//printf("%s\n",d+80-l);
    else k=1;
    if(k==0){
      for(i=79;i>-1;i--){//printf("%c %c\n",c[i],d[i]);
	d[i]=c[i]+d[i]+k-'0';
	k=0;
	if(d[i]>'9'){
	  k=1;
	  d[i]-=10;
	}
      }
      for(i=0;i<79;i++){
	if(d[i]!='0')break;
      }
    }
    if(k)printf("overflow\n");
    else printf("%s\n",d+i);
  }
  return 0;
}

Measured memory_bytes: 596
if __name__ == '__main__':

	n = int(input())
	res = [[0 for i in range(0, 3)] for i in range(0, n+1)]

	for i in range(1,n+1):
		x, y, z =  map(int,input().split())
		res[i][0] = max(res[i-1][1], res[i-1][2])
		res[i][1] = max(res[i-1][0], res[i-1][2])
		res[i][2] = max(res[i-1][0], res[i-1][1])
		res[i][0]+=x
		res[i][1]+=y
		res[i][2]+=z

	r = max(res[-1])
	print(r)


Measured memory_bytes: 24308
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};

int main () {
    ll n, m, k; cin >> n >> m >> k;
    vector<ll> a(n+1), b(m+1);
    rep(i, n) cin >> a[i+1];
    rep(i, m) cin >> b[i+1];
    ll sum = 0;
    rep(i, m+1) sum += b[i];
    int nb = m;
    int ans = 0;
    for (int na = 0; na <= n; na++) {
        sum += a[na];
        while (sum > k && nb >= 0) {
            sum -= b[nb];
            nb--;
        }
        if (nb < 0) break;
        ans = max(ans, na+nb);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6424
from sys import stdin
from collections import Counter


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    a_arr = list(map(int,_in[1].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    count = Counter(a_arr)
    cnt = 0
    keys = sorted(count.keys())
    for key in keys:
        _ = count[key]
        try:
            _ += count[key+1]
        except:
            pass
        try:
            _ += count[key-1]
        except:
            pass
        cnt = max(cnt,_)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 56812
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,R;cin >> n >> m >> R;
    vector<int> r(R);
    rep(i,R){
        cin >> r[i];
        r[i]--;
    }
    vector<vector<ll>> d(n,vector<ll>(n,inf));
    rep(i,n){
        d[i][i]=0;
    }
    rep(i,m){
        int a,b,c;cin >> a >> b >> c;
        a--,b--;
        d[a][b]=c;
        d[b][a]=c;
    }
    rep(i,n){
        rep(j,n){
            rep(k,n){
                chmin(d[j][k],d[j][i]+d[i][k]);
            }
        }
    }
    sort(r.begin(),r.end());
    int ans=inf;
    do{
        int res=0;
        rep(i,R-1){
            res+=d[r[i]][r[i+1]];
        }
        chmin(ans,res);
    }while(next_permutation(r.begin(),r.end()));
    cout << ans << endl;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)

using namespace std;


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    ll a, b, c;
    cin >> a >> b >> c;

    if(c <= a+b) cout << c + b << endl;
    else         cout << 2*(a+b)-a+1 << endl;


    return 0;
}



Measured memory_bytes: 256
from collections import deque
def check():
  N, M = map(int, input().split())
  edge = [[] for _ in range(N)]
  for i in range(M):
    a,b,d = map(int, input().split())
    edge[a-1].append([b-1,d])
    edge[b-1].append([a-1,-d])
  
  visited = [float('inf')]*N
  D = deque()
  for i in range(N):
    if visited[i]==float('inf'):
      visited[i]=0
      D.append(i)
      while len(D)>0:
        v = D.popleft()
        for w,d in edge[v]:
          if visited[w]==float('inf'):
            visited[w] = visited[v]+d
            D.append(w)
          elif visited[w]!=visited[v]+d:
            return 'No'
  return 'Yes'
print(check())

Measured memory_bytes: 130316
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> num(N, -1);

	auto valid = true;
	for (auto i = 0; i < M; ++i)
	{
		int s, c;
		cin >> s >> c;
		--s;

		if (c == 0 && s == 0 && N > 1)
		{
			valid = false;
		}
		else if (num[s] < 0)
		{
			num[s] = c;
		}
		else if (num[s] != c)
		{
			valid = false;
		}
	}

	if (valid == false)
	{
		cout << -1 << endl;
	}
	else
	{
		for (auto i = 0; i < N; ++i)
		{
			if (num[i] < 0)
			{
				if (i == 0 && N > 1)
				{
					num[i] = 1;
				}
				else
				{
					num[i] = 0;
				}
			}
			cout << num[i];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

typedef long long LL;

LL a, b, c, d;

LL getmax(LL p, LL q) {return p>q?p:q;}

int main() {
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
    printf("%lld", getmax(getmax(a * c, b * d), getmax(a * d, b * c)));
}


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

int main() {
    int n;
    cin >> n;
    int d[n];
    rep(i,n) cin >> d[i];

    int sum=0;
    rep(i,n-1){
        for(int k=i+1;k<n;k++)
            sum += d[i]*d[k];
    }

    cout<<sum;

    return 0;
}


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

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N, M;
VI G[200011];
int deg[200011];
int rnk[200011];
int par[200011];

void MAIN() {
    scanf("%d%d", &N, &M);
    REP (i, M+N-1) {
	int x, y;
	scanf("%d%d", &x, &y);
	x--; y--;
	G[x].push_back(y);
	deg[y]++;
    }

    VI ord;
    ord.reserve(N);
    REP (i, N) if (deg[i] == 0) ord.push_back(i);
    REP (i_, N) {
	int v = ord[i_];
	EACH (e, G[v]) {
	    deg[*e]--;
	    if (deg[*e] == 0) {
		ord.push_back(*e);
	    }
	}
    }

    REP (i, N) rnk[ord[i]] = i;

    memset(par, -1, sizeof par);

    REP (v, N) EACH (e, G[v]) {
	if (par[*e] == -1 || rnk[par[*e]] < rnk[v]) {
	    par[*e] = v;
	}
    }
    REP (i, N) printf("%d\n", par[i]+1);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 10880