akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main ()
{
    int a[7] = {1,3,5,7,8,10,12};
    int n = 7;
    int b[4] = {4,6,9,11};
    int m = 4;

    int x, y;
    cin >> x;
    cin >> y;
    int c = 0;

    for(int i = 0; i<n; i++)
    {
        if (a[i] == x)
        {
            c++;
            break;
        }

    }
    for(int j = 0; j<n; j++)
    {
        if (a[j] == y)
        {
            c++;
            break;
        }

    }
    if(c == 2) cout << "Yes\n";
    else
    {
        c = 0;
        for(int k = 0; k<m; k++)
        {
            if (b[k] == x)
            {
                c++;
                break;
            }

        }
        for(int l = 0; l<m; l++)
        {
            if (b[l] == y)
            {
                c++;
                break;
            }

        }
        if (c == 2)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
	int a, b;	scanf("%d %d", &a, &b);
	if (a <= 0 && 0 <= b){
		printf("Zero\n");
		return 0;
	}
	int x = 0;
	if (a < 0){
		x = -a;
		if (b < 0)
			x -= -(b + 1);
	}
	if (x & 1)
		cout << "Negative\n";
	else
		cout << "Positive\n";
	return 0;
}


Measured memory_bytes: 256
#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& ch) {
	string s = "";
	s += ch;
	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() { cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL_DEFINE
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
   
// #define int long long
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
typedef pair<int, int> pii;
const int mod = (int) 1000000007; // 998244353;
const int inf = (int) 2e18;

const int maxn = 1e6 + 10;
int a[maxn], freq[maxn];

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
	
	
	int n;
	cin >> n;
	for(int i = 0; i < n; ++ i)
	{
		cin >> a[i];
		++ freq[a[i]];
	}
	int ans = 0;
	for(int i = 0; i < n; ++ i)
	{
		-- freq[a[i]];
		bool ok = true;
		for(int j = 1; j * j <= a[i]; ++ j)
		{
			if(a[i] % j == 0)
			{
				ok &= (!freq[j]);
				ok &= (!freq[a[i] / j]);
				debug(a[i], j, freq[j], freq[a[i] / j]);
			}
		}
		ans += ok;
		++ freq[a[i]];
	}
	
	cout << ans << '\n';
	
	return 0;
}






Measured memory_bytes: 8276
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
int count=0;
cin>>N;
if(N>=1&&N<=100){
for(int i=1;i>=1&&i<=9;i++){
    for(int j=1;j>=1&&j<=9;j++){
        if(i*j==N){
           count++;
        }
    }
}
if(count>=1){
    cout<<"Yes";
}
else{
    cout<<"No";
}
}
   return 0;
   
}

Measured memory_bytes: 3632
from collections import defaultdict


# xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


# xとyの属する集合の併合
def unite(x, y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        # sizeの大きいほうがx
        if par[x] > par[y]:
            x, y = y, x
        par[x] += par[y]
        par[y] = x
        return True


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


# xが属する集合の個数
def size(x):
    return -par[find(x)]


n, m, k = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]
cd = [list(map(int, input().split())) for i in range(k)]

# 初期化
# 根なら-size,子なら親の頂点
par = [-1] * n

not_see = defaultdict(set)

for a, b in ab:
    a -= 1
    b -= 1
    unite(a, b)
    if same(a, b):
        not_see[a].add(b)
        not_see[b].add(a)

for c, d in cd:
    c -= 1
    d -= 1
    if same(c, d):
        not_see[c].add(d)
        not_see[d].add(c)

for i in range(n):
    print(size(i) - len(not_see[i]) - 1)

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

const ll inf = (1 << 30) - 1;
ll dp[1010][1003];
int N, M;

int main()
{
    char c;
    cin >> c;
    map<char, char> mp;
    mp['A'] = 'T';
    mp['T'] = 'A';
    mp['G'] = 'C';
    mp['C'] = 'G';
    cout << mp[c] << endl;
}

Measured memory_bytes: 256
s = str(input())
k = int(input())
lis = []
for u in range(6):
	for i in range(len(s)):
		try:
			if s[i:i+u] == "":
				continue
			if s[i:i+u] not in lis:
				lis.append(s[i:i+u])
		except:
			continue
lis.sort()
print(lis[k-1])

Measured memory_bytes: 3932
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 100000;

int aa[N * 3];
long long pp[N + 1], qq[N + 1];
int pq[N * 2], ip[N + 1], cnt;

bool lt(int i, int j) {
	return aa[i] < aa[j];
}

int p2(int p) {
	return (p *= 2) > cnt ? 0 : p < cnt && lt(ip[p + 1], ip[p]) ? p + 1 : p;
}

void pq_dn(int i) {
	int j, p, q;
	for (p = pq[i]; (q = p2(p)) > 0 && lt(j = ip[q], i); p = q)
		ip[pq[j] = p] = j;
	ip[pq[i] = p] = i;
}

void pq_add_last(int i) {
	ip[pq[i] = ++cnt] = i;
}

void solve(long long *pp, int n) {
	cnt = 0;
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		pq_add_last(i);
		sum += aa[i];
	}
	for (int p = cnt / 2; p; p--)
		pq_dn(ip[p]);
	for (int i = n; i < n * 2; i++) {
		pp[i - n] = sum;
		int d = aa[i] - aa[ip[1]];
		if (d > 0) {
			sum += d;
			pq[i] = 1, pq_dn(i);
		}
	}
	pp[n] = sum;
}

int main() {
	int n; cin >> n;
	int n3 = n * 3;
	for (int i = 0; i < n3; i++)
		cin >> aa[i];
	solve(pp, n);
	for (int i = 0; i < n3; i++)
		aa[i] = -aa[i];
	for (int i = 0, j = n3 - 1; i < j; i++, j--)
		swap(aa[i], aa[j]);
	solve(qq, n);
	long long ans = -0x3f3f3f3f3f3f3f3fLL;
	for (int i = 0; i <= n; i++)
		ans = max(ans, pp[i] + qq[n - i]);
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 7484
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()

typedef long long LL;
typedef long double LD;

bool compare_by_a(pair<int, int> a, pair<int, int> b)
{
    if (a.first != b.first) {
        return a.first < b.first;
    } else {
        return a.second < a.second;
    }
}

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int N, K;
    string S;
    cin >> N >> K;
    cin >> S;

    char temp = S[K-1];

    if (temp == 'A') S[K-1] = 'a';
    else if (temp == 'B') S[K-1] = 'b';
    else S[K-1] = 'c';

    cout << S << endl;
    return 0; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7' )
    {
        cout << "Yes" << endl;

    }
    else  
    cout << "No" << endl;
}

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

template <typename T>
class SlideMinimum {
  // (位置, 値)
  std::deque<std::pair<int, T>> deq;
  int pos, window;

 public:
  SlideMinimum(int _w) : pos(0), window(_w) {}
  T query(T val) {
    while (!deq.empty() && deq.front().first <= pos - window) deq.pop_front();
    while (!deq.empty() && deq.back().second >= val) deq.pop_back();
    deq.push_back(std::make_pair(pos++, val));
    return deq.front().second;
  }
};

using namespace std;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

// verified: http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3385735
int main() {
  int N, L;
  cin >> N >> L;
  SlideMinimum<int> sm(L);
  vector<int> ret;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    int t = sm.query(a);
    if (i >= L - 1) ret.push_back(t);
  }
  printv(ret);
}



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

const int M = 1000000007;

int main() {
    int isp[1000010] = {};
    for (int i = 2; i < 1000010; i++) isp[i] = 1;
    for (int i = 2; i * i < 1000010; i++) if (isp[i]) for (int j = i * i; j < 1000010; j += i) isp[j] = 0;

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<vector<long long>> dp(n, vector<long long>(2));
    dp[0][0] = isp[a[0]];
    for (int i = 1; i < n; ++i) {
        if (a[i] > a[i - 1] && isp[a[i]]) {
            dp[i][0] = (dp[i][0] + dp[i - 1][0]) % M;
        }
        if (i > 1 && a[i] > a[i - 2] && isp[a[i]]) {
            dp[i][0] = (dp[i][0] + dp[i - 2][0]) % M;
        }
        dp[i][1] = dp[i - 1][0];
    }
    cout << (dp[n - 1][0] + dp[n - 1][1]) % M << "\n";
    return 0;
}



Measured memory_bytes: 12664
def g;gets.split.map &:to_i;end
n,q=g
l=[-i=1]+[m=0]*n
q.times{a,v=g
j=l[a]+=v
v>0?m<j ?(i,m=a,j):m==j&&i>a&&i=a :a==i&&(m=l.max;i=l.index m)
puts [i,m]*" "}

Measured memory_bytes: 21736
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REPF(i, a, n) for (int i = (a); i < (int)(n); i++)
#define REP(i, n) REPF(i, 0, n)
#define ALL(x) begin(x),end(x)
#define SZ(x) (int)(x.size())

signed main() {
    cout << setprecision(15) << fixed;
    const double PI = acos(-1);

    int A, B;
    cin >> A >> B;

    if (A < B) {
        cout << 4.0 * PI * B * B * B / 3.0 << endl;
        return 0;
    }
    return 0;
}


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

using namespace std;
using ll = long long;

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

  ll n;
  ll k;
  cin >> n >> k;
  vector<ll> a(n);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }

  vector<bool> visit(n, false);
  // 循環の始まり
  ll c = 0;
  while (true) {
    if (visit[c]) {
      break;
    }
    visit[c] = true;
    c = a[c];
  }
  // 0からcまでの長さ(cは含まない)
  ll len = 0;
  ll cur = 0;
  while (true) {
    if (cur == c) {
      break;
    }
    cur = a[cur];
    len++;
  }
  // 循環する経路の長さ
  ll clen = 0;
  cur = c;
  while (true) {
    cur = a[cur];
    clen++;
    if (cur == c) {
      break;
    }
  }

  if (k <= len) {
    ll ans = 0;
    while (k > 0) {
      ans = a[ans];
      k--;
    }
    cout << ans + 1 << endl;
    return 0;
  }

  k -= len;
  k %= clen;
  ll ans = c;
  while (k > 0) {
    ans = a[ans];
    k--;
  }
  cout << ans + 1 << endl;

  return 0;
}


Measured memory_bytes: 4776
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

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

int main()
{
  string s, t;
  cin >> s >> t;
  cout << t << s << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mod 1000000007
#define PI 3.1415926535
#define all(x) x.begin(),x.end()
#define speedUp ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
void CyBerForCe()
{
	string s;
	cin>>s;
	if(s[0]=='R' && s[1]=='R' && s[2]=='R')
	cout<<"3\n";
	else if(s[0]=='R' && s[1]=='R' && s[2]=='S' || s[0]=='S' && s[1]=='R' && s[2]=='R')
	cout<<"2\n";
	else
	{
	    if(s[0]=='R' && s[1]=='S' && s[2]=='S' || s[0]=='R' && s[1]=='S' && s[2]=='R' || s[0]=='S' && s[1]=='R' && s[2]=='S' || s[0]=='S' && s[1]=='S' && s[2]=='R')
	    cout<<"1\n";
	    else
	    cout<<"0\n";
	}
}
signed main()
{
    speedUp
    /*int t;
    cin>>t;
    while(t--)*/
    CyBerForCe();
    return 0;
}

Measured memory_bytes: 3608
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True


def main():
    N = I()
    A = LI()
    ans = 1
    LIMIT = 10 ** 18

    if not all(A):
        print(0)
        return

    for i in range(N):
        ans *= A[i]
        if ans > LIMIT:
            print(-1)
            return

    print(ans)



if __name__ == '__main__':
    main()


Measured memory_bytes: 86032
# -*- coding: utf-8 -*-
"""
Pattern - Largest Rectangle
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_3_B&lang=jp

"""
import sys


def solve(H, W, grid):
    def calc_hist(m):
        ans = [[0] * W for _ in range(H)]
        for y, row in enumerate(m):
            for x, ch in enumerate(row):
                if ch == '0':
                    ans[y][x] = ans[y - 1][x] + 1 if y > 0 else 1
        return ans

    def calc_area(hist):
        stack = []
        area, left = 0, 0
        for x, h in enumerate(hist):
            if not stack or stack[-1][0] < h:
                stack.append((h, x))
            elif stack[-1][0] > h:
                while stack and stack[-1][0] >= h:
                    hh, left = stack.pop()
                    area = max(area, hh*(x-left))
                stack.append((h, left))
        return area

    hist = calc_hist(grid)
    ans = 0
    for y in range(H):
        ans = max(ans, calc_area(hist[y]+[0]))
    return ans


def main(args):
    H, W = map(int, input().split())
    grid = [input().replace(' ', '') for _ in range(H)]
    ans = solve(H, W, grid)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])



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

int main () {

    int AB, BC, CA;
    cin >> AB >> BC >> CA;

    int ans = 0;

    if (AB * AB + BC * BC == CA * CA) {
        ans = AB * BC / 2;
    }
    else if (BC * BC + CA * CA == AB * AB) {
        ans = BC * CA / 2;
    }
    else {
        ans = CA * AB / 2;
    }
    cout << ans << endl;

    return 0;
}

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

void swap(int *x,int *y){
  int z = *x;
  *x = *y;
  *y = z;
}
class HeapTree{
public:
  void push(int x){
    tree.push_back(x);
    int focus = tree.size() - 1;
    while(true){
      if(focus != 0 && tree[focus] < tree[(focus - 1) / 2]){
        swap(&tree[focus],&tree[(focus - 1) / 2]);
        focus = (focus - 1) / 2;
      }
      else{
        break;
      }
    }
  }
  int pop(){
    int r = tree[0];
    int l = tree[tree.size() - 1];
    tree.pop_back();
    tree[0] = l;
    int focus = 0;
    int cand1 = focus * 2 + 1;
    int cand2 = focus * 2 + 2;
    while(1){
      int c = 0;
      if(cand1 >= tree.size()){
        break;
      }
      if(cand2 >= tree.size()){
        c = cand1;
      }
      else if(tree[cand1] < tree[cand2]){
        c = cand1;
      }
      else{
        c = cand2;
      }
      if(tree[focus] > tree[c]){
        swap(&tree[focus],&tree[c]);
        focus = c;
        cand1 = focus * 2 + 1;
        cand2 = focus * 2 + 2;
      }
      else{
        break;
      }
    }
    return r;
  }
  vector<int> getTree(){
    return tree;
  }
private:
  vector<int> tree;

};


int main() {
  int N;
  int K;
  //vector<int> p;
  HeapTree p;
  
  cin >> N;
  cin >> K;
  for(int i = 0;i < N;++i){
    int t;
    cin >> t;
    p.push(t);
  }
    
  int sum = 0;
  for(int i = 0;i < K;++i){
    int t = p.pop();
    sum += t;
  }
  cout << sum << endl;
}


Measured memory_bytes: 3608
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        String B = sc.next();
        long B1 = 0L;
        long B2 = 0L;
        boolean flag = false;
        for(int i=0; i<B.length(); i++) {
            switch(B.charAt(i)) {
                case '.':
                    flag = true;
                    break;
                default:
                    if(flag) {
                        B2 = B2 * 10 + (B.charAt(i) - '0');
                    } else {
                        B1 = B1 * 10 + (B.charAt(i) - '0');
                    }
                    break;
            }
        }
        BigInteger AA = new BigInteger(String.format("%d", A * 100L));
        BigInteger BB = new BigInteger(String.format("%d", B1 * 100L + B2));
        BigInteger rr = AA.multiply(BB);
        BigInteger ss = rr.divide(new BigInteger("10000"));
        System.out.println(ss.toString());
    }
}


Measured memory_bytes: 36144
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int h, n, a[100010],ans=0;
	cin >> h >> n;
	for (int i = 1; i <= n;i++) {
		cin >> a[i];
		ans += a[i];
	}
	if (ans>=h) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

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

	long long total = 0;

	vector<string> s(N);
	map<string, int> sM{};

	for (int i = 0; i < N; i++)
	{
		string temp;
		cin >> temp;
		sort(temp.begin(), temp.end());

		/*	s[i] = temp;*/

		sM[temp]++;



	}



	for (auto val : sM)
	{


		total += (long long)val.second * (val.second - 1) / 2;


	}


	cout << total << endl;


}

Measured memory_bytes: 12032
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pb push_back

# define inOut(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
# define RESET(a) memset(a,0,sizeof(a))
# define MEMO(a) memset(a,-1,sizeof(a))
# define DEBUG puts("Debug-Has-Come-Until-Here")


typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define MAXPRIME 1000000

bitset<MAXPRIME+1> boolPrime(0);
int prefPrime[1000001] ={};

void sieve(int n){
	int i,j;
	boolPrime[1] = 1;
	for (i=2; i<=sqrt(n); i++){
		if (boolPrime[i] == 0)
		for (j=2*i; j<=n; j+=i){
			boolPrime[j] = 1;
		}
	}
}

int main(){
	cin.tie(NULL);
	
	int i,j,n = 0;
	sieve(MAXPRIME);
	for (i=1; i<=MAXPRIME; i++){
		n += !boolPrime[i];
		prefPrime[i] = n;
	}
	while(scanf("%d", &n) != EOF){
		printf("%d\n", prefPrime[n]);
	}
	return 0;
}

Measured memory_bytes: 7128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f first
#define s second
#define pb push_back
#define mod 1000000007
ll dp[2][10001][101];
void solve()
{
    ll d;
    string k;
    cin>>k>>d;
    ll n=k.length();
    memset(dp,0,sizeof(dp));
    dp[1][0][0]=1ll;
    for(ll x=1;x<=n;x++)
    {
     ll g=k[x-1]-'0';
     for(ll z=0;z<10;z++)
     {
        for(ll y=0;y<d;y++)
        {
            if(z<g)
            {
              dp[0][x][y]+=(dp[1][x-1][(10*d+y-z)%d]+dp[0][x-1][(10*d+y-z)%d]);
              dp[0][x][y]%=mod;
            }
            if(z==g)
            {
              dp[1][x][y]+=(dp[1][x-1][(10*d+y-z)%d]);
              dp[0][x][y]+=(dp[0][x-1][(10*d+y-z)%d]);
              dp[1][x][y]%=mod;
              dp[0][x][y]%=mod;
            }
            if(z>g)
            {
                  dp[0][x][y]+=(dp[0][x-1][(10*d+y-z)%d]);
                  dp[0][x][y]%=mod;
            }
        }
     }
    }
    cout<<(mod+dp[0][n][0]+dp[1][n][0]-1)%mod;
}
int main()
{ 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll i=1;
  //cin>>i;
  ll k=0;
  while(k<i)
  {
       solve();
       ++k;
  }   
}
    

Measured memory_bytes: 16000
import java.util.Scanner;
	import java.util.*;
	
	public class Main{
		
		public static void main(String[] args) {
			
			Scanner sc=new Scanner(System.in);
			
		while(true){int n=sc.nextInt();if(n==0){break;}
		int N[]=new int[n+1];
		
		for(int i=0;i<n+1;i++){N[i]=sc.nextInt();}
		
		bi:for(int i=0;i<n+1;i++){
			List<Integer>tousa=new ArrayList<Integer>();
		for(int p=0;p<n+1;p++){
			tousa.add(N[p]);}
		tousa.remove(i);
			for(int p=0;p<n-2;p++){
				if(tousa.get(p)-tousa.get(p+1)!=tousa.get(p+1)-tousa.get(p+2)){continue bi;}
			}System.out.println(N[i]);break;
		
		}}}}
		
		
		
		
		
		
		
		

Measured memory_bytes: 54468
#include <stdio.h>
int main(){
  int i,j,N,flag,count=0;
  int tmp;
  scanf("%d",&N);
  int A[N];
  for(i=0;i<N;i++)scanf("%d",&A[i]);

  flag=1;
  while(flag==1){
    flag=0;
    for(j=N-1;j>0;j--){
      if(A[j]<A[j-1]){
	tmp=A[j];
	A[j]=A[j-1];
	A[j-1]=tmp;
	flag=1;
	count++;
      }
    }
  }


  for(i=0;i<N-1;i++)printf("%d ",A[i]);
  printf("%d",A[N-1]);
  printf("\n%d\n",count);
  return 0;
}

Measured memory_bytes: 600
def main()->None:
    # gridの処理
    # 近傍の座標をdx=[-1,0,1], dy=[-1,0,1]を用いて
    # (xx, yy) が　xx = x + dx , yy = y + dy　とできる
    # 参考：http://prd-xxx.hateblo.jp/entry/2017/10/19/205331
    # 入力のグリッドから一点ずつ座標指定して選んでその周囲８マスを調べる。
    H, W = map(int, input().split())
    src = [input() for _ in range(H)]
    ans = []
    for row in src:
        ans.append(list(row))


    dxdy = [(-1,-1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)]
    for y in range(H):
        for x in range(W):
            if src[y][x] == "#":continue
            c = 0
            for dx, dy in dxdy:
                # 探索範囲はx:0~W, y:0~Hでその周囲８マスを探索する
                if x+dx < 0 or x+dx > W-1 or y+dy < 0 or y+dy > H-1: continue
                if src[y+dy][x+dx] == "#": c += 1
            ans[y][x] = c
    
    for row in ans:
        print("".join(list(map(str, row))))


if __name__ == "__main__":
    main()

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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll n, m;
	cin >> n >> m;
	vector<ll>v(n + 1), w(n + 1);
	for (int i = 1; i <= n; i++) {
		cin >> v[i] >> w[i];
	}

	vector<vector<ll>> dp(n + 1, vector<ll>(m + 1));
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (j >= w[i]) {
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
			} else {
				dp[i][j] = dp[i - 1][j];
			}
		}
	}

	cout << dp[n][m] << endl;
	return 0;
}



Measured memory_bytes: 10800
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
#define PI 3.14159265359

const int mod = 1e9 + 7;

int sum(long long left, long long right){
  long long ret = (right+left) * (right-left+1) / 2;
  return ret;
}

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

  int N, K;

  cin >> N >> K;

  int ans = 0;

  for(int i=K; i<=N+1; i++){
    int small = sum(0, i-1);
    int big = sum(N-i+1, N);
    ans += (big- small + 1);
    ans %= mod;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
/*
         ########     ########   ########   #########   ##       #######   ##       #######
         #      #     #      #   #      #       #       # #      #     #   # #      #     #
         #      #     #      #   #      #       #       #  #     #     #   #  #     #     #
         ########     #      #   #      #       #       #   #    #     #   #   #    #     #
         ###          #      #   #      #       #       #    #   #######   #    #   #######
         #  #         #      #   #      #       #       #   #    #     #   #   #    #     #
         #   #        #      #   #      #       #       #  #     #     #   #  #     #     #
         #    #       #      #   #      #       #       # #      #     #   # #      #     #
         #     #      ########   ########       #       ##       #     #   ##       #     #     
*/

#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define bitcount __builtin_popcount //count no's of ones in a set bit
#define prq priority_queue
#define mp make_pair
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define debug(a)          \
    cerr << #a << ": ";   \
    for (auto i : a)      \
        cerr << i << " "; \
    cerr << '\n';
#define trace(a) cerr << #a << ": " << a << "\n"
#define print(ar, n)            \
    for (int u = 0; u < n; u++) \
    {                           \
        cout << ar[u] << " ";   \
    }                           \
    cout << endl;
#define int long long
#define M 1000000007
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
signed main()
{
    rootdada;
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //  //   freopen("output.txt", "w", stdout);
    //  //  freopen("error.txt", "w", stderr);
    // #endif
    int n;
    cin >> n;
    vi a(n);
    rep(i, 0, n)
            cin >>
        a[i];
    int ans = 0;
    rep(i, 0, n)
    {
        if ((i + 1) % 2 == 1 && a[i] % 2 == 1)
            ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
 
#define N 200010
 
using namespace std;
 
typedef long long ll;
 
int a[N], pre[N], nxt[N], val[N];
 
char *p1, *p2, buf[100000];
 
#define nc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1 ++ )
 
int rd() {
    int x = 0;
    char c = nc();
    while (c < 48) {
        c = nc();
    }
    while (c > 47) {
        x = (((x << 2) + x) << 1) + (c ^ 48), c = nc();
    }
    return x;
}
 
ll rd2() {
    ll x = 0;
    char c = nc();
    while (c < 48) {
        c = nc();
    }
    while (c > 47) {
        x = (((x << 2) + x) << 1) + (c ^ 48), c = nc();
    }
    return x;
}
 
int First[N];
 
int main() {
    int n = rd();
    ll k = rd2();
    for (int i = 1; i <= n; i ++ ) {
        a[i] = rd();
    }
    if (n == 1) {
        if (k & 1) {
            printf("%d\n", a[1]);
        }
        return 0;
    }
    for (int i = n; i; i -- ) {
        First[a[i]] = i;
    }
    for (int i = 1; i <= n; i ++ ) {
        if (pre[a[i]]) {
            nxt[pre[a[i]]] = (i + 1) % n;
            if (!nxt[pre[a[i]]]) {
                nxt[pre[a[i]]] = n;
            }
        }
        pre[a[i]] = i;
    }
    for (int i = 1; i <= n; i ++ )
	{
        if (!nxt[i])
		{
            if (First[a[i]] != i)
                nxt[i] = First[a[i]] + 1;
            else if (i == n)
                    nxt[i] = 1;
            else
                nxt[i] = i + 1;
        }
    }
    for(int i = 1; i <= n; i++)
	{
        if (nxt[i] >= i + 2)
            val[i] = nxt[i] - i;
        else
            val[i] = nxt[i] + n - i;
    }
    if (nxt[n] == 1) {
        val[n] = n + 1;
    }
    ll mdl = 0;
    int now = 1;
    while (1) {
        mdl += val[now];
        now = nxt[now];
        if (now == 1) {
            break;
        }
    }
    ll pre = mdl / n;
    k %= pre;
    if(!k)
        return 0;
    int id = 1;
    now = 1;
    while (1) {
        if (nxt[now] >= now + 2) {
            now = nxt[now];
            continue;
        }
        if (id == k) {
            if (nxt[now] == 1 && now != n) {
                return 0;
            }
            printf("%d ", a[now]);
            if (now == n) {
                return 0;
            }
            now ++ ;
        }
        else {
            id ++ ;
            now = nxt[now];
        }
    }
    return 0;
}

Measured memory_bytes: 7764
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);
static const ll MOD = 10007;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define DEC(i, s) for (int i = (s); i >= 0; i--)

#define SIZE(v) (int)((v).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define FIND(m, w) ((m).find(w) != (m).end())

int n;
int edge[100010][2];
int cost[100010][2];
bool visit[10010];

ll dfs(int where, int parent, int lmax, ll ans) {
  if (visit[where]) { return ans; }
  visit[where] = true;
  REP(j, 2) {
    int to = edge[where][j];
    if (to == parent) { continue; }
    if (cost[where][j] == lmax) { ans++; }
    else if (cost[where][j] > lmax) {
      lmax = cost[where][j];
      ans = 1;
    }
    return dfs(to, where, lmax, ans);
  }
  assert(false);
  return 0;
}

int main() {
  while (scanf("%d", &n), n) {
    REP(i, n) {
      REP(j, 2) {
        scanf("%d %d", &edge[i][j], &cost[i][j]);
      }
    }
    MEMSET(visit, false);
    ll ans = 1;
    REP(i, n) {
      if (visit[i]) { continue; }
      ans = (ans * dfs(i, i, 0, 0)) % MOD;
    }
    printf("%lld\n", ans);
  }
}

Measured memory_bytes: 0
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const T &a) {
    for (auto e : a) cout << e << ' ';
    cout << '\n';
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    int i_max = max_element(a.begin(), a.end()) - a.begin();
    int ma = a[i_max];

    int d = -1;
    int j = 0;
    for (int i = 0; i < n; i++) {
        if (i == i_max) continue;
        if (d < min(a[i], ma-a[i])) {
            j = a[i];
            d = min(a[i], ma-a[i]);
        }
    }

    print(ma, j);
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int X = A * B;

		if (X % 2 == 0) {

			System.out.println("Even");

		} else {

			System.out.println("Odd");

		}
	}
}


Measured memory_bytes: 19924
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
using namespace std;
int main(){
    string s;
    cin >> s;
    int w,a,b;
    cin >> w;
    a = s.size();
    if(a%w==0){
        b = a/w;
    }else{
        b = a/w + 1;
    }
    for(int i=0;i<b;i++){
        cout << s[i*w];
    }
    cout << endl;
}

    

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

namespace codeTester.contest190727
{
    class ProblemA
    {
        static List<long> ab = new List<long>();
        static string answer = "";

        public static void Main(string[] args)
        {
            Input();
            Logic();
            Output();
        }

        static void Input()
        {
            ab = ReadSpaceSeparatedValues();
        }

        public static List<long> ReadSpaceSeparatedValues()
        {
            List<long> values = new List<long>();
            string[] inputs = Console.ReadLine().Split(' ');
            foreach (string input in inputs)
            {
                values.Add(long.Parse(input));
            }

            return values;
        }

        static void Logic()
        {
            long a = ab[0];
            long b = ab[1];
            if ((a + b) % 2 == 0) {
                answer = ((a + b) / 2).ToString();
                return;
            }
            answer = "IMPOSSIBLE";
        }

        static void Output()
        {
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int N,M;
int Map[55][55];
int visit[55];
int main(){

    cin>>N>>M;
    for(int i = 1;i<=M;i++)
    {
        int a,b;
        cin>>a>>b;
        visit[a]++;
        visit[b]++;
        Map[a][b] = Map[b][a] = 1;
    }
    int sum = 0;
    int xi;
    bool falg = true;
    while(1)
    {
        falg = true;
        for(int i = 1;i<=N;i++)
        {
            if(visit[i]==1)
            {
                sum++;
                xi = i;
                falg = false;
                visit[i]--;
                break;
            }
        }
        if(falg) break;
        for(int i = 1;i<=N;i++)
        {
            if(Map[xi][i]==1)
                visit[i]--;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long K, X;
    scan(K, X);
    writeln(500 * K < X ? "No" : "Yes");
}


Measured memory_bytes: 256
from collections import defaultdict
N,K,L = map(int,input().split())
 
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    def check(self, x, y):
        return self.find(x) == self.find(y)

# 道路
A = UnionFind(N)
for i in range(K):
    x,y = map(int,input().split())
    A.unite(x,y)

# 鉄道
B = UnionFind(N)
for i in range(L):
    x,y = map(int,input().split())
    B.unite(x,y)

dic = defaultdict(int)
for i in range(1,N+1):
    dic[A.find(i),B.find(i)] += 1

Ans = list(dic[A.par[i],B.par[i]] for i in range(1,N+1))
print(" ".join(map(str,Ans)))



Measured memory_bytes: 65016
n = int(input())
mark = [0] * n
num = [0] * n
slist = list() ;s_out = list()
hlist = list() ;h_out = list()
clist = list() ;c_out = list()
dlist = list() ;d_out = list()

for i in range(n) :
	mark[i], num[i] = input().split()
	num[i] = int(num[i])
	if mark[i] == "S" :
		slist.append(num[i])
	if mark[i] == "H" :
		hlist.append(num[i])
	if mark[i] == "C" :
		clist.append(num[i])
	if mark[i] == "D" :
		dlist.append(num[i])

for i in range(1, 14) :
	if not i in slist :
		print("S", i)
for i in range(1, 14) :
	if not i in hlist :
		print("H", i)
for i in range(1, 14) :
	if not i in clist :
		print("C", i)
for i in range(1, 14) :
	if not i in dlist :
		print("D", i)



Measured memory_bytes: 5616
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<char,int>;

const ll MOD = INF + 7;

int main(){
   int n;
   cin >> n;
   vector<int> t(n), x(n), y(n);
   rep(i, n){
       cin >> t[i] >> x[i] >> y[i];
       if(t[i] < x[i] + y[i]){
           cout << "No";
           return 0;
       }
   }

   REP(i, 1, n - 1){
       if(t[i] - t[i - 1] < abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])){
           cout << "No";
           return 0;
       }
   }
   REP(i, 0, n - 1){
       if(t[i] % 2 != (x[i] + y[i]) % 2){
           cout << "No";
           return 0;
       }
   }
   cout << "Yes";
}



Measured memory_bytes: 1408
def resolve():
    S = input()
    Q = int(input())

    from collections import deque
    strings = deque([S])
    switch = 0
    for _ in range(Q):
        line = input()
        if line.startswith('1'):
            switch ^= 1
            continue
        _, n, char = line.split()
        if n == '1':
            if switch == 0:
                strings.appendleft(char)
            else:
                strings.append(char)
        else:
            if switch == 0:
                strings.append(char)
            else:
                strings.appendleft(char)

    if switch:
        print(''.join(strings)[::-1])
    else:
        print(''.join(strings))
resolve()

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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
int n,k;
bool used[11]={false};
str s[11];
bool memo[11][11];
set<str> ans;
void f(int num,str st){
    if(num==k){
        ans.insert(st);
        return;
    }else{
        rep(i,0,n){
            if(!used[i]){
                used[i]=true;
                f(num+1,st+s[i]);
                used[i]=false;
            }
        }
        return;
    }
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
    ans.clear();
    cin >> n;
    cin >> k;
    if(n==0&&k==0)break;
    rep(i,0,n)cin >> s[i];
    f(0,"");
    cout << ans.size() << endl;
    }
    /*for(str k:ans){
        cout << k << endl;
    }*/
    return 0;
}

Measured memory_bytes: 3412
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string>
#include<set>
#include<string>
#include<climits>
using namespace std;

static int n;
static long long fib[110];

void init()
{
	fib[0] = 2;
	fib[1] = 1;
	for (int i = 2; i <= 100; i++) fib[i] = fib[i - 1] + fib[i - 2];
}


int main()
{
	init();
	while (scanf("%d",&n)!=EOF)
	{
		printf("%lld\n", fib[n]);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector <vll> vvll;
typedef pair <ll,ll> pll;
typedef vector <pll> vpll;

#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back
#define newl '\n'
#define gcd __gcd
#define fo(i,k,n) for(ll i=k;i<n;i++)
#define rev(i,k,n) for(ll i=k;i>n;i--)
#define MOD 1000000007 //10^9 + 7
#define deb(x) cout<<x<<" "<<#x<<newl
#define all(x) x.begin(),x.end()
#define print(x) for(auto i=x.begin();i!=x.end();i++)cout<<*i<<' ';cout<<endl;

ll INF = 1000000000000000005LL;

ll power(ll x, ll y, ll p=MOD){ //positive y
    ll res = 1;
    x = x % p; 
    while (y > 0) { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 

ll inverse(ll a,ll m=MOD){
    return power(a,m-2,m);
}

vvll matmul(const vvll &a,const vvll &b,ll M=MOD){
    ll n=a.size(),m=a[0].size(),l=b[0].size();
    assert(m==b.size());
    vvll c(n,vll(l,0));
    fo(i,0,n)
    fo(j,0,l)
    fo(k,0,m)
    {
        c[i][j]=(c[i][j]+a[i][k]*b[k][j])%M;
    }
    return c;
}

vvll matpow(vvll a,ll p,ll M=MOD){
    assert(a.size()==a[0].size());
    ll n=a.size();
    vvll res(n,vll(n,0));
    fo(i,0,n)   res[i][i]=1;
    while(p>0)
    {
        if(p&1) res=matmul(res,a,M);
        a=matmul(a,a,M);
        p>>=1;
    }
    return res;
}

void solve(){
    ll n,d;
    cin>>n>>d;

    ll x,y;
    ll ctr = 0;

    fo(i,0,n){
        cin>>x>>y;
        if(x*x + y*y <= d*d) ctr++;
    }

    cout<<ctr;

}

int main() {
    
    // fast io
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    
    //Number of Test cases
    ll T=1; 
    //cin>>T;
    
    while(T--){
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 3652
w = input()

length = len(w)

letters = []
for i in range(length):
    if w[i] not in letters:
        letters.append(w[i])

wareru = True
for i in range(len(letters)):
    if(w.count(letters[i])%2 != 0):
        wareru = False

if wareru:
    print("Yes")
else:
    print("No")

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

int main() {
  int q,w,e; cin >>q>>w>>e;
  if(q+w <e){
    cout << "No";
  }
  else{
    cout << "Yes";
  }
}

Measured memory_bytes: 3568
#include<iostream>
using namespace std;
int main(){
  long N, K;
  cin>>N>>K;
  
  long long P=1;
  for(int i=1;i<=30;i++){
    P*=K;
    if(N<P){
      cout<<i;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256