akhauriyash/Code-Regression huggingface dataset:
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int n, k;
bool isout[11];

bool calc(int n) {
	string s = to_string(n);
	REP(i, s.size()) {
		if (isout[s[i] - '0'])return false;
	}
	return true;
}

int main() {
	cin >> n >> k;
	REP(i, k) {
		int d;
		cin >> d;
		isout[d] = true;
	}
	while (!calc(n))n++;
	cout << n << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int l[4], r[4], i;

int main()
{
    double a, b;
    
    for(;~scanf("%lf%lf", &a, &b);)
    {
        l[a < 0.2 ? 3 : a < 0.6 ? 2 : a < 1.1 ? 1 : 0]++;
        r[b < 0.2 ? 3 : b < 0.6 ? 2 : b < 1.1 ? 1 : 0]++;
    }
    
    for(i = 0; i < 4; i++)
    {
        printf("%d %d\n", l[i], r[i]);
    }
    
    return 0;
}

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

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

  int N, M, K;
  cin >> N >> M >> K;

  int sx, sy, ex, ey;
  cin >> sx >> sy >> ex >> ey;
  sx--, sy--, ex--, ey--;

  vector<string> A(N);
  vector<set<int>> row_lotus(N);
  vector<set<int>> col_lotus(M);
  vector<set<int>> row_unvis(N);
  vector<set<int>> col_unvis(M);

  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < M; i++) {
    col_lotus[i].emplace(-1);
    col_lotus[i].emplace(N);
  }
  for (int i = 0; i < N; i++) {
    row_lotus[i].emplace(-1);
    row_lotus[i].emplace(M);
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (A[i][j] == '@') {
        row_lotus[i].emplace(j);
        col_lotus[j].emplace(i);
      } else {
        row_unvis[i].emplace(j);
        col_unvis[j].emplace(i);
      }
    }
  }

  int dist[N][M] = {};
  memset(dist, -1, sizeof(dist));

  queue<pair<int, int>> q;
  q.emplace(sx, sy);
  dist[sx][sy] = 0;
  row_unvis[sx].erase(sy);
  col_unvis[sy].erase(sx);
  while (!q.empty()) {
    int x = q.front().first;
    int y = q.front().second;
    q.pop();
    int limit;

    // down
    limit = min(x + K, *col_lotus[y].upper_bound(x) - 1);
    auto it = col_unvis[y].upper_bound(x);
    while (it != end(col_unvis[y])) {
      if (*it <= limit) {
        auto it2 = it; it2++;
        if (dist[*it][y] == -1) {
          q.emplace(*it, y);
          dist[*it][y] = dist[x][y] + 1;
        }
        col_unvis[y].erase(it);
        it = it2;
      } else {
        break;
      }
    }

    // up
    limit = max(x - K, *prev(col_lotus[y].upper_bound(x)) + 1);
    it = col_unvis[y].upper_bound(x);
    while (it != begin(col_unvis[y])) {
      auto it2 = it; it2--;
      if (*it2 >= limit) {
        if (dist[*it2][y] == -1) {
          q.emplace(*it2, y);
          dist[*it2][y] = dist[x][y] + 1;
        }
        col_unvis[y].erase(it2);
      } else {
        break;
      }
    }

    // left
    limit = max(y - K, *prev(row_lotus[x].upper_bound(y)) + 1);
    it = row_unvis[x].upper_bound(y);
    while (it != begin(row_unvis[x])) {
      auto it2 = it; it2--;
      if (*it2 >= limit) {
        if (dist[x][*it2] == -1) {
          q.emplace(x, *it2);
          dist[x][*it2] = dist[x][y] + 1;
        }
        row_unvis[x].erase(it2);
      } else {
        break;
      }
    }

    // right    
    limit = min(y + K, *row_lotus[x].upper_bound(y) - 1);
    it = row_unvis[x].upper_bound(y);
    while (it != end(row_unvis[x])) {
      if (*it <= limit) {
        auto it2 = it; it2++;
        if (dist[x][*it] == -1) {
          q.emplace(x, *it);
          dist[x][*it] = dist[x][y] + 1;
        }
        row_unvis[x].erase(it);
        it = it2;
      } else {
        break;
      }
    }
  }

  cout << dist[ex][ey] << "\n";
  return 0;
}


Measured memory_bytes: 289416
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <math.h>

#define PREP(i, m, n) for(int i = m; i < n; i++)
#define MREP(i, m, n) for(int i = m - 1; i >= n; i--)

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define X first
#define Y second
#define MP make_pair
#define PB push_back

using namespace std;

map<int, char> number;

bool stringSearch(string input, string *after){
	for(int i = 0; i < 2; i++){
		if(input.find(after[i], 0) != string::npos){
			return true;
		}
	}
	return false;
}

void convert(string *after, string *key, int a, int b){
	for(int i = 0; i < 2; i++){
		for(int j = 0; j < key[i].size(); j++){
			after[i].push_back(number[(a * key[i][j] + b) % 26]);
		}
	}
}

void listConvert(map<char, char> &afterlist, int a, int b){
	for(int i = 0; i < 26; i++){
		afterlist[number[i]] = number[(a * number[i] + b) % 26];
	}
}

bool allSearch(string input, string *key){
	for(int a = 0; a < 26; a++){
		for(int b = 0; b < 26; b++){

			string after[2];
			map<char, char> afterlist;
			convert(after, key, a, b);
			listConvert(afterlist, a, b);

			if(stringSearch(input, after)){
				//文字があったら
				string answer;
				for(int i = 0; i < input.size(); i++){
					if(input[i] != ' '){
						for(map<char, char>::iterator it = afterlist.begin(); it != afterlist.end(); it++){
							if(it->second == input[i]){
								answer.push_back(it->first);
								break;
							}
						}
					}
					else answer.push_back(' ');
				}
				cout << answer << endl;
				return true;
			}

		}
	}
	return false;
}

int main(){
	string key[] = {"this", "that"};
	number[0] = 'a';
	number[1] = 'b';
	number[2] = 'c';
	number[3] = 'd';
	number[4] = 'e';
	number[5] = 'f';
	number[6] = 'g';
	number[7] = 'h';
	number[8] = 'i';
	number[9] = 'j';
	number[10] = 'k';
	number[11] = 'l';
	number[12] = 'm';
	number[13] = 'n';
	number[14] = 'o';
	number[15] = 'p';
	number[16] = 'q';
	number[17] = 'r';
	number[18] = 's';
	number[19] = 't';
	number[20] = 'u';
	number[21] = 'v';
	number[22] = 'w';
	number[23] = 'x';
	number[24] = 'y';
	number[25] = 'z';
	
	int n = 0;
	cin >> n;
	cin.ignore();
	while(n--){
		string input;
		getline(cin, input);
		allSearch(input, key);
	}

	return 0;
}

Measured memory_bytes: 1228
#include<iostream>
#include<cassert>
#include<vector>
#include<map>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
template<class T> void vp(T &a,int size){rep(i,size)cout << a[i]<<" ";cout << endl;}

typedef vector<int> vint;
map<vector<int>,string> dton;//ツ篠淞個ウツづ鳴シツ前ツづ個妥篠可楪付ツつッ
map<string,vector<int> > ntod;//ツ鳴シツ前ツづ篠淞個ウツづ個妥篠可楪付ツつッ
map<string,string> vton;//variabe to name
bool hasError=false;
int gn;

vint formula(int &,string &);

vint factor(int &p,string &in){
  if (in[p] == '('){
    p++;
    vint res = formula(p,in);
    p++;
    return res;
  }else{
    string tmp="";
    while(p < in.size() && isalpha(in[p]))tmp += in[p++];
    vint res=vector<int>(gn);
    if (vton.count(tmp) == 0)hasError = true,assert(false);
    else {
      string tmp2 = vton[tmp];
      assert(ntod.count(tmp2) != 0);
      res = ntod[tmp2];
    }
    return res;
  }
  assert(false);
}

vint term(int &p,string &in){
  vint res = factor(p,in);
  while(p < in.size() && in[p] == '*' || in[p] == '/'){
    bool mul=false;
    if (in[p] == '*')mul = true;
    p++;
    vint tmp = factor(p,in);
    if (!mul)rep(i,tmp.size())tmp[i] *= -1;
    rep(i,tmp.size())res[i] += tmp[i];
  }
  return res;
}

vector<int> formula(int &p,string &in){
  vint res = term(p,in);
  while(p < (int)in.size() && in[p] == '+' || in[p] == '-'){
    p++;
    vint tmp = term(p,in);
    if (res != tmp)hasError = true;
  }
  return res;
}

main(){
  int n,m,p;
  while(cin>>n>>m>>p && n){
    hasError = false;
    dton.clear();
    ntod.clear();
    vton.clear();
    gn = n;

    rep(i,m){
      string name;
      vector<int> vec(n);
      cin>>name;
      rep(j,n){
	cin>>vec[j];
      }
      dton[vec] = name;
      ntod[name] = vec;
    }

    string in;
    cin>>in;
    rep(i,p){
      string v,name;
      cin>>v>>name;
      vton[v] = name;
    }
    
    //vector<int> formula(int &p,string &in){
    int p = 0;
    vint result = formula(p,in);
    if (hasError)cout  <<"error"<<endl;
    else if (dton.count(result) == 0)cout <<"undefined"<<endl;
    else cout << dton[result] << endl;
  }
  return false;
}

Measured memory_bytes: 960
#include <iostream>
#include <algorithm>
using namespace std;

int main(void)
{
  int a,b,c; cin>>a>>b>>c;
  int d; cin>>d;
  if((abs(a-b)<=d&&abs(b-c)<=d)||abs(a-c)<=d)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
        string n;
        in >> n;
        if (1 == n.size()) {
            out << n << endl;
        }
        else {
            bool check = true;
            for (int i = 1; i < n.size(); i++) {
                if (n[i] != '9') {
                    check = false;
                    break;
                }
            }
            if (!check) {
                for (int i = 1; i < n.size(); i++) {
                    n[i] = '0';
                }
            }
            ll num = atoll(n.c_str());
            if (!check) {
                num--;
            }
            ll ans = 0;
            while (0 < num) {
                ans += num % 10;
                num /= 10;
            }
            out << ans << endl;
        }
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;

int main()
{

  int N, M;
  vector<int> A;
  cin >> N;
  cin >> M;
  int selected_items = 0;

  int vote = 0;
  int sum = 0;
  for (int i = 0; i < N; i++)
  {
    cin >> vote;
    sum += vote;
    A.push_back(vote);
  }

  double condition = (1.0 / (4 * M)) * sum;

  for (int i = 0; i < N; i++)
  {
    if (A[i] >= condition)
    {
      selected_items++;
    }
  }

  if (selected_items >= M)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  return 0;
}

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

int main() {
	int n, ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (0 <= i && i <= 9)ans++;
		else if (100 <= i && i <= 999)ans++;
		else if (10000 <= i && i <= 99999)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3552
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

vector<int> g[512512][2];
deque<int> dq;
map<P, int> mp;
int dist[512512];
bool done[512512];

int main(void){
	int n,m,u,v,c,i,p,q,vtx;
	fill(dist,dist+512512,INF);
	cin >> n >> m; vtx = n;
	for(i=0; i<m; ++i){
		cin >> u >> v >> c;
		--u; --v;
		if(mp.find(P(u,c)) == mp.end()){
			mp[P(u,c)] = vtx; ++vtx;
		}
		p = mp[P(u,c)];
		if(mp.find(P(v,c)) == mp.end()){
			mp[P(v,c)] = vtx; ++vtx;
		}
		q = mp[P(v,c)];
		g[u][1].push_back(p);
		g[v][1].push_back(q);
		g[p][0].push_back(u);
		g[q][0].push_back(v);
		g[p][0].push_back(q);
		g[q][0].push_back(p);
	}
	dist[0] = 0;
	dq.push_back(0);
	while(!dq.empty()){
		u = dq.front();
		dq.pop_front();
		for(c=0; c<2; ++c){
			for(i=(g[u][c].l_ength()-1); i>=0; --i){
				v = g[u][c][i];
				if(dist[v] > dist[u]+c){
					dist[v] = dist[u]+c;
					if(c){
						dq.push_back(v);
					}else{
						dq.push_front(v);
					}
				}
			}
		}
	}
	cout << ((dist[n-1]<INF)?dist[n-1]:(-1)) << endl;
	return 0;
}


Measured memory_bytes: 68040
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int[] r = new int[N];
    	int index = 1;
    	int crush = 0;
    	boolean can = false;
    	for (int i = 0; i < N; i++) {
    		r[i] = sc.nextInt();
    		if (r[i] == index) {
    			can = true;
    			index++;
    		} else {
    			crush++;
    		}
    	}
    	System.out.println(can ? crush : -1);
    }
}

Measured memory_bytes: 85172
// 

// g++ -std=c++11 abc145_c.cc && ./a.out 
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    string s;
    cin >> s;
    if (s == "AAA" || s == "BBB") {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 760
using System;
using System.Collections.Generic;
using System.Linq;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine().Trim();

            var l = new List<char>();
            foreach(var c in s.ToCharArray()){
                var i = alphabet.IndexOf(c);
                l.Add(alphabet[i + n]);
            }

            Console.WriteLine(string.Join("",l));
        }
    }
}


Measured memory_bytes: 13268
// Example program
#include <iomanip>
#include <iostream>
using namespace std;

int main()
{
  int a, b;
  char op;
  while(1){
  cin >> a >> op >> b;
  if (op == '?') break;
  if (op == '+'){
      cout << a+b << endl;
  } else if (op == '-'){
      cout << a-b << endl;
  } else if (op == '*'){
      cout << a*b << endl;
  } else if (op == '/'){
      cout << a/b << endl;
  }
  }
  return 0;
}



Measured memory_bytes: 3080
n = int(input())
a = sorted(list(map(int, input().split())))
data = [[-1, 0]]
for x in a:
    if data[-1][0] == x:
        data[-1][1] += 1
    else:
        data.append([x, 1])
data = data[1:]

if len(data) == 1:
    print("Yes" if data[0][0] * 2 <= n or data[0][0] + 1 == n else "No")
elif len(data) == 2:
    if data[0][0] + 1 == data[1][0] and data[0][0] >= data[0][1] and data[1][1] >= 2 * (data[1][0] - data[0][1]):
        print("Yes")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 18028
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <math.h>
#include <stack>
using namespace std;
typedef long long ll;

ll dp[250][2];

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int l,k; cin >> l >> k;
	ll ans=0;
	dp[0][0]=1;
	for(int i=0;i<=l;i++){
		dp[i+1][0]+=dp[i][1];
		dp[i+1][1]+=dp[i][0];
		dp[i+k][1]+=dp[i][0];
		ans+=dp[i][1];
	}
	cout << ans << endl;
}


Measured memory_bytes: 3232
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
const int maxn = 1e5 + 10;
int n, a, b;
ll num[maxn];
ll ans;

int main(){
	cin >> n >> a >> b;
	for (int i = 0; i < n; ++i)
		cin >> num[i];
	sort(num, num + n);
	for (int i = 1; i < n;++i)
	if ((num[i] - num[i - 1])*a < b)ans += (num[i] - num[i - 1])*a;
	else ans += b;
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int price[100000];
int weight[100000];
ll dp[101][100001];
ll solve(int index,int required) //recursive approach to the given problem
{
    if(index<0 || required <=0)
        return 0;
    if(dp[index][required] != -1)
        return dp[index][required];
    if(weight[index] <= required) //if the weight of the given index in less than the required weight
        dp[index][required] = max(solve(index-1,required),(price[index]+solve(index-1,required - weight[index]))); //we have two options from here : either we count the price of the given index or we dont.
    else
        dp[index][required] = solve(index-1,required);// here we have one option only i.e. don't count the price because it's weight is more than the required weight
    return dp[index][required];
}

int main()
{
    int n,w;
    cin >>n>>w;
    for(int i=0;i<101;i++)
    {
        for(int j=0;j<100001;j++)
        {
            dp[i][j] = -1;
        }
    }
    for(int i=0;i<n;i++)
    {
        cin >>weight[i]>>price[i];
    }
    ll ans = solve(n-1,w);
    cout <<ans;

}

Measured memory_bytes: 79104
import java.util.*;
import java.io.*;
public class Main {
	private static IO io = new IO();
	public static void main(String[] args) {
		
		Map<Integer, Integer> ans = new HashMap<>();
		Deque<int[][]> que = new ArrayDeque<>();
		int init[] = {0,1,2,3,4,5,6,7};
		//0??????????????¶??????1??????????????????2??´?????????????????????3?§?????????°
		que.offer(new int[][] {init,{0},{-1},{0}});
		int dx[] = {-4, 1, 4, -1};
		
		while (!que.isEmpty()) {
			int[][] p = que.pollFirst();
			if (ans.containsKey(conv(p[0]))) continue;
			else ans.put(conv(p[0]), p[3][0]);
			//System.out.println(conv(p[0]));
			for (int i=0; i<4; i++) {
				int go = p[1][0] + dx[i];
				if (go==p[2][0] || go<0 || 7<go || (p[1][0]==3 && go==4) || (p[1][0]==4 && go==3)) continue;
				int next[];
				next = p[0].clone();
				swap(next, p[1][0], go);
				que.offer(new int[][] {next, {go}, {p[1][0]}, {p[3][0]+1}});
			}
		}
				
		while (io.hasNext()) {
			int q = 0;
			for (int i=0; i<=7; i++) {
				q += (io.nextInt()+1) * Math.pow(10, 7-i);
			}
			System.out.println(ans.get(q));
		}
	}
	
	private static void swap(int ar[], int a, int b) {
		int tmp = ar[a];
		ar[a] = ar[b];
		ar[b] = tmp;
	}
	
	private static int conv(int ar[]) {
		int ans = 0;
		for (int i=0; i<=7; i++) {
			ans += (ar[7-i]+1)*Math.pow(10, i);
		}
		return ans;
	}

	static class IO extends PrintWriter {
		private final InputStream in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		IO() { this(System.in);}
		IO(InputStream source) { super(System.out); this.in = source;}
		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			}else{
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}
		private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
		private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
		private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
		boolean hasNext() { skipUnprintable(); return hasNextByte();}
		long nextLong() {
			if (!hasNext()) {
				throw new NoSuchElementException();
			}
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while(true){
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				}else if(b == -1 || !isPrintableChar(b)){
					return minus ? -n : n;
				}else{
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
		int nextInt() {
			long nl = nextLong();
			if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
				throw new NumberFormatException();
			}
			return (int) nl;
		}
		public void close() {
			super.close();
			try {
				in.close();
			} catch (IOException ignored) {}
		}
	}
}

Measured memory_bytes: 35484
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define fix(n) cout<<fixed<<setprecision(n);
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<int>> vvi;

int main(){
  int n,ans=0; string s;
  cin>>n>>s;
  vvi v(10);
  rep(i,0,n){
    int w=s[i]-48;
    pb(v[w],i);
  }
  
  rep(i,0,1000){
    int a=i/100,b=i%100/10,c=i%10;
    int x,y,z;
    if(v[a].size()==0) continue;
    x=v[a][0];
    
    y=lower_bound(all(v[b]),x+1)-v[b].begin();
    if(y==v[b].size()) continue;
    
    z=lower_bound(all(v[c]),v[b][y]+1)-v[c].begin();
    if(z==v[c].size()) continue;
    ans++;
  }
  co(ans); 
  
  return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int dp[102][2][5];

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    string N;
    cin >> N;
    int K;
    cin >> K;

    int lenN = (int)N.size();

    dp[0][0][0] = 1;
    for (int i = 0; i < lenN; i++) {
        int Ni = N[i] - '0';
        for (int smaller = 0; smaller < 2; smaller++) {
            for (int j = 0; j <= K; j++) {
                for (int d = 0; d <= (smaller ? 9 : Ni); d++) {
                    dp[i + 1][smaller || (d < Ni)][j + (d != 0)] += dp[i][smaller][j];
                }
            }
        }
    }

    cout << dp[lenN][0][K] + dp[lenN][1][K] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    vector<unordered_set<int>> w(n + 1);
    vector<vector<int>> dist(n + 1, vector<int>(n + 1, 0));
    for (int i = 1; i <= n - 1; i++) {
        w[i].insert(i + 1);
        w[i + 1].insert(i);
    }
    w[x].insert(y);
    w[y].insert(x);

    for (int k = 1; k <= n; k++) {
        queue<int> q;
        q.push(k);
        while (!q.empty()) {
            int top = q.front();
            q.pop();
            for (int i : w[top]) {
                if (dist[k][i]) continue;
                dist[k][i] = dist[k][top] + 1;
                q.push(i);
            }
        }
    }

    vector<int> ans(n);
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++)
            ans[dist[i][j]] += 1;

    for (int k = 1; k < n; k++) cout << ans[k] << endl;
}


Measured memory_bytes: 16256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<list>
#include<climits>
using namespace std;

int dp[100001];


int lg(vector<list<int>>& v,int n, int m,int src){

    if(dp[src]!=-1)
        return dp[src];
    
    int leaf=1;
    int bestChild = 0;
    for(auto child : v[src]){
        leaf = 0;
        bestChild = max(bestChild,1+lg(v,n,m,child));
    }
    
    return dp[src] = leaf ? 0 : bestChild;
}

int main(){

    int n,m;
    cin>>n>>m;
    vector<list<int>> v(n+1);

    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
    }
    memset(dp,-1,sizeof(dp));

    // for(int i=1;i<=n;i++){
    //     cout<<i<<" : ";
    //     for(auto element:v[i]){
    //         cout<<element<<",";
    //     }
    //     cout<<endl;
    // }
    int ans = 0;
    for(int i=1;i<=n;i++){
        ans=max(ans,lg(v,n,m,i));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 12404
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    int n;
    cin >> n;
    int a[10010], count = 0;
    count = n;

    for (int i = 0; i < n; i++){ 
        cin >> a[i]; 
        for (int j = 1; j <= sqrt(a[i]); j++){
            if (j != 1 && a[i]%j == 0){
                count--;
                break;
            }
        }
    }

    cout << count << endl;
}


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

using namespace std;

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int n;
vector<int> a;
vector<ll> dp;

ll solve(int i) {
	ll ans = dp[n];
	int idx1 = lower_bound(ALL(dp), dp[i + 1] / 2) - dp.begin() - 1;
	int idx2 = lower_bound(ALL(dp), dp[i + 1] + (dp[n] - dp[i + 1]) / 2) - dp.begin() - 1;

	const int r = 10;
	REPU(i1, idx1 - r, idx1 + r) REPU(i2, idx2 - r, idx2 + r) {
		if (i1 < 0 || i1 >= n || i2 < 0 || i2 >= n) continue;
		if (!(i1 < i && i < i2 && i2 < n - 1)) continue;
		ll x1 = dp[i1 + 1];
		ll x2 = dp[i + 1] - x1;
		ll x3 = dp[i2 + 1] - x1 - x2;
		ll x4 = dp[n] - x1 - x2 - x3;
		ll tmp = max(max(x1, x2), max(x3, x4)) - min(min(x1, x2), min(x3, x4));
		//DEBUG(i1, i, i2, tmp);
		amin(ans, tmp);
	}
	return ans;
}

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	cin >> n;
	a.resize(n);
	dp.resize(n + 1);
	dp[0] = 0;
	REPU(i, 0, n) {
		cin >> a[i];
		dp[i + 1] = dp[i] + a[i];
	}
	ll ans = dp[n];
	REPU(i, 1, n - 2) {
		amin(ans, solve(i));
	}
	cout << ans << endl;
	

	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s, t; cin >> s >> t;
  int a = s.size(), b = t.size();
  vector<vector<int>> dp(a + 1, vector<int> (b + 1, 0));
  for(int i = 0; i < a; i++) {
    for(int j = 0; j < b; j++) {
      dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
      if(s.at(i) == t.at(j)) dp[i + 1][j + 1] = max(dp[i][j] + 1, dp[i + 1][j + 1]);
    }
  }
  int x = a, y = b;
  string ans = "";
  while(x > 0 && y > 0) {
    if(dp[x][y] == dp[x][y - 1]) {
      y--;
    } else if(dp[x][y] == dp[x - 1][y]) {
      x--;
    } else {
      ans += s.at(x - 1);
      x--; y--;
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define R cin>>
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

int c1[1600000],c2[1600000];
int main() {
  int n,m;
  while(cin >> n >> m && n) {
    int a[n+10],b[m+10];
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    memset(c1,0,sizeof(c1));
    memset(c2,0,sizeof(c2));
    rep(i,n) {
      int x;
      R x;
      a[i+1]=a[i]+x;
      rep(j,i+1) c1[a[i+1]-a[j]]++;
    }
    rep(i,m) {
      int x;
      R x;
      b[i+1]=b[i]+x;
      rep(j,i+1) c2[b[i+1]-b[j]]++;
    }
    ll ans=0;
    rep(i,1500001) ans+=(ll)c1[i]*(ll)c2[i];
    pr(ans);
  }
  return 0;
}


Measured memory_bytes: 13672
// ABC095B - Bitter Alchemy

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

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

	int sum = 0;
	int minT = 1001;

	for (int i = 0; i < N; i++) {
		int t;
		cin >> t;
		sum += t;
		minT = min(minT, t);
	}

	cout << (X - sum) / minT + N << endl;

	return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	let a: u64 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		Err(_) => panic!(""),
	};
	let b: u64 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		Err(_) => panic!(""),
	};
	let k: u64 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		Err(_) => panic!(""),
	};
	if a >= k {
		println!("{} {}", a - k, b);
	}else if a + b >= k {
		println!("0 {}", b - (k - a));
	}else {
		println!("0 0");
	}
}

Measured memory_bytes: 4352
#include<stdio.h>
int main(){
    int n,i,a[10]={0},s,j;
    while(scanf("%d",&n) != EOF){
        if(n==0) break;
        for(i=0;i<n;i++){
            scanf("%d",&s);
            a[s]++;
        }
        for(i=0;i<10;i++){
            if(a[i]==0){
                printf("-");
            }
        if(a[i]!=0){
            for(j=0;j<a[i];j++){
                printf("*");
            }
        }
            printf("\n");
        }
        for(i=0;i<10;i++) a[i] =0;
    }
    return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define  rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;


int main()
{
    int N,L;
    cin>>N>>L;
    vs S(N);
    rep(i,N) cin>>S[i];
    sort(begin(S),end(S));
    for(auto s:S) cout<<s;
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
S = input()
A,B,C,D = int(S[0]),int(S[1]),int(S[2]),int(S[3])
for i in [B,-1*B]:
    for j in [C,-1*C]:
        for k in [D,-1*D]:
            if A + i + j + k == 7:
                print("{:d}{:+d}{:+d}{:+d}=7".format(A,i,j,k),end="")
                exit()

Measured memory_bytes: 3064
#include <stdio.h>
int new(int n){
    int a, b, c, d, result = 0;
    for (a = 0; a <= 9; a++) {
        for (b = 0; b <= 9; b++) {
            for (c = 0; c <= 9; c++) {
                for (d = 0; d <= 9; d++) {
                    if (a + b + c + d == n) {
                        result++;
                    }
                }
            }
        }
    }
    return result;
}
int main(int argc, const char * argv[])
{
    int n;
    while(scanf("%d", &n) != EOF){
        printf("%d\n", new(n));
    }
    return 0;
}

Measured memory_bytes: 596
N = int(input())
Xlist = list(map(int, input().split()))
X_sort = sorted(Xlist)
left_med = X_sort[N//2-1]
right_med = X_sort[N//2]
for i in range(N):
    if Xlist[i] <= left_med:
        print(right_med)
    else:
        print(left_med)


Measured memory_bytes: 93652
# -*- coding: utf-8 -*-

from sys import stdin

def load():
    n = stdin.readline()
    return n

def calc(n):
    countup = False
    whites = 0
    total = 0

    for i,x in enumerate(n):
        if x == 'B':
            countup = True
        elif x == 'W':
            if countup:
                total += i - whites
            whites += 1
    return total

n = load()
print(calc(n))

Measured memory_bytes: 3372
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = read.to!int;
	long k = read.to!long;
	int[] as;
	foreach(i; 0 .. n) as ~= read.to!int;
	
	long[] lxs = new long[](n);
	long[] xs = new long[](n);
	
	foreach(i; 0 .. n) foreach(j; 0 .. n){
		if(j < i && as[j] > as[i]) lxs[i] += 1;
		if(as[j] > as[i]) xs[i] += 1;
	}
	
	Finite ans = Finite(0);
	foreach(i; 0 .. n){
		Finite q = k * (k - 1) / 2;
		ans += lxs[i] * k;
		ans += xs[i] * q;
		log("i:", i, "ans:", ans);
	}
	
	ans.writeln;

}



import std.conv;
struct Finite{ ulong value; static ulong mod = 1_000_000_007;
	private static ulong[] _inv = [0, 1], _frac = [1, 1], _invfrac = [1, 1];
	this(ulong v){ value = v % mod; }
	bool opCast(T: bool)(){ return value != 0; }
	Finite opUnary(string s){ ulong v;
		if(s == "+") v = value;
		else if(s == "-") v = mod - value;
		else if(s == "++") v = value + 1;
		else if(s == "--") v = value + mod - 1;
		else assert(0, "Operator unary " ~ s ~ " not implemented");
		return Finite(v);
	}
	Finite opBinary(string s)(Finite b){
		return opBinary!s(b.value);
	}
	Finite opBinary(string s)(ulong u){ ulong v;
		if(s == "+") v = value + u;
		else if(s == "-") v = value + mod - u;
		else if(s == "*") v = value * u;
		else if(s == "/") v = value * inv(u);
		else assert(0, "Operator " ~ s ~ " not implemented");
		return Finite(v);
	}
	Finite opBinaryRight(string s)(ulong u){ ulong v;
		if(s == "+") v = u + value;
		else if(s == "-") v = u + mod - value;
		else if(s == "*") v = u * value;
		else if(s == "/") v = u * invvalue;
		else assert(0, "Operator " ~ s ~ " not implemented");
		return Finite(v);
	}
	Finite opAssign(ulong v){ value = v; return this; }
	Finite opOpAssign(string s)(Finite b){
		return opOpAssign!s(b.value);
	}
	Finite opOpAssign(string s)(ulong v){
		if(s == "+") value = (value + v) % mod;
		else if(s == "-") value = (value + mod - v) % mod;
		else if(s == "*") value = (value * v) % mod;
		else if(s == "/") value = (value * inv(v)) % mod;
		else assert(0, "Operator " ~ s ~ "= not implemented");
		return this;
	}
	bool opEquals(Finite b){
		return(value == b.value);
	}
	string toString(){ return value.to!string; }
	ulong inv(ulong v){
		assert(v > 0);
		assert(v < mod);
		while(v >= _inv.length){
			_inv ~= _inv[mod % $] * (mod - mod / _inv.length) % mod;
		}
		return _inv[v.to!uint];
	}
	ulong invvalue(){
		return inv(value);
	}
	static Finite opCall(ulong v){
		return Finite(v);
	}
}


Measured memory_bytes: 636
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

ll a_max = 1000010;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;++i){
        cin>>a[i];
    }
    sort(a.begin(), a.end());

    vector<bool> dp(a_max, true);
    for(ll i=1;i<n;++i){
        if(a[i] == a[i-1] and dp[a[i]]){
            for(ll j=a[i];j<a_max;j+=a[i]){
                dp[j] = false;
            }
        }
    }

    for(ll i=0;i<n;++i){
        if(dp[a[i]] == true){
            for(ll j=2*a[i];j<a_max;j+=a[i]){
                dp[j] = false;
            }
        }
    }

    ll ans = 0;
    for(ll i=0;i<n;++i){
        if(dp[a[i]] == true){
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

#define reps(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) reps(v, 0, n)
#define lep(v, n) reps(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }
template<typename T> void show(T& a, char del='\n', char last='\n'){ rep(i, a.size() - 1) cout << a[i] << del; cout << a[a.size() - 1] << last; }

int main()
{
  int n;
  while (n = in()){
    int total = 0;
    rep(i, n * (n - 1) / 2) total += in();
    printf("%d\n", total / (n - 1));
  }

  return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>

void swap(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
}

int bubbleSort(int A[],int N) {
    int i,j;
    int sw = 0;
    unsigned short flag = 1;
    for(i=0;flag;i++) {
        flag = 0;
        for(j=N-1;j>=i+1;j--) {
            if(A[j]<A[j-1]) {
                swap(&A[j],&A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main(void) {
    int i, A[100], N, sw;
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = bubbleSort(A,N);

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

    return 0;
}


Measured memory_bytes: 2088
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
template<class T> inline bool change(T a,T b){if(a > b){swap(a,b);return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
ll fac[cmax], finv[cmax], inv[cmax];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    if(S[0] == '9' || S[1] == '9'){
        cout << "Yes" << endl;return 0;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3632
parseint(x) = parse(Int, x)

function main()
    n = readline() |> parseint
    h = map(parseint, readline() |> split)
    ans = 0
    step = 0
    for i = 1:n-1
        if h[i] >= h[i+1]
            step += 1
        else
            ans = max(ans, step)
            step = 0
        end
    end
    ans = max(ans, step)
    println(ans)
end

main()

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1e9;

int main() {
  ll n, ans = 0;
  cin >> n;
  vector<ll> a(n + 1, 0);
  for (int i = 1; i <= n; ++i) {
    int j = i;
    while (j <= n) a[j]++, j += i;
  }

  rep(i, n + 1) ans += a[i] * i;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 81400
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false);cin.tie(0);
#define setnow clock_t tStart;
#define setTime tStart = clock();
#define time0 (double)(clock() - tStart)/CLOCKS_PER_SEC
#define setin(x) ifstream cin(x);
#define setout(x) ofstream cout(x);
#define NMAX 30
typedef long long ll;
typedef long long int lli;
typedef pair < int, int> dbl;
const int maxInt = 1e9*2;
const lli maxLong = 1e18*2;
int main(){
    string str;
    cin >> str;
    int cnt1, cnt0;
    int sz = str.size();
    cnt1=cnt0=sz;
    for(int i=0;i<str.size();i++){
        int a = max(i, 1);
        int b = max(i, sz-i-1);
        if(str[i] == '0'){
                cnt0 = min(cnt0, max(a, b));
        }else{
                cnt1 = min(cnt1, max(a, b));
        }
    }
    cout << max(cnt1, cnt0);
}


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

int main(){
    int H,W;
   while(true){
       cin >>H >>W;
       if(H == 0&&W ==0) break;
       for(int i =0;i<H;i++){
           for(int j=0;j<W;j++){
               if(i==0||i==H-1||j==0||j==W-1){
                   cout << "#";
               }else{
                   cout << ".";
               }
           }
           cout << "\n";
       }
       cout << endl;
       



   }
   return 0;
    
}


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

int main()
{
	//?????°???????????????
	string in;
	string sarch;
	int flag;

	//?????????s??¨?????????p?????????
	getline(cin, in);
	getline(cin, sarch);

	//s????????????????????????????????????
	in += in;

	//?????????s???????????????p???????´¢??????????????¨???
	if (in.find(sarch) != std::string::npos)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

signed main(void)
{
  int n;
  cin >> n;
  bool flag = false;
  REP(i, n) {
    char c;
    cin >> c;
    if(c == 'Y') flag = true;
  }

  if(flag) cout << "Four" << endl;
  else cout << "Three" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  int n;
  cin >> n;
  vector<vll> f(n,vll(10));
  rep(i,n)rep(j,10) cin >> f[i][j];
  vector<vll> p(n,vll(11));
  rep(i,n)rep(j,11) cin >> p[i][j];
  ll ans = LLONG_MIN;
  for(ll i = 1; i < (1<<10); i++) {
    ll res = 0;
    rep(j,n) {
      ll cnt = 0;
      rep(k,10) {
        if(i>>k&1) {
          if(f[j][k]) cnt++;
        }
      }
      res += p[j][cnt];
    }
    ans = max(ans,res);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

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

void solve() {
	ll A, B, C, D;
	cin >> A >> B >> C >> D;
	if (A < B) { // 開店時に買えない
		cout << "No" << endl;
		return;
	}
	if (D < B) { // 補充が明らかに不足
		cout << "No" << endl;
		return;
	}
	// 毎日の開店時の本数はgcd(A,B,D)の倍数なので、
	// A,B,C,Dをgcd(A,B,D)で割っても答えは不変
	ll g = gcd(gcd(A, B), D);
	A /= g, B /= g, C /= g, D /= g;
	if (C >= B - 1) { // 十分量があるときに十分量補充される
		cout << "Yes" << endl;
		return;
	}
	// 開店時の本数が(C,B)になると次の日に買えなくなる
	if ((A - C - 1) / B >= (A - B + 1) / B + ((A - B + 1) % B ? 1 : 0)) {
		cout << "No" << endl;
		return;
	}
	if (D % B == 0) {
		cout << "Yes" << endl;
		return;
	}
	if (gcd(D % B, B) == 1) {
		cout << "No" << endl;
		return;
	}
	if (C + 1 <= A % B && A % B <= B - 1) {
		cout << "No" << endl;
		return;
	}
	if (gcd(D % B, B) <= B - C - 1) {
		cout << "No" << endl;
		return;
	}
	cout << "Yes" << endl;
}

int main() {
	int T; cin >> T;
	while (T--) solve();
	return 0;
}

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

def yakusu(num):
    cnt=0
    for i in range(1,num+1):
        if num%i==0:
            cnt+=1
    return cnt

ans=0
for i in range(1,n+1):
    if i%2==1 and yakusu(i)==8:
        ans+=1
print(ans)


Measured memory_bytes: 2940