akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;

void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vi a(n);
    map<int, int> m;
    REP(i, n) {
        cin >> a[i];
        m[a[i]]++;
    }

    vb b(1000001, true);
    int ans = 0;
    for (auto e : m) {
        if (e.second == 1 and b[e.first]) ans++;
        if (b[e.first]) {
            for (int i = e.first; i <= 1000000; i += e.first) b[i] = false;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 13720
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <utility>

using namespace std;

int main() {
    long n, m;
    cin >> n >> m;

    if (n >= 2 && m >= 2)
        cout << (n - 2) * (m - 2) << endl;
    else if (n == 1 && m >= 2)
        cout << m - 2 << endl;
    else if (m == 1 && n >= 2)
        cout << n - 2 << endl;
    else
        cout << 1 << 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;
typedef long long ll;

int main(){
  string s;
  cin >> s;
  int w=0;
  int k=s.size();
  rep(i,k){
    if(s[i]=='o') w++;
  }
  if(w+(15-k)>=8) cout << "YES" <<endl;
  else cout << "NO" << endl;
  return 0;
}

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

string str;
bool vis[3];

int main() {
	cin >> str;
	vis[str[0] - 'a'] = vis[str[1] - 'a'] = vis[str[2] - 'a'] = 1;
	printf(vis[0] && vis[1] && vis[2] ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
import sys 
m,d = map(int,input().split())
if m<=3:
  print(0)
  sys.exit()
cnt = 0
def make_d(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i and n//i != n:
        divisors.append(n//i)

  divisors.sort()
  return divisors
  
for i in range(4,m+1):
  l = make_d(i)
  l.pop(0)
  n = len(l)
  if not l:
    pass

  elif n%2 == 0:
    for x in range(n//2):
      if int(str(l[x])+str(l[-x-1])) <= d:
        cnt += 1

      if int(str(l[-x-1])+str(l[x])) <= d:
        cnt += 1  

  else:
    for x in range(n//2):
      if int(str(l[x])+str(l[-x-1])) <= d:
        cnt += 1

      if int(str(l[-x-1])+str(l[x])) <= d:
        cnt += 1
        
    if int(str(l[n//2])+str(l[n//2])) <= d:
      cnt += 1  
print(cnt)
  
  

Measured memory_bytes: 38384
s,t = gets.chomp.split(" ").map(&:to_s);
a,b = gets.chomp.split(" ").map(&:to_i);
u = gets.to_s.chomp

if u == s then
	a = a-1
	puts (a.to_s)+" "+(b.to_s)
else
	b = b-1
	puts (a.to_s)+ " " +(b.to_s)
end



Measured memory_bytes: 14084
#include<stdio.h>

int main(void)
{
	char Chr[1000];
	int total = 0;
	int n = 0;
	int count = 0;
	int kekka[1000];
	while (1)
	{
		scanf("%c", &Chr[n]);
		if (Chr[n] == '\n')
		{
			kekka[count] = total;
			total = 0;
			count++;
		}
		else
		{
			total = total + (Chr[n] - '0');
		}

		//最初に0が入力されたら終了
		if (Chr[n] == '0' && total ==0)
		{
			break;
		}

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


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

using namespace std;

vector <int> V;

int n, ans;

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(NULL);
  
  	int i, a;
  
  	cin >> n;
  	
  	for(i=0; i<n+n; i++){
      	cin >> a;
      	V.push_back(a);
    }
  	
  	sort(V.begin(), V.end());
  	
  	for(i=0; i<n; i++){
      	ans += V[i << 1];
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll X, Y;

int main() {
	scanf("%lld %lld", &X, &Y);
	ll sum = 0;
	sum += X + (Y / 2);
	printf("%lld\n", sum);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const int N=2e5+5;
int n;
string str;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&& a!=c || a==c&& a!=b || b==c && b!=a)puts("Yes");
	else puts("No");
	return 0;
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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



void func(long long N, long long K, std::vector<long long> V){

    lli ans = -INF;
    for(lli a = 0; a<= min(N,K) ;a++){
        for(lli b=0;a+b <= min(N,K);b++){
            LOG2(a,b);
            priority_queue<lli,vector<lli>,greater<lli>> q;
            REP(i,0,a)q.push(V[i]);
            REP(i,0,b)q.push(V[N-1-i]);

            lli leftK = K - (a+b);
            REP(i,0,leftK){
                if(q.size()==0)break;
                if(q.top()<0){
                    q.pop();
                }
            }
            lli sum = 0;
            while(q.size()){
                sum += q.top();
                q.pop();
            }
            chmax(ans,sum);
        }
    }
    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> V(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&V[i]);
    }
    func(N, K, std::move(V));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int h, n;
	vector<int> a;

	cin >> h >> n;
	a.resize(n);
	for(auto& ai : a) {
		cin >> ai;
	}

	for(auto ai : a) {
		h -= ai;
	}

	cout << (h <= 0 ? "Yes" : "No");
}

Measured memory_bytes: 640
function Main (input) {
  input = input.split("\n");
  const N = parseInt(input[0], 10);
  const A = input[1].split(" ").map(inp => parseInt(inp, 10));
  var ans1 = [];
  var ans = "APPROVED";
  for (var i = 0; i < N; i++) {
    if (A[i] % 2 == 0) {
      ans1.push(A[i]);
    }
  }
  for (var i of ans1) {
    if (i % 3 != 0 && i % 5 != 0) {
      ans = "DENIED";
      break;
    }
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
//***The night is the darkest just before the dawn***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
ll red[4002];
ll blue[4002];
ll green[4002];

int main(){
    ll n,ans=0;
    cin>>n;
    string s;
    cin>>s;
    for(ll i=s.length()-1;i>=0;i--){
        if(s[i]=='R') red[i]++;
        else if(s[i]=='B') blue[i]++;
        else green[i]++;
        red[i]+=red[i+1];
        green[i]+=green[i+1];
        blue[i]+=blue[i+1];
    }
    forn(i,n){
        for(ll j=i+1;j<n;j++){
            if((s[i]=='R')&&(s[j]=='G')){
                ans+=blue[j+1];
                if(((2*j-i)<n)&&(s[2*j-i]=='B')) ans--;
            }
            if((s[i]=='R')&&(s[j]=='B')){
                ans+=green[j+1];
                if(((2*j-i)<n)&&(s[2*j-i]=='G')) ans--;
            }
            if((s[i]=='B')&&(s[j]=='G')){
                ans+=red[j+1];
                if(((2*j-i)<n)&&(s[2*j-i]=='R')) ans--;
            }
            if((s[i]=='B')&&(s[j]=='R')){
                ans+=green[j+1];
                if(((2*j-i)<n)&&(s[2*j-i]=='G')) ans--;
            }
            if((s[i]=='G')&&(s[j]=='R')){
                ans+=blue[j+1];
                if(((2*j-i)<n)&&(s[2*j-i]=='B')) ans--;
            }
            if((s[i]=='G')&&(s[j]=='B')){
                ans+=red[j+1];
                if(((2*j-i)<n)&&(s[2*j-i]=='R')) ans--;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3728
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N = in.nextInt
  val counts = Array.fill(N + 1)(0L)
  val As = Array.fill(N)(in.nextInt)
  As.foreach(a => counts(a) += 1)
  val pairs = counts.map(c => c * (c - 1) / 2)
  val sum = pairs.sum
  val results = counts.map(c => sum - c * (c - 1) / 2 + (if (c > 0) (c - 1) * (c - 2) / 2 else 0))
  println(As.map(a => results(a)).mkString("\n"))
}

Measured memory_bytes: 97504
#include <stdio.h>

int main( void ) {
	int n, a, b, c;

	for ( scanf( "%d", &n ); n--;  ) {
		scanf( "%d %d %d", &a, &b, &c );

		if ( a * a + b * b == c * c || b * b + c * c == a * a || c * c + a * a == b * b )
			puts( "YES" );
		else
			puts( "NO" );
	}

	return 0;
}

Measured memory_bytes: 580
#include <stdio.h>
int main(void)
{
	int n,s[100001],i,j,tmp,sum=0;
	scanf("%d",&n);
	for(i=0; i<n; i++){
		scanf("%d",&s[i]);
		sum=sum+s[i];
	}
	if(sum%10!=0){
		printf("%d\n",sum);
		return 0;
	}
	for(i=0; i<n; i++){
		for(j=i+1; j<n; j++){
			if(s[i]>s[j]){
				tmp=s[i];
				s[i]=s[j];
				s[j]=tmp;
			}
		}
	}
	for(i=0; i<n; i++){
		if(s[i]%10!=0){
			printf("%d\n",sum-s[i]);
			return 0;
		}
	}
	printf("%d\n",0);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <ll,ll>
#define N 100005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;
 
ll A[65][65];
map <string, int> m;
map <int, string> rm;
void map_possibilities()
{
	int x = 1;
	for (int i = 1; i <= 4; ++i)
	{
		for (int j = 1; j <= 4; ++j)
		{
			for (int k = 1; k <= 4; ++k)
			{
				int val = i * 100 + j * 10 + k;
				string s = to_string(val);
				m[s] = x;
				rm[x] = s;
				x++;
			}
		}
	}
}
bool valid(string s)
{
	int n = (int) s.size();
	if(s.find("132") != string::npos)
		return false;
	for (int i = 0; i < n - 1; ++i)
	{
		swap(s[i], s[i + 1]);
		if(s.find("132") != string::npos)
			return false;
		swap(s[i], s[i + 1]);
	}
	return true;
}
void calc_matrix()
{
	string s, t;
	int cnt = 0;
	for (int i = 1; i <= 64; ++i)
	{
		for (int j = 1; j <= 64; ++j)
		{
			s = rm[i], t = rm[j];
			if(s[1] != t[0] || s[2] != t[1])
				continue;
			s.push_back(t.back());
			if(valid(s))
			{
				A[j][i] = 1;
			}
		}
	}
}
void matrix_mul(ll x[][65], ll y[][65])
{
	ll c[65][65];
	memset(c, 0, sizeof(c));
	for (int i = 1; i <= 64; ++i)
	{
		for (int j = 1; j <= 64; ++j)
		{
			for (int k = 1; k <= 64; ++k)
			{
				c[i][j] += x[i][k] * y[k][j];
				c[i][j] %= MOD;
			}
		}
	}
	for (int i = 1; i <= 64; ++i)
		for (int j = 1; j <= 64; ++j)
			x[i][j] = c[i][j];
}
ll matrix_expo(ll mat[][65], int b)
{
	ll res[65][65], cnt = 0;
	memset(res, 0, sizeof(res));
	for (int i = 1; i <= 64; ++i)
	{
		res[i][i] = 1;
	}
	while(b != 0)
	{
		if(b & 1)
			matrix_mul(res, mat);
		matrix_mul(mat, mat);
		b /= 2;
	}
	for (int i = 1; i <= 64; ++i)
	{
		for (int j = 1; j <= 64; ++j)
		{
			cnt += res[i][j];
			cnt %= MOD;
		}
	}
	return cnt;
}
int main()
{
	int n;
	cin >> n;
	memset(A, 0, sizeof(A));
	map_possibilities();
	calc_matrix();
	if(n == 3)
		cout << 61;
	else
		cout << matrix_expo(A, n - 3);
}

Measured memory_bytes: 3808
//Volume1-0160
import java.util.Scanner;

class Main {

	public static void main(String[] arg){

		            int    n,l,w,size,sum;
		      final int    OVER = -1;
		      final int[]  srnk = { 60, 80, 100, 120, 140, 160},
		                   wrnk = {  2,  5,  10,  15,  20,  25},
		                   fee  = {600,800,1000,1200,1400,1600};

		Scanner sc = new Scanner(System.in);

		while((n = sc.nextInt()) != 0){
			sum = 0;
			while(n-- > 0){
				l = sc.nextInt()+sc.nextInt()+sc.nextInt();
				w = sc.nextInt();

				size = -1;
				for(int i=0;i<6;i++)
					if(l <= srnk[i] && w <= wrnk[i]){
						size = i;
						break;
					}
				if(size == OVER){continue;}
				sum += fee[size];
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 58532
import java.io.PrintWriter
import java.util.StringTokenizer

fun main() {

    fun PrintWriter.solve() {
        var (n,m) = List(2){nextInt()}
        var arr = IntArray(n){-1}
        
        if (n == 1 && m == 0){
            println(0)
            return
        }

        repeat(m){
            var (s,c) = List(2){nextInt()}
            s--
            if (arr[s] == -1 || arr[s] == c){
                arr[s] = c
            }
            else{
                println(-1)
                return
            }
        }

        if (arr[0] == -1)arr[0] = 1
        arr.indices.forEach { if(arr[it] == -1) arr[it] = 0 }

        if (n != 1 && arr[0] == 0){
            println(-1)
            return
        }
        println(arr.joinToString("") )



    }

    writer.solve()
    writer.flush()


}


private val reader = System.`in`.bufferedReader()
private val writer = PrintWriter(System.out, false)

private var tokenizer: StringTokenizer = StringTokenizer("")

private fun next(): String {
    while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(reader.readLine())
    return tokenizer.nextToken()
}

private fun nextInt() = next().toInt()
private fun nextLong() = next().toLong()
private fun nextDouble() = next().toDouble()
private fun nextLine() = reader.readLine()



Measured memory_bytes: 38544
N, K = map(int, input().split())
H = [0] + list(map(int, input().split()))

INF = 10**12
dp = [[INF] * (N+1) for i in range(N+1)]
dp[0][0] = 0

for x in range(1, N+1):
  dp[x][0] = 0
  dp[x][1] = H[x]
  for y in range(2, x+1):
    for i in range(x):
      dp[x][y] = min(dp[x][y], dp[i][y-1]+max(0, H[x]-H[i]))

ans = INF
for i in range(N+1):
  ans = min(ans, dp[i][N-K])

print(ans)

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;

void solve()
{
    LL X;
    cin >> X;

    // 最適解は 1..k までの整数の任意を選んで
    // 和をXとできるような k のうち最小のもの
    // つまりある k が存在して 1..k の和がXに一致すればそのkが答えであり,
    // 一致しなければ, 和がXを超える最も小さいkが答え.
    // (何もしないを適切な場所に挟めば良い)
    LL n = (-1 + sqrt(1 + 8 * X)) / 2;

    cout << n + ((n * (n + 1)) / 2 != X) << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 256
n, a, b = list(map(int, input().split()))
if a > n:
  print(n)
elif a == 0:
  print(0)
elif b == 0:
  print(n)
else:
  x = n // (a+b)
  y = n % (a+b)
  r = x * a
  r = r + min(a,y)
  print(r)

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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  string s;cin>>s;
  vector<bool>a(10,false);
  vector<bool>b(100,false);
  vector<bool>c(1000,false);
  rep(i,0,n){
    ll x=s[i]-'0';
    rep(j,0,100){
      if(b[j])c[j*10+x]=true;
    }
    rep(j,0,10){
      if(a[j]){
        //cout<<j spa j*10+x<<endl;
        b[j*10+x]=true;
      }
    }
    a[x]=true;
  }
  //debug(a,10);
  //debug(b,100);
  //debug(,10);
  rep(i,0,1000)if(c[i])res++;
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 384
import Data.List

solve n x | m == 0    = len - x
          | otherwise = len + (solve x m)
    where
      (d, m) = n `divMod` x
      len = d * x * 2

run::[Integer]->Integer
run (n:x:[]) = b - a + (solve n x)
    where
      b = n - x
      a = x

f = show . run . map read . words

main = interact f

Measured memory_bytes: 508
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] s = line.split("");
        int N = s.length;
        int count = 0;
        for(int i = 0; i < N / 2; i++) {
            if(s[i].equals(s[N - 1 - i])) {
                continue;
            }else {
                count++;
            }
        }
        
        System.out.println(count);
    }
}

Measured memory_bytes: 23764
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#define INF 999999999

using namespace std;

string s1, s2;
int d[1050][1050];

int tmin(int a, int b, int c)
{
	int d = min(a, b);
	int res = min(d, c);
	return res;
}

int main()
{
	cin >> s1;
	cin >> s2;

	int n = s1.length();
	int m = s2.length();

	for (int i = 0; i <= n; i++) {
		d[i][0] = i;
	}
	for (int i = 0; i <= m; i++) {
		d[0][i] = i;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (s1[i-1] == s2[j-1])d[i][j] = tmin(d[i][j - 1] + 1, d[i - 1][j] + 1, d[i - 1][j - 1]);
			else d[i][j] = tmin(d[i][j - 1] + 1, d[i - 1][j] + 1, d[i - 1][j - 1] + 1);
		}
	}

	/*
	for (int i = 0; i <= n; i++) {
	for (int j = 0; j <= m; j++) {
	cout << d[i][j] << " ";
	}
	cout << endl;
	}
	*/

	cout << d[n][m] << endl;

	return 0;
}

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

int main(){
  int t,n,s,f,ans;

  while(1){
    ans=0;
    cin >> t;
    if(t==0){
      break;
    }
    cin >> n;
    for(int i=0;i<n;i++){
      cin >> s >> f;
      ans+=f-s;
    }
    if(ans>=t){
      cout << "OK\n";
    }else{
      cout << t-ans << '\n';
    }
  }
  
  return 0;
}



Measured memory_bytes: 3088
const input=require("fs").readFileSync("/dev/stdin","utf8"),lines=input.trim().split("\n"),getMax=(e,t)=>t.reduce((t,i)=>i>t&&i<=e?i:t,0),getHighestPriceSum=(e,t)=>{const s=[];for(i=0;i<t.length;i++){const e=t[i];for(j=0;j<t.length;j++)if(i!==j){const i=t[j];s.push(e+i)}}return getMax(e,s)};let ctr=0;const dataSets=[],objHolder={};for(;line=lines.shift();){if(ctr%2==0){const e=line.split(" ").map(Number)[1];objHolder.budget=e}else{const e=line.split(" ").map(Number);objHolder.priceList=e,dataSets.push(Object.assign({},objHolder))}ctr++}dataSets.forEach(e=>{const{budget:t,priceList:i}=e,s=getHighestPriceSum(t,i);0===s?console.log("NONE"):console.log(s)});


Measured memory_bytes: 95200
#include<stdio.h>

int main(void)
{
 int max,min,n;
 int tmp,i,s[100];

 scanf("%d",&n);

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

 for(i=1;i<n;i++){
   if(max<s[i]) max=s[i];
   if(min>s[i]) min=s[i];
 }

 tmp=max-min;
 printf("%d\n",tmp);

 return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pll;
typedef pair<int,pll> plll;
const int N=1e6+10;
char g[1010][1010];
int s1,t1,s2,t2;
priority_queue<plll,vector<plll>,greater<plll> > q;
int st[1010][1010];
ll ans;
int n,m;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
int bfs(){
    q.push({0,{s1,t1}});
    int i,j;
    while(q.size()){
        auto t=q.top();
        q.pop();
        int a=t.second.first;
        int b=t.second.second;
        int c=t.first;
        if(st[a][b])
            continue;
        st[a][b]=1;
        if(a==s2&&b==t2){
            ans=c;
            return true;
        }
        for(i=-2;i<=2;i++){
            for(j=-2;j<=2;j++){
                int x=a+i;
                int y=b+j;
                if(x<=0||x>n||y<=0||y>m)
                    continue;
                if(st[x][y]||(g[x][y]=='#'))
                    continue;
                q.push({c+1,{x,y}});
            }
        }
        for(i=0;i<4;i++){
            int x=a+dx[i];
            int y=b+dy[i];
            if(x<=0||x>n||y<=0||y>m)
                    continue;
            if(st[x][y]||(g[x][y]=='#'))
                    continue;
            q.push({c,{x,y}});
        }
    }
    return false;
}
int main(){
    ios::sync_with_stdio(false);
    cin>>n>>m;
    int i,j;
    cin>>s1>>t1>>s2>>t2;
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++)
            cin>>g[i][j];
    }
    if(bfs()){
        cout<<ans<<endl;
    }
    else{
        cout<<-1<<endl;
    }
}


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

int main (void) {
    int N;
    std::cin >> N;

    std::vector<long long> n_devisor(N+1, 0);
    for ( int i = 1; i <= N; i++ ) {
        for ( int j = i; j <= N; j += i ) {
            n_devisor.at(j)++;
        }
    }

    long long ans = 0;
    for ( int i = 1; i <= N; i++ ) {
        ans += i * n_devisor.at(i);
    }

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


Measured memory_bytes: 81384
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    long long int ans = 0;
    long long int n; cin >> n;
    if(n==1 || n==2){cout << 0 << endl; return 0;}
    for(long long int i = 0; n >= (i * i); i++){
        if(n % (i+1) == 0){
            long long int t = (n / (i+1) )-1;
            if( n / t == (n % t)) ans = ans + t;
            if(i != 0 &&  n / i == (n % i)) ans = ans + i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)

	sc.Scan()
	nm := strings.Split(sc.Text(), " ")
	n, _ := strconv.Atoi(nm[0])
	m, _ := strconv.Atoi(nm[1])
	kList := []int{}
	sMapList := []map[int]bool{}
	for i := 0; i < m; i++ {
		sc.Scan()
		line := sc.Text()
		strs := strings.Split(line, " ")
		convedK, _ := strconv.Atoi(strs[0])
		kList = append(kList, convedK)
		sMap := map[int]bool{}
		strsCount := len(strs)
		for j := 1; j < strsCount; j++ {
			sIndex, _ := strconv.Atoi(strs[j])
			sIndex--
			sMap[sIndex] = true
		}
		sMapList = append(sMapList, sMap)
	}
	sc.Scan()
	strPList := strings.Split(sc.Text(), " ")
	pList := []int{}
	for _, v := range strPList {
		intV, _ := strconv.Atoi(v)
		pList = append(pList, intV)
	}
	totalCount := int(math.Pow(float64(2), float64(n)))
	res := 0
	for i := 0; i < totalCount; i++ {
		countList := make([]int, m)
		for j := 0; j < n; j++ {
			if (i >> uint(j) & 1) == 1 {
				for k, v := range sMapList {
					if v[j] {
						countList[k]++
					}
				}
			}
		}
		flg := true
		for k, v := range pList {
			if countList[k]%2 != v {
				flg = false
			}
		}
		if flg {
			res++
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main(){
    int n;
    while (cin >> n){
        if(n==0)
            break;
        int x,y;
        int a=0;
        int b=0;
        for(int i=0;i<n;i++){
            cin >> x >> y;
            if(x>y)
                a+=x+y;
            if(x<y)
                b+=x+y;
            if(x==y){
                a+=x;
                b+=y;
            }
        }
        cout << a << " " << b << endl;
    }
}

Measured memory_bytes: 1160
N, M = map(int, input().split())

A = []
B = []
for i in range(M):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)
AB = A + B

# 各都市間の道路の本数は、ABに含まれる各都市の個数（番号）に等しい
roadsCntArray = []
# 入力に含まれる都市の個数を数える
for i in range(N):
    roadsCntArray.append(AB.count(i+1))
    print(roadsCntArray[i])

Measured memory_bytes: 3064
# coding: utf-8
import queue

class Dinic:
    """Implementation of Dinic's Alogorithm"""

    def __init__(self, v, inf = 1000000007):
        self.V = v
        self.inf = inf
        self.G = [[] for _ in range(v)]
        self.level = [0 for _ in range(v)]
        self.iter = [0 for _ in range(v)]

    def add_edge(self, from_, to, cap):
        # to: 行き先, cap: 容量, rev: 反対側の辺
        self.G[from_].append({'to':to, 'cap':cap, 'rev':len(self.G[to])})
        self.G[to].append({'to':from_, 'cap':0, 'rev':len(self.G[from_])-1})

    # sからの最短距離をbfsで計算
    def bfs(self, s):
        self.level = [-1 for _ in range(self.V)]
        self.level[s] = 0;
        que = queue.Queue()
        que.put(s)
        while not que.empty():
            v = que.get()
            for i in range(len(self.G[v])):
                e = self.G[v][i]
                if e['cap'] > 0 and self.level[e['to']] < 0:
                    self.level[e['to']] = self.level[v] + 1
                    que.put(e['to'])

    # 増加バスをdfsで探す
    def dfs(self, v, t, f):
        if v == t: return f
        for i in range(self.iter[v], len(self.G[v])):
            self.iter[v] = i
            e = self.G[v][i]
            if e['cap'] > 0 and self.level[v] < self.level[e['to']]:
                d = self.dfs(e['to'], t, min(f, e['cap']))
                if d > 0:
                    e['cap'] -= d
                    self.G[e['to']][e['rev']]['cap'] += d
                    return d

        return 0

    def max_flow(self, s, t):
        flow = 0
        while True:
            self.bfs(s)
            # bfsで到達不可
            if self.level[t] < 0 : return flow
            self.iter = [0 for _ in range(self.V)]
            f = self.dfs(s, t, self.inf)
            while f > 0:
                flow += f
                f = self.dfs(s,t, self.inf)

if __name__ =="__main__":
    #H,W=map(int,input().split())
    #C=[list(input()) for i in range(H)]
    N=int(input())
    a=[0 for i in range(N)]
    b=[0 for i in range(N)]
    c=[0 for i in range(N)]
    d=[0 for i in range(N)]
    for i in range(N):
        a[i],b[i]=map(int,input().split())
    for i in range(N):
        c[i],d[i]=map(int,input().split())
    Dn=Dinic(2*N+2)
    for i in range(N):
        for j in range(N):
            if a[i]<c[j] and b[i]<d[j]:
                Dn.add_edge(i+1,j+N+1,1)
        Dn.add_edge(0,i+1,1)
        Dn.add_edge(i+N+1,2*N+1,1)
    ans=Dn.max_flow(0,2*N+1)
    print(ans)

Measured memory_bytes: 5744
#include <bits/stdc++.h>
#define L long long
#define LL long long
#define SS string
#define PB push_back
#define pp pair<L,L>
#define f(x,n) for (L i = x ; i <= n ; i++)
#define N 100005
using namespace std;
L visited[N];
L a[N] , h[N];
    L n ,k;
int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    L mx[n+1][3];
    L a[n+1][3];
    f(1,n)
    {
        cin >> mx[i][0] >> mx[i][1] >> mx[i][2];
        // a[][]
    }
    a[1][0] = mx[1][0];
    a[1][1] = mx[1][1];
    a[1][2] = mx[1][2];
    f(2,n)
    {
        a[i][0] = max(a[i-1][1] + mx[i][0],a[i-1][2] + mx[i][0]);

        a[i][1] = max(a[i-1][0] + mx[i][1],a[i-1][2] + mx[i][1]);
        a[i][2] = max(a[i-1][1] + mx[i][2],a[i-1][0] + mx[i][2]);
    }
    cout << max(a[n][0],max(a[n][1],a[n][2]));
    return 0; 
}

Measured memory_bytes: 4992
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  int n, ans = 0;
  string s;
  cin >> s;
  for (int i = 0; i < 3; i++) {
    if (s[i] == 'R') {
      ans = 1;
    }
  }
  for (int i = 0; i < 2; i++) {
    if (s.substr(i, 2) == "RR") {
      ans = 2;
    }
  }
  if (s == "RRR") {
    ans = 3;
  }
  cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl


int main(){
    int n;
    cin>>n;
    vi a(n*3);
    REP(i,3*n){
        cin>>a[i];
    }
    sort(all(a));
    ll sum=0;
    REP(i,n,3*n,2){
        sum+=a[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;
int n;
int len;
int N;
int x[10];
bool han(int n){
  if( n == 0 ) return true;
  //桁数 k
  int k= 0;
  for(int i = 0; i < 100 ; i++){
    if(n == 0) break;
    x[i] = n%10;
    n /= 10;
    k++;
  }
  // cout << k << " " ;
  for(int i = 0 ; i < k/2 ; i++ ){
    if(x[i] != x[k-1-i]) return false;
  }
  return true;
}
int main(){
  cin >> n;
  int ansp = n, ansm = n;  
  if(han(n)) cout << n << endl;
  else{
    while(1){
      ansm--;
      if(han(ansm)){
	cout << ansm << endl;
	break;
      }
      ansp++;
      if(han(ansp)){
	cout << ansp << endl;
	break;
      }
    }
  }
  //  han(n);
  return 0;
}
  

 

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX 
#define mod 1000000007
using namespace std;
int main(){
    ll A,B;
    cin >> A >> B;
    if(abs(A-B)<=1){
        cout << "Brown" << endl;
    }else{
        cout << "Alice" << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		if(Integer.parseInt(sc.next()) < Integer.parseInt(sc.next())) {
			System.out.println(0);
		} else {
			System.out.println(10);
		}

	}
}

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

int main(){

	while(true)
	{
		int n,x;
		cin >> n >> x;

		if(n+x ==0) break;
		int count = 0;

		for(int i=1;i<=n;i++){
			for(int k=i+1;k<=n;k++){
				for(int r=k+1;r<=n;r++){
					if(i+k+r == x) count++;
				}
			}
		}
		cout << count << endl;
	}

	return 0;
}



Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
void chmin(int &a, int b) {if(a > b) a = b;}
void chmax(int &a, int b) {if(a < b) a = b;}

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};


int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,0,n) cin >> a[i];
    //累積和
    vector<ll> s(n+1, 0);
    for(int i = 0 ; i < n ;i++){
        s[i+1] = s[i] + a[i];
    }
    ll ans = 0;
    map<ll,ll> mp;
    for(int i = 0 ; i <= n ; i++){
        mp[s[i]]++;
    }
    for(auto i : mp){
        ll x = i.second;
        ans += x *(x-1)/2;
    }
    printf("%lld", ans);
}

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

int main(){
	int N, M;
	cin >> N >> M;
	vector<pair<long, int> > AB(N);
	for(int i = 0; i < N; i++) cin >> AB.at(i).first >> AB.at(i).second;
	sort(AB.begin(), AB.end());
	long ans = 0;
	int cnt = 0;
	int i = 0;
	while(1){
		if(cnt + AB.at(i).second <= M){
			cnt += AB.at(i).second;
			ans += AB.at(i).first * AB.at(i).second;
		}else{
			ans += AB.at(i).first * (M - cnt);
			cnt = M;
		}
		if(cnt == M) break;
		i++;
	}
	cout << fixed;
	cout << setprecision(12) << ans << endl;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s = r.readLine();
    String[] sl = s.split("[\\s]+");
    Double n = Double.parseDouble(sl[0]);
    Double m = Double.parseDouble(sl[1]);
    Double d = Double.parseDouble(sl[2]);

    Double t = 2 * (m - 1) * (n - d) / n / n;

    if(d == 0)
    {
      t /= 2;
    }

   System.out.printf("%.15f", t);
  }
}

Measured memory_bytes: 23124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var sc = new Scanner();
            int a = sc.NextInt();
            int b = sc.NextInt();

            int x = Math.Max(a, b);
            int y = Math.Min(a,b);

            Console.WriteLine(x - y > 1 ? 2 * x - 1 : x + y);
        }
    }

    class Scanner
    {
        int index = -1;
        string[] buf;

        public Scanner()
        {
        }

        public int NextInt()
        {
            CheckNext();
            return int.Parse(buf[index++]);
        }

        public string NextString()
        {
            CheckNext();
            return buf[index++];
        }

        private void CheckNext()
        {
            if (index >= 0 && index < buf.Length) return;

            buf = Console.ReadLine().Split(' ');
            index = 0;
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdlib>
#include <set>
#include <queue>
using namespace std;

#define X first
#define Y second
#define N 1010
typedef long long ll;
typedef pair<int,int> pii;
const int Mod=1000000007;

const double INF=1e18;

bool flag[N];
int p[N],b[N];

void work(int x)
{
	for (int i=1;i<=p[0] && p[i]<=x;i++)
	{
		while (x%p[i]==0) x/=p[i],b[i]++;
	}
}

int main()
{
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
	
	int n,ans=1; cin >> n;
	for (int i=2;i<N;i++)
	{
		if (!flag[i]) p[++p[0]]=i;
		for (int j=1;j<=p[0] && i*p[j]<N;j++)
		{
			flag[i*p[j]]=true;
			if (i%p[j]==0) break;
		}
	}
	for (int i=2;i<=n;i++) work(i);
	for (int i=1;i<=p[0];i++) ans=1ll*ans*(b[i]+1)%Mod;
	cout<<ans<<endl;
	return 0;

}


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

int d, n, ans;

int main() {
  cin >> d >> n;
  ans = n;
  if (n == 100) ans++;
  rep (i, d) ans *= 100;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3556
import sys
aC = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
#a1+b1 a1+b2 a1+b3
#a2+b1 a2+b2 a2+b3
#a3+b1 a3+b3 a3+b3

#ABC
#DEF
#GHI

#A+E=B+D
#E+I=F+H
#A+I=C+G

if aC[0][0] + aC[1][1] == aC[0][1] + aC[1][0] and aC[2][2]+aC[1][1] == aC[2][1] + aC[1][2] and aC[0][0]+aC[2][2] == aC[2][0] + aC[0][2] :
    print("Yes")
else:
    print("No")


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

int main()
{
	int n, m;
	int a[1000], p[1000];

	memset(p, 0, sizeof(p));

	cin >> n >> m;

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

	for (int j = 0; j < m; j++) {
		int b;

		cin >> b;

		for (int i = 0; i < m; i++) {
			if (a[i] <= b) {
				p[i]++;
				break;
			}
		}
	}

	int mx = 0, k = 0;
	for (int i = 0; i < n; i++) {
		if (p[i] > mx) {
			mx = p[i];
			k = i;
		}
	}

	cout << k + 1 << endl;

	return 0;
}



Measured memory_bytes: 3064
K,N = map(int,input().split())

List = [int(i) for i in input().split()]
dis =[0] *N
for j in range(N):
  if j == N-1:
    dis[j]=K-List[j]+List[0]
  else:
    dis[j] = List[j+1]-List[j]
ans = sum(dis)-max(dis)

print(ans)

Measured memory_bytes: 26444
#include <stdio.h>
#include <string.h>

int main()
{
    char s[27];
    char ans[4] = "yes";
    scanf("%s", s);
    int i, j;
    for (i=0; i<=strlen(s)-2; i++)
    {
        for (j=i+1; j<=strlen(s)-1; j++)
        {
            if (s[i] == s[j]) {
                strcpy(ans, "no");
            }
        }
    }
    printf("%s\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a <= b && b <= c){
    cout << a << " " << b << " " << c << endl;
  } else if(a <= c && c <= b){
    cout << a << " " << c << " " << b << endl;
  } else if(b <= a && a <= c){
    cout << b << " " << a << " " << c << endl;
  } else if(b <= c && c <= a){
    cout << b << " " << c << " " << a << endl;
  } else if(c <= a && a <= b){
    cout << c << " " << a << " " << b << endl;
  } else if(c <= b && b<= a){
    cout << c << " " << b << " " << a << endl;
  }
  return 0;
}
 
 



Measured memory_bytes: 3100
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;

#define dbg(x) cerr << #x"=" << x << endl;
typedef long long LL;


int main(){
   // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    int n,d;
    cin >> n >> d;
    vector<int> v[n];
    int x;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < d; ++j){
            cin >> x;
            v[i].push_back(x);
        }
    }
    int ans = 0;
    for(int i = 0; i < n; ++i){
        for(int j = i+1; j < n; ++j){
            int sum = 0;
            for(int k = 0; k < d; ++k){
                sum += (v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
            }
            int x = sqrt(sum);
            if(x*x == sum) ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    HAPPY = [list(map(int, input().split())) for i in range(N)]
    dp = [[0]*3 for i in range(N+1)]
    for i in range(N):
        for j in range(3):
            for k in range(3):
                if j == k:
                    continue
                dp[i+1][k] = max(dp[i+1][k], HAPPY[i][k] + dp[i][j])
    print(max(max(dp[N][0], dp[N][1]), dp[N][2]))

if __name__ == '__main__':
    main()

Measured memory_bytes: 47332
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<60;
typedef pair<ll, ll> P;


vec memo(2e+6 + 10, -1);
ll num_two(ll n){
    if(memo[n] != -1) return memo[n];
    ll res = 0;
    while(n > 0){
        res += n / 2;
        n /= 2;
    }
    return memo[n] = res;
}

int comb(int n, int k){
    return (num_two(n) > num_two(n - k) + num_two(k) ? 0 : 1);
}

int main() {
    cin>>N>>S;
    vec a(N);
    bool exist_one = false, two = false;
    rep(i,N){
        a[i] = S[i] - '1';
        if(a[i] == 1) exist_one = true;
    }
    if(!exist_one){
        two = true;
        rep(i,N) if(a[i] == 2) a[i] = 1;
    }else{
        rep(i,N) if(a[i] == 2) a[i] = 0;
    }
    int ans = 0;
    rep(i,N){
        //cout<<a[i]<<' ';
        ans = ans ^ (comb(N - 1, i) * a[i]);
        //cout<<comb(N - 1, i)<<endl;
    }
    //cout<<endl;
    cout<<(two ? ans * 2 : ans)<<endl;
}

Measured memory_bytes: 24836
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>

using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  string s;
  cin >> s;
  if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])){
    cout << "Yes\n";
  }
  else{
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

N = int(input())
Array = list(map(int, input().split()))
tmp = 0

for i in range(N):
    tmp = Array[i]
    if tmp % 2 == 0:
        if tmp % 3 == 0 or tmp % 5 == 0:
            pass
        else:
            print('DENIED')
            exit()
else:
    print('APPROVED')

Measured memory_bytes: 3060
#pragma gcc optimize("Ofast")

#include "bits/stdc++.h"
using namespace std;
typedef int64_t lld;
typedef pair<int,int> pii;
typedef pair<lld,lld> pll;
typedef pair<int,pll> pip;
typedef pair<pll,int> ppi;
typedef pair<lld,pll> plp;
typedef pair<pll,lld> ppl;
typedef pair<pll,pll> ppp;
template<typename T>
using maxHeap = priority_queue<T,vector<T>,less<T>>;
template<typename T>
using minHeap = priority_queue<T,vector<T>,greater<T>>;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define endl '\n'
#define jizz cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
inline void input(int &_x) {
    _x = 0;
    int _tmp = 1; char _tc = getchar();
    while((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
    if(_tc == '-') _tc = getchar(), _tmp = -1;
    while(_tc >= '0' && _tc <= '9') _x = _x*10+(_tc-48), _tc = getchar();
    _x *= _tmp;
}
inline void output(int _x) {
    char _buff[20]; int _f = 0;
    if(_x == 0)putchar('0');
    while(_x > 0)
    {
        _buff[_f++] = _x%10+'0';
        _x /= 10;
    }
    for(_f-=1; _f >= 0; _f--)
        putchar(_buff[_f]);
    putchar('\n');
}
template<typename Iter>
ostream& _out(ostream &s, Iter b, Iter e) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}
template<class T1,class T2>
ostream& operator<<(ostream& out, pair<T1,T2> p) {
    return out << '(' << p.first << ", " << p.second << ')';
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) {
     return _out(s,c.begin(),c.end());
 }
#ifdef erd1
    #define pprint(x) cerr<<__PRETTY_FUNCTION__<<":"<<__LINE__<<" - "<<(#x)<<"="<<(x)<<endl
#else
    #define pprint(x)
#endif

// code starts here
inline int S(lld x){
    int ans = 0;
    do ans += x%10;
    while(x/=10);
    return ans;
}
signed main(){jizz
    int n;
    lld cur = 1, next = 2, incr = 1;
    cin >> n;
    string j = "";
    while(n--){
        if(cur*S(next) > next*S(cur)){
            cur += 9*incr;
            incr *= 10;
            next = cur + incr;
        }
        cout << cur << endl;
        cur += incr;
        next += incr;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    if(N/10==9){
        cout << "Yes" << endl;
    }
    else if((N-9)%10==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256