akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N,A,B; cin >> N >> A >> B;
    cout << min(N*A,B) << endl;
    return 0;
}


Measured memory_bytes: 3548
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
    int n = ri();
    int m = ri();
    if (n>m)swap(n,m);
    s64 res;
    if (n == 1 && m ==1) res = 1;
    else if (n==1)res = m-2;
    else res = ((s64)n-2)*(m-2);
    cout << res << endl;
 return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <functional>
#include <iomanip>
using namespace std;

//??°?????????????????°

void function()
{
	//??¢??°
}

int main()
{
	string s;
	int sum;
	while (cin >> s)
	{
		if (s == "0")
		{
			break;
		}
		sum = 0;
		for (int i = 0; i < s.length(); i++)
		{
			sum += (int)s[i] - (int)'0';
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1188
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
typedef std::numeric_limits< double > dbl;
using namespace std;
const long long N=200005, INF=2000000000000000000;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int a,b,n;
    cin>>a>>b>>n;
    if(n>=b)
    n=b-1;
    int ans=((a*n)/b);
    cout<<ans;
}

Measured memory_bytes: 3640
#include<stdio.h>

int main()
{   
    int A[100];
    int t,N,count=0;
    int i,j,flag=1;
    scanf("%d",&N);
    for(i=0;i<N;i++){
      scanf("%d",&A[i]);
    }
    while(flag){
      flag=0;
      for(j=N-1;j>=1;j--)
        {
	  if(A[j]<A[j-1])
            {
	      t=A[j];
	      A[j]=A[j-1];
	      A[j-1]=t;
	      flag=1;
	      count++;
            }
        }      
    }
    for(j=0;j<N-1;j++){
    printf("%d ",A[j]);
    }
    printf("%d",A[N-1]);
    printf("\n%d\n",count);
    return 0;
}



Measured memory_bytes: 2088
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;

int main() {
    int A, B;
    cin >> A >> B;
    bool find = 0;
    rep(i, 1001) {
        if(floor(i * 0.08) == A && floor(i * 0.1) == B) {
            cout << i << endl;
            find = 1;
            break;
        }
    }
    if(!find) {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n; cin >> n;
    cout << n/3 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>

using namespace std;

int main(void) {
	int n, a, b; cin >> n >> a >> b;

	cout << min(a, b) << " " << max(0, a + b - n) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<limits.h>
using namespace std;
#define INF LLONG_MAX
#define inf INT_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<int, int> P;
ll GCD(ll a, ll b) {
	if (b == 0)return a;
	return GCD(b, a%b);
}
ll LCM(ll a, ll b) {
	return a / GCD(a, b)*b;
}
ll mypow(ll a, ll b) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1)*a;
	else return mypow(a, b / 2)*mypow(a, b / 2) ;
}
/*
//Conbination!
ll c[51][51];
void comb(int n) {
	rep(i, 51) {
		rep(j, i + 1) {
			if (j == 0 || j == i)c[i][j] = 1;
			else c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
		}
	}
}
*/
int n, z, w, a[100010];
int main() {
	cin >> n >> z >> w;
	rep(i, n)cin >> a[i];
	if (n == 1)cout << abs(a[0] - w) << endl;
	else cout << max({abs(a[n - 1] - w),abs(a[n - 1] - a[n - 2])});
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int a,b;
    cin>>a>>b;
    if(b==1){
      cout<<0<<endl;
      return 0;
    }
    int cnt=1;
    int cur=a;
    while(cur<b){
        cur+=a-1;
        ++cnt;
    }
    cout<<cnt<<endl;
    return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;

  //問題の条件を満たすNを1から10000まで検証する
  for (int n = 0; n < 10000; ++n) {
    int za = n*8/100;
    int zb = n*10/100;
    if (a == za && b == zb) {
      cout << n << endl;
      return 0;//この命令で処理が終わっている。For文以下のコードは処理されない
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
   int n;cin>>n;
   cout<<max(0,(n-75)/30+(n>188))<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
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; }

// 入力
int N;
long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル
long long dp[100010][3];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];
    
    // 初期化は既に 0 に初期化される
    // 初期条件も既に 0 で OK
    
    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                chmax(dp[i + 1][j], dp[i][k] + a[i][j]);
            }
        }
    }
    
    // 答え
    long long res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
    cout << res << endl;
}

Measured memory_bytes: 4992
using System;

namespace A___Fifty_Fifty
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(solver() ? "Yes" : "No");
        }
        static bool solver()
        {
            var S = Console.ReadLine();
            if (S[0] == S[1])
                if (S[2] == S[3] && S[0] != S[2]) return true;
            if (S[0] == S[2])
                if (S[1] == S[3] && S[0] != S[1]) return true;
            if (S[0] == S[3])
                if (S[1] == S[2] && S[0] != S[1]) return true;
            return false;
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>

using namespace std;


int main()
{

  int N;
  cin >> N;

  int A;

  double invsum;

  for(int i = 0; i < N; i++){
    cin >> A;

    invsum += (double)1.0/A;
  }

  cout << (double)1.0/invsum << endl;

  return 0;
}


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

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL_DEFINE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
   
#define int long long
typedef pair<int, int> pii;
const int mod = (int) 1000000007;


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(9);
	#ifdef LOCAL_DEFINE
		freopen("in.txt", "rt", stdin);
	#endif
	
	
	string s;
	cin >> s;
	int n = s.size();
	if(n % 2 == 1)
	{
		cout << "No\n";
	}
	else
	{
		bool ok = true;
		for(int i = 0; i < n; i += 2)
		{
			string cur = s.substr(i, 2);
			ok &= (cur == "hi");
		}
		if(ok)
			cout << "Yes\n";
		else
			cout << "No\n";
	}
	
	return 0;
}






Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,y;
    scanf("%d%d",&x,&y);
    if(x>0)
	printf("Positive");
    else 
	if(x==0||(x<0&&y>0))
    {
    printf("Zero");
	}
    else 
	if((abs(y)-abs(x))%2)
	{
	printf("Positive");	
	}
    else 
    {
    printf("Negative");
	}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう

#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  int n,m;
  int ans=0;
  vector<int> v(n,-1);
  cin>>n>>m;
  rep(i,m){
    int x=0;
    int y=0;
    cin>>x>>y;
    x--;
    if(n!=1&&x==0&&y==0){ans=-1;break;}
    if(v[x]==-1||v[x]==y){v[x]=y;}
    else{ans=-1;break;}
  }
  if(ans){cout<<ans<<endl;return 0;}
  rep(j,n){if(v[j]<0)v[j]=0;
           if(v[0]==0&&n!=1)v[0]=1;
                cout<<v[j];}
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}
const int PrimeMax = 50001;
int is_prime[PrimeMax];
void Eratosthenes(int N){
  for(int i = 0; i < N; i++){
    is_prime[i] = 1;
  }
  is_prime[1] = 0;
  for(int i = 2; i*i < N ; i++){
    if(is_prime[i]){
      for(int j = 0; i * (j + 2) < N; j++){
        is_prime[i *(j + 2)] = 0;
      }
    }
  }
}
int ans[50001];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  Eratosthenes(PrimeMax);
  vary(int,v,0,0);
  v.clear();
  rep(i,PrimeMax){
    if(is_prime[i] != 0){
      v.pb(i);
    }
  }
  REP(i,1,v.size()){
    REP(j,i,v.size()){
      if(v[i] + v[j] < PrimeMax){
        ans[v[i]+v[j]]++;
      }
    }
  }
  int n;
  while(cin >> n){
    if(n == 0)break;
    cout << ans[n] << endl;
  }
  return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<ll,ll>;

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

ll N, A[50];

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

    std::cin >> N;

    ll S = 0ll;
    for(int i=0;i<N;++i){
        std::cin >> A[i];
        S += A[i];
    }

    ll res = 1001001001001001001ll;
    for(ll i=0;i<=min((N-1)*N, S);++i){        
        ll c = S - i;      
        P range;
        for(int j=0;j<N;++j){
            ll a = ((A[j] + c) - (N - 1) + N) / (N + 1),
                b = (A[j] + c) / (N + 1);

            a = max(a, 0ll);
            b = min(b, c);
            
            if(j == 0){
                range = std::make_tuple(a, b);
            }else{
                fst(range) += a;
                snd(range) += b;
            }
        }

        if(fst(range) <= c && c <= snd(range)){
            res = min(res, c);
        }
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define _for(i,a,b) for(int i = (a);i<(b);i++)
#define endl  '\n'
#define inf 0x3f3f3f3f
using namespace std;
const int mod=1e9+7;
const int MAX=1e6+7;

ll a[MAX];
int main()
{
 	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 	int n;
	 cin>>n;
    map<int,int>pos;
    _for(i,1,n+1){
        int x;cin>>x;
        a[i] = x+i;
        ++pos[i-x];
    }
    ll ans = 0;
    _for(i,1,n+1){
        ans += pos[a[i]];
    }
    cout<<ans;
 	
 	
}

Measured memory_bytes: 22176
from functools import lru_cache

N = input()
K = int(input())

@lru_cache(maxsize=None)
def search(d, k, isLess):
    if k == K:
        return 1
    if d == len(N):
        return 0

    n = int(N[d])

    if isLess:
        return search(d + 1, k, isLess) + search(d + 1, k + 1, isLess) * 9

    ret = 0
    for i in range(n + 1):
        ret += search(d + 1, k + (1 if i > 0 else 0) , isLess or (i < n))
    return ret

print(search(0, 0, False))


Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
 typedef long long ll;
 
int pri(long long N) {
    if (N == 1) return 1;
    int j=0;
    for (long long i = 1; i <= N; ++i) {
        if (N % i == 0) j++;
    }
    return j;
}



int main() {
int n;
cin>>n;
int ans=0;
for(int k=1;k<=n;k++){
if(pri(k)==8 && k%2==1)ans++;
}
cout<<ans<<endl;
}


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

#define REP(A, H) for(int A = 0; A < H; A++)
#define RREP(A, B, H, W) for(int A = 0; A < H; A++) for (int B = 0; B < W; B++)
#define MAX(A, B) (A = std::max(A, B))
#define MIN(A, B) (A = std::min(A, B))

typedef long long ll;

struct POINT {
  int x; int y;
  POINT(int x, int y) : x(x), y(y) {}
};

POINT operator +(const POINT& a, const POINT& b) {
  return POINT(a.x + b.x, a.y + b.y);
}

POINT operator -(const POINT& a, const POINT& b) {
  return POINT(a.x - b.x, a.y - b.y);
}

/* std::cout << ;*/
/* std::cout << << std::endl; */

int main(void) {
  int n, k; std::cin >> n >> k; 

  int limit = (n-1) * (n-2) / 2;

  if (k > limit) {
    std::cout << -1 << std::endl;
    return 0;
  }

  std::vector<POINT> graph;

  REP(i, n) {
    if (i == 0) continue;
    graph.push_back(POINT(0, i));
  }
  
  if (limit != k) {
    int cnt = 0;
    for (int i = 1; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        graph.push_back(POINT(i, j));
        cnt++;
        if (limit - k == cnt) {
          break;
        }
      }
      if (limit - k == cnt) {
        break;
      }
    }
  }

  std::cout << graph.size() << std::endl;
  REP(i, graph.size()) {
    std::cout << graph[i].x + 1 << " " << graph[i].y + 1 << std::endl;
  }

  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long LL;

int main(){
  LL H, W;
  cin >> H >> W;
  if(H == 1 || W == 1) {
    cout << 1 << endl;
  } else {
    LL ret = H * W - (H * W / 2);
    cout << ret << endl;
  }
}

Measured memory_bytes: 256
import numpy as np
import itertools


N, M, Q = map(int, input().split(" "))

vals = []
for i in range(Q):
    vals.append(list(map(int, input().split(" "))))
    
maxv = 0
cand = list(itertools.combinations_with_replacement(range(1, M+1), N))
for c in cand:
    sumv = 0
    for v in vals:
        if (c[v[1]-1] - c[v[0]-1]) == v[2]:
            sumv += v[3]
    if maxv < sumv:
        maxv = sumv
print(maxv)

Measured memory_bytes: 39508
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

struct UnionFind
{
  vector<i64> p;

  UnionFind(i64 n)
  {
    p.resize(n, -1);
  }
  i64 root(i64 n)
  {
    return (p[n] < 0 ? n : p[n] = root(p[n]));
  }
  i64 unite(i64 x, i64 y)
  {
    x = root(x);
    y = root(y);
    if (x == y)
      return 0;
    if (y < x)
      swap(x, y);
    p[y] += p[x];
    p[x] = y;
    return 0;
  }
};

int main()
{
  i64 n, m, k;
  cin >> n >> m >> k;
  UnionFind uf(n + m);
  for (i64 i = 0; i < k; i++)
  {
    i64 t;
    cin >> t;
    if (t == 1)
    {
      i64 a, b;
      cin >> a >> b;
      a--;
      b--;
      a = uf.root(a);
      b = uf.root(b);
      if (n <= a && n <= b && a != b)
      {
        cout << i + 1 << endl;
        return 0;
      }
      uf.unite(a, b);
    }
    else
    {
      i64 c, x;
      cin >> c >> x;
      c--;
      x--;
      c = uf.root(c);
      if (n <= c && c != x + n)
      {
        cout << i + 1 << endl;
        return 0;
      }
      uf.unite(c, x + n);
    }
  }
  cout << 0 << endl;
  return 0;
}



Measured memory_bytes: 4400
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    string s1, s2;

    cin >> s1 >> s2;
    int i;

	if(s1.length() > s2.length())
		cout << "GREATER" << endl;
	else if(s2.length() > s1.length())
		cout << "LESS" << endl;
	else
	{
	    for(i = 0; i < min(s1.length(), s2.length()); i ++)
	    {
	    	if(s1[i] > s2[i])
	    	{
	    		cout << "GREATER" << endl;
	    		break;
	    	}
	    	else if(s1[i] < s2[i])
	    	{
	    		cout << "LESS" << endl;
	    		break;
	    	}
	    	else
	    		continue;
	    }

	    if(i == s1.length())
	    	cout << "EQUAL" << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll pw(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)res=res*x%M;
        x=x*x%M;
        y>>=1;
    }
    return res;
}
ll h,w,n,ka[200005],inv[200005],dp[3005][2],ans;
P g[3005];
ll cm(ll x,ll y){
    return ka[x]*inv[x-y]%M*inv[y]%M;
}
int main(void){
    scanf("%lld%lld%lld",&h,&w,&n);
    ka[0]=1,inv[0]=1;
    for(ll i=1;i<=h+w;i++){
        ka[i]=ka[i-1]*i%M;
        inv[i]=pw(ka[i],M-2);
    }
    g[0]=P(1,1);
    for(int i=1;i<=n;i++){
        scanf("%lld%lld",&g[i].S,&g[i].F);
    }
    sort(g,g+n+1);
    dp[0][0]=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<i;j++){
            if(g[i].S<g[j].S)continue;
            ll dx=g[i].F-g[j].F,dy=g[i].S-g[j].S;
            dp[i][0]=(dp[i][0]+dp[j][1]*cm(dx+dy,dx))%M;
            dp[i][1]=(dp[i][1]+dp[j][0]*cm(dx+dy,dx))%M;
        }
    }
    for(int i=0;i<=n;i++){
        ans=(ans+(dp[i][0]-dp[i][1]+M)%M*cm(h-g[i].S+w-g[i].F,w-g[i].F))%M;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <stdlib.h>
using namespace std;

int main(){
    int N,L;
    cin >> N >> L;
    int taste[200];
    for(int i=0;i<N;i++){
        taste[i]=L+i;
    }
    int pie = 0;
    for(int i=0;i<N;i++){
        pie += taste[i];
    }
    vector<int> e_pie;
    for(int i=0;i<N;i++){
        int eat = i;
        int sum = 0;
        for(int j=0;j<N;j++){
            if(j==eat){
                continue;
            }
            sum += taste[j];
        }
        e_pie.push_back(sum);
    }
    int gap=abs(pie),ans=0;
    for(int i;i<N;i++){
        int tmp = abs(pie-e_pie[i]);
        if(gap>tmp){
            gap=tmp;
            ans = e_pie[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

L, R = map(int, input().split())

ans = 2019
for i in range(L, min(R+1, L+2018)):
    for j in range(i+1, min(R+1, L+2018)):
        ans = min(ans, (i*j) % 2019)

print(ans)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,h[100100],d[100100];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>h[i];
	} 
	for(int i=1;i<n;i++)
	{
		int b;
		int a=abs(h[i-1]-h[i]);
		if(i>=2) b=abs(h[i-2]-h[i]);
		else b=0;
		d[i]=d[i-1]+a;
		if(i>1 && d[i]>d[i-2]+b)
		{
			d[i]=d[i-2]+abs(h[i-2]-h[i]);
		} 
	}
	cout<<d[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

const int MAXN=1e5+5;
int dp[MAXN], h[MAXN];

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

    int n; cin>>n;
    FOR(i,n)
        cin>>h[i];

    memset(dp, 0x7f, sizeof dp);
    dp[0] = 0;

    FOR(i,n) {
        dp[i+2] |= MIN( dp[i] + abs(h[i+2]-h[i]) );
        dp[i+1] |= MIN( dp[i] + abs(h[i+1]-h[i]) );
    }

    cout<<dp[n-1]<<endl;

    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define pf push_front
#define eb emplace_back
#define f(i,x,n) for(ll i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define int ll

template < typename T > using indexed_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
 
const double PI = acos(-1);
const ll LINF = LLONG_MAX;
const int MOD = 1e9+7, INF = INT_MAX, N = 2e5 + 10;
 
int n;
int A[N];
map<int,int> C;

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   cin >> n;
   f(i,1,n+1){
      cin >> A[i];
      C[i-A[i]]++;
   }
   int ans = 0;
   f(i,1,n+1){
      C[i-A[i]]--;
      ans += C[i+A[i]];
   }
   cout << ans << '\n';
   return 0;
}

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

int main() {
	int n;

	cin >> n;
	getchar();
	for (int i = 0; i < n; i++) {
		char str[1001];
		gets(str);
		for (int j = 0, len = strlen(str); j < len - 6; j++) {
			if (strncmp(&str[j], "Hoshino", strlen("Hoshino")) == 0) {
				strncpy(&str[j], "Hoshina", strlen("Hoshina"));
			}
		}
		cout << str << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  long long int a,b=1;cin>>a;
  rep(i,a){
    b*=(i+1);
    b%=1000000007;
  }  
  cout<<b;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

bool used[5252];
constexpr ll INF=1e18;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n, p[5252];
  ll k, c[5252];
  cin>>n>>k;
  REP(i, n){
    cin>>p[i];
    --p[i];
  }
  REP(i, n){
    cin>>c[i];
  }
  ll ans=-INF;
  REP(i, n){
    if(used[i]){
      continue;
    }
    vi ids;
    int idx=i;
    while(!used[idx]){
      ids.push_back(idx);
      used[idx]=true;
      idx=p[idx];
    }
    int m=ids.size();
    ll total=0;
    for(auto& idx : ids){
      total+=c[idx];
    }
    ll ma[5252];
    REP(j, m){
      ma[j]=-INF;
    }
    REP(j, m){
      ll tmp=0;
      REP(k, m){
        CHMAX(ma[k], tmp);
        int idx=(j+k)%m;
        tmp+=c[ids[idx]];
      }
    }
    if(k<m){
      FOR(j, 1, k+1){
        CHMAX(ans, ma[j]);
      }
      continue;
    }
    if(total<0){
      FOR(j, 1, m){
        CHMAX(ans, ma[j]);
      }
      continue;
    }
    REP(j, m){
      if(j<=(k%m)){
        CHMAX(ans, total*(k/m)+ma[j]);
      }
      CHMAX(ans, total*(k/m-1)+ma[j]);
    }
  }
  cout<<ans<<'\n';
  return 0;
}


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

int main(){
  int i,j,i2,j2;ll cnt=0;
  int n,m;
  cin>>n>>m;
  int k[m],p[m];
  int s[m][n];
  for(i=0;i<m;i++){
    cin>>k[i];
    for(j=0;j<k[i];j++)cin>>s[i][j];
  }
  for(i=0;i<m;i++)cin>>p[i];
  int sw[n+1];
  for(i=1;i<=n;i++)sw[i]=0;
  for(i=0;i<(int)round(pow(2,n));i++){
    for(j=0;j<n;j++){
      sw[j+1]=(i/(int)round(pow(2,j)))%2;
    }
    for(j=0;j<m;j++){
      int sum=0;
      for(i2=0;i2<k[j];i2++){
        sum+=sw[s[j][i2]];
      }
      if(sum%2!=p[j]){
        cnt++;
        break;
      }
    }
  }
  cout<<(int)round(pow(2,n))-cnt;
}

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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=50000;
    rep(y,1,P){
        ll x=mod(y*k);
        
        if(abs(x)<=P||x+P>=i_7){
            if(x+P>=i_7){
                x-=i_7;
            }
            cout<<x<<"/"<<y<<endl;
            //cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
typedef vector<ll> vl;
//////////////////////////


int main(){fastio
    
    ll x;cin>>x;
    assert(-40<=x&&x<=40);
    if(x>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
int main(){
	int i;
	int m;
	scanf("%d",&i);
	if(i>999||i<0) printf("error");
	else{
		m=i%10;

	if(m==2||m==4||m==5||m==7||m==9) printf("hon");
	if(m==0||m==1||m==8||m==6) printf("pon");
	if(m==3) printf("bon");}
	return 0;
} 

Measured memory_bytes: 1692
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 1000000009
using P = pair<int,int>;

int main(){
  ll k;
  cin >> k;
  queue<ll> que;
  for(int i = 1;i < 10;i++){
    que.push(i);
  }
  ll i = 0;
  while(k > 0){
    i = que.front();
    que.pop();
    ll newi = i*10 + (i%10);
    if(newi % 10 != 0){
      que.push(newi - 1);
    }
    que.push(newi);
    if(newi % 10 != 9){
      que.push(newi + 1);
    }
    k--;
  }
  cout << i << endl;
}



Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = __gnu_pbds::tree<T, __gnu_pbds::null_type, less_equal<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define PI atan2(0, -1)
#define epsilon 1e-9
#define INF 5e18
#define MOD 1000000007

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

int N;
long long arr [100010], fac = 1, mult = 0, ret = 0;

long long modInverse(long long a, long long m){ //Assume That a and m are relatively prime to each other
    long long m0 = m, t, q;
    long long x0 = 0ll, x1 = 1ll;
    while(a > 1ll){
        // q is quotient
        q = a/m;
        t = m;
        // m is remainder now, process same as
        // Euclid's Algorithm
        m = a%m, a = t;
        t = x0;
        x0 = x1-q*x0;
        x1 = t;
    }
    // Make x1 positive
    if(x1 < 0) x1 += m0;
    return x1;
}

int main(){
    //freopen("sort.in", "r", stdin); freopen("sort.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);
    cin >> N; for(int i = 0; i < N; i++) cin >> arr[i];
    for(int i = 1; i < N; i++) fac = (fac*(long long)i)%MOD;
    for(int i = 1; i < N; i++){
        //cout << mult*modInverse(i, MOD) << endl;
        mult += fac*modInverse(i, MOD); mult %= MOD;
        ret += mult*(arr[i]-arr[i-1]); ret %= MOD;
    }
    cout << ret << '\n';
    return 0;
}

/******************************
Kateba ii dake no hanashi darou
Success is only a victory away
- No Game No Life Opening
******************************/


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

const int maxn = 200010;
int n, a[maxn];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    auto chk = [&](int x) {
        map<int, int> mp;
        for (int i = 2; i <= n; i++) if (a[i - 1] >= a[i]) {
            if (x == 1) return 0;
            while (!mp.empty()) {
                int mx = mp.rbegin()->first;
                if (mx > a[i]) mp.erase(mx);
                else break;
            }
            int j = a[i];
            while (j && mp[j] + 1 == x) mp.erase(j), j--;
            if (!j) return 0; mp[j]++;
        }
        return 1;
    };
    int l = 1, r = n, ans;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (chk(mid)) r = (ans = mid) - 1;
        else l = mid + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

vector<int> tree[610];
R dp[610];

R calc(int n, int skip){
	dp[n - 1] = 0.0;

	rrep(v, n - 1){
		int d = tree[v].size();
		R total = 0.0, cmax = 0.0;

		for(auto &u: tree[v]){
			chmax(cmax, dp[u]);
			total += dp[u];
		}

		if (skip == v and d > 1) {
			total -= cmax;
			d--;
		}

		dp[v] = 1.0 * total / d + 1.0;
	}

	return dp[0];
}

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

	rep(i, m){
		int a, b;
		cin >> a >> b;
		tree[a - 1].push_back(b - 1);
	}

	R ans = 1e100;
	rep(skip, -1, n) chmin(ans, calc(n, skip));

	cout.precision(20);
	cout << fixed << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
def solve(string):
    n, *a = map(int, string.split())
    for i in range(n // 2, 0, -1):
        a[i - 1] = sum(a[i - 1::i]) % 2
    ans = [str(i + 1) for i, _a in enumerate(a) if _a == 1]
    return "0" if len(ans) == 0 else "{}\n{}".format(len(ans), " ".join(ans))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 14516
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskC {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int m = in.nextInt();
			int sa = Math.abs(m-n);
			int mod = 1000000007;

			if (Math.abs(sa) > 1) out.print(0);
			if (Math.abs(sa) == 1) {
				out.println((MathUtils.calcModNum(n, mod) * MathUtils.calcModNum(m, mod)) % mod);
			}
			if (Math.abs(sa) == 0) {
				out.println((MathUtils.calcModNum(n, mod) * MathUtils.calcModNum(m, mod) * 2) % mod);
			}
		}
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class MathUtils {
		public static long calcModNum(int a,int mod) {
			long divide = 1;
			for (int i = 1; i <= a; i++) {
				divide = divide * i % mod;
			}
			return divide;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 21460
#include <stdio.h>

int main(int argc, char *argv[])
{
	int H, W;
	while (1)
	{
		scanf("%d %d", &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)
				{
					printf("#");
				}
				else
				{
					if (j == 0 || j == W -1)
					{
						printf("#");
					}else {
						printf(".");
					}
				}

			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 2040
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<string> s(n);
        for(int i=0; i<n; ++i)
            cin >> s[i];

        int ret = 0;
        for(int i=0; i<n; ++i){
            for(int j=0; j<n; ++j){
                for(int k=0; k<8; ++k){
                    int y = i;
                    int x = j;
                    int num = 0;
                    while(0 <= y && y < n && 0 <= x && x < n && s[y][x] == '1'){
                        ++ num;
                        y += dy[k];
                        x += dx[k];
                    }
                    ret = max(ret, num);
                }
            }
        }

        cout << ret << endl;
    }
}

Measured memory_bytes: 992
import java.util.Scanner;

public class Main {

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

		int n = 1;

		for (int i = 0; i >= 0; i++) {
			n = n * 2;
			if (n > s) {
				int nn = n / 2;
				System.out.println(nn);
				return;
			}
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int n,m,p;
    std::deque<int> deq;
    while (cin>>n>>m) {
        if (n==0&&m==0) {
            break;
        } else {
            for (int i=0;i<n;i++) {
                cin>>p;
                deq.emplace_back(p);
            }
            sort(deq.begin(),deq.end(),greater<int>());
            int sum=0;
            while (n>=m) {
                for (int j=0;j<m;j++) {
                    if (j!=m-1) {
                        sum+=deq.front();
                        deq.pop_front();
                        n--;
                    } else {
                        deq.pop_front();
                        n--;
                    }
                }
            }
            if (n!=0) {
                for (int k=0;k<n;k++) {
                    sum+=deq.front();
                    deq.pop_front();
                }
            }
            cout<<sum<<endl;
        }
    }
}


Measured memory_bytes: 3168
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

W, H, x, y = map(int, input().split())

if W == x * 2 and H == y * 2:
    print(W * H / 2, 1)
else:
    print(W * H / 2, 0)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    if (s == "abc") {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256