akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;

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

    ll N, K, S;
    cin >> N >> K >> S;
    ll other;
    if(S == 1e9){
        other = 1e9 - 1;
    }else{
        other = S + 1;
    }
    for(int i = 0; i < N; i++)
    {
        if(i > 0){
            cout << " ";
        }
        if(i < K){
            cout << S;
        }else{
            cout << other;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1280
#include "bits/stdc++.h"
using namespace std;

class Timer {
	std::chrono::high_resolution_clock::time_point m_start;
public:
	Timer() 
	: m_start(std::chrono::high_resolution_clock::now()) {}

	~Timer() {
		auto end = std::chrono::high_resolution_clock::now();
  		auto duration_s = std::chrono::duration<double>(end - m_start).count();
  		cerr << "Completed in " << duration_s << endl;
  	}
};

template < class c > struct rge { c b, e; };
template < class c > rge<c> range(c i, c j) { return rge<c>{i, j}; }
template < class c > auto dud(c* x) -> decltype(cerr << *x, 0);
template < class c > char dud(...);
struct debug {
#ifdef LOCAL
	~debug() { cerr << endl; }
	template < class c > typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) { cerr << boolalpha << i; return *this; }
	template < class c > typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) { return *this << range(begin(i), end(i)); }
	template < class c, class b > debug & operator <<(pair < b, c > d) {
	  return * this << "(" << d.first << ", " << d.second << ")";
	}
	template < class c > debug & operator <<(rge<c> d) {
	  *this << "[";
	  for (auto it = d.b; it != d.e; ++it)
	    *this << ", " + 2 * (it == d.b) << *it;
	  return * this << "]";
	}
#else
	template < class c > debug & operator <<(const c&) { return * this; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int INF = 1e9 + 5;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#include <iostream>

void solve() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	Timer timer;

	

	int sum = 0;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] == 'R') {
			if (i+1 < s.length() && s[i+1] == s[i]) {
				sum += 1;
			}
		}
		if (s[i] == 'L') {
			if (i-1 >= 0 && s[i-1] == s[i]) {
				sum += 1;
			}
		}
	}
	cout << min(int(s.length() - 1), sum + 2*k) << endl;
	
}

int main() {
	FAST
	int t = 1;
	// cin >> t;

	for (int i = 0; i < t; ++i) {
		solve();
	}
}

Measured memory_bytes: 512
;; C - Poll

(defun main ()
  (let* ((n  (read))
         (ss (loop repeat n collect (read-line))))
    (format t "~{~a~%~}" (solve ss))))

(defun solve (ss)
  (let ((count (group-count (sort ss #'string<) :test #'string=)))
    (setf count (stable-sort count #'> :key #'cdr))
    (loop with m = (cdar count)
          for (s . c) in count
          while (= c m)
          collect s)))

(defun group-count (lst &key (test #'eql))
  "(group-count '(a a b b b c d d)) => ((a . 2) (b . 3) (c . 1) (d . 2))"
  (labels ((grouping (acc elem)
             (if (and acc (funcall test (caar acc) elem))
                 (cons (cons (caar acc) (1+ (cdar acc))) (cdr acc))
                 (cons (cons elem 1) acc))))
    (nreverse
      (reduce #'grouping lst :initial-value nil))))

(main)


Measured memory_bytes: 69736
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

const ll MOD = 1000000007;

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

  int N;
  cin >> N;
  vector<vector<int> > F(N, vector<int>());
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      int f;
      cin >> f;
      F[i].push_back(f);
    }
  }
  vector<vector<int> > P(N, vector<int>());
  for (int i = 0; i < N; i++){
    for (int j = 0; j < 10+1; j++) {
      int p;
      cin >> p;
      P[i].push_back(p);
    }
  }

  int maxProfit = -1000000007;
  for (int i = 1; i < (1 << 10); i++) {
    vector<int> match(N, 0);
    for (int j = 0; j < N; j++) {
      int x = i;
      for (int k = 0; k < 10; k++) {
        if (x & 1 && F[j][k]) match[j]++;
        x >>= 1;
      }
    }
    int profit = 0;
    for (int j = 0; j < N; j++) {
      profit += P[j][match[j]];
    }
    if (profit > maxProfit) maxProfit = profit;
  }

  cout << maxProfit << endl;
  return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

long long int a, b, c, d;

long long int Search(map<long long int, long long int >&mp, long long int num) {
	//cout << num << endl;
	if (mp.find(num) != mp.end()) {
		return mp[num];
	}
	long long int ret = MOD * MOD;
	for (int i = -4; i <= 4; i++) {
		long long int nx = num + i;
		if (nx < 0)continue;
		if (nx == 0) {
			ret = min(ret, abs(i)*d);
		}
		if (nx&&nx % 2 == 0 && nx / 2 < num) {
			ret = min(ret, Search(mp, nx / 2) + a + abs(i)*d);
		}
		if (nx&&nx % 3 == 0 && nx / 3 < num) {
			ret = min(ret, Search(mp, nx / 3) + b + abs(i)*d);
		}
		if (nx&&nx % 5 == 0 && nx / 5 < num) {
			ret = min(ret, Search(mp, nx / 5) + c + abs(i)*d);
		}
	}
	if (num < ret / d)mp[num] = num * d;
	else mp[num] = ret;
	return mp[num];
}

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

	int loop;
	cin >> loop;
	while (loop--) {
		cin >> N;
		cin >> a >> b >> c >> d;
		map<long long int, long long int>mp;
		mp[0] = 0;
		cout << Search(mp, N) << endl;
		//for (auto i : mp)cout << i.first << " " << i.second << endl;
	}
}

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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

set<string> st;
string str;
int n;

int main(){
  cin >> n;
  while(n--){
    cin >> str;
    st.insert(str);
  }
  cout << st.size();
  return 0;
}


Measured memory_bytes: 19200
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        long count = (long) (k * Math.pow(k - 1, n - 1));
        System.out.println(count);
    }

}


Measured memory_bytes: 23764
n = int(input())

# a, b =map(int,input().split())
a = list()
d = {}
for i in range(n):
    val = input()
    d[val] = d.get(val, 0)+1
k = int(input())
b = list()
for i in range(k):
    val = input()
    d[val] = d.get(val, 0)-1

val_sorted = sorted(d.items(), key=lambda x: x[1], reverse=True)
for i in val_sorted:
    if int(i[1]) < 0:
        print(0)
        break
    print(i[1])
    break


Measured memory_bytes: 3064
#include <stdio.h>
int abs(int a){
  if(a<0){
    return (-1)*a;
  }else{
    return a;
  }
}
int main(){
  int n;
  scanf("%d", &n);
  int i;
  int pre_t = 0;
  int pre_x = 0;
  int pre_y = 0;
  int ans = 1;
  for(i=0;i<n;i++){
    int t,x,y;
    scanf("%d%d%d",&t,&x,&y);
    if(t - pre_t < abs(x - pre_x) + abs(y - pre_y) || abs(t - x - y) % 2 == 1){
      ans = 0;
    }
    pre_t = t;
    pre_x = x;
    pre_y = y;
  }
  if (ans == 1){
    puts("Yes");
  }else{
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    while(1){
        cin>>n;
        if(n==0) break;
        int sum=0;
        if(n!=1) sum+=1;
        for(int i=2;i*i<n;i++){
            if(n%i==0){
                sum+=i+n/i;
            }
        }
        if(sum==n){
            cout<<"perfect number"<<endl;
        }
        else if(sum<n){
            cout<<"deficient number"<<endl;
        }
        else cout<<"abundant number"<<endl;
    }
    return 0;
}



Measured memory_bytes: 3080
a="-.,!? -abc-def-ghi-jkl-mno-pqrs-tuv-wxyz".split "-"
gets.to_i.times{puts gets.gsub("0"," ").split.map{|i|b=i[0].to_i;a[b][(i.size-1)%a[b].size]}.join}

Measured memory_bytes: 6120
#include <iostream>
using namespace std;
int n,a[100],ans=0;

void solve() {
  int fin = n-1;
  while(fin != 0) {
    for(int i=0;i<fin;i++) {
      if(a[i] > a[i+1]) {
        swap(a[i],a[i+1]);
        ans++;
      }
    }
    fin--;
  }
  return;
}

int main() {
  while(cin >> n) {
    if(n==0) break;
    for(int i=0;i<n;i++) {
      cin >> a[i];
    }
    solve();
    cout << ans << endl;
    ans = 0;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long D;
vector<long> c(26);
vector<vector<long>> s(365,vector<long>(26));
vector<long> t(365);

void INPUT(){
  cin >> D;
  rep(i,26) cin >> c.at(i);
  rep(i,D){
    rep(j,26) cin >> s.at(i).at(j);
  }
}

long greedy(){
  vector<long> lastday(26,-1);

  long ans = 0;
  rep(i,D){
    vector<long> tmpscore(26,ans);
    rep(j,26){
      tmpscore.at(j) += s.at(i).at(j);
      rep(k,26){
        if(j != k){
          tmpscore.at(j) -= (i - lastday.at(k))*c.at(k);
        }
      }
    }
    long day = 0;
    long maxi = tmpscore.at(0);
    rep(j,26){
      if(tmpscore.at(j) > maxi){
        maxi = tmpscore.at(j);
        day = j;
      }
    }
    ans = maxi;
    //cout << day+1 << endl;
    t.at(i) = day;
    lastday.at(day) = i;
  }
  return ans;
}

long calc(){
  vector<long> lastday(26,-1);
  long ans = 0;
  rep(i,D){
    long tt = t.at(i);
    ans += s.at(i).at(tt);
    lastday.at(tt) = i;
    rep(j,26){
      ans -= (i - lastday.at(j)) * c.at(j);
    }
    //cout << ans << endl;
  }
  return ans;
}

void OUTPUT(){
  rep(i,D){
    cout << t.at(i)+1 << endl;
  }
}

int main(){
  long start = clock();
  INPUT();
  long now = greedy();
  srand(time(NULL));
  while((clock() - start)/(CLOCKS_PER_SEC/1000) < 1900){
    long d = rand() % D;
    long q = rand() % 26;
    long prev_q = t.at(d);
    t.at(d) = q;
    long res = calc();
    if(res > now){
      now = res;
    }else{
      t.at(d) = prev_q;
    }
  }
  OUTPUT();
}

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

int main(void) {
  int n, k;
  string s;
  cin >> n >> k >> s;

  vector<int> comp;

  int cnt = 1;
  s += '5';
  rep (i, n) {
    if (s[i] == s[i + 1]) cnt++;
    else {
      comp.push_back(cnt);
      cnt = 1;
    }
  }

  vector<int> sum(comp.size() + 1, 0);
  rep (i, comp.size()) sum[i + 1] = comp[i];
  rep (i, comp.size()) sum[i + 1] += sum[i];

  int ans = 0;
  int t = s[0] - '0' ;
  for (int left = 0; left < sum.size(); left++) {
    if (left % 2 != t) {
      int right = left + k * 2 + 1;
      if (right >= sum.size()) right = sum.size() - 1;
      ans = max(ans, sum[right] - sum[left]);
    }
    else {
      int right = left + k * 2;
      if (right >= sum.size()) right = sum.size() - 1;
      ans = max(ans, sum[right] - sum[left]);
    }
  }

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

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M, K;
void solve() {
	cin >> N >> M >> K;
	rep(i, 0, N + 1) {
		rep(j, 0, M + 1) {
			if(i * (M - j) + (N - i) * j == K) {
				cout << "Yes\n";
				return;
			}
		}
	}
	cout << "No\n";		
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {
  i64 a, b, c;
  cin >> a >> b >> c;
  cout << ((a+b+c>=22) ? "bust" : "win") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>

using namespace std;

const int NUMBER = 200000;

int partition(int a[],int p,int r)
{
    int x = a[r];
    int i = p-1;
    for (int j = p;j < r;j++){
        if (a[j] <= x){
            swap(a[i+1],a[j]);
            i++;
        }
    }
    swap(a[i+1],a[r]);
    
    return i+1;
}

void quicksort(int a[],int p,int r)
{
    if (p < r){
        int q = partition(a,p,r);
        quicksort(a,p,q-1);
        quicksort(a,q+1,r);
    }
}

int main()
{
    int n;
    int a[NUMBER];
    int c = 1;
    
    cin >> n;
    for (int i = 0;i < n;i++){
        cin >> a[i];
    }
    quicksort(a,0,n-1);
    for (int i = 0;i < n-1;i++){
        if (a[i] == a[i+1]){
            c = 0;
            break;
        }
    }
    if (c == 1){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}



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


int main()
{
    int a,b,c,d,n;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    bool can = true;
    bool can1 = false;
    if(c < d){
        for(int i = a; i < c - 2; i++){
            if(s[i] == '#' && s[i + 1] == '#') can = false;
        }
        for(int i = b; i < d - 2; i++){
            if(s[i] == '#' && s[i + 1] == '#') can = false;
        }
    } else {
        for(int i = b - 2; i < d - 1; i++){
            if(s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') can1 = true;
        }
        if(can1){
            for(int i = a; i < c - 2; i++){
                if(s[i] == '#' && s[i + 1] == '#') can = false;
            }
        }else{
            can = false;
        }
    
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 640
import numpy as np

N, M, Q = map(int, input().split())
field = np.array([list(map(int, input())) for _ in range(N)], dtype = np.int64)
xyxys = [tuple(map(int, input().split())) for _ in range(Q)]

above = np.zeros((N+1, M+1), dtype = np.int64)
np.logical_and(field[1:], field[:-1], out = above[2:, 1:])
np.cumsum(above, axis = 0, out = above)
np.cumsum(above, axis = 1, out = above)

right = np.zeros((N+1, M+1), dtype = np.int64)
np.logical_and(field[:, 1:], field[:, :-1], out = right[1:, 2:])
np.cumsum(right, axis = 0, out = right)
np.cumsum(right, axis = 1, out = right)

field_csum = np.zeros((N+1, M+1), dtype = np.int64)
field_csum[1:, 1:] = np.cumsum(np.cumsum(field, axis = 1), axis = 0)

for x1, y1, x2, y2 in xyxys:
    x1 -= 1
    y1 -= 1
    ans = field_csum[x2][y2] - field_csum[x1][y2] - field_csum[x2][y1] + field_csum[x1][y1]
    
    y1 += 1
    ans -= right[x2][y2] - right[x1][y2] - right[x2][y1] + right[x1][y1]
    y1 -= 1
    
    x1 += 1
    ans -= above[x2][y2] - above[x1][y2] - above[x2][y1] + above[x1][y1]
    x1 -= 1
    print(ans)

Measured memory_bytes: 227572
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
    cout<<fixed;
}
int main(){
    init();

    ll N;cin>>N;
    vector<ll>A(N);
    for(int i=0;i<N;i++)cin>>A[i];

    ll ans=0;
    for(int i=1;i<N;i++){
        if(A[i-1]<A[i])ans++;
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3624
#include<iostream>

using namespace std;

int main(void){
  int m,a[8],b[8],g,n,dp[8][1001];

  while(cin >> m,m){

    for(int i=0;i<8;i++){
      for(int j=0;j<1001;j++){
	dp[i][j]=0;
      }
    }

    for(int i=0;i<m;i++)
      cin >> a[i] >> b[i];
    
    for(int j=0;j<=b[0];j++){
      dp[0][a[0]*j]++;
    }
    
    
    for(int i=0;i<m-1;i++){
      for(int j=0;j<1001;j++){
	for(int k=0;k<=b[i+1];k++){
	  if(j+(a[i+1]*k)<1001)
	    dp[i+1][j+(a[i+1]*k)]+=dp[i][j];
	}
      }
    }
    
    cin >> g;
    while(g--){
      cin >> n;
      cout << dp[m-1][n] << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3100
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
  char str[50];
  int str_len;
  scanf("%s", str);
  str_len = strlen(str);

  int i;
  for(i=0; i<str_len; i++){
    printf("%c", str[str_len-i-1]);
  }
  printf("\n");
  return 0;
}

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

int main()
{
    int N;
    int a;
    int i = 0;
    int ANS[200001] = { 0 };

    scanf("%d",&N);


    for (i = 0; i < N-1; i++) {
        cin >> a;
        ANS[a - 1]++;
    }

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

    return 0;
}

Measured memory_bytes: 4596
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>  // std::accumulate(m.begin(), m.end(), 0LL);
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

class CumulativeSum {
  private:
    std::vector<long long> s;
  public:
    explicit CumulativeSum (int N) {
      s.resize(N+1);
    }
    void build ( const std::vector<long long> &a ) {
      s[0] = 0;
      for(int i=1; i<s.size(); i++) s[i] = s[i-1] + a[i-1];
    }
    long long Get ( int i, int j ) {
      return s[j] - s[i];
    }
};

int main (void) {
  int N; std::cin >> N;
  std::string S; std::cin >> S;
  std::vector<ll> East(N), West(N);
  for(int i=0; i<N; i++) {
    if ( S[i] == 'E' ) East[i] = 1;
    else West[i] = 1;
  }

  CumulativeSum E(N); E.build(East);
  CumulativeSum W(N); W.build(West);

  int ans = 1e9;
  for(int i=0; i<N; i++) {
    int r = W.Get(0,i) + E.Get(i+1,N);
    ans = std::min(ans, r);
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 9988
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> arr;
typedef vector<arr> matrix;
typedef vector<ll> longarr;
typedef vector<longarr> longmat;
typedef map<int, arr> graph;
typedef vector<char> chararr;
typedef vector<chararr> charmat;
typedef pair<int, int> fraction;
ll MOD = 1000000007;
int n;
ll ar[3000];
ll dp[3000][3000][2];

ll fun(int i, int j, int turn) {
	if (i > j) return 0;
	ll &ans = dp[i][j][turn];
	if (ans != -1) return ans;
	if (turn == 0) ans = min(fun(i + 1, j, 1), fun(i, j - 1, 1));
	else ans = max(ar[i] + fun(i + 1, j, 0), ar[j] + fun(i, j - 1, 0));
	return ans;
}
int main() {

	cin >> n;
	ll sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> ar[i];
		sum += ar[i];
	}
	memset(dp, -1, sizeof(dp));
	cout << (2 * (fun(0, n - 1, 1)) - sum);

}

Measured memory_bytes: 144472
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long
//#define int long long

int H, W;
int c[11][11];
int A[202][202];
int ans;
signed main() {
	cin >> H >> W;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> c[i][j];
		}
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
	
	REP(k, 10) {
		REP(i, 10) {
			REP(j, 10) {
				c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
			}
		}
	}

	ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (A[i][j] == -1) continue;
			ans += c[A[i][j]][1];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rngll(chrono::steady_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for(auto &x: a){
		cin >> x;
	}
	int res = numeric_limits<int>::max();
	for(int i = 1; i <= 100; ++ i){
		int cur = 0;
		for(auto x: a){
			cur += (x - i) * (x - i);
		}
		ctmin(res, cur);
	}
	cout << res;
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main(){
    string ans;
    int a,b,c;
    cin >> a >> b >> c;
    //sort(a.begin(),a.end());
    if(a==b && a==c) ans = "Yes";
    else ans = "No";
    cout << ans<< endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void YN(int a){if(a==1)printf("Yes\n");if(a==0)printf("No\n");}
LL lpow(LL a,LL n){LL ans=pow(a,n)*10;if(ans%10<5)return ans/10;return ans/10+1;}
LL dup(LL a,LL d){if(a%d==0)return a/d;else return a/d+1;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}

int main(){
  LL H,N,i,a=0,ans=0;
  scanf("%lld%lld",&H,&N);
  LL A[N];
  FOR(i,0,N)scanf("%lld",&A[i]);
  FOR(i,0,N)a+=A[i];
  if(H>a)YN(0);
  else YN(1);

  //printf("%lld\n",dup(H,A));
	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(a*c, max(a*d, max(b*c, b*d))) << endl;
  return 0;
}

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

int main(){
    using namespace std;
    unsigned long A, B, C, D, E;
    cin >> A >> B >> C >> D;
    E = C / __gcd(C, D) * D;
    ++B;
    auto f = [](auto a, auto d){return (a + d - 1) / d;};
    cout << B + f(A, C) + f(A, D) + f(B, E) - (A + f(B, C) + f(B, D) + f(A, E)) << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WvNINGS
#include <bits/stdc++.h>
using namespace std;
#define ll long long
string ss, s;
int dp[3003][3003];
pair<int, int> vis[3003][3003];

int main() {
    cin.sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> s >> ss;
    int n = s.size(), m = ss.size();
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (s[i - 1] == ss[j - 1]) {
                dp[i][j] = dp[i - 1][j - 1] + 1;
            }
            else {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    //cout << dp[n][m];
    string ans = "";
    int x = n, y = m;
    while (y != 0 && x != 0) {
        if (dp[x - 1][y] == dp[x][y])
            --x;
        else if (dp[x][y - 1] == dp[x][y])
            --y;
        else {
            ans = ss[y - 1] + ans;
            --x;
            --y;
        }
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 36352
let f i k = 
  let res = ref 0 in
  while i * (1 lsl !res) < k do
    res := !res + 1
  done;
  !res
;;

let g n = 0.5 ** n;;

let rec sum n k p = if n = 0 then p else sum (n - 1) k (p +. (f n k |> float_of_int |> g));;

let sum n k = (sum n k 0.) /. (float_of_int n);;

let () = Scanf.scanf "%d %d" (fun n k -> print_float (sum n k));;

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

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

const int INF=1e9;
const int MOD=1e9+7;

int main(){
    int N; cin >> N;
    char c[N];
    int cnt[N]={};
    for(int i=0;i<N;i++){
        cin >> c[i];
        if(c[i]=='W') cnt[i]++;
    }
    for(int i=1;i<N;i++){
        cnt[i]+=cnt[i-1];
    }
    int tmp=0;
    int ans=0;
    for(int i=N-1;i>=0;i--){
        if(c[i]=='R'){
            if(cnt[i]>tmp){
                ans++;
                tmp++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4600
#include <iostream>
#include <string>

using namespace std;


int main(){

	string c_hanako,c_taro;
	int n,p_hanako = 0,p_taro = 0;
	cin >> n;

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

		//??????????????°????????????
		//??¢??????????????????????????????????????°?????§??????
		//??????????????´?????????????¶??¶?
		//??????????????´???????????¨????????°???????°???????????????????break;
		if (c_hanako == c_taro){
			p_taro++;
			p_hanako++;
		
		}
		else if (c_hanako < c_taro){
			p_taro += 3;
		}
		else{ p_hanako += 3; }

	
	
	}	cout << p_hanako << " " << p_taro << endl;





	return 0;
}

Measured memory_bytes: 1208
#include<stdio.h>
#define N 200000

int main(){
  int max,min,j,n,R[N];
  
  scanf("%d",&n);
  for(j=0;j<n;j++){
    scanf("%d",&R[j]);
  }
  min=R[0];
  max=R[1]-R[0];
  
  for(j=1;j<n;j++){
    if(max<R[j]-min)
      max=R[j]-min;
    if(min>R[j])
      min=R[j];
  }
  printf("%d\n",max);
  return 0;
  
}

Measured memory_bytes: 1376
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<int>v,a,b;
    for(int i=0;i<n;i++){
        v.push_back(i+1);
    }
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        a.push_back(x);
    }
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        b.push_back(x);
    }
    int l,r;
    int cnt=0;
    do{
        cnt++;
        if(v==a)l=cnt;
        if(v==b)r=cnt;
    }while(next_permutation(v.begin(),v.end()));
    cout<<abs(r-l)<<endl;
}


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

using namespace std;


#define PI 3.14159265
#define int long long



main(){

	string s; cin >> s;

	if(s == "SUN"){
		cout << 7 << endl; return 0;
	}
	if(s == "MON"){
		cout << 6 << endl; return 0;
	}
	if(s == "TUE"){
		cout << 5 << endl; return 0;
	}
	if(s == "WED"){
		cout << 4 << endl; return 0;
	}
	if(s == "THU"){
		cout << 3 << endl; return 0;
	}
	if(s == "FRI"){
		cout << 2 << endl; return 0;
	}
	if(s == "SAT"){
		cout << 1 << endl; return 0;
	}
	
	return 0;
}

Measured memory_bytes: 256
n = list(input())
n = [int(i) for i in (n)]
m = len(n)
if m == 1:
    print(n[0])
else:
    flg = False
    for i in range(1,m):
        if n[i] != 9:
            flg = True
            break
    if flg:
        print(n[0] - 1 + 9 * (m - 1))
    else:
        print(sum(n))

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL //デバッグ出力系
#define dout(s) cout<<s<<"\n";
#define debug() if(true)
#else
#define dout(s)
#define debug() if(false)
#endif//
#define next asdnext
#define prev asdprev
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define vout(v) for(auto &i:v){cout<<i<<" ";}cout<<"\n"; //配列出力
#define vin(v) for(auto &i:v)cin>>i; //配列入力
#define vec(v,n) vector<int> v(n);
typedef long long ll;
typedef unsigned long long ull;

struct RES {
public:
	int P;
	string S;
	int index;
};

bool hikaku(const RES &A, const RES &B) {
	if (A.S == B.S) return (A.P > B.P);
	else return (A.S < B.S);
}

void Main() {
	int N;
	cin >> N;
	vector<RES> res(N);
	int cnt = 0;
	for (auto&i:res) {
		cin >> i.S >> i.P;
		i.index = ++cnt;
	}

	sort(all(res), hikaku);

	for (auto&i : res) {
		cout << i.index <<"\n";
	}

}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define initdp(a, b)  for (int i = 0; i <= a; i++)   for (int j = 0; j <= b; j++) dp[i][j] = -1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define ll long long
#define pll pair<ll, ll>
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repd(i, n) for (int i = n - 1; i >= 0; i--)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 1000005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define umapi unordered_map<ll, ll>
#define umapc unordered_map<char, int>
#define endl "\n"
#define pui pair<int, pair<int,int> >
using namespace std;

/*
            ॐ
    || Jai Shree Ram ||  
 
 */






void solve(){
    
    int n;
    cin >> n;

    vec arr(n);
    rep(i,n) {
        cin>>arr[i];
    }

   // sort(all(arr));
    int ans = 0;
    set<vector<int> > st;

    for(int i=0; i<n-2; i++) {
        for(int j=i+1; j<n-1; j++) {
            for(int k=j+1; k<n; k++) {
                vec v;
                v.pb(arr[i]);
                v.push_back(arr[j]);
                v.push_back(arr[k]);
                sort(all(v));
                if( (v[2] < (v[0] + v[1]) ) && v[0] != v[1] && v[1] != v[2]) {
                    // ans++;
                        ans++;
                         // cout<<arr[i]<<" "<<arr[j]<<" "<<arr[k]<<endl;   
                }
            }
            
        }
    }

    cout<<ans<<endl;








}

 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(10);
    int t = 1;
    // //cin >> t;
    while (t--)
    {
        solve();
    }
}



Measured memory_bytes: 3648
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());

		ArrayList<Integer> wArrayList = new ArrayList<>();

		for (int i=0; i<n; i++){
			wArrayList.add(Integer.parseInt(sc.next()));
		}

		int ans = Integer.MAX_VALUE;

		for (int i=0; i<n; i++){
			List<Integer> lList = wArrayList.subList(0, i);
			List<Integer> rList = wArrayList.subList(i, wArrayList.size());

			int lsum = lList
		  		      .stream()
		  		      .mapToInt(v -> v)
		  		      .sum();

			int rsum = rList
		  		      .stream()
		  		      .mapToInt(v -> v)
		  		      .sum();

			if (ans > Math.abs(lsum - rsum)){
				ans = Math.abs(lsum - rsum);
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 26964
#include <stdio.h>

int main(void) {
  int i, n, a, b, cnta = 0, cntb = 0;
  scanf("%d%d%d", &n, &a, &b);
  char s[n + 10];
  scanf("%s", s);
  for(i = 0; i < n; ++i) {
    if(s[i] == 'a' && cnta < a + b) printf("Yes\n"), cnta++;
    else if(s[i] == 'b' && cnta < a + b && cntb < b) printf("Yes\n"), cnta++, cntb++;
    else printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main{
    public static void main(String [] args){
        int n,m=0;
        Scanner sc = new Scanner(System.in);
        String st;
        String kiridasi;
        String kiridasi1;
        String kiridasi2;
        st=sc.nextLine();   //文字列格納
        String[] list=st.split(""); //文字列から配列へ
        ArrayList<String> str2=new ArrayList<String>();//list str2を作った
        for(int i=list.length-1;i>=0;i--){
            str2.add(list[i]);              //str2の中へ逆文字列を配列として格納
        }
        kiridasi =String.join("",str2);//連結メソッドjoin 使用 文字列へと戻す
        n=(list.length-1)/2;
        m=(list.length+3)/2;
        String a = st.substring(0,n);
        String b = st.substring(m-1,list.length);
        ArrayList<String> str3=new ArrayList<String>();
        ArrayList<String> str4=new ArrayList<String>();
        for(int k=0;k<n;k++){
                str3.add(list[k]);
        }
        kiridasi1=String.join("",str3);
        for(int l=0;l<n;l++){
                str4.add(list[l]);
        }
        kiridasi2=String.join("",str4);
        if(st.equals(kiridasi) && kiridasi1.equals(a) && kiridasi2.equals(b)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }

}

Measured memory_bytes: 23124
n = int(input())
p = [0]*(n+1)
for i in range(2,n+1):
    for j in range(2,n+1):
        while i%j == 0:
            p[j] += 1
            i //= j
a,b,c,e,d = 0,0,0,0,0
for prime in p:
    if prime >= 74:
        a += 1
    if prime >= 24:
        b += 1
    if prime >= 14:
        c += 1
    if prime >= 4:
        d += 1
    if prime >= 2:
        e += 1
print(a+b*(e-1)+c*(d-1)+(e-2)*d*(d-1)//2)

Measured memory_bytes: 3064
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();sc.nextLine();
		String str[]=new String[n];
		for(int i=0;i<n;i++) {
			str[i]=sc.nextLine();
		}
		int m=sc.nextInt();sc.nextLine();
		String str2[]=new String[m];
		for(int i=0;i<m;i++) {
			str2[i]=sc.nextLine();
		}
		int count[] = new int[n];
		for(int i=0;i<n;i++) {
			int tmp=0;
			for(int k=0;k<n;k++) {
				if(str[i].equals(str[k])) {
					tmp++;
				}
			}
			for(int k=0;k<m;k++) {
				if(str[i].equals(str2[k])) {
					tmp--;
				}
			}
			count[i]=tmp;
		}
		int goal=0;
		for(int i=0;i<n;i++) {
			goal=Math.max(goal, count[i]);
		}
		System.out.println(goal);
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
int gcd(int x,int y){
    if(x<y){
        swap(x,y);
    }
    if(x%y==0){
        return y;
    }else{
        return gcd(y,x%y);
    }
}
 
int main (){
    int k;
    cin>>k;
 
    int gcd_sum=0;
 
    for(int a=1; a<k+1; a++){
        for(int b=1; b<k+1; b++){
            for(int c=1; c<k+1; c++){
                gcd_sum+=gcd(gcd(a,b),c);
            }
        }
    }
 
    cout<<gcd_sum<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>  /** 2fat2code a.k.a grandmixer420  **/
#define ll long long
#define all(a) (a).begin(), (a).end()
#define sz() size()
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define int long long
using namespace std;

const int mod=1e9+7;

map<char,int>q;
int n,ans=1;
string s;

signed main(){
    cin >> n >> s;
    for(int i=0;i<n;i++){
        q[s[i]]++;
    }
    auto it=q.begin();
    while(it!=q.end()){
        ans*=(it->second+1);
        it++;
        ans=ans%mod;
    }
    ans--;
    if(ans<0) ans+=mod;
    cout<<ans;
}


Measured memory_bytes: 512
n,k = map(int,input().split())
mod_count = {}
a = n//k
b = n%k
for i in range(k):
    count = a
    if (1<=i<=b):
        count +=1
    mod_count[i]=count
ans = 0
for ai in mod_count.keys():
    bi = (k - ai)%k
    ci = (k - ai)%k
    if (bi+ci)%k ==0:
        ans += mod_count[ai]*mod_count[bi]*mod_count[ci]
    else:
        continue
print(ans)

Measured memory_bytes: 27112
m, d = map(int, input().split())

ans = 0
for i in range(2, m + 1):
    for j in range(11, d + 1):
        # if len(str(j)) != 2: continue
        d1 = j % 10
        d10 = j // 10
        if d1 >= 2 and d10 >= 2 and d1 * d10 == i:
            ans += 1
print(ans)

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

int main(void){
	string s;
	long long k;
	cin >> s >> k;
	long long cnt = 0LL;
	long long i;
	for(i = 0LL; i < s.size(); ++i){
		if(s[i] != '1' || i == k) break;
	}
	if(i == k){
		cout << 1 << endl;
	}else{
		cout << s[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{

  char name[100];
  int t;

}P;

P Q[LEN];

int head,tail,n;

void enqueue(P x){

  Q[tail] = x;
  tail = (tail + 1) % LEN;/*ring buffer*/

}

P dequeue(){

  P x;

  x = Q[head];

  head = (head + 1) % LEN;

  return x; /*?§????????????£??\???????????¨????????£????????°??????????????????return??????*/

}

int min(int a,int b){ return a < b ? a : b;};

int main(){

  int elaps = 0,c;
  int i ,q;
  P u;

  scanf("%d %d", &n,&q);

  for(i = 1; i <= n; i++){

  scanf("%s", Q[i].name);
  scanf("%d",&Q[i].t);

  }

  head = 1;
  tail = n + 1;


  while(head != tail){

    u = dequeue();
    c = min(q,u.t);
    u.t = u.t - c;
    elaps = elaps + c;
    if(u.t > 0){

      enqueue(u);
    }

    else{
      printf("%s %d\n",u.name,elaps);

    }

  }

  return 0;

}

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

int main() {
    int n, p[200000];
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    int a = p[0], b = 1;
    for (int i = 1; i < n ;++i) {
        if (a >= p[i]) {
            a = p[i];
            ++b;
        }
    }
    cout << b << endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long W0 = W.Min();
		List<long>[] L = new List<long>[4];
		for(int i=0;i<4;i++) L[i] = new List<long>();
		for(int i=0;i<N;i++){
			L[W[i] - W0].Add(V[i]);
		}
		
		for(int i=0;i<4;i++){
			L[i].Sort();
			L[i].Reverse();
		}
		
		
		long[][] Ls = new long[4][];
		for(int i=0;i<4;i++){
			Ls[i] = new long[N+1];
			for(int j=0;j<L[i].Count;j++){
				Ls[i][j+1] = L[i][j] + Ls[i][j];
			}
		}
		
		long max = 0;
		for(int i=0;i<=L[0].Count;i++){
			for(int j=0;j<=L[1].Count;j++){
				if( i+j > N || (W0 * i + (W0+1) * j) > Wl) break;
				for(int k=0;k<=L[2].Count;k++){
					if( i+j+k > N || (W0 * i + (W0+1) * j + (W0+2) * k) > Wl) break;
					int rest = (int) Math.Min(N - i - j - k, ((Wl - (W0 * i + (W0+1) * j + (W0+2) * k)) / (W0+3) ));
					long val = Ls[0][i] + Ls[1][j] + Ls[2][k] + Ls[3][rest];
					max = Math.Max(max,val);
				}
			}
		}
		
		Console.WriteLine(max);
		
		
		
		
		
		
		
	}
	int N;
	long Wl;
	long[] W,V;
	public Sol(){
		var d = ria();
		N = d[0]; Wl = d[1];
		W = new long[N];
		V = new long[N];
		for(int i=0;i<N;i++){
			d = ria();
			W[i] = d[0];
			V[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13396
import sys

I = 0
K = 1
C = 2
P = 3
D = 4

def setd(A, id, d):
    n = A[id]
#    print("depth d:{} n:{} {}".format(d,id,n))
    n[D] = d
    if n[K] > 0:
        for c in n[C]:
            setd(A, c, d + 1)

def setp(A, id, pid):
    n = A[id]
#    print("parent n:{} {}".format(id,n))
    if pid > -1:
        n[P] = pid
    if n[K] > 0:
        for c in n[C]:
            setp(A, c, n[I])

def getroot(A, id):
    if A[id][P] > -1:
        return getroot(A,A[id][P])
    return A[id][I]

def main():

    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    nlist = list(istr.splitlines())
    
    nodes = [[i,0,None,-1,0] for i in range(num)]

    for nstr in nlist:
        i = list(map(int,nstr.split()))
        id = i[0]
        n = nodes[id]
#        print("set n:{} {}".format(id,n))
        if i[K] != 0:
            n[K] = i[K]
            n[C] = i[2:]
            setp(nodes, i[0], -1)

    r = getroot(nodes, 0)
    setd(nodes,r, 0)

    for id in range(num):
        n = nodes[id]
#        print("print n:{} {}".format(id,n))
        type = "leaf"
        children = ""
        if n[K] > 0:
            type = "internal node"
            children = ", ".join(map(str,n[C]))
        if n[P] == -1:
            type = "root"
        print("node {0}: parent = {1}, depth = {2}, {3}, [{4}]".format(n[I], n[P], n[D], type, children))

if __name__ == '__main__':
    main()

Measured memory_bytes: 41936
#include<bits/stdc++.h>
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 ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumlate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  ll n; cin >> n;

  ROF(i,ll(sqrt(n))+1,1){
    ll j = n / i;
    if(i * j == n){
      string s = to_string(i), t = to_string(j);
      cout << max(s.size(),t.size()) << endl;;
      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>;


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

    else{
        cout << "ABC" << endl;
    }


    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    ll N,M;
    cin>>N>>M;
    v K(N);
    vv A(N);
    vector <bool> ok(M,true);
    rep(i,0,N){
        cin>>K[i];
        vector <bool> ok2(M,false);
        rep(j,0,K[i]){
            ll a;
            cin>>a;
            A[i].PB(a);
            ok2[a] = true;
        }
        rep(j,1,M+1){
            if(ok2[j] == false)ok[j] = false;
        }
        ll l = 0;
    }
    ll sum =0;
    rep(i,1,M+1){
        if(ok[i])sum++;
    }
    cout<<sum;
    
    return 0;
}

Measured memory_bytes: 256
n=int(input())
#a, b, c = (int(_) for _ in input().split())
alist = list(map(int, input().split()))
alist=sorted(alist)

judge=0

if n%3!=0:
    if alist[-1]==0:
        judge=1
    else:
        judge=0
else:
    tani=int(n/3)
    #print(alist)
    if alist[0]==alist[tani-1] and alist[tani]==alist[tani*2-1] and alist[tani*2]==alist[n-1]:
        #print(alist[0], alist[tani], alist[tani*2], alist[0]^alist[tani])
        if (alist[0]^alist[tani])==alist[tani*2]:
            judge=1
        else:
            judge=0
    else:
        judge=0

if judge==1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14116