akhauriyash/Code-Regression huggingface dataset:
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            foreach (var c in S)
            {
                if (S.Where(x => x == c).Count() != 2)
                {
                    Console.WriteLine("No");
                    return;
                }                
            }
            Console.WriteLine("Yes");
        }
        //static void Main(string[] args)
        //{
        //    var temp = new Atcoder.ABC130.D();
        //    temp.Run();
        //}

    }
}

Measured memory_bytes: 13268
n, knapsack = gets.split.map(&:to_i)
goods = n.times.map {gets.split.map(&:to_i)}

dp = Array.new(n + 1) {Array.new(10001, 0)}

goods.each_with_index do |(value, weight), i|
  (0..knapsack).each do |w|
    dp[i + 1][w] = if w >= weight
      [dp[i][w - weight] + value, dp[i][w]].max
    else
      dp[i][w]
    end
  end
end

puts dp[n][knapsack]


Measured memory_bytes: 14772
/*author* Priyanshu Shrivastav (from IIT Palakkad) *
 * *_ __ ___  _ ______ ___  _ ____   ___  ___| |_  *
 * | '_ ` _ \| '__/ __/ _ \| '_ \ \ / / |/ __| __| *
 * | | | | | | | | (_| (_) | | | \ V /| | (__| |_  *
 * |_| |_| |_|_|(_)___\___/|_| |_|\_/ |_|\___|\__| *
When I wrote this, only God and I understood what I was doing
 ** * * * * * * * Now, only God knows * * * * * * */
#include         <bits/stdc++.h>
using namespace std;
#pragma GCC      optimize ("Ofast")
#pragma GCC      optimize ("unroll-loops")
#pragma GCC      target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define IOS      ios_base::sync_with_stdio(false); cin.tie (nullptr)
#define PREC     cout.precision (10); cout << fixed
#define bg(x)    " [ " << #x << " : " << (x) << " ] "
#define x        first
#define y        second
using ll = long long;
using ff = long double;
using pii = pair<int,int>;

#define debug(args...) { \
/* WARNING : do NOT compile this debug func calls with following flags: // \
 * // -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2*/ \
   string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');\
   stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); \
}
void err(istream_iterator<string> it) { it->empty();
   cerr << " (Line : " << __LINE__ << ")" << '\n';
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << fixed << setprecision(15) << " [ " <<  *it << " : " << a  << " ] "<< ' ';
	err(++it, args...);
}

// let k = a + b + c
// E(a,b,c) := Expected no. of trials required to reach (0,0,0) from (a,b,c)
// E(a,b,c) = (n-k)/n * (1 + E(a,b,c)) + a/n * (1 + E(a-1,b,c)) + b/n * (1 + E(a+1,b-1,c)) + c/n * (1 + E(a,b+1,c-1))
// hence, E(a,b,c) = n/k + a/k * E(a-1,b,c) + b/k * E(a+1,b-1,c) + c/k * E(a,b+1,c-1)

const int N = 304;

ff E[N][N][N];
int n, cnt[3];

void solve() {
   E[0][0][0] = 0;

   for (int c = 0; c <= n; ++c) {
      for (int b = 0; b+c <= n; ++b) {
         for (int a = 0; a+b+c <= n; ++a) {
            if (a + b + c > n) continue;
            if (!a && !b && !c) continue;

            int k = a + b + c;
            ff repeat = 1.0*n/k;
            ff p_a = 1.0*a/k, p_b = 1.0*b/k, p_c = 1.0*c/k;

            E[a][b][c] = repeat;

            if (a) E[a][b][c] += E[a-1][b][c] * p_a;
            if (b) E[a][b][c] += E[a+1][b-1][c] * p_b;
            if (c) E[a][b][c] += E[a][b+1][c-1] * p_c;
         }
      }
   }
   cout << E[cnt[0]][cnt[1]][cnt[2]] << '\n';
}

signed main() {
   IOS; PREC;
   cin >> n;

   cnt[0] = cnt[1] = cnt[2] = 0;

   for (int i = 0, foo; i < n; ++i)
      cin >> foo, cnt[foo-1]++;

   cerr << cnt[0] << ' ' << cnt[1] << ' ' << cnt[2] << '\n';

   solve();

   return EXIT_SUCCESS;
}


Measured memory_bytes: 434432
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio>

#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; i++)
#define DOW(i, a, b) for(int i = (a), _b = (b); i >= _b; i--)

using namespace std;

const int MAXN = 111000;
const int MAXD = 11;
vector<int> adj[MAXN];
bool painted[MAXN][MAXD];
int color[MAXN];
int qd[MAXN], qc[MAXN], qv[MAXN];

void setColor(int v, int c) {
  if (color[v] == 0) color[v] = c;
}

void update(int u, int d, int c) {
  if (d < 0) return;
  if (painted[u][d]) return;
  FOR(d1, 0, d) painted[u][d1] = true;
  setColor(u, c);
  FOR(i, 0, adj[u].size() - 1) {
    int v = adj[u][i];
    update(v, d - 1, c);
  }
}

int main() {
  ios::sync_with_stdio(false);
  int n, m, u, v, q;
  while (cin >> n >> m) {
    FOR(i, 1, n) adj[i].clear();
    memset(painted, 0, sizeof(painted));
    memset(color, 0, sizeof(color));
    FOR(i, 1, m) {
      cin >> u >> v;
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    cin >> q;
    FOR(i, 1, q) {
      cin >> qv[i] >> qd[i] >> qc[i];
    }
    DOW(i, q, 1) {
      update(qv[i], qd[i], qc[i]);
    }
    FOR(i, 1, n) cout << color[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 9592
a, b, k = map(int, input().split())
ans = []
for i in range(a, min(a + k, b)):
    if i not in ans:
        ans.append(i)
for i in range(b, max(b - k, a - 1), -1):
    if i not in ans:
        ans.append(i)
ans.sort()
for i in range(len(ans)):
    print(ans[i])


Measured memory_bytes: 3060
#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()
{
  int N;
  while (cin >> N, N)
  {
    int field[400][400];
    memset(field, -1, sizeof(field));
    field[200 + 0][200 + 0] = 0;
    for (int k = 1; k <= N - 1; ++k)
    {
      int n, d;
      cin >> n >> d;
      for (int i = 0; i < 400; ++i)
      {
        for (int j = 0; j < 400; ++j)
        {
          if (field[i][j] == n)
          {
            if (d == 0)
              field[i][j - 1] = k;
            else if (d == 1)
              field[i - 1][j] = k;
            else if (d == 2)
              field[i][j + 1] = k;
            else
              field[i + 1][j] = k;
          }
        }
      }
    }

    int l, u, d, r;
    l = u = d = r = -1;
    for (int i = 0; i < 400; ++i)
    {
      for (int j = 0; j < 400; ++j)
      {
        if (field[i][j] != -1)
          d = i;
      }
      if (d != -1)
        break;
    }
    for (int j = 0; j < 400; ++j)
    {
      for (int i = 0; i < 400; ++i)
      {
        if (field[i][j] != -1)
          l = j;
      }
      if (l != -1)
        break;
    }
    for (int i = 399; i >= 0; --i)
    {
      for (int j = 0; j < 400; ++j)
      {
        if (field[i][j] != -1)
          u = i;
      }
      if (u != -1)
        break;
    }
    for (int j = 399; j >= 0; --j)
    {
      for (int i = 0; i < 400; ++i)
      {
        if (field[i][j] != -1)
          r = j;
      }
      if (r != -1)
        break;
    }
    cout << r - l + 1 << ' ' << u - d + 1 << endl;
  }

  return 0;
}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
#define spn setprecision
#define fr(x,a,b,c) for(int x = a; x <= b; x+=c)
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 501;
const int mod = 1e9+7;
int arr[3][upperlimit];
int colour[upperlimit][upperlimit];
int ans[3];
int main() {
	int a,b;
	sd(a);
	sd(b);
	b-=a;
	b*=b-1;
	b/=2;
	b-=a;
	pd(b);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int i, j;
	int n, m, a;

	while (scanf("%d %d %d", &n, &m, &a), n) {
		int h[1000], p[1000], q[1000];
		int cur_h;

		for (i = 0; i < m; i++)
			scanf("%d %d %d", h + i, p + i, q + i);

		for (cur_h = 1000; cur_h >= 0; cur_h--)
			for (j = 0; j < m; j++)
				if (h[j] == cur_h)
					if (p[j] == a) {
						a = q[j];
						break;
					} else if (q[j] == a) {
						a = p[j];
						break;
					}

		printf("%d\n", a);
	}

	return 0;
}

Measured memory_bytes: 612
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
using namespace std;

#define INF 1e9
#define rep(i,j,n) for(int (i)=(j);(i)<(n);(i)++)
#define rep2(i,j,n) for(int (i)=(j);(i)<=(n);(i)++)
#define all(i) (i).begin(),(i).end()
#define rall(i) (i).rbegin(),(i).rend()

typedef long long i64;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<vs> vvs;

int main(){
  string s;
  cin>>s;
  set<char> st;
  rep(i,0,s.size()) st.insert(s[i]);
  rep(i,0,26){
    char c='a'+i;
    if(!st.count(c)){
      cout<<c<<endl;
      return 0;
    }
  }
  cout<<"None\n";
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<endl;}return os;}

namespace ndifix{
template<class T>void sort(T &v){std::sort(v.begin(),v.end());}
}

int main(){
  int a,b;cin>>a>>b;
  if(a+b==15)cout<<'+'<<endl;
  else if(a*b==15)cout<<'*'<<endl;
  else cout<<'x'<<endl;

  return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
B.sort()

AB = defaultdict(int)

for b in B:
    AB[b] = bisect_left(A, b)

sumAB = defaultdict(int)
sumAB[0] = 0
s = 0
for b in B:
    s += AB[b]
    sumAB[b] = s

B.insert(0, 0)
ans = 0
for c in C:
    r = bisect_left(B, c)
    ans += sumAB[B[r - 1]]

print(ans)

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

int main()
{
	int n;
	cin >> n;
	vector<int> a(3),b(3);
	cin >> a[0] >> a[1] >> a[2];
	cin >> b[0] >> b[1] >> b[2];

// a → b

	//dp[i] : どんぐりi個で持つ価値の最大
	vector<ll> dp(100000000,0);
	for(int i=0;i<=n;i++)
		dp[i]=i;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<3;j++)
		{
			if(i>=a[j])dp[i]=max(dp[i],dp[i-a[j]]+b[j]);
		}
	}


	int atob=dp[n];

// b → a

	//初期化
	for(int i=0;i<=atob;i++)
		dp[i]=i;

	for(int i=1;i<=atob;i++)
	{
		for(int j=0;j<3;j++)
		{
			if(i>=b[j])dp[i]=max(dp[i],dp[i-b[j]]+a[j]);
		}
	}

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

Measured memory_bytes: 781440
#include <unordered_map>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <tuple>
#include <set>
#include <map>

#define FOR0(var, max) for (ul (var) = 0; (var) < (max); ++(var))
#define FORi(var, min, max) for (ul (var) = (min); (var) < (max); ++(var))
#define FORi_INV(var, min, max) for (ul (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

static si A, B;

void solve(void) {
  cout << max(A - 2 * B, 0) << endl;
}

int main(void) {
  cin >> A >> B;
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 (a>b) { a=b; return 1; } return 0; }
    
int main(){
    int n, x, t;
    cin >> n >> x >> t;
    int ans = 0;
    ans = ceil((double)n / x);
    ans *= t;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
  int n;
  cin>>n;
  while(n--){
    int a,b;
	char d;
	cin>>a>>d>>b;
	double h=abs(30.0*a-5.5*b);
	//cout<<h<<endl;
	if(h<30||360-h<30)cout<<"alert"<<endl;
	else if(h>=90&&h<=270)cout<<"safe"<<endl;
	else cout<<"warning"<<endl;
  }
}

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

using namespace std;

const int N = 3;
const int M = 3;


int main() {

	ios_base :: sync_with_stdio(0);
	cin.tie(NULL);

	vector< vector<int> >  a(N, vector<int>(M));
	vector< vector<bool> > marked(N, vector<bool>(M));

	map< int, pair<int,int> > pos; //value -> position

	for(int i = 0; i < N; ++i)
		for(int j  = 0; j < M; ++j) {
			cin >> a[i][j];
			pos[a[i][j]] = {i, j};
		}

	int n; cin >> n;

	for(int i = 0, x; i < n; ++i) {
		cin >> x;
		if (pos.count(x)) marked[pos[x].first][pos[x].second] = true;
	}

	bool ans = false;

	//diagonal
	ans |= (marked[0][0] && marked[1][1] && marked[2][2]);
	ans |= (marked[0][2] && marked[1][1] && marked[2][0]);

	//col / lin
	ans |= (marked[0][0] && marked[0][1] && marked[0][2]);
	ans |= (marked[1][0] && marked[1][1] && marked[1][2]);
	ans |= (marked[2][0] && marked[2][1] && marked[2][2]);

	ans |= (marked[0][0] && marked[1][0] && marked[2][0]);
	ans |= (marked[0][1] && marked[1][1] && marked[2][1]);
	ans |= (marked[0][2] && marked[1][2] && marked[2][2]);

	cout << (ans ? "Yes" : "No") << '\n';

	return 0;	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 2e5 + 5;
int edge[MAX], when[MAX];

void solve() {
    int n;
    ll k;
    cin >> n >> k;
    fori (i, 1, n + 1) cin >> edge[i];
    int tempo = 1;
    int node = 1;
    while (k > 0) {
        if (when[node] != 0) {
            int cycle_size = tempo - when[node];
            k %= cycle_size;
            break;
        }
        when[node] = tempo++;
        k--;
        node = edge[node];
    }
    fori (i, 0, k) node = edge[node];
    cout << node << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}



Measured memory_bytes: 5204
import Data.List
main=print.f.map read.words=<<getContents
f(n:ds)=g 0 24.sort$ds
g a b(x:ds)
  |x-a<b-y=min(b-y)$g a y ds
  |otherwise=min(x-a)$g x b ds
  where y=24-x
g a b _=b-a

Measured memory_bytes: 636
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;

ll n;

int main()
{
	cin>>n;
	ll sum=0;
	for(ll i=1;i<=n;i++)
	{
		if(i%3!=0&&i%5!=0) sum+=i;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <bitset>

using namespace std;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define epr(...) fprintf(stderr, __VA_ARGS__)
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; 
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

#define equal equalll
#define less lesss
typedef long long ll;
const int N = 1e5 + 10;
const long long INF = 1e9 + 19;
const int MOD = 1e9 + 7;


int n;
int a[N];
int b[N];

void read() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    for (int i = 0; i < n; i++)
        scanf("%d", &b[i]);
}

void solve() {
    ll answer = 1;
    for (int i = 0; i < n; i++) {
        ll ex = -1;
        if (i == 0 || (a[i - 1] < a[i])) {
            ex = a[i];
            //db2(i, ex);
        }
        if (i == (n - 1) || b[i] > b[i + 1]) {
            if (ex != -1 && ex != b[i]) {
                puts("0");
                return;
            }
            ex = b[i];
        }
        if (a[i] < ex || b[i] < ex) {
            //db2(i, ex);
            //db2(a[i], b[i]);
            puts("0");
            return;
        }
        if (ex == -1) {
            answer = (answer * min(a[i], b[i])) % MOD;
            //db(i);
        }
    }

    cout << answer << endl;
}

void stress() {

}


int main(){
#ifdef MY_DEBUG
    freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
#endif
    if (1) {
        int k = 1;
        for (int tt = 0; tt < k; tt++) {
            read();
            solve();
        }
    }
    else {
        stress();
    }

    return 0;
}








Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var inputs = ReadLongs();
            var N = inputs[0];
            var K = inputs[1];
            var Q = inputs[2];

            var A = new long[(int)N];
            for (int i = 0; i < Q; i++)
            {
                A[ReadLong() - 1]++;
            }

            var sb = new StringBuilder();
            for (int i = 0; i < N; i++)
            {
                if (K - (Q - A[i]) <= 0)
                {
                    sb.AppendLine("No");
                }
                else
                {
                    sb.AppendLine("Yes");
                }
            }

            return sb.ToString().Trim();
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (ll i=0;i<N;i++) cin >> A[i];
    vector<ll> zero(61);
    vector<ll> one(61);
    for (ll i=0;i<N;i++){
        for (ll bit=0;bit<61;bit++){
            if ((A[i]>>bit)&1) {
                one[bit]++;
                one[bit] %= mod;
            } else {
                zero[bit]++;
                zero[bit] %= mod;
            } 
        }
    }
    mint ans = 0;
    for (ll bit=0;bit<61;bit++){
        ans += mint(1LL<<bit)*one[bit]*zero[bit];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 5504
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys
input = sys.stdin.readline
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

s = input()
if s.isupper():
    print('A')
else:
    print('a')
    

Measured memory_bytes: 61708
/***********************************************************
	When you are inspired by passion 
	and you want to live for the current moment

	When your every thought and action
	has the power to become the story of your future

	When difficulties stand to demolish your Glory
	Just remember that Life is a 'Golden adverse Story'

	Withstand it to acheive your passion and dreams
	more amazingly more easily.

	Why then? When writing the story of your Life
	You want to Let someone else hold your pen

					huzaifa242©

***********************************************************/
#include "bits/stdc++.h"
using namespace std;
#define int int32_t
#define MAX 100005
#define x first 
#define y second

int seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline int rnd(int l = 0, int r = numeric_limits <int>::max())
{return uniform_int_distribution<int> (l, r)(rng);}

template <typename T, typename G>
ostream& operator << (ostream& out, const pair <T, G> &a) 
{return out << "( " << a.x << ", " << a.y << ")";}

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

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

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

template <typename T, size_t N>
typename enable_if<!is_same <typename remove_cv <T>::type, char>::value,
ostream&>::type operator << (ostream& out, T (&a)[N])
{out << "[ "; for(const auto &i: a) out << i << ", "; return out << "]" << endl;}

void debug_out(){cerr << endl;} 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{cerr << (H) << ' '; debug_out(T...);}
 
#ifdef LOCAL
#define debug(...) cerr << '#' << #__VA_ARGS__ << ":\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 24
#endif

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	map <string,int> count;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >>s;
		count[s]++;
	}
	cout << "AC x " << count["AC"] << '\n';
	cout << "WA x " << count["WA"] << '\n';
	cout << "TLE x " << count["TLE"] << '\n';
	cout << "RE x " << count["RE"] << '\n';
	return 0;
}


Measured memory_bytes: 3672
function Main(input) {
  const data = input.trim().split('\n')
  const N = data[0].split(' ').map(s => parseInt(s))[0]
  const rest = data[1].split(' ').map(s => parseInt(s)).sort((a, b) => a - b)

  const DIV = N - 1

  // コマ数が指定座標より多い場合。
  if (N >= rest.length) {
    console.log(0)
    return
  }

  var list = []
  for(var i = 0; i < rest.length - 1; ++i) {
    var dist = Math.abs(rest[i + 1] - rest[i])
    list.push(dist)
  }

  list.sort((a, b) => a - b)

  list = list.slice(0, list.length - DIV)
  var ans = list.reduce((prev, current) => prev += current)
  console.log(ans)  
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

bool isGoo(string s) {
    if(s.length() % 2 != 0) { return false; }
    int mid = s.length() / 2;
    if(s.substr(0, mid) == s.substr(mid, mid)) { return true; }
    return false;
}

signed main()
{
    string S;
    cin >> S;
    int ans = 0;
    for(int i = 2; i < S.length(); ++i) {
        string cand = S.substr(0, i);
        if(isGoo(cand)) { ans = max(ans, (int)cand.length()); }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n, m;
  cin >> n >> m;
  cout << (n == m ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        long n = scan.nextLong();

        String[] str = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};

        String ans = "";

        while (n > 0) {
            int r = (int)(n % 26l);
            if (r == 0) {
                r = 26;
                n = n - 1l;
            }
            ans = str[r - 1] + ans;
            n = n / 26l;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 39128
// Best practice

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 

#define int         long long
#define pb          emplace_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 

#define fbo find_by_order
#define ook order_of_key

signed main() {
   tezz
   
    int n;
    cin >> n;
    float p,ans=0;
    for(int i=0; i<n; i++){
        cin >> p;
        ans += 1/p;
    }
    cout << setprecision(15) << 1/ans << endl;
   
   return 0;
}


Measured memory_bytes: 384
import java.util.*;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	static class Node {
		int id;
		Map<Integer, Integer> edgeTypes;

		Node(int id) {
			this.id = id;
			this.edgeTypes = new HashMap<>();
		}
	}

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		int N = Integer.parseInt(in.readLine());

		List<Node> nodes = new ArrayList<>();
		for (int i = 0; i < N; ++i) {
			nodes.add(new Node(i));
		}
		addEdge(nodes, 1);

		for (int i = 0; i + 1 < N; ++i) {
			Node node = nodes.get(i);
			for (int j = i + 1; j < N; ++j) {
				System.out.print(node.edgeTypes.get(j) + " ");
			}
			System.out.println("");
		}

	}

	static void addEdge(List<Node> nodes, int val) {
		if (nodes.size() == 2) {
			Node node = nodes.get(0);
			Node another = nodes.get(1);
			node.edgeTypes.put(another.id, val);
			another.edgeTypes.put(node.id, val);
		} else if (nodes.size() == 3) {
			for (int i = 0; i < 2; ++i) {
				nodes.get(i).edgeTypes.put(nodes.get(i + 1).id, val);
				nodes.get(i + 1).edgeTypes.put(nodes.get(i).id, val);
			}
			nodes.get(0).edgeTypes.put(nodes.get(2).id, val + 1);
			nodes.get(2).edgeTypes.put(nodes.get(0).id, val + 1);
		} else {
			// Listを2つに分ける
			List<Node> listA = new ArrayList<>();
			List<Node> listB = new ArrayList<>();
			for (int i = 0; i < nodes.size() / 2; ++i) {
				listA.add(nodes.get(i));
			}
			for (int i = listA.size(); i < nodes.size(); ++i) {
				listB.add(nodes.get(i));
			}
			// list間のedgeにvalの値を付与
			for (Node node : listA) {
				for (Node another : listB) {
					node.edgeTypes.put(another.id, val);
					another.edgeTypes.put(node.id, val);
				}
			}
			addEdge(listA, val + 1);
			addEdge(listB, val + 1);
		}
	}

}


Measured memory_bytes: 54100
#include <iostream>
#include "string.h"
using namespace std;

class Node{
	public:
		Node* prev;
		Node* next;
		int data;
		Node(){ prev=0; next=0; data=0;}
};

class List{
	private:
		Node head;
	public:
		List(){ head.prev=&head; head.next=&head;}
		int insertx(int x);
		int deletex(int x);
		int deleteFirst();
		int deleteLast();
		int print();
};

//ここに問題がある！！
int List::insertx(int x){
	Node* p=new Node();
	if(p==0)
		return -1;

	Node* q=head.next;
	Node* r=&head;
	
	p->prev=r;
	p->next=q;
	p->data=x;

	r->next=p;
	q->prev=p;
	
	return 0;
}

int List::deletex(int x){
	for(Node* p=head.next; p!=&head; p=p->next){
		if(p->data==x){
			Node* q=p->prev;
			Node* r=p->next;

			q->next=r;
			r->prev=q;

			delete p;

			return 0;
		}
		
	}
	return -2;
}
int List::deleteFirst(){
	Node* p=head.next;
	Node* q=&head;
	Node* r=p->next;
	
	if(p==q)
		return -3;	//何も入っていない

	q->next=r;
	r->prev=q;	
	
	delete p;
		return 0;
}

int List::deleteLast(){
	Node* p=head.prev;
	Node* q=&head;
	Node* r=p->prev;
	
	if(p==q)
		return -3;	//何も入っていない

	q->prev=r;
	r->next=q;	
	
	delete p;
		return 0;
}

int List::print(){
	for(Node* p=head.next; p!=&head; p=p->next){
		if(p!=head.prev)
			cout << p->data <<' ';
		else
			cout << p->data << endl;
	}
	
}

int main(){
	List L;
	int n,x;
	char a[12];
	cin>>n;

	for(int i=0; i<n; i++){
		cin >> a;

		if(a[0]=='i'){
			cin >>x;
			L.insertx(x);
		}
		else if(a[6]=='F'){
			L.deleteFirst();
		}
		else if(a[6]=='L'){
			L.deleteLast();
		}
		else{
			cin >>x;
			L.deletex(x);
		}
	}
	L.print();
	return 0;
}


	
		 

Measured memory_bytes: 32444
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

char s[maxn];

int main()
{
	scanf("%s",s+1); int len=strlen(s+1);
	if(len%2==1) {puts("No"); return 0;}
	for(int i=1;i<=len;i+=2)
	{
		if(s[i]!='h'||s[i+1]!='i')
			{puts("No"); return 0;}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld ;
#define pb push_back
#define fi first
#define se second
const int N = 3e6+5;
ll a[N];
ll b[N];
bool vis[N];
void solve(){
    int s,w;
    cin>>s>>w;
    if(w>=s){
        cout<<"unsafe"<<endl;
    }
    else{
        cout<<"safe"<<endl;
    }
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//    preprocess();
    int t =1;
 //   cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 3652
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7

mb=format(max(a),'b')
arr=[0]*len(mb)

for i in range(n):
    b=format(a[i],'b')
    for j in range(len(b)):
        if b[-j-1]=='1':
            arr[j]+=1

ans=0

for i in range(len(mb)):
    ans+=(arr[i]*(n-arr[i])*(2**i))%mod
print(ans%mod)

Measured memory_bytes: 122936
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define ALL(x)          (x).begin(), (x).end()
#define rALL(x)         (x).rbegin(), (x).rend()
#define REP(i, n)       for(int i = 0; (i) < (int)(n); (i)++)
#define rREP(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define FOR(i, a, b)    for(int i = (a); (i) < (int)(b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/

bool judge(ll &x){
    if(x < 2) return false;
    else return true; 
}

/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    ll n; cin >> n;
    vector<ll> a(n+1);
    vector<ll> val(n+1, 0);
    FOR(i, 1, n+1){
        cin >> a[i];
        val[a[i]]++;
    }
    ll ans = 0;
    for(int k = 1; k <= n; k++){
        if(judge(val[k])){
            ans += ((val[k] * val[k] - val[k]) / 2);
        }
    }


    for(int i = 1; i <= n; i++){
        cout << ans - val[a[i]] + 1 << endl;
    }

return 0;
}

Measured memory_bytes: 6348
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

void solve();

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

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

    map<ll,ll> mp;
    for(ll i=2;i*i<=p;++i){
        while(p%i==0){
            ++mp[i];
            p/=i;
        }
    }
    if(p>1)++mp[p];

    ll ans=1;
    for(auto &p:mp){
        rep(i,p.second/n)ans*=p.first;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <complex>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;

#define REP(i,s,t) for(int i=(s);i<(t);i++)
#define FILL(x,v) memset(x,v,sizeof(x))

const int INF = (int)1E9;
#define MAXN 100005


int main(){
	int h[10];
	REP(i,0,10) cin >> h[i];
	sort(h,h+10,greater<int>());
	REP(i,0,3) printf("%d\n", h[i]);
	return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/env python

n = int(input())

arr = [int(i) for i in input().split(' ')]

parr = [0]*n

parr[n-1] = arr[n-1]

ans = 0
mod = int(10**9+7)

for j in range(n-2, -1, -1):
    parr[j] = arr[j] + parr[j+1]

    ans += arr[j] * parr[j+1]
    ans = ans % mod

print(ans)


Measured memory_bytes: 98736
#include <iostream>
#include <string>
#include <map>
#include <cstdlib>
#include <cctype>
#include <sstream>

using namespace std;

map<string, int> at;
string form;
int pos;

class Formula {
private:
  int pos;
  int exp();
  int term();
  int factor();
public:
  string str;
  int ans();
};

int Formula::exp() {
  int x = term();
  while(str[pos] == '+' || str[pos] == '-') {
    switch(str[pos++]) {
    case '+':
      x += term();
      break;
    case '-':
      x += term();
      break;
    }
  }
  return x;
}

int Formula::term() {
  int x = factor();
  while(str[pos] == '*' || str[pos] == '/') {
    switch(str[pos++]) {
    case '*':
      x *= factor();
      break;
    case '-':
      x /= factor();
      break;
    }
  }
  return x;
}

int Formula::factor() {
  int x;
  if(str[pos] == '(') {
    ++pos;
    x = exp();
    ++pos;
  } else {
    int s = pos;
    while(isdigit(str[pos])) ++pos;
    x = atoi((str.substr(s, pos-s)).c_str());
  }
  return x;
}

int Formula::ans() {
  pos = 0;
  return exp();
}

string toString(int x) {
  stringstream ss;
  string s;
  ss << x;
  ss >> s;
  return s;
}

string convert(string &s) {
  string s2;
  int i = 0;
  bool flag = false;
  while(i < s.size()) {
    if(s[i] == '(') {
      if(flag) {
	s2 += '+';
	flag = false;
      }
      s2 += s[i];
      ++i;
      continue;
    }

    if(s[i] == ')') {
      flag = true;
      s2 += s[i];
      ++i;
      continue;
    }

    if(isdigit(s[i])) {
      flag = true;
      int st = i++;
      while(i < s.size() && isdigit(s[i])) ++i;
      s2 += '*';
      s2 += s.substr(st, i-st);
      continue;
    }

    int tmp;
    if(flag) s2 += '+';
    else     flag = true;
    if(i+1 < s.size() && islower(s[i+1])){
      tmp = at[s.substr(i, 2)];
      i += 2;
    } else {
      tmp = at[s.substr(i, 1)];
      ++i;
    }
    if(!tmp) return "0";
    s2 += toString(tmp);
  }
  return s2;
}

void solve(string &s) {
  Formula f;
  int ans;
  f.str = convert(s);
  ans = f.ans();
  if(ans == 0) cout << "UNKNOWN" << endl;
  else         cout << ans << endl;
}

main() {
  string s;
  while((cin >> s) && s != "END_OF_FIRST_PART") {
    cin >> at[s];
  }
  while((cin >> s) && s != "0") solve(s);
}

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

int main() {
    int n,m;
    cin>>n>>m;
    char a[100][100],b[100][100];
    for(int i=0;i<n;i++) {
        for(int j=0;j<n;j++) {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<m;i++) {
        for(int j=0;j<m;j++) {
            cin>>b[i][j];
        }
    }
    bool flag=false;
    for(int vy=0;vy<n;vy++) {
        for(int vx=0;vx<n;vx++) {
            if(vy+m-1>=n || vx+m-1>=n) continue;
            bool match=true;
            for(int y=0;y<m;y++) {
                for(int x=0;x<m;x++) {
                    if(a[vy+y][vx+x]!=b[y][x]) match=false;
                }
            }
            if(match) flag=true; 
        }
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int n=stdIn.nextInt(),k=stdIn.nextInt(),s=1,i;
		for(i=0;i<n;i++) {
			if(s*2>s+k) s+=k;
			else s*=2;
		}
		System.out.print(s);
	}
}

Measured memory_bytes: 21716
import sys
sys.setrecursionlimit(100000) 
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
A = [0]*(n)
if k >= n:
    k = n
for i in range(1,k):
    A[i] = abs(l[i]-l[0])
for i in range(k,n):
    tmp = float('Inf')
    for j in range(1,k+1):
        dis = A[i-j] + abs(l[i]-l[i-j])
        tmp = min(tmp,dis)
    A[i] = tmp
print(A[n-1])


Measured memory_bytes: 52448
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;

int main()
{
	//freopen("in.txt","r",stdin);
	long long n;
	cin>>n;

	if(n==1)
		cout<<0;
	else {
		
		long long lim=n;

        int ans=0;
        bool chk=false;
		for(long long i=2;i*i<=lim;i+=2)
		{
			//cout<<i<<" ";
			int div=i;
			while(n%div==0)
			{
				//cout<<i<<" ";
				chk=true;
				ans++;
				n/=div;
			
				div*=i;
				if(n%div!=0)
				{
					while(n%i==0) n/=i;
				}
			}
			if(i==2)i-=1;
		}
		if(n!=1)ans++;
		
		if(chk==false)ans=1;

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

Measured memory_bytes: 3624
import sys
import os
import math
import bisect

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = sorted(il())
    B = sorted(il())
    C = sorted(il())

    ret = 0
    for b in B:
        al = bisect.bisect_right(A, b-1)
        cl = len(C) - bisect.bisect_left(C, b+1)
        ret += al*cl
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 22100
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;



int main(){
    string a;
    cin >> a;
    if(a[0] == a[2]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n;
set<int> se;

int main() {
	cin >> n;
	
	se.insert(1);
	incII(i, 2, n) {
		for(int j = i * i; j <= n; j *= i) { se.insert(j); }
	}
	
	cout << (*se.rbegin()) << endl;
	
	return 0;
}


Measured memory_bytes: 256
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    it.next();
    let mut a: Vec<char> = it.next().unwrap().chars().collect();
    a.dedup();
    println!("{}", a.len());
}

fn main() {
    run();
}

Measured memory_bytes: 4352
#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<deque>
#include<utility>
#include<map>
#include<set>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<functional>
#include<sstream>
#include<cstring>
#include<bitset>
#include<stack>
using namespace std;

int k,t,ans;
int a[105];

bool cmp(int a,int b)
{
	return a>b;
}

int main()
{
	cin>>k>>t;
	for(int i=1;i<=t;i++)
	{
		cin>>a[i];
	}
	
	int x=1,y=2;
	while(1)
	{
		sort(a+1,a+t+1,cmp);
		if(a[x]==0)break;
		if(a[y]==0)
		{
			ans=a[x];
			ans--;
			break;
		}
		a[x]-=a[y];
		a[y]-=a[y];
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
string s;char t;
long long k,cnt;
main(){
    cin>>s>>k;
    for(int i=0;i<s.size();i++){
        if(s[i]=='1')cnt++;
        else{t=s[i];break;}
    }
	cout<<((cnt>=k)?'1':t)<<endl;
}

Measured memory_bytes: 256